zhaojs
2023-08-11 83e49ed8b1ab05dd332def0fba6c3703d1e91373
uniapp/pages/index/index.vue
@@ -1,9 +1,11 @@
<template>
    <view v-if="isshowtype">
      <indexnewPage :Topheight="Topheight" :recomendType="recomendType" :canrefush='canrefush' :fixedClass='fixedClass'></indexnewPage>
   <view v-if="isshowtype">
      <indexnewPage :Topheight="Topheight" :recomendType="recomendType" :canrefush='canrefush'
         :fixedClass='fixedClass'></indexnewPage>
   </view>
   <view v-else 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:'+ (categoryCurrent>0?'#EE1B14':(scrollTop>30?'#EE1B14;':bannerColor) +';')">
         <view class="topbarbox"></view>
         <view class="headerSearch-container rowCenBet borderBox">
            <view class="leftgoSearchbox rowCen borderBox" @click="goPath('search')">
@@ -24,10 +26,13 @@
         </view>
         <view class="categoryNavbar-container rowCenBet">
            <scroll-view class="categoryScroll" scroll-x scroll-with-animation @scroll="rowscroll" :scroll-into-view="nowcurrentid" :scroll-left="scrollleftnum">
            <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">
                     <view class="category-items colCenCen" @click="cateChange(index)" :id="categoryCurrent==index?'category-items-active':''" :class="categoryCurrent==index?'category-items-active':''">
                     <view class="category-items colCenCen" @click="cateChange(index)"
                        :id="categoryCurrent==index?'category-items-active':''"
                        :class="categoryCurrent==index?'category-items-active':''">
                        <view class="categoryname">
                           {{items.cname}}
                        </view>
@@ -68,15 +73,20 @@
      </view>
      <view class="body-container colCen borderBox">
         <swiper class="pageSwiper" :disable-touch='canswiper' duration="200" :current='categoryCurrent' @change='changeCatepage' @transition='swipering' @animationfinish='stopswiper'>
         <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>
                  <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
                     v-if="index==categoryCurrent+1 || index==categoryCurrent-1 || index==categoryCurrent"
                     :parentId='items.cid' :Topheight='Topheight' :canrefush='canrefush'
                     :canload='index==categoryCurrent'>
                  </categoryPage>
               </view>
            </swiper-item>
@@ -84,14 +94,15 @@
      </view>
      <!-- 弹框广告 -->
      <u-mask :show="showBulletFrame">
          <view class="warp">
              <!-- <view @tap.stop> -->
                  <image class="pic" :src="BulletFrameData.image" mode="aspectFit"  @tap.stop="goToShowBulletFrame(BulletFrameData)"/>
              <!-- </view> -->
              <view class="clone" @click="showBulletFrame = false">
                  <image class="image" width="64rpx" height="64rpx" src="/static/images/app/close.png"></image>
              </view>
          </view>
         <view class="warp">
            <!-- <view @tap.stop> -->
            <image class="pic" :src="BulletFrameData.image" mode="aspectFit"
               @tap.stop="goToShowBulletFrame(BulletFrameData)" />
            <!-- </view> -->
            <view class="clone" @click="showBulletFrame = false">
               <image class="image" width="64rpx" height="64rpx" src="/static/images/app/close.png"></image>
            </view>
         </view>
      </u-mask>
   </view>
