zhao_js
2023-11-28 6b4ede1806da26d93f5fad839199fe8b2e0641f5
uniapp/components/indexPage.vue
@@ -39,7 +39,7 @@
                        <swiper-item v-for="(sliderItem, index) in navbarShowList" :key="index">
                           <view class="slider_itemslist rowSta">
                              <view class="item colCen" v-for="(item, idx) in sliderItem" :key="idx"
                                 @click="goUrl(item)">
                                 @click="perVerification(item)">
                                 <image :src="item.image" :lazy-load="true" mode="aspectFit"></image>
                                 <view class="desc">{{ item.mname }}</view>
                              </view>
@@ -392,6 +392,7 @@
                  v-if="bottomGoodsList.length>0">
                  <block v-for="(items,index) in bottomGoodsList" :key="index">
                     <view class="goods-items" @click="goDetails(items)">
                         <!-- <colGoodsImg v-if="index==0&&itembannerList&&itembannerList.length>0" :popBannerSList="itembannerList"></colGoodsImg> -->
                        <colGoods :items="items"></colGoods>
                     </view>
                  </block>
@@ -403,6 +404,9 @@
         </view>
      </scroll-view>
      <slideTop v-if="scrollTop>1000" @toTop='scrolltoTops'></slideTop>
      <u-modal v-model="showConModel" show-cancel-button :content="conContent" @confirm="modConfirm" :async-close="true">
      </u-modal>
   </view>
