| | |
| | | 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 |
| | |
| | | selectedIconPath: '../../static/tabBar-icon/Bmine57.png', |
| | | text: '我的' |
| | | } |
| | | ] |
| | | ], |
| | | fourth: [{ |
| | | pagePath: 'pages/tabbar-page/index-tabbar/index-tabbar', |
| | | iconPath: '../../static/tabBar-icon/home.png', |
| | | selectedIconPath: '../../static/tabBar-icon/homeblue.png', |
| | | text: '进场' |
| | | },{ |
| | | pagePath: 'pages/doorkeeper-page/doorkeeper-index/exit-index', |
| | | iconPath: '../../static/tabBar-icon/home.png', |
| | | selectedIconPath: '../../static/tabBar-icon/homeblue.png', |
| | | text: '出场' |
| | | }, |
| | | { |
| | | pagePath: 'pages/tabbar-page/myPage-tabbar/myPage-tabbar', |
| | | iconPath: '../../static/tabBar-icon/Gmine10.png', |
| | | selectedIconPath: '../../static/tabBar-icon/Bmine57.png', |
| | | text: '我的' |
| | | }, |
| | | |
| | | ], |
| | | five:[{ |
| | | pagePath: 'pages/tabbar-page/index-tabbar/index-tabbar', |
| | | iconPath: '../../static/tabBar-icon/home.png', |
| | | selectedIconPath: '../../static/tabBar-icon/homeblue.png', |
| | | text: '首页' |
| | | }, |
| | | { |
| | | pagePath: 'pages/loadUnload-page/orderPlanList/index', |
| | | iconPath: '../../static/tabBar-icon/Gmine10.png', |
| | | selectedIconPath: '../../static/tabBar-icon/Bmine57.png', |
| | | text: '日计划' |
| | | }, |
| | | { |
| | | pagePath: 'pages/tabbar-page/myPage-tabbar/myPage-tabbar', |
| | | iconPath: '../../static/tabBar-icon/Gmine10.png', |
| | | selectedIconPath: '../../static/tabBar-icon/Bmine57.png', |
| | | text: '我的' |
| | | }, |
| | | ] |
| | | } |
| | | const store = new Vuex.Store({ |
| | | state: { |
| | |
| | | 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', |
| | |
| | | confirmWeighContent: '', |
| | | // 称重稳定态 0/稳定 1/非稳定 非稳定态不能点称重 |
| | | globalWarning: false, |
| | | filedId:'', //煤场id |
| | | bunkerList:'', //煤仓list |
| | | }, |
| | | mutations: { |
| | | setUserInfo(state, identity) { |
| | |
| | | state.userTabbar = userRoleTabbar.second |
| | | uni.setStorageSync('userTabbar', state.userTabbar) |
| | | } else if (roleType == 5) { |
| | | state.userTabbar = userRoleTabbar.three |
| | | state.userTabbar = userRoleTabbar.five |
| | | uni.setStorageSync('userTabbar', state.userTabbar) |
| | | }else if (roleType == 6) { |
| | | state.userTabbar = userRoleTabbar.fourth |
| | | uni.setStorageSync('userTabbar', state.userTabbar) |
| | | } |
| | | }, |
| | |
| | | changesocketTask(state, payload) { |
| | | state.socketTask = payload |
| | | }, |
| | | // 改版全局websocket状态 |
| | | // 改版全局websocket状态(判断是否正常链接) |
| | | changeisconnect(state, payload) { |
| | | state.globalisconnect = 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') { |
| | |
| | | }, |
| | | 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' }), |
| | |
| | | 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) |
| | | }) |
| | | }, |
| | | } |
| | | }) |
| | | |
| | | export default store |
| | | export default store |