From 9d613909e7caf4ae5904d5047e69e9f013d01155 Mon Sep 17 00:00:00 2001 From: 819527061@qq.com <123456> Date: 星期三, 29 五月 2024 14:37:37 +0800 Subject: [PATCH] feture:新增取样页面 --- store/index.js | 92 ++++++++++++++++++++++++++++++++++++++------- 1 files changed, 77 insertions(+), 15 deletions(-) diff --git a/store/index.js b/store/index.js index bdb23b7..ac8863b 100644 --- a/store/index.js +++ b/store/index.js @@ -1,6 +1,10 @@ import Vue from 'vue' import Vuex from 'vuex' -import { webSocketUrl } from '@/api/request.js' +import { webSocketUrl,BaseUrl } from '@/api/request.js' +// 璇锋眰鐩稿叧 +import { + reqGet, +} from '@/api/index.js' Vue.use(Vuex) // 鍔ㄦ�佸簳閮╰abbar @@ -93,8 +97,8 @@ globalIntervalId: null, is_open_socket: false, //閬垮厤閲嶅杩炴帴 connectNum: 1, //閲嶈繛娆℃暟, - reconnectTimeOut: null, - // 鎵撳嵃鍑哄叆闂ㄨ瘉 涓�娆″氨鍙互鏈夋墦鍗板叆闂ㄨ瘉锛� 涓ゆ鍙互鏈夊叆闂ㄨ瘉 鍑洪棬璇� 0娆′竴寮犻兘娌℃湁 + reconnectTimeOut: null, //閲嶆柊閾炬帴鐨勫畾鏃跺櫒 + // 鎵撳嵃鍑哄叆闂ㄨ瘉 涓�娆″氨鍙互鏈夋墦鍗板叆闂ㄨ瘉锛� 涓ゆ鍙互鏈夊叆闂ㄨ瘉 鍑洪棬璇� 0娆′竴寮犻兘娌℃湁 ablePrintInduction: false, //鍏ラ棬璇� ablePrintOut: false, //鍑洪棬璇� driverTourImgList: ['https://mx.jzeg.cn:9096/appimg/image/tour/driver/sj1.png', @@ -147,12 +151,13 @@ wsgContent: '', globalIsFirstWeighing: 1, //鏄惁鏄涓�娆′笂纾� confirmWeighVisiable: false, //纾呮埧绠$悊纭绉伴噸瀹屾垚鎻愮ず寮圭獥 - confirmWeighContent: '' + confirmWeighContent: '', + // 绉伴噸绋冲畾鎬� 0/绋冲畾 1/闈炵ǔ瀹� 闈炵ǔ瀹氭�佷笉鑳界偣绉伴噸 + globalWarning: false, + filedId:'', //鐓ゅ満id + bunkerList:'', //鐓や粨list }, mutations: { - lengthchange(state, payload) { - state.fleetDriverDataLength = payload - }, setUserInfo(state, identity) { state.userInfo = userObj[identity] }, @@ -194,7 +199,7 @@ changesocketTask(state, payload) { state.socketTask = payload }, - // 鏀圭増鍏ㄥ眬websocket鐘舵�� + // 鏀圭増鍏ㄥ眬websocket鐘舵�侊紙鍒ゆ柇鏄惁姝e父閾炬帴锛� changeisconnect(state, payload) { state.globalisconnect = payload }, @@ -244,14 +249,37 @@ }, changeconfirmWeighContent(state, payload) { state.confirmWeighContent = payload + }, + // 鏀瑰彉绋冲畾鎬� + changeWarning(state, payload) { + state.globalWarning = payload + }, + // 鐓ゅ満filedId鐨勮幏鍙� + getFiledId(state, payload) { + console.log(payload,'filedId=====') + state.filedId = payload + uni.setStorageSync('filedId', state.filedId) + }, + getBunkerList(state, payload) { + console.log('鎴戞墽琛屼簡getBunkerList====',payload) + state.bunkerList = payload + uni.setStorageSync('bunkerList', state.bunkerList) } }, actions: { websocketInit({ state, dispatch, commit }) { + // #ifdef H5 + let wsUrl = `access_token=${uni.getStorageSync('token')}` + // #endif + // #ifndef H5 let wsUrl = `${webSocketUrl}?access_token=${uni.getStorageSync('token')}` + // #endif state.socketTask = uni.connectSocket({ url: wsUrl, - header: { CLIENT_TOC: 'Y' }, + header: { + clientToc: 'Y' , + 'CLIENT_TOC': 'Y', + }, success: res => { console.log(res, 'socketSuccess') if (res.errMsg === 'connectSocket:ok') { @@ -274,8 +302,8 @@ }, websocketOnOpen({ state, commit }) { console.log('ws鎵撳紑') - clearInterval(state.reconnectTimeOut) - clearInterval(state.globalIntervalId) + clearInterval(state.reconnectTimeOut) //娓呴櫎涓婁竴娆$殑瀹氭椂鍣� + clearInterval(state.globalIntervalId) //娓呴櫎蹇冭烦 state.globalIntervalId = setInterval(() => { state.socketTask.send({ data: JSON.stringify({ type: 'ping' }), @@ -295,8 +323,7 @@ clearInterval(state.reconnectTimeOut) state.socketTask = null commit('changereconnectState', false) - console.log(state.connectNum, state.connectNum.connectNum, '閾炬帴鏁�'); - if (state.connectNum < 6 || state.connectNum.connectNum < 6 && state.globalisLogin) { + if ((state.connectNum < 6 || state.connectNum.connectNum < 6) && state.globalisLogin) { uni.showToast({ title: '杩炴帴澶辫触锛屾鍦ㄥ皾璇曢噸鏂拌繛鎺�', icon: 'none' @@ -350,8 +377,43 @@ dispatch('websocketInit') }, 5000) } - } + }, + + //filedId + async getBunkerList({ state,dispatch, commit }) { //鑾峰彇filedId + // this.$reqGet(`getList/${this.deptId}`).then(res => { + // console.log(res,'鎯冲緱鍒癴iledId') + // }) + let deptId = uni.getStorageSync('userInfo').deptIds + console.log(deptId,'deptId====') + await uni.request({ //鑾峰彇deptId + url: `/wrzs/jccoalfiled/list/${deptId}`, + method: 'GET', + header: { + Authorization: 'Bearer' + ' ' + uni.getStorageSync('token'), + clientToc: 'Y', + 'CLIENT_TOC': 'Y', + }, + success: res => { + console.log(res,'filedId鎺ュ彛000000000000') + commit('getFiledId',res.data.data[0].id || '') + dispatch('getFiledIdCoalBunker') + // console.log(res,'shuj------') + // this.filedId = res.data?.data.length > 0 ? res.data.data[0].id : ''; + // this.getFiledIdCoalBunker() + } + }) + + }, + getFiledIdCoalBunker({ state, commit }) { //鐓や粨鍒楄〃锛堥噰鏍峰湴鐐癸級 + let filedId = uni.getStorageSync('filedId') + console.log(filedId,'鏈�缁堢殑filedId=============') + reqGet('getFiledIdCoalBunker', {filedId: filedId}).then(res => { + console.log(res,'res----鐓や粨') + commit('getBunkerList',res.data) + }) + }, } }) -export default store \ No newline at end of file +export default store -- Gitblit v1.9.1