819527061@qq.com
2024-06-25 7d91779d2bb2bfec7f4f803a9e2cf65b90e401c6
store/index.js
@@ -157,6 +157,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) {
@@ -211,7 +220,11 @@
         state.globalisLogin = payload
         console.log(state.globalisLogin, '全局登录状态改变了')
      },
      changesocketTask(state, payload) {
         state.socketTask = payload
      },
      setWebsocketData(state, data) {
         console.log(data,'data-----')
         state.websocketData = data
      },
      // 改变重连状态
@@ -241,7 +254,7 @@
   actions: {
      websocketInit({ state, dispatch, commit }) {
         let wsUrl = `${webSocketUrl}?access_token=${uni.getStorageSync('token')}`
         state.socketTast = uni.connectSocket({
         state.socketTask = uni.connectSocket({
            url: wsUrl,
            header: { CLIENT_TOC: 'Y' },
            success: res => {
@@ -259,17 +272,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,14 +291,14 @@
         }, 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({
@@ -309,7 +322,7 @@
         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({
@@ -342,7 +355,10 @@
            }, 5000)
         }
      }
   },
   getters: {
      websocketData:(state) => state.websocketData
   }
})
export default store
export default store