819527061@qq.com
2024-07-30 e52e720168541aa02e0326a505d251f42828aedf
store/index.js
@@ -55,19 +55,22 @@
         iconPath: '../../static/tabBar-icon/checking.png',
         selectedIconPath: '../../static/tabBar-icon/checkingblue.png',
         text: '验质'
      },
      {
      },{
         pagePath: 'pages/customer-page/zhijian-bangfang/zhijian-bangfang',
         iconPath: '../../static/tabBar-icon/bang.png',
         selectedIconPath: '../../static/tabBar-icon/bangblue.png',
         text: '磅房'
      },{
         pagePath: 'pages/customer-page/customer-my/faYunstatistics/faYunstatistics',
         iconPath: '../../static/tabBar-icon/statistics.png',
         selectedIconPath: '../../static/tabBar-icon/statisticsactive.png',
         text: '统计'
      },
      {
      },{
         pagePath: 'pages/tabbar-page/myPage-tabbar/myPage-tabbar',
         iconPath: '../../static/tabBar-icon/Gmine10.png',
         selectedIconPath: '../../static/tabBar-icon/Bmine57.png',
         text: '我的'
      }
      },
   ]
}
const store = new Vuex.Store({
@@ -157,6 +160,15 @@
         'https://mx.jzeg.cn:9095/appimg/image/tour/quality/quality16.jpg',
         'https://mx.jzeg.cn:9095/appimg/image/tour/quality/quality17.jpg',
      ],
      qualityTourImgList:['https://mx.jzeg.cn:9095/appimg/image/tour/quality/quality1.jpg',
      'https://mx.jzeg.cn:9095/appimg/image/tour/quality/quality2.jpg',
      'https://mx.jzeg.cn:9095/appimg/image/tour/quality/quality3.jpg',
      'https://mx.jzeg.cn:9095/appimg/image/tour/quality/quality4.jpg',
      'https://mx.jzeg.cn:9095/appimg/image/tour/quality/quality5.jpg',
      'https://mx.jzeg.cn:9095/appimg/image/tour/quality/quality6.jpg',
      'https://mx.jzeg.cn:9095/appimg/image/tour/quality/quality7.jpg',
      'https://mx.jzeg.cn:9095/appimg/image/tour/quality/quality8.jpg',
      'https://mx.jzeg.cn:9095/appimg/image/tour/quality/quality9.jpg']
   },
   mutations: {
      lengthchange(state, payload) {
@@ -168,6 +180,7 @@
      // 设置底部栏
      setUserTabbar(state, roleType) {
         state.roleType = roleType
         console.log(roleType,'roledType===')
         if (roleType === 1) {
            state.userTabbar = userRoleTabbar.first
            uni.setStorageSync('userTabbar', state.userTabbar)
@@ -211,6 +224,9 @@
         state.globalisLogin = payload
         console.log(state.globalisLogin, '全局登录状态改变了')
      },
      changesocketTask(state, payload) {
         state.socketTask = payload
      },
      setWebsocketData(state, data) {
         state.websocketData = data
      },
@@ -220,10 +236,14 @@
      },
      // 改变重连次数
      changereconnectNum(state, payload) {
         if (state.connectNum <= 6) {
            state.connectNum += payload
         if (payload.isWeigh) {
            state.connectNum = payload.connectNum
         } else {
            state.connectNum = payload
            if (state.connectNum < 6) {
               state.connectNum += payload.connectNum
            } else {
               state.connectNum = payload.connectNum
            }
         }
      },
      // 改变稳定态
@@ -241,7 +261,8 @@
   actions: {
      websocketInit({ state, dispatch, commit }) {
         let wsUrl = `${webSocketUrl}?access_token=${uni.getStorageSync('token')}`
         state.socketTast = uni.connectSocket({
         // let wsUrl = `${webSocketUrl}?UUID=boyingtest`
         state.socketTask = uni.connectSocket({
            url: wsUrl,
            header: { CLIENT_TOC: 'Y' },
            success: res => {
@@ -259,17 +280,17 @@
            }
         })
         state.socketTast.onOpen(() => dispatch('websocketOnOpen'))
         state.socketTast.onMessage(result => dispatch('websocketOnMessage', result.data))
         state.socketTast.onClose(e => dispatch('websocketOnClose', e))
         state.socketTast.onError(e => dispatch('websocketOnError', e))
         state.socketTask.onOpen(() => dispatch('websocketOnOpen'))
         state.socketTask.onMessage(result => dispatch('websocketOnMessage', result.data))
         state.socketTask.onClose(e => dispatch('websocketOnClose', e))
         state.socketTask.onError(e => dispatch('websocketOnError', e))
      },
      websocketOnOpen({ state, commit }) {
         console.log('ws打开')
         clearInterval(state.reconnectTimeOut)
         clearInterval(state.globalIntervalId)
         state.globalIntervalId = setInterval(() => {
            state.socketTast.send({
            state.socketTask.send({
               data: JSON.stringify({ type: 'ping' }),
               success(e) {
                  console.log(e, '发送心跳成功')
@@ -278,24 +299,24 @@
         }, 30000)
      },
      websocketOnClose({ state, commit, dispatch }, e) {
         if (!state.socketTast) return
         if (!state.socketTask) return
         console.log('ws关闭', e)
         state.socketTast.close(e => {
         state.socketTask.close(e => {
            commit('changeisconnect', false)
         })
         clearInterval(state.globalIntervalId)
         clearInterval(state.reconnectTimeOut)
         state.socketTast = null
         state.socketTask = null
         commit('changereconnectState', false)
         if (state.connectNum <= 6 && state.globalisLogin) {
            uni.showToast({
               title: `连接失败,正在尝试第${state.connectNum}次连接`,
               icon: 'none'
            })
            commit('changereconnectNum', 1)
         if ((state.connectNum < 6 || state.connectNum.connectNum < 6) && state.globalisLogin) {
            // uni.showToast({
            //    title: '连接失败,正在尝试重新连接',
            //    icon: 'none'
            // })
            commit('changereconnectNum', { connectNum: 1, isWeigh: false })
            dispatch('reconnect')
         } else if (state.connectNum > 6 && state.globalisLogin) {
            commit('changereconnectNum', 1)
         } else if (state.connectNum >= 6 && state.globalisLogin) {
            commit('changereconnectNum', { connectNum: 1, isWeigh: false })
            uni.showToast({
               title: '网络异常,请稍后重试',
               icon: 'none'
@@ -309,17 +330,17 @@
         console.log('ws报错', e)
         clearInterval(state.globalIntervalId)
         clearInterval(state.reconnectTimeOut)
         state.socketTast = null
         state.socketTask = null
         commit('changereconnectState', false)
         if (state.connectNum < 6 && state.globalisLogin) {
            uni.showToast({
               title: `连接失败,正在尝试第${state.connectNum}次连接`,
               icon: 'none'
            })
            commit('changereconnectNum', 1)
         if (state.connectNum < 6 || state.connectNum.connectNum < 6 && state.globalisLogin) {
            // uni.showToast({
            //    title: '连接失败,正在尝试重新连接',
            //    icon: 'none'
            // })
            commit('changereconnectNum', { connectNum: 1, isWeigh: false })
            dispatch('reconnect')
         } else if (state.connectNum >= 6 && state.globalisLogin) {
            commit('changereconnectNum', 1)
         } else if (state.connectNum > 6 && state.globalisLogin) {
            commit('changereconnectNum', { connectNum: 1, isWeigh: false })
            uni.showToast({
               title: '网络异常,请稍后重试',
               icon: 'none'
@@ -342,7 +363,12 @@
            }, 5000)
         }
      }
   },
   getters: {
      websocketData:(state) => state.websocketData,
      globalweigh:(state) => state.globalweigh,
      userTabbar: (state) => state.userTabbar,
   }
})
export default store
export default store