</template>
@@ -411,6 +415,7 @@
   import slideTop from './slideTop.vue'
   import colGoods from './colGoods.vue'
   import empowerModel from './empowerModel.vue'
      import colGoodsImg from '@/components/colGoodsImg.vue'
   export default {
      props: {
         recomendType: {
@@ -432,10 +437,12 @@
      components: {
         slideTop,
         colGoods,
         empowerModel
         empowerModel,
         colGoodsImg
      },
      data() {
         return {
            popBannerSList:[],
            fallingList: [],
            pageHeight: '',
            headerColor: '',
@@ -491,9 +498,19 @@
            swpidx: 0,
            canrefresh: true,
            fastenter:[],
            popBannerSList:[],
            itembannerList:[],
            enterTop:[],
            enterDown:[]
            enterDown:[],
            tbbanner:[],
            jdbanner:[],
            dybanner:[],
            pddbanner:[],
            wphbanner:[],
            haspreference:false,
            preferData:{},
            showConModel:false,
            conContent:'',
            urlInfo:{}
         }
      },
      watch: {
@@ -521,14 +538,16 @@
      },
      created() {
         this._freshing = false;
         this.changeRecommend();
         //this.changeRecommend();
         this.checkPreferenceGoods();
         uni.$emit('initpage')
         this.getBannerInfo();
         this.getHomeMenuList();
         this.getrecommendGoods();
         this.getbottomGoodsList(this.bottomType);
         //this.getbottomGoodsList(this.bottomType);
         this.getGOODSfalling();
         this.getRQList();
         //this.getPageImg();
      },
      mounted() {
         this.$emit('scrolltoTop')
@@ -538,6 +557,76 @@
         }, 1500)
      },
      methods: {
         perVerification(info)
         {
            this.urlInfo=info;
            var mapPer="本地生活,电影7折"
            var menuName=info.mname;
            if(mapPer.indexOf(menuName)>-1)
            {
               this.conContent='应用将申请位置权限,用于快速选定所在城市';
               this.showConModel=true;
            }
            else
            {
               this.goUrl(info);
            }
         },
         modConfirm()
         {
            this.showConModel=false;
            this.goUrl(this.urlInfo);
         },
         checkPreferenceGoods()
         {//是否有推荐
            var that = this;
            var tmp_1 = {
               mainTitle: '天猫',
               subTitle: '天猫热销',
               type: 5
            };
            var tmp_2 = {
               mainTitle: '天猫',
               subTitle: '为你推荐',
               type: 1
            };
            var tmp_3= {
               mainTitle: '推荐',
               subTitle: '猜你喜欢',
               type: 7
            };
            var open_like_recommend = uni.getStorageSync('open_like_recommend');
            if(this.typedataList.length == 5)this.typedataList.shift()
            if(open_like_recommend == 1){
               this.typedataList.unshift(tmp_2);
               this.bottomType = tmp_2.type;
            }else{
               this.typedataList.unshift(tmp_1);
               this.bottomType = tmp_1.type;
            }
            this.$u.api.checkPreferenceGoods({
            }).then(e => {
               console.log(e);
               if(e.code != 0)
               {
                  that.currentPage = 1;
                  that.getbottomGoodsList(that.bottomType);
                  return;
               };
               if(e.data&&e.data.p_cids)
               {//有偏好
                   that.preferData=e.data;
                  that.typedataList.unshift(tmp_3);
                  that.bottomType = tmp_3.type;
                  //去除唯品会
                  that.typedataList = that.typedataList.filter(function(item) {return item.type !== 4});
               }
               that.currentPage = 1;
               that.getbottomGoodsList(that.bottomType);
            }).catch(function (err) {
               this.changeRecommend();
            })
         },
         changeRecommend(){
            var tmp_1 = {
               mainTitle: '天猫',
@@ -545,7 +634,7 @@
               type: 5
            };
            var tmp_2 = {
               mainTitle: '推荐',
               mainTitle: '天猫',
               subTitle: '为你推荐',
               type: 1
            };
@@ -595,7 +684,6 @@
         },
         onRestore() {
            this.swpidx = 0
            console.log('下拉被终止');
         },
         pagescroll(e) {
            this.$emit('scrollNum', e.detail.scrollTop)
@@ -626,11 +714,14 @@
            this.$u.api.getBanner({
               type: '1,3,4,5,11,12,13,14'
            }).then(e => {
               console.log(e)
               if (e.code == 1) return that.$alert(e.msg);
               var res = e.data.info;
               this.topBannerList = res.topBannerList;
               this.headerColor = this.topBannerList[0].colour;
               if(res.topBannerList&&res.topBannerList.length>0)
               {
                  this.topBannerList = res.topBannerList;
                  this.headerColor = this.topBannerList[0].colour;
               }
               this.singleLineList = res.singleLineList;
               this.doubleLineList = res.doubleLineList;
               this.bottomBannerList = res.bottomBannerList;
@@ -685,43 +776,82 @@
               that.dyList = e.data.dygoods;
            }).catch(function(err) {})
         },
         getPageImg()
         {
             var that=this;
            this.$u.api.getBanner({
               type: '11,16,17,18,19,20'
            }).then(e => {
               if (e.code == 1) return that.$alert(e.msg);
               var res = e.data.info;
               that.tbbanner=res.tmImg;
               that.jdbanner=res.jdImg;
               that.dybanner=res.dyImg;
               that.pddbanner=res.pddImg;
               that.wphbanner=res.wphImg;
               that.changeBanner(that.bottomCurrent);
            }).catch(function(err) {
               console.log(err)
            })
         },
         changeBanner(type)
         {
            switch(type)
            {
               case 2://京东
                 this.itembannerList=this.jdbanner;
                 break;
               case 6://抖音
                 this.itembannerList=this.dybanner;
                 break;
               case 3://拼多多
                  this.itembannerList=this.pddbanner;
                  break;
               case 4://唯品会
                  this.itembannerList=this.wphbanner;
                  break;
               default:
               this.itembannerList=[];
                  break;
            }
            if(this.itembannerList&&this.itembannerList>0)
            {
               that.bottomGoodsList.unshift(this.itembannerList[0]);
            }
         },
         getbottomGoodsList(type) {
            var that = this;
            this.$u.api.getGoodThing({
               deviceType: getApp().globalData.platform == 'android' ? (getApp().globalData.systemLevel < 10 ?
                  'IMEI' : 'OAID') : 'IDFA',
               deviceValue: getApp().globalData.equipmentNumber,
               pageId: 1,
               pageSize: 10,
               type: type
            }).then(e => {
                console.log(e)
               if (e.code != 0) return that.$alert(e.msg)
               var res = e.data.list;
               if (res.length < 10) {
                  that.loadingState = false
                  that.loadstatus = 'normal'
               } else {
                  that.currentPage++
                  that.loadstatus = 'loading'
                  that.loadingState = true
               }
               that.bottomGoodsList = res
            }).catch(function(err) {})
         },
         getNextPage() {
            if (this.loadingState) {
               this.loadingState = false
               var that = this;
            if(type==7&&that.preferData)
            {//猜你喜欢
            console.log(that.preferData);
               this.$u.api.gussessLikeGoods({
                  platefrom:that.preferData.p_platefrom,
                  cids:that.preferData.p_cids,
                  pageId:1,
                  pageSize:10
               }).then(e=>{
                  console.log(e);
                  var res = e.data.list;
                  if (res.length < 10) {
                     that.loadingState = false
                     that.loadstatus = 'normal'
                  } else {
                     that.currentPage++
                     that.loadstatus = 'loading'
                     that.loadingState = true
                  }
                  that.bottomGoodsList = res
               })
            }
            else
            {
               this.$u.api.getGoodThing({
                  deviceType: getApp().globalData.platform == 'android' ? (getApp().globalData.systemLevel <
                     10 ? 'IMEI' : 'OAID') : 'IDFA',
                  deviceType: getApp().globalData.platform == 'android' ? (getApp().globalData.systemLevel < 10 ?
                     'IMEI' : 'OAID') : 'IDFA',
                  deviceValue: getApp().globalData.equipmentNumber,
                  pageId: this.currentPage,
                  pageId: 1,
                  pageSize: 10,
                  type: this.bottomType
                  type: type
               }).then(e => {
                  if (e.code != 0) return that.$alert(e.msg)
                  var res = e.data.list;
@@ -733,8 +863,60 @@
                     that.loadstatus = 'loading'
                     that.loadingState = true
                  }
                  that.bottomGoodsList = that.bottomGoodsList.concat(res)
                  that.bottomGoodsList = res
               }).catch(function(err) {})
            }
         },
         getNextPage() {
            if (this.loadingState) {
               this.loadingState = false
               var that = this;
               if(that.bottomType==7&&that.preferData)
               {//猜你喜欢
                  this.$u.api.gussessLikeGoods({
                     platefrom:that.preferData.p_platefrom,
                     cids:that.preferData.p_cids,
                     pageId:this.currentPage,
                     pageSize:10
                  }).then(e=>{
                     console.log(e);
                     if (e.code != 0) return that.$alert(e.msg)
                     var res = e.data.list;
                     if (res.length < 10) {
                        that.loadingState = false
                        that.loadstatus = 'normal'
                     } else {
                        that.currentPage++
                        that.loadstatus = 'loading'
                        that.loadingState = true
                     }
                     that.bottomGoodsList = that.bottomGoodsList.concat(res);
                  })
               }
               else{
                  this.$u.api.getGoodThing({
                     deviceType: getApp().globalData.platform == 'android' ? (getApp().globalData.systemLevel <
                        10 ? 'IMEI' : 'OAID') : 'IDFA',
                     deviceValue: getApp().globalData.equipmentNumber,
                     pageId: this.currentPage,
                     pageSize: 10,
                     type: this.bottomType
                  }).then(e => {
                     if (e.code != 0) return that.$alert(e.msg)
                     var res = e.data.list;
                     if (res.length < 10) {
                        that.loadingState = false
                        that.loadstatus = 'normal'
                     } else {
                        that.currentPage++
                        that.loadstatus = 'loading'
                        that.loadingState = true
                     }
                     that.bottomGoodsList = that.bottomGoodsList.concat(res)
                  }).catch(function(err) {})
               }
            }
         },
@@ -742,6 +924,7 @@
            if (this.bottomCurrent != idx) {
               this.currentPage = 1;
               this.bottomType = info.type;
               this.changeBanner(info.type);
               this.getbottomGoodsList(this.bottomType);
               this.$nextTick(() => {
                  this.$emit('scrolltoview')
@@ -764,7 +947,7 @@
               }
            })
         },
         goUrl(info) {
            utils.goUrl(info, this)
         },