zhao_js
2023-11-15 b44e169dd8a6e0f15d3788970176922e96aec6e1
uniapp/components/sh_page/indexNewPage.vue
@@ -1,6 +1,6 @@
<template>
   <view style="background: #fff;" class="index-wrapper wrapperLayer borderBox">
      <view class="fixed-container colCen borderBox" :style="'background:'+ (categoryCurrent>0?'#EE1B14':(scrollTop>30?'#EE1B14;':bannerColor) +';')">
      <view class="fixed-container colCen borderBox" style="background: #0f0f0f;">
         <view class="topbarbox"></view>
         <view class="headerSearch-container rowCenBet borderBox">
            <view class="leftgoSearchbox rowCen borderBox" @click="goPath('search')">
@@ -8,7 +8,7 @@
                  <view>&#xe616;</view>
               </view>
               <view class="hotSearchbox rowCenCen">
                  <view>输入商品名</view>
                  <view>输入商品名或粘贴宝贝标题搜索</view>
               </view>
            </view>
            <view class="rightgoMsg rowCenCen iconfont searchImg" @click="goPath('turnChain')">
@@ -19,8 +19,8 @@
               <u-badge v-show="isNewMessage" :is-dot="true" type="success"></u-badge>
            </view>
         </view>
         <!-- <view class="categoryNavbar-container rowCenBet">
         <view class="categoryNavbar-container rowCenBet">
            <scroll-view class="categoryScroll" scroll-x scroll-with-animation @scroll="rowscroll" :scroll-into-view="nowcurrentid" :scroll-left="scrollleftnum">
               <block v-for="(items,index) in categoryList" :key='index'>
                  <view class="category-container">
@@ -33,11 +33,11 @@
                  </view>
               </block>
            </scroll-view>
            <view class="category-icon-box rowCenCen" @click="showCateModel()">
               <view class="iconfont">&#xe618;</view>
            </view>
         </view> -->
         </view>
      </view>
      <!-- 弹框 -->
      <view class="categoryModel-wrapper" @touchmove.prevent>
@@ -79,6 +79,47 @@
            </swiper-item>
         </swiper>
      </view>
      <!-- 弹框 -->
      <view class="categoryModel-wrapper" @touchmove.prevent>
         <view class="shadow" :class="cateModel?'showShadow':''" @click="closeModel()"></view>
         <view class="category-content" :style="'top:'+Topheight+'px'" :class="cateModel?'showcate':''">
            <view class="catelist-box colCen borderBox" v-if="cateModel">
               <view class="titlebar rowCen">
                  <view>选择分类</view>
               </view>
               <view class="list-container borderBox rowCen">
                  <block v-for="(items,index) in categoryList" :key='index'>
                     <view class="cate-items colCen" v-if="index!=0" @click="changeCurrent(index,items.cid)">
                        <view class="picbox defIcon">
                           <image :src="items.cpic" mode="aspectFill" :lazy-load="true"></image>
                        </view>
                        <view class="catename">
                           {{items.cname}}
                        </view>
                     </view>
                  </block>
               </view>
            </view>
         </view>
      </view>
      <view class="body-container colCen borderBox">
         <swiper class="pageSwiper" :disable-touch='canswiper' duration="200" :current='categoryCurrent' @change='changeCatepage' @transition='swipering' @animationfinish='stopswiper'>
            <swiper-item v-for="(items,index) in categoryList" :key='index' :current-item-id='items.cid'>
               <view v-if='index==0'>
                  <indexPage ref='indexPage' :recomendType="recomendType" :canrefush='canrefush' :fixedClass='fixedClass' @scrolltoTop='scrolltoTop' @scrolltoview='scrolltoview'
                   @pushfixed='getfixed' @scrollNum='getScroll' :Topheight='Topheight' @passColor='getColor'></indexPage>
               </view>
               <view v-else>
                  <categoryPage v-if="index==categoryCurrent+1 || index==categoryCurrent-1 || index==categoryCurrent" :parentId='items.cid'
                   :Topheight='Topheight' :canrefush='canrefush' :canload='index==categoryCurrent'>
                  </categoryPage>
               </view>
            </swiper-item>
         </swiper>
      </view>
      <!-- 弹框广告 -->
      <u-mask :show="showBulletFrame">
          <view class="warp">
@@ -99,7 +140,18 @@
   import categoryPage from '@/components/categoryPage.vue';
   export default {
      props: {
         recomendType: {
            type: Number,
            default: 1
         },
         Topheight: {
            type: Number,
            default: 90
         },
         fixedClass: {
            type: Boolean,
            default: false
         }
      },
      components: {
         indexPage,
@@ -113,21 +165,20 @@
            shareShow: false,
            bannerColor: '',
            cateModel: false,
            Topheight: 0,
            categoryCurrent: 0,
            current: 1,
            scrollTop: 0,
            fixedClass: false,
            canrefush:true,
            categoryList: [],
            canswiper:false,
            scrollleftnum:0,
            rowLeft:0,
            canrefush:false,
            nowcurrentid:'',
            recomendType:1
         }
      },
      created() {
         this.getCategoryList();
         this.getPopBannerInfo();
         if(this.categoryList){
@@ -139,14 +190,6 @@
         this.recomendType = open_like_recommend == "" ? 1 : open_like_recommend;
      },
      onShow() {
         if(!this.hasLogin){
            setTimeout(function(){
               uni.reLaunch({
                  url:"/pages/login/wxlogin"
               })
            },1000);
            return;
         }
         var user= uni.getStorageSync('userInfo');
         console.log(user);
         if(!user.invitation_code)
@@ -160,9 +203,6 @@
            return;
         }
         
      },
      onReady() {
         this.getTopheight()
      },
      watch: {},
      methods: {
@@ -178,7 +218,6 @@
            }).then(e => {
               if (e.code == 1) return that.$alert(e.msg);
               var res = e.data.info;
               console.log(res)
               if(res.length > 0){
                  this.showBulletFrame = true;
                  this.BulletFrameData = res[0]
@@ -302,9 +341,9 @@
         },
         changeCatepage(e) {
            // 滑动切换
            /* this.bannerColor = '#EE1B14'
             this.bannerColor = '#EE1B14'
            this.categoryCurrent = e.detail.current
            this.currentscroll() */
            this.currentscroll()
         },
         cateChange(idx) {
            // 分类点击
@@ -313,6 +352,7 @@
         },
         getTopheight() {
            // 获取顶部高度
            console.log("开始获取高度")
            uni.createSelectorQuery().in(this).select('.fixed-container').boundingClientRect(data => {
               console.log("得到布局位置信息" + JSON.stringify(data));
               this.Topheight = data.height
@@ -339,14 +379,15 @@
   }
</script>
<style lang="scss">
   .index-wrapper {
      height: 100vh;
      overflow: hidden;
margin-top: 160rpx;
      .body-container {
         width: 100%;
         .pageSwiper {
            width: 100%;
            overflow: hidden;
@@ -367,8 +408,7 @@
         left: 0;
         padding: 0 32rpx;
         z-index: 600;
         background: linear-gradient(to right,#ee1b14,#ee1b144d);
         //background-color: #EE1B14;
         background-color: #EE1B14;
         // transition: all 0.5s;
         .headerSearch-container {
@@ -569,3 +609,4 @@
       }
   }
</style>