Houjie
2025-06-03 2fda34643bc22e25f6c569415da5f955c81536bf
pages/home/home.vue
@@ -2,11 +2,12 @@
   <view>
      <scroll-view>
         <!-- 轮播 -->
         <swiper class="screen-swiper square-dot"  :indicator-dots="true" :circular="true"
          :autoplay="true" interval="5000" duration="500" :style="[{animation: 'show 0.2s 1'}]">
         <swiper class="screen-swiper square-dot" :indicator-dots="true" :circular="true" :autoplay="true"
            interval="5000" duration="500" :style="[{animation: 'show 0.2s 1'}]">
            <swiper-item v-for="(item,index) in swiperList" :key="index">
               <image :src="item.url" mode="aspectFill" v-if="item.type=='image'"></image>
               <video :src="item.url" autoplay loop muted :show-play-btn="false" :controls="false" objectFit="cover" v-if="item.type=='video'"></video>
               <video :src="item.url" autoplay loop muted :show-play-btn="false" :controls="false"
                  objectFit="cover" v-if="item.type=='video'"></video>
            </swiper-item>
         </swiper>
         
@@ -17,13 +18,25 @@
            </view>
         </view>
            
         <view class="cu-list grid col-4 text-sm">
         <!--          <view class="cu-list grid col-4 text-sm">
            <view class="cu-item animation-slide-bottom" :style="[{animationDelay: (index + 1)*0.05 + 's'}]" v-for="(item,index) in usList" :key="index" @tap="goPage(item.page)">
               <view class="padding text-center">
                  <image :src="item.icon" style="width:28px;height:28px;">
                     <view class="cu-tag badge margin-top-sm" style="margin-left:1.2em" v-if="getTtemDotInfo(item)">
                        <block v-if="getTtemDotInfo(item)">{{getTtemDotInfo(item)}}</block>
                     </view>
                  </image>
                  <view class="margin-top-xs">{{item.title}}</view>
               </view>
            </view>
         </view> -->
         <view class="cu-list grid col-4 text-sm">
            <view class="cu-item animation-slide-bottom" :style="[{animationDelay: (index + 1)*0.05 + 's'}]"
               v-for="(item, index) in usList" :key="index" @tap="goPage(item.page)">
               <view class="padding text-center">
                  <image :src="item.icon" style="width:28px;height:28px;">
                     <view class="cu-tag badge margin-top-sm" style="margin-left:1.2em"
                        v-if="getTtemDotInfo(item)"></view>
                  </image>
                  <view class="margin-top-xs">{{item.title}}</view>
               </view>
@@ -37,7 +50,8 @@
            </view>
         </view>
         <view class="cu-list grid col-4 text-sm">
            <view class="cu-item animation-slide-bottom" :style="[{animationDelay: (index + 1)*0.1 + 's'}]" v-for="(item,index) in osList" :key="index" @tap="goPage(item.page)">
            <view class="cu-item animation-slide-bottom" :style="[{animationDelay: (index + 1)*0.1 + 's'}]"
               v-for="(item,index) in osList" :key="index" @tap="goPage(item.page)">
               <view class="padding text-center">
                  <image :src="item.icon" style="width:28px;height:28px;"/>
                  <view class="margin-top-xs">{{item.title}}</view>
@@ -53,7 +67,8 @@
            </view>
         </view>
         <view class="cu-list grid col-4 text-sm">
            <view class="cu-item animation-slide-bottom" :style="[{animationDelay: (index + 1)*0.1 + 's'}]" v-for="(item,index) in wsList" :key="index" @tap="goPage(item.page)">
            <view class="cu-item animation-slide-bottom" :style="[{animationDelay: (index + 1)*0.1 + 's'}]"
               v-for="(item,index) in wsList" :key="index" @tap="goPage(item.page)">
               <view class="padding text-center">
                  <image :src="item.icon" style="width:28px;height:28px;"/>
                  <view class="margin-top-xs">{{item.title}}</view>
