qingyiay
2023-07-18 472a1ffc28590479b3f4027cbe8d04e699b6e592
store/index.js
@@ -105,7 +105,9 @@
      globalIntervalId: null,
      is_open_socket: false, //避免重复连接
      connectNum: 1, //重连次数,
      reconnectTimeOut: null
      reconnectTimeOut: null,
      // 称重稳定态  0/稳定 1/非稳定  非稳定态不能点称重
      globalWarning: false
   },
   mutations: {
      lengthchange(state, payload) {
@@ -169,12 +171,16 @@
      },
      // 改变重连次数
      changereconnectNum(state, payload) {
         if (state.connectNum < 6) {
         if (state.connectNum <= 6) {
            state.connectNum += payload
         } else {
            state.connectNum = payload
         }
      },
      // 改变稳定态
      changeWarning(state, payload) {
         state.globalWarning = payload
      }
   },
   actions: {
      websocketInit({ state, dispatch, commit }) {
@@ -225,7 +231,7 @@
         clearInterval(state.reconnectTimeOut)
         state.socketTast = null
         commit('changereconnectState', false)
         if (state.connectNum < 6 && state.globalisLogin) {
         if (state.connectNum <= 6 && state.globalisLogin) {
            uni.showToast({
               title: `连接失败,正在尝试第${state.connectNum}次连接`,
               icon: 'none'
@@ -256,7 +262,7 @@
            })
            commit('changereconnectNum', 1)
            dispatch('reconnect')
         } else if (state.connectNum > 6 && state.globalisLogin) {
         } else if (state.connectNum >= 6 && state.globalisLogin) {
            commit('changereconnectNum', 1)
            uni.showToast({
               title: '网络异常,请稍后重试',