| | |
| | | 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) |
| | | |
| | | // 动态底部tabbar |
| | |
| | | confirmWeighContent: '', |
| | | // 称重稳定态 0/稳定 1/非稳定 非稳定态不能点称重 |
| | | globalWarning: false, |
| | | filedId:'', //煤场id |
| | | bunkerList:'', //煤仓list |
| | | }, |
| | | mutations: { |
| | | setUserInfo(state, identity) { |
| | |
| | | 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: { |
| | | header: { |
| | | clientToc: 'Y' , |
| | | 'CLIENT_TOC': 'Y', |
| | | }, |
| | |
| | | dispatch('websocketInit') |
| | | }, 5000) |
| | | } |
| | | } |
| | | }, |
| | | |
| | | //filedId |
| | | async getBunkerList({ state,dispatch, commit }) { //获取filedId |
| | | // this.$reqGet(`getList/${this.deptId}`).then(res => { |
| | | // console.log(res,'想得到filedId') |
| | | // }) |
| | | 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) |
| | | }) |
| | | }, |
| | | } |
| | | }) |
| | | |