From 9ca5d844e24a9d72307f17f6d81eac0f843ec9e2 Mon Sep 17 00:00:00 2001
From: xuefei <564615061@qq.cm>
Date: 星期一, 03 七月 2023 09:11:37 +0800
Subject: [PATCH] 请求过滤null
---
store/index.js | 90 +++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 87 insertions(+), 3 deletions(-)
diff --git a/store/index.js b/store/index.js
index 72a6b9c..5b11172 100644
--- a/store/index.js
+++ b/store/index.js
@@ -1,5 +1,6 @@
import Vue from 'vue'
import Vuex from 'vuex'
+import { webSocketUrl } from '@/api/request.js'
Vue.use(Vuex)
// 鍔ㄦ�佸簳閮╰abbar
@@ -28,6 +29,31 @@
iconPath: '../../static/tabBar-icon/home.png',
selectedIconPath: '../../static/tabBar-icon/homeblue.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: '鎴戠殑'
+ }
+ ],
+ three: [{
+ pagePath: 'pages/tabbar-page/index-tabbar/index-tabbar',
+ iconPath: '../../static/tabBar-icon/home.png',
+ selectedIconPath: '../../static/tabBar-icon/homeblue.png',
+ text: '棣栭〉'
+ },
+ {
+ pagePath: 'pages/driver-page/driver-index/bill-of-lading-details/selectOrderPlan/selectOrderPlan',
+ iconPath: '../../static/tabBar-icon/checking.png',
+ selectedIconPath: '../../static/tabBar-icon/checkingblue.png',
+ text: '楠岃川'
},
{
pagePath: 'pages/customer-page/customer-my/faYunstatistics/faYunstatistics',
@@ -71,8 +97,12 @@
weight: '',
userId: ''
},
- globalisconnect: false,
- globalisUploadimg: false
+ globalisconnect: true,
+ globalisUploadimg: false,
+ globalisLogin: false,
+ socketTask: null,
+ websocketData: null, // 瀛樻斁浠庡悗绔帴鏀跺埌鐨剋ebsocket鏁版嵁
+ globalIntervalId: null,
},
mutations: {
lengthchange(state, payload) {
@@ -89,6 +119,9 @@
uni.setStorageSync('userTabbar', state.userTabbar)
} else if (roleType == 2 || roleType == 3) {
state.userTabbar = userRoleTabbar.second
+ uni.setStorageSync('userTabbar', state.userTabbar)
+ } else if (roleType == 4) {
+ state.userTabbar = userRoleTabbar.three
uni.setStorageSync('userTabbar', state.userTabbar)
}
},
@@ -119,8 +152,59 @@
},
changeisUploadimg(state, payload) {
state.globalisUploadimg = payload
+ },
+ changeisLogin(state, payload) {
+ state.globalisLogin = payload
+ console.log(state.globalisLogin, '鍏ㄥ眬鐧诲綍鐘舵�佹敼鍙樹簡')
+ },
+ setWebsocketData(state, data) {
+ state.websocketData = data
+ }
+ },
+ actions: {
+ websocketInit({ state, dispatch, commit }) {
+ let wsUrl = `${webSocketUrl}?access_token=${uni.getStorageSync('token')}`
+ state.socketTast = uni.connectSocket({
+ url: wsUrl,
+ header: { CLIENT_TOC: 'Y' },
+ complete: res => {
+ console.log(res, 'socket缁撴灉')
+ if (res.errMsg === 'connectSocket:ok') {
+ commit('changeisconnect', true)
+ }
+ }
+ })
+ 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'))
+ },
+ websocketOnOpen({ state, commit }) {
+ console.log('onOpen')
+ state.globalIntervalId = setInterval(() => {
+ state.socketTast.send({
+ data: JSON.stringify({ type: 'ping' }),
+ success(e) {
+ console.log(e, '鍙戦�佸績璺虫垚鍔�')
+ }
+ })
+ }, 30000)
+ },
+ websocketOnClose({ state, commit }) {
+ if (!state.socketTast) return
+ state.socketTast.close(e => {
+ commit('changeisconnect', false)
+ })
+ console.log('ws鍏抽棴')
+ },
+ websocketOnError(e) {
+ console.log('socket鎶ラ敊', e)
+ },
+ // 鎺ユ敹鏁版嵁
+ websocketOnMessage({ state, commit }, result) {
+ commit('setWebsocketData', result)
}
}
})
-export default store
+export default store
\ No newline at end of file
--
Gitblit v1.9.1