From 9579955eecf9584697c546eae6ba90fb33795e40 Mon Sep 17 00:00:00 2001
From: qingyiay <2386314947@qq.com>
Date: 星期四, 29 六月 2023 18:18:23 +0800
Subject: [PATCH] 称重修改

---
 store/index.js |  108 ++++++++++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 101 insertions(+), 7 deletions(-)

diff --git a/store/index.js b/store/index.js
index 1321749..1ce1db3 100644
--- a/store/index.js
+++ b/store/index.js
@@ -1,14 +1,21 @@
 import Vue from 'vue'
 import Vuex from 'vuex'
+import { webSocketUrl } from '@/api/request.js'
 Vue.use(Vuex)
 
 // 鍔ㄦ�佸簳閮╰abbar
 const userRoleTabbar = {
 	first: [{
 			pagePath: 'pages/tabbar-page/index-tabbar/index-tabbar',
-			iconPath: '../../static/tabBar-icon/Gfayun.png',
-			selectedIconPath: '../../static/tabBar-icon/Bfayun1.png',
+			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',
@@ -19,9 +26,15 @@
 	],
 	second: [{
 			pagePath: 'pages/tabbar-page/index-tabbar/index-tabbar',
-			iconPath: '../../static/tabBar-icon/Ghome.png',
-			selectedIconPath: '../../static/tabBar-icon/Bhome.png',
+			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',
@@ -44,7 +57,27 @@
 		// 鍏ㄥ眬weihousecode
 		globalweighHouseCode: '',
 		// 鍏ㄥ眬绾㈠鐘舵��
-		globalinfraredStatus: false
+		globalinfraredStatus: false,
+		// 鍙告満淇敼涓汉淇℃伅
+		globaluserInfo: {
+			phone: '',
+			name: '',
+			username: '',
+			type: 3,
+			idCard: '',
+			carNo: '',
+			carImg: '',
+			drivingImg: '',
+			axleNum: '',
+			weight: '',
+			userId: ''
+		},
+		globalisconnect: true,
+		globalisUploadimg: false,
+		globalisLogin: false,
+		socketTask: null,
+		websocketData: null, // 瀛樻斁浠庡悗绔帴鏀跺埌鐨剋ebsocket鏁版嵁
+		globalIntervalId: null,
 	},
 	mutations: {
 		lengthchange(state, payload) {
@@ -67,7 +100,7 @@
 		// 鏀瑰彉閲嶉噺
 		changeWeigh(state, payload) {
 			state.globalweigh = payload
-			console.log(state.globalweigh, '閲嶉噺鏀瑰彉浜�')
+			console.log(state.globalweigh, '鍏ㄥ眬閲嶉噺鏀瑰彉浜�')
 		},
 		// 娑堟伅鎺ㄩ��
 		pushMessage(state, payload) {
@@ -81,8 +114,69 @@
 		// 鏀瑰彉绾㈠鐘舵��
 		changeinfraredStatus(state, payload) {
 			state.globalinfraredStatus = payload
+		},
+		changeuserInfo(state, payload) {
+			state.globaluserInfo = payload
+		},
+		// 鏀圭増鍏ㄥ眬websocket鐘舵��
+		changeisconnect(state, payload) {
+			state.globalisconnect = payload
+		},
+		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