| | |
| | | 'https://mx.jzeg.cn:9095/appimg/image/tour/quality/quality16.jpg', |
| | | 'https://mx.jzeg.cn:9095/appimg/image/tour/quality/quality17.jpg', |
| | | ], |
| | | qualityTourImgList:['https://mx.jzeg.cn:9095/appimg/image/tour/quality/quality1.jpg', |
| | | 'https://mx.jzeg.cn:9095/appimg/image/tour/quality/quality2.jpg', |
| | | 'https://mx.jzeg.cn:9095/appimg/image/tour/quality/quality3.jpg', |
| | | 'https://mx.jzeg.cn:9095/appimg/image/tour/quality/quality4.jpg', |
| | | 'https://mx.jzeg.cn:9095/appimg/image/tour/quality/quality5.jpg', |
| | | 'https://mx.jzeg.cn:9095/appimg/image/tour/quality/quality6.jpg', |
| | | 'https://mx.jzeg.cn:9095/appimg/image/tour/quality/quality7.jpg', |
| | | 'https://mx.jzeg.cn:9095/appimg/image/tour/quality/quality8.jpg', |
| | | 'https://mx.jzeg.cn:9095/appimg/image/tour/quality/quality9.jpg'] |
| | | }, |
| | | mutations: { |
| | | lengthchange(state, payload) { |
| | |
| | | state.globalisLogin = payload |
| | | console.log(state.globalisLogin, '全局登录状态改变了') |
| | | }, |
| | | changesocketTask(state, payload) { |
| | | state.socketTask = payload |
| | | }, |
| | | setWebsocketData(state, data) { |
| | | console.log(data,'data-----') |
| | | state.websocketData = data |
| | | }, |
| | | // 改变重连状态 |
| | |
| | | actions: { |
| | | websocketInit({ state, dispatch, commit }) { |
| | | let wsUrl = `${webSocketUrl}?access_token=${uni.getStorageSync('token')}` |
| | | state.socketTast = uni.connectSocket({ |
| | | state.socketTask = uni.connectSocket({ |
| | | url: wsUrl, |
| | | header: { CLIENT_TOC: 'Y' }, |
| | | success: res => { |
| | |
| | | } |
| | | |
| | | }) |
| | | 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', e)) |
| | | state.socketTask.onOpen(() => dispatch('websocketOnOpen')) |
| | | state.socketTask.onMessage(result => dispatch('websocketOnMessage', result.data)) |
| | | state.socketTask.onClose(e => dispatch('websocketOnClose', e)) |
| | | state.socketTask.onError(e => dispatch('websocketOnError', e)) |
| | | }, |
| | | websocketOnOpen({ state, commit }) { |
| | | console.log('ws打开') |
| | | clearInterval(state.reconnectTimeOut) |
| | | clearInterval(state.globalIntervalId) |
| | | state.globalIntervalId = setInterval(() => { |
| | | state.socketTast.send({ |
| | | state.socketTask.send({ |
| | | data: JSON.stringify({ type: 'ping' }), |
| | | success(e) { |
| | | console.log(e, '发送心跳成功') |
| | |
| | | }, 30000) |
| | | }, |
| | | websocketOnClose({ state, commit, dispatch }, e) { |
| | | if (!state.socketTast) return |
| | | if (!state.socketTask) return |
| | | console.log('ws关闭', e) |
| | | state.socketTast.close(e => { |
| | | state.socketTask.close(e => { |
| | | commit('changeisconnect', false) |
| | | }) |
| | | clearInterval(state.globalIntervalId) |
| | | clearInterval(state.reconnectTimeOut) |
| | | state.socketTast = null |
| | | state.socketTask = null |
| | | commit('changereconnectState', false) |
| | | if (state.connectNum <= 6 && state.globalisLogin) { |
| | | uni.showToast({ |
| | |
| | | console.log('ws报错', e) |
| | | clearInterval(state.globalIntervalId) |
| | | clearInterval(state.reconnectTimeOut) |
| | | state.socketTast = null |
| | | state.socketTask = null |
| | | commit('changereconnectState', false) |
| | | if (state.connectNum < 6 && state.globalisLogin) { |
| | | uni.showToast({ |
| | |
| | | }, 5000) |
| | | } |
| | | } |
| | | }, |
| | | getters: { |
| | | websocketData:(state) => state.websocketData |
| | | } |
| | | }) |
| | | |
| | | export default store |
| | | export default store |