@@ -67,7 +82,14 @@
</template>
<script>
   import { us,os,ws} from '@/common/util/work.js'
   import {
      ACCESS_TOKEN
   } from '@/common/util/constants.js'
   import {
      us,
      os,
      ws
   } from '@/common/util/work.js'
   import socket from '@/common/js-sdk/socket/socket.js'
   export default {
      name: 'home',
@@ -85,20 +107,52 @@
      },
      data() {
         return {
          swiperList: [
              {id:1,type: 'image',url: '/static/banner/eam_banner1.png', link: ''},
              {id:2,type: 'image',url: '/static/banner/eam_banner2.png', link: ''},
              {id:3,type: 'image',url: '/static/banner/eam_banner3.png', link: ''},
              {id:4,type: 'image',url: '/static/banner/eam_banner4.png', link: ''},
            url: {
               bindingThirdPhone: '/sys/permission/getUserPermissionByToken',
               countItem: '/assign/flow/taskCountBySelf'
            },
            swiperList: [{
                  id: 1,
                  type: 'image',
                  url: '/static/banner/eam_banner1.png',
                  link: ''
               },
               {
                  id: 2,
                  type: 'image',
                  url: '/static/banner/eam_banner2.png',
                  link: ''
               },
               {
                  id: 3,
                  type: 'image',
                  url: '/static/banner/eam_banner3.png',
                  link: ''
               },
               {
                  id: 4,
                  type: 'image',
                  url: '/static/banner/eam_banner4.png',
                  link: ''
               },
            ],
            middleApps: [
              {icon: 'line2_icon1.png', title: '审批', 'text': '个人审批'},
              {icon: 'line2_icon2.png', title: '审批稿', 'text': '审批草稿箱'},
            middleApps: [{
                  icon: 'line2_icon1.png',
                  title: '审批',
                  'text': '个人审批'
               },
               {
                  icon: 'line2_icon2.png',
                  title: '审批稿',
                  'text': '审批草稿箱'
               },
            ],
            usList:us.data,
            osList:os.data,
            wsList:ws.data,
            msgCount:0,
            toDomsgCount: 0,
            dot:{
              mailHome:false
            }
@@ -109,6 +163,8 @@
            console.log("-----------home------------")
             this.onSocketOpen()
             this.onSocketReceive()
            this.saveClientId()
            this.taskCountBySelf();
             this.loadCount(0);
         },
         goPage(page){
@@ -119,7 +175,9 @@
              this.msgCount = 0
            }
            this.dot[page]=false
            this.$Router.push({name: page})
            this.$Router.push({
               name: page
            })
         },
         // 启动webSocket
         onSocketOpen() {
@@ -141,6 +199,14 @@
               }
            }
         },
         taskCountBySelf() {
            let token = uni.getStorageSync(ACCESS_TOKEN)
            this.$http.get(this.url.countItem).then(res => {
               console.log("res::taskCountBySelf>", res)
               this.toDomsgCount = res.data.result
            })
         },
         loadCount(flag){
            console.log("loadCount::flag",flag)
            let url = '/sys/annountCement/listByUser';
@@ -154,14 +220,38 @@
              }
            })
         },
         saveClientId() {
            let token = uni.getStorageSync(ACCESS_TOKEN)
            this.$http.get(this.url.bindingThirdPhone, {
               params: {
                  token: token
               }
            }).then(res => {
               const authData = res.data.result.auth
               // 确保是数组
               if (!Array.isArray(authData)) {
                  console.warn('auth 不是数组:', authData)
                  return
               }
               // 存入 store
               this.$store.dispatch('saveAuth', authData)
               console.log('当前 store 中的 auth:', this.$store.getters.getAuth)
            }).catch(err => {
               console.error("获取 auth 失败:", err)
            })
         },
         loadEmailCount(){
            this.dot.mailHome = true
         },
         getTtemDotInfo(item){
            if(item.page==='annotationList' && this.msgCount>0){
              return this.msgCount
            if (item.page === 'ToDoList' && this.toDomsgCount > 0) {
               // return this.toDomsgCount
               return true
            }
            return '';
            return false;
         }
      }
   }
@@ -171,9 +261,9 @@
   .cu-list.grid>.cu-item {
     padding: 0px 0px; 
   }
    .line2-icon {
     width: 60px;
     height: 60px;
    }
</style>