</template>
@@ -109,9 +120,9 @@
      },
      data() {
         return {
            BulletFrameData:{},
            showBulletFrame:false, // 用于控制弹框广告的显示
            isNewMessage:false,
            BulletFrameData: {},
            showBulletFrame: false, // 用于控制弹框广告的显示
            isNewMessage: false,
            shareShow: false,
            bannerColor: '',
            cateModel: false,
@@ -120,28 +131,27 @@
            current: 1,
            scrollTop: 0,
            fixedClass: false,
            canrefush:true,
            canrefush: true,
            categoryList: [],
            canswiper:false,
            scrollleftnum:0,
            rowLeft:0,
            nowcurrentid:'',
            recomendType:1,
            isshowtype:false,
            hasshow:false
            canswiper: false,
            scrollleftnum: 0,
            rowLeft: 0,
            nowcurrentid: '',
            recomendType: 1,
            isshowtype: false,
            hasshow: false
         }
      },
      onLoad() {
         this.getCategoryList();
         this.getPopBannerInfo();
         this.getCusPopupInfo();
         this.getArgument();
      },
      onShow() {
         if(!this.hasshow)
         {
         if (!this.hasshow) {
            this.shShow();
         }
         if(this.categoryList){
         }
         if (this.categoryList) {
            this.getCategoryList();
         }
         this.getNewMessage();
@@ -154,31 +164,37 @@
      },
      watch: {},
      methods: {
         shShow()
         getArgument()
         {
            var that=this;
            var istoLogin=true;
            var arg=getApp().globalData.argumentStr;
            if(arg&&arg.length>0)
            {
               getApp().targetArgument(arg);
               getApp().globalData.argumentStr="";
            }
         },
         shShow() {
            var that = this;
            var istoLogin = true;
            this.$u.api.comminInt({}).then(e => {
               that.hasshow=true;
               that.hasshow = true;
               // #ifdef APP-PLUS
               if (plus.os.name == 'iOS') {
                  if (e.data.basic.iosExamine && plus.runtime.version == e.data.basic.IosExamineV) {
                     that.isshowtype=true;
                     istoLogin=false;
                     that.isshowtype = true;
                     istoLogin = false;
                  } else {
                     that.isshowtype=false;
                     that.isshowtype = false;
                  }
               }
               if(istoLogin)
               {
                  if(!that.hasLogin){
               if (istoLogin) {
                  if (!that.hasLogin) {
                     setTimeout(() => {
                        uni.reLaunch({
                           url:"/pages/login/wxlogin"
                           url: "/pages/login/wxlogin"
                        })
                     }, 1000)
                  }
                  /* var user= uni.getStorageSync('userInfo');
                  if(!user.invitation_code)
@@ -192,15 +208,32 @@
                     return;
                  } */
               }
               // #endif
            }).catch(function(err) {
               console.log(err);
            })
         },
         goToShowBulletFrame(info){
             this.showBulletFrame = false
         goToShowBulletFrame(info) {
            this.showBulletFrame = false
            utils.goUrl(info, this)
         },
         getCusPopupInfo() { //获取自定义弹窗数据
            var that = this;
            this.$u.api.getCustomizePopup({}).then(e => {
               if (e.code == 0) {
                  var res = e.data;
                  if (res.haspop) { //有自定义弹窗
                     this.showBulletFrame = true;
                     this.BulletFrameData = res.info;
                  } else {
                     this.getPopBannerInfo();
                  }
               }
            }).catch(function(err) {
               this.getPopBannerInfo();
            })
         },
         getPopBannerInfo() {
            // banner数据
@@ -210,46 +243,46 @@
            }).then(e => {
               if (e.code == 1) return that.$alert(e.msg);
               var res = e.data.info;
               if(res.length > 0){
               if (res.length > 0) {
                  this.showBulletFrame = true;
                  this.BulletFrameData = res[0]
               }
            }).catch(function(err) {
            })
            }).catch(function(err) {})
         },
         getNewMessage(){
         getNewMessage() {
            var that = this;
            this.$u.api.getTopMessId({}).then(e => {
               if(e.code != 0)return that.$alert(e.msg)
               if(e.data.id){
               if (e.code != 0) return that.$alert(e.msg)
               if (e.data.id) {
                  let oldId = uni.getStorageSync('topMessageId');
                  if(oldId != e.data.id)that.isNewMessage = true;
                  if (oldId != e.data.id) that.isNewMessage = true;
               }
            }).catch(function (err) {
            })
            }).catch(function(err) {})
         },
         rowscroll(e){
         rowscroll(e) {
            this.rowLeft = e.scrollLeft
         },
         currentscroll(left){
         currentscroll(left) {
            this.nowcurrentid = ''
            this.scrollleftnum = this.rowLeft
            this.$nextTick(()=>{
            this.$nextTick(() => {
               this.nowcurrentid = 'category-items-active'
            })
         },
         getCategoryList() {
            var that = this;
            this.$u.api.getTopCalss({ctype:1,parentId:0}).then(e => {
               if(e.code != 0)return that.$alert(e.msg)
            this.$u.api.getTopCalss({
               ctype: 1,
               parentId: 0
            }).then(e => {
               if (e.code != 0) return that.$alert(e.msg)
               var obj = {}
               obj.cname = '推荐';
               obj.cid = 0;
               obj.ctype = 0;
               that.categoryList = e.data.list;
               that.categoryList.unshift(obj);
            }).catch(function (err) {
            })
            }).catch(function(err) {})
         },
         // 页面样式处理
@@ -283,12 +316,12 @@
               this.$refs.indexPage[0].getNextPage()
            }
         },
         swipering(){
         swipering() {
            this.canrefush = false
         },
         stopswiper(){
         stopswiper() {
            this.canrefush = true
         },
         // 路由跳转
@@ -301,9 +334,7 @@
               uni.navigateTo({
                  url: './officialNotice'
               })
            }
            else if(url=='turnChain')
            {
            } else if (url == 'turnChain') {
               uni.navigateTo({
                  url: '../mine/tools/turnChain'
               })
@@ -369,11 +400,11 @@
</script>
<style lang="scss">
   uni-image
   {
      width:30rem;
      height:25rem
   uni-image {
      width: 30rem;
      height: 25rem
   }
   .index-wrapper {
      height: 100vh;
      overflow: hidden;
@@ -440,8 +471,9 @@
               color: #FFFFFF;
            }
         }
         .searchImg{
            image{
         .searchImg {
            image {
               width: 40rpx;
               height: 40rpx;
               font-size: 50rpx;
@@ -576,30 +608,33 @@
         }
      }
   }
   .warp{
       position: relative;
       top:50%;
       left:50%;
       transform: translate(-50%, -50%);
       display:flex;
       align-items: center;
       justify-content: center;
   .warp {
      position: relative;
      top: 50%;
      left: 50%;
      transform: translate(-50%, -50%);
      display: flex;
      align-items: center;
      justify-content: center;
      width: 100%;
       .pic{
     //       width: 86.6%;
      .pic {
         //       width: 86.6%;
         // height: 100vw;
       }
      }
   }
   .clone {
       position:absolute;
       bottom: -30rpx;
       transform: translate(calc(50% - 32rpx));
       .image {
           width: 64rpx;
           margin: 0 auto;
           height: 64rpx;
           display: block;
       }
      position: absolute;
      bottom: -30rpx;
      transform: translate(calc(50% - 32rpx));
      .image {
         width: 64rpx;
         margin: 0 auto;
         height: 64rpx;
         display: block;
      }
   }
</style>
</style>