From bb04d82473b44a79e9b823ab2054ee79814098a2 Mon Sep 17 00:00:00 2001
From: liuyg <liuyg@qq.com>
Date: Mon, 21 Feb 2022 11:38:31 +0800
Subject: [PATCH] +整体任务实行流程完善
---
leafletMapOur/grabOrdersMap/js/vueMain.js | 31
pages/grabOrders/feedback.vue | 19
store/positions.js | 113 ++++
pages/grabOrders/map - 副本.vue | 83 +++
pages/grabOrders/grabOrders.vue | 650 ++++++++++++++-----------
store/lid/getPosition.js | 180 +++++++
store/websocket.js | 84 +++
App.vue | 23
store/state.js | 66 +-
store/lid/websocketL.js | 128 +++++
pages/grabOrders/inPage/page0.vue | 13
pages/grabOrders/map.vue | 59 ++
store/mutations.js | 9
store/actions.js | 17
14 files changed, 1,107 insertions(+), 368 deletions(-)
diff --git a/App.vue b/App.vue
index f5f7fc0..d5f7b90 100644
--- a/App.vue
+++ b/App.vue
@@ -27,8 +27,27 @@
}
}
},
- watch: {},
- mounted() {},
+ computed: {
+ socketValue() {
+ return this.$store.state.socketValue;
+ }
+ },
+ watch: {
+ socketValue() {
+ console.log(this.socketValue);
+ let that = this;
+ if (that.socketValue.type === "start") {
+ console.log("任务开启")
+ this.$store.commit("addTask", this.socketValue.rid);
+ } else if (that.socketValue.type === "stop") {
+ console.log("任务结束")
+ this.$store.commit("stopTask", this.socketValue.rid);
+ }
+ }
+ },
+ mounted() {
+ this.$store.dispatch("connectws");
+ },
onLaunch: function() { //初始化完成时触发(全局只触发一次)
console.log('第一次进入')
// Window.say = Window.console;
diff --git a/leafletMapOur/grabOrdersMap/js/vueMain.js b/leafletMapOur/grabOrdersMap/js/vueMain.js
index 1fb8810..9af9922 100644
--- a/leafletMapOur/grabOrdersMap/js/vueMain.js
+++ b/leafletMapOur/grabOrdersMap/js/vueMain.js
@@ -40,17 +40,7 @@
},
methods: {
setUniAppMsg(data) {
- // console.log(data)
- // console.log(uni)
- uni.postMessage({
- data: {
- action: 'message'
- }
- });
- uni.getEnv(function(res) {
- console.log('当前环境:' + JSON.stringify(res));
- });
-
+ window.parent.hBackMsg(data)
},
openAPP(type) {
// console.log(type)
@@ -59,13 +49,22 @@
if (that.data.butCT == "beginUp") {
// 反馈
uni.navigateTo({
- url: '/pages/grabOrders/feedback?data=' + JSON.stringify(this.data)
+ url: '/pages/grabOrders/feedback?data=' + JSON.stringify(this.data) +
+ '&other="11111"'
});
} else if (that.data.butCT == "begin") {
// 开始任务
this.setUniAppMsg({
- type: "begin",
- data: that.data
+ type: "start",
+ data: {
+ id: that.data.id,
+ serid: that.data.serid
+ },
+ fn: function(val) {
+ if(val == "success"){
+ console.log("成功开启任务")
+ }
+ }
})
}
} else {
@@ -135,10 +134,10 @@
}
//url解码
this.data = this.getQueryVariable('data') || data;
- if (this.data.team) {
+ console.log(this.data)
+ if (typeof this.data.team === "string") {
this.data.team = this.data.team.split(',');
}
- console.log(this.data)
let lines = this.data.line
let position = lines.slice(lines.indexOf("(") + 1, lines.indexOf(",")).split(" ");
// console.log(position)
diff --git a/pages/grabOrders/feedback.vue b/pages/grabOrders/feedback.vue
index 145b180..e7401d7 100644
--- a/pages/grabOrders/feedback.vue
+++ b/pages/grabOrders/feedback.vue
@@ -1,5 +1,6 @@
<template>
<view class="mapJQtijiao">
+ <u-top-tips ref="uTips"></u-top-tips>
<!-- <view class="head">
<u-navbar :is-fixed="false" :border-bottom="false" :is-back="false" title=""
:background="{ background: '#0cd7e5' }">
@@ -90,7 +91,8 @@
upData() {
// console.log('开始上传');
let video = "",
- imgs = "";
+ imgs = "",
+ that = this;
for (let k in this.imgs) {
imgs += this.imgs[k].src;
if (k != this.imgs.length - 1) {
@@ -112,14 +114,22 @@
serid: uni.getStorageSync("ids")
// result: this.content,
};
- // console.log(dataList)
- // return;
+ let ds = {
+
+ }
wx.showLoading({
title: "提交中...",
mask: true
})
// console.log(dataList);
+ let d = {
+ rid: this.data.id,
+ serid: this.data.serid,
+ type: "stop",
+ that: that
+ }
+ that.$store.commit('useWebScoketApi', d);
wx.request({
url: this.$store.state.piAPI + 'taskfk/save', //仅为示例,并非真实接口地址。
data: dataList,
@@ -139,7 +149,7 @@
clearTimeout(time);
time = null;
uni.redirectTo({
- url: './grabOrders'
+ url: './grabOrders?from="feedback"'
});
}, 1000)
}
@@ -149,6 +159,7 @@
});
}
});
+
},
takePhoto() {
var that = this;
diff --git a/pages/grabOrders/grabOrders.vue b/pages/grabOrders/grabOrders.vue
index 1165720..6d8a967 100644
--- a/pages/grabOrders/grabOrders.vue
+++ b/pages/grabOrders/grabOrders.vue
@@ -1,319 +1,373 @@
<template>
- <view class="grabOrders">
- <view>
- <u-tabs-swiper
- ref="uTabs"
- :list="list"
- :current="current"
- @change="tabsChange"
- :is-scroll="false"
- swiperWidth="750"
- ></u-tabs-swiper>
- </view>
- <!-- @animationfinish="animationfinish" -->
- <swiper
- :current="swiperCurrent"
- @transition="transition"
- @animationfinish="animationfinish"
- :style="{height: 'calc(' + useHeight+' - 40px)', width: '100%'}"
- >
- <swiper-item
- class="swiper-item"
- v-for="(item, index) in list"
- :key="index"
- :style="{height: useHeight, width: '100%'}"
- >
- <scroll-view
- scroll-y
- :style="{height: useHeight, width: '100%'}"
- @scrolltolower="onreachBottom"
- >
- <page0
- :listData="leftdata"
- :swiperCurrent="0"
- v-if="item.name == '正在进行'"
- @openOnce="openOnce"
- @getOrders="getOrders"
- ></page0>
- <page1
- :listData="rightdata"
- :swiperCurrent="1"
- v-if="item.name == '可参与'"
- @openOnce="openOnce"
- @getOrders="getOrders"
- ></page1>
+ <view class="grabOrders">
+ <u-top-tips ref="uTips"></u-top-tips>
+ <view>
+ <u-tabs-swiper ref="uTabs" :list="list" :current="current" @change="tabsChange" :is-scroll="false"
+ swiperWidth="750"></u-tabs-swiper>
+ </view>
+ <!-- @animationfinish="animationfinish" -->
+ <swiper :current="swiperCurrent" @transition="transition" @animationfinish="animationfinish"
+ :style="{ height: 'calc(' + useHeight + ' - 40px)', width: '100%' }">
+ <swiper-item class="swiper-item" v-for="(item, index) in list" :key="index"
+ :style="{ height: useHeight, width: '100%' }">
+ <scroll-view scroll-y :style="{ height: useHeight, width: '100%' }" @scrolltolower="onreachBottom">
+ <page0 :listData="leftdata" :swiperCurrent="0" v-if="item.name == '正在进行'" @openOnce="openOnce"
+ @getOrders="getOrders"></page0>
+ <page1 :listData="rightdata" :swiperCurrent="1" v-if="item.name == '可参与'" @openOnce="openOnce"
+ @getOrders="getOrders"></page1>
- <!-- <view class="a" v-if="item.name == '正在进行'">
+ <!-- <view class="a" v-if="item.name == '正在进行'">
{{leftdata}}
</view>
<view class="b" v-if="item.name == '可参与'">
{{rightdata}}
</view>-->
- </scroll-view>
- </swiper-item>
- </swiper>
- <view>
- <u-modal
- v-model="showPopup"
- :content="appdetitle"
- :show-cancel-button="true"
- @confirm="confirms"
- ></u-modal>
- <!-- <u-button @click="open">
+ </scroll-view>
+ </swiper-item>
+ </swiper>
+ <view>
+ <u-modal v-model="showPopup" :content="appdetitle" :show-cancel-button="true" @confirm="confirms"></u-modal>
+ <!-- <u-button @click="open">
打开模态框
</u-button>-->
- </view>
- </view>
+ </view>
+ </view>
</template>
<script>
-import page0 from "./inPage/page0.vue"
-import page1 from "./inPage/page1.vue"
-export default {
- components: {
- page0,
- page1,
- },
- data () {
- return {
- list: [{
- name: "正在进行",
- },
- {
- name: "可参与",
- },
- ],
- // 因为内部的滑动机制限制,请将tabs组件和swiper组件的current用不同变量赋值
- current: 0, // tabs组件的current值,表示当前活动的tab选项
- swiperCurrent: 0, // swiper组件的current值,表示当前那个swiper-item是活动的
- leftdata: [],
- rightdata: [],
- showPopup: false,
- appdetitle: "",
- popupData: {},
- useHeight: '100%'
- }
- },
- watch: {
- current () {
- // console.log(this.current)
- this.getGrabOrders(this.current)
- },
- change () {
- this.getGrabOrders(this.current)
- },
- },
- mounted () {
- // this.getGrabOrders(this.current);
- let type = uni.getSystemInfoSync().platform
- if (type == "android") {
- this.useHeight = "100vh"
- }
- },
- computed: {
- change () {
- return this.$store.state.gotuGrabOrders
- },
- },
- onLoad: function (options) {
- // debugger
- // console.log(options)
- if (options.detailData == 0) {
- this.current = 0
- this.swiperCurrent = 0
- } else {
- this.current = 1
- this.swiperCurrent = 1
- }
- this.getGrabOrders(this.current)
- },
- methods: {
- // tabs通知swiper切换
- tabsChange (index) {
- this.swiperCurrent = index
- },
- // swiper-item左右移动,通知tabs的滑块跟随移动
- transition (e) {
- let dx = e.detail.dx
- this.$refs.uTabs.setDx(dx)
- },
- // 由于swiper的内部机制问题,快速切换swiper不会触发dx的连续变化,需要在结束时重置状态
- // swiper滑动结束,分别设置tabs和swiper的状态
- animationfinish (e) {
- let current = e.detail.current
- this.$refs.uTabs.setFinishCurrent(current)
- this.swiperCurrent = current
- this.current = current
- },
- // scroll-view到底部加载更多
- onreachBottom () { },
- openOnce (val) {
- //打开地图
- // console.log(this.swiperCurrent)
- val["buttype"] = this.swiperCurrent //tab标识,0正在进行,1可参与
- val["serid"] = uni.getStorageSync("ids") + ","
- val["appenUrl"] = this.$store.state.piAPI
- //打开地图
+ import page0 from "./inPage/page0.vue";
+ import page1 from "./inPage/page1.vue";
+ export default {
+ components: {
+ page0,
+ page1,
+ },
+ data() {
+ return {
+ list: [{
+ name: "正在进行",
+ },
+ {
+ name: "可参与",
+ },
+ ],
+ // 因为内部的滑动机制限制,请将tabs组件和swiper组件的current用不同变量赋值
+ current: 0, // tabs组件的current值,表示当前活动的tab选项
+ swiperCurrent: 0, // swiper组件的current值,表示当前那个swiper-item是活动的
+ leftdata: [],
+ rightdata: [],
+ showPopup: false,
+ appdetitle: "",
+ popupData: {},
+ useHeight: "100%",
+ };
+ },
+ watch: {
+ current() {
+ // console.log(this.current)
+ this.getGrabOrders(this.current);
+ },
+ change() {
+ this.getGrabOrders(this.current);
+ },
- if (val.iscation == 1) {
- if (val.type == 0) {
- //是队长-上传反馈
- val["butCT"] = "beginUp"
- } else if (val.type == 2) {
- //是队长-开始任务
- val["butCT"] = "begin"
- } else {
- //是队长-完成任务任务
- val["butCT"] = "over"
- }
- } else {
- if (val.type == 0) {
- //不是队长-上传反馈
- val["butCT"] = "over"
- } else if (val.type == 2) {
- //不是队长-开始任务
- val["butCT"] = "over"
- } else {
- //不是队长-完成任务任务
- val["butCT"] = "over"
- }
- }
- console.log(val)
- // return
- uni.navigateTo({
- url: "./map?data=" + JSON.stringify(val),
- })
- },
- getGrabOrders (val = 0) {
- //获取全部的数据
- let that = this,
- d = {
- serid: uni.getStorageSync("ids"),
- type: val + "",
- }
+ },
+ mounted() {
+ // this.getGrabOrders(this.current);
+ let type = uni.getSystemInfoSync().platform;
+ if (type == "android") {
+ this.useHeight = "100vh";
+ }
+ },
+ computed: {
+ change() {
+ return this.$store.state.gotuGrabOrders;
+ },
+ },
+ onLoad: function(options) {
+ // debugger
+ // console.log(options)
+ if (options.detailData == 0) {
+ this.current = 0;
+ this.swiperCurrent = 0;
+ } else {
+ this.current = 1;
+ this.swiperCurrent = 1;
+ }
+ this.getGrabOrders(this.current);
- if (val == 1) {
- d.jurisdiction = this.$store.state.UserData.jurisdiction
- }
+ if (options.from == "feedback") {
+ that.useWebScoketApi(item.id, item.serid, "stop");
+ }
+ },
+ methods: {
+ //实时位置传递
+ setNowposition(rid, jd, wd) {
+ console.log(uni.getStorageSync("ids"), rid, jd, wd);
+ },
+ // tabs通知swiper切换
+ tabsChange(index) {
+ this.swiperCurrent = index;
+ },
+ // swiper-item左右移动,通知tabs的滑块跟随移动
+ transition(e) {
+ let dx = e.detail.dx;
+ this.$refs.uTabs.setDx(dx);
+ },
+ // 由于swiper的内部机制问题,快速切换swiper不会触发dx的连续变化,需要在结束时重置状态
+ // swiper滑动结束,分别设置tabs和swiper的状态
+ animationfinish(e) {
+ let current = e.detail.current;
+ this.$refs.uTabs.setFinishCurrent(current);
+ this.swiperCurrent = current;
+ this.current = current;
+ },
+ // scroll-view到底部加载更多
+ onreachBottom() {},
+ openOnce(val) {
+ //打开地图
+ // console.log(this.swiperCurrent)
+ val["buttype"] = this.swiperCurrent; //tab标识,0正在进行,1可参与
+ val["serid"] = uni.getStorageSync("ids") + ",";
+ val["appenUrl"] = this.$store.state.piAPI;
+ //打开地图
- uni.request({
- url: this.$store.state.piAPI + "taskqd/selectLi",
- method: "POST",
- data: d,
- header: {
- "content-type": "application/x-www-form-urlencoded",
- },
- success (res) {
- const data = res.data.data
- // console.log(data);
- if (val == 1) {
- that.rightdata = data
- } else {
- let no = [],
- ok = [],
- bigin = [],
- no1 = [],
- ok1 = [],
- bigin1 = []
- for (var k in data) {
- if (data[k].iscation == 1) {
- if (data[k].type == 0) {
- //是队长-上传反馈
- no1.push(data[k])
- } else if (data[k].type == 2) {
- //是队长-开始任务
- bigin1.push(data[k]) //是队长-上传反馈
- } else {
- //是队长-完成任务任务
- ok1.push(data[k])
- }
- } else {
- if (data[k].type == 0) {
- //不是队长-上传反馈
- no.push(data[k])
- } else if (data[k].type == 2) {
- //不是队长-开始任务
- bigin.push(data[k])
- } else {
- //不是队长-完成任务任务
- ok.push(data[k])
- }
- }
- }
+ if (val.iscation == 1) {
+ if (val.type == 0) {
+ //是队长-上传反馈
+ val["butCT"] = "beginUp";
+ } else if (val.type == 2) {
+ //是队长-开始任务
+ val["butCT"] = "begin";
+ } else {
+ //是队长-完成任务任务
+ val["butCT"] = "over";
+ }
+ } else {
+ if (val.type == 0) {
+ //不是队长-上传反馈
+ val["butCT"] = "over";
+ } else if (val.type == 2) {
+ //不是队长-开始任务
+ val["butCT"] = "over";
+ } else {
+ //不是队长-完成任务任务
+ val["butCT"] = "over";
+ }
+ }
+ console.log(val);
+ // return
+ uni.navigateTo({
+ url: "./map?data=" + JSON.stringify(val),
+ });
+ },
+ getGrabOrders(val = 0) {
+ //获取全部的数据
+ let that = this,
+ d = {
+ serid: uni.getStorageSync("ids"),
+ type: val + "",
+ };
- that.leftdata = [...bigin1, ...bigin, ...no1, ...no, ...ok1, ...ok]
- }
- },
- })
- },
- getOrders (b) {
- let val = b.val,
- item = b.item
- // console.log(val, item)
- let that = this
- if (val != 0) {
- //接单
- this.appdetitle = "是否参与任务:" + item.rname
- this.showPopup = true
- this.popupData = item
- // return;
- } else {
- //反馈
- //
- uni.navigateTo({
- url: "./feedback?data=" + JSON.stringify(item),
- // url: "./feedback"
- })
- }
- },
- confirms () {
- let that = this
- this.popupData["serid"] = uni.getStorageSync("ids") + ","
- this.popupData["captain"] = uni.getStorageSync("name")
- // console.log(item)
- // return;
- uni.request({
- url: this.$store.state.piAPI + "taskqd/Graborder",
- method: "POST",
- // data: {
- // securityId: this.$store.state.puserID,
- // status: tab
- // },
- header: {
- "content-type": "application/json",
- },
- data: this.popupData,
- success (res) {
- const data = res.data.msg
- // console.log(data);
- if (data == "抢单成功") {
- uni.showToast({
- title: data,
- duration: 2000,
- })
- }
- // that.listData = data;
- // that.getGrabOrders(this.);
- that.$store.commit("changegotuGrabOrders")
- },
- })
- },
- },
-};
+ if (val == 1) {
+ d.jurisdiction = this.$store.state.UserData.jurisdiction;
+ }
+
+ uni.request({
+ url: this.$store.state.piAPI + "taskqd/selectLi",
+ method: "POST",
+ data: d,
+ header: {
+ "content-type": "application/x-www-form-urlencoded",
+ },
+ success(res) {
+ const data = res.data.data;
+ // console.log(data);
+ if (val == 1) {
+ that.rightdata = data;
+ } else {
+ let no = [],
+ ok = [],
+ begin = [],
+ no1 = [],
+ ok1 = [],
+ begin1 = [];
+ for (var k in data) {
+ data[k].type = data[k].rtype;
+ if (data[k].iscation == 1) {
+ if (data[k].type == 0) {
+ //是队长-上传反馈
+ no1.push(data[k]);
+ } else if (data[k].type == 2) {
+ //是队长-开始任务
+ begin1.push(data[k]); //是队长-上传反馈
+ } else {
+ //是队长-完成任务任务
+ ok1.push(data[k]);
+ }
+ } else {
+ if (data[k].type == 0) {
+ //不是队长-上传反馈
+ no.push(data[k]);
+ } else if (data[k].type == 2) {
+ //不是队长-开始任务
+ begin.push(data[k]);
+ } else {
+ //不是队长-完成任务任务
+ ok.push(data[k]);
+ }
+ }
+ }
+
+ that.leftdata = [...begin1, ...begin, ...no1, ...no, ...ok1, ...ok];
+ // console.log(that.leftdata)
+ // for (let k in begin) {
+ // let id = begin[k].id;
+ // that.isBeginTask[id] = {
+ // id: id,
+ // // position: that.createPosition(id)
+ // }
+ // }
+ // for (let k in begin1) {
+ // let id = begin1[k].id;
+ // that.isBeginTask[id] = {
+ // id: id,
+ // // position: that.createPosition(id)
+ // }
+ // }
+ // for (let k in no1) {
+ // let id = no1[k].id;
+ // that.$store.commit("addTask", id)
+ // }
+ // for (let k in no) {
+ // let id = no[k].id;
+ // that.$store.commit("addTask", id)
+ // }
+ // that.isOnTask[44].position.continuedTime();
+ }
+ },
+ });
+ },
+ createPosition(id) {
+ return new $getPositions({
+ id: id,
+ fn: function(res) {
+ console.log(res);
+ // that.setNowposition(re)
+ }
+ })
+ },
+ // tips(type, title) {
+ // this.$refs.uTips.show({
+ // title: title,
+ // type: type,
+ // duration: '2300'
+ // })
+ // this.getGrabOrders(this.current); //重获取数据
+ // },
+ // useWebScoketApi(rid, serid, type) {
+ // let that = this;
+ // uni.request({
+ // url: this.$store.state.piAPI + "taskqd/startTask?" + `rid=${rid}&serid=${serid}&type=${type}`,
+ // method: "GET",
+ // success(res) {
+ // let type = res.data.data.type;
+ // if (type == 'start') { //开启成功
+ // that.tips('success', '开启任务成功')
+ // return;
+ // }
+ // if (type == 'stop') { //开启成功
+ // that.tips('success', '反馈任务成功')
+ // return;
+ // }
+ // },
+ // });
+ // },
+ getOrders(b) {
+ let val = b.val,
+ item = b.item,
+ that = this;
+ console.log(val, item)
+
+ if (val == 0) { //正在进行
+ if (item.type == "2") { //开始任务按钮
+ // that.useWebScoketApi(item.id, item.serid, "start");
+ let d = {
+ rid: item.id,
+ serid: item.serid,
+ type: "start",
+ that: that,
+ fn: () => {
+ that.getGrabOrders(that.current); //重获取数据
+ }
+ }
+ that.$store.commit('useWebScoketApi', d);
+ }
+ if (item.type == "0") { //上传反馈
+ //反馈
+ uni.navigateTo({
+ url: "./feedback?data=" + JSON.stringify(item),
+ // url: "./feedback"
+ });
+ }
+ } else { //可参与
+ //接单
+ this.appdetitle = "是否参与任务:" + item.rname;
+ this.showPopup = true;
+ this.popupData = item;
+ }
+ },
+ confirms() {
+ let that = this;
+ this.popupData["serid"] = uni.getStorageSync("ids") + ",";
+ this.popupData["captain"] = uni.getStorageSync("name");
+ // console.log(item)
+ // return;
+ uni.request({
+ url: this.$store.state.piAPI + "taskqd/Graborder",
+ method: "POST",
+ // data: {
+ // securityId: this.$store.state.puserID,
+ // status: tab
+ // },
+ header: {
+ "content-type": "application/json",
+ },
+ data: this.popupData,
+ success(res) {
+ const data = res.data.msg;
+ // console.log(data);
+ if (data == "抢单成功") {
+ uni.showToast({
+ title: data,
+ duration: 2000,
+ });
+ }
+ // that.listData = data;
+ // that.getGrabOrders(this.);
+ that.current = 0;
+ that.swiperCurrent = 0;
+ that.$store.commit("changegotuGrabOrders");
+
+ },
+ });
+ },
+ },
+ };
</script>
<style scoped lang="scss">
-page,
-.grabOrders {
- height: 100% !important;
- width: 100% !important;
-}
+ page,
+ .grabOrders {
+ height: 100% !important;
+ width: 100% !important;
+ }
-page {
- overflow: hidden !important;
-}
+ page {
+ overflow: hidden !important;
+ }
-// .uni-scroll-view{
-// height: 100% !important;
-// border: 1px solid red
-// }
+ // .uni-scroll-view{
+ // height: 100% !important;
+ // border: 1px solid red
+ // }
</style>
diff --git a/pages/grabOrders/inPage/page0.vue b/pages/grabOrders/inPage/page0.vue
index cb36e0f..9e5e96b 100644
--- a/pages/grabOrders/inPage/page0.vue
+++ b/pages/grabOrders/inPage/page0.vue
@@ -20,12 +20,12 @@
</view>
</view>
<view class="onve-right">
- <u-button :class="[swiperCurrent == 0?'orange':'green',item.type == 0?'greens':'']" size="mini" :disabled="true"
+ <u-button :class="[item.type == 1?'':item.type == 0?'blues':'greens']" size="mini" :disabled="true"
v-if="item.iscation == 0" @click="getOrders(swiperCurrent,item)">
<span class="Cation notCation">队员</span>{{item.type == 1?"完成反馈":item.type == 0?"正在进行":"还未开始"}}
</u-button>
- <u-button :class="[swiperCurrent == 0?'orange':'green']" size="mini" :disabled="item.type == 1"
- v-if="item.iscation == 1" @click="getOrders(swiperCurrent,item)">
+ <u-button :class="[item.type == 1?'':item.type == 0?'blues':'greens']" size="mini"
+ :disabled="item.type == 1" v-if="item.iscation == 1" @click="getOrders(swiperCurrent,item)">
<span class="Cation">队长</span>{{item.type == 1?"完成反馈":item.type == 0?"上传反馈":"开始任务"}}
</u-button>
<view class="o-r-$">
@@ -154,16 +154,21 @@
}
.orange {
- color: orange;
+ color: #FF7B15;
}
.green {
color: #00e713;
}
+
.greens {
color: #18a655 !important;
}
+ .blues {
+ color: #2680F0 !important;
+ }
+
.Cation {
display: inline-block;
position: absolute;
diff --git "a/pages/grabOrders/map - \345\211\257\346\234\254.vue" "b/pages/grabOrders/map - \345\211\257\346\234\254.vue"
new file mode 100644
index 0000000..d297262
--- /dev/null
+++ "b/pages/grabOrders/map - \345\211\257\346\234\254.vue"
@@ -0,0 +1,83 @@
+<template>
+ <view class="content">
+ <web-view :src="urls" @message="message"></web-view>
+ </view>
+</template>
+
+<script>
+ export default {
+ data() {
+ return {
+ urls: '',
+ // dataList: [],
+ }
+ },
+ methods: {
+ message(event) {
+ console.log(event.detail.data)
+ }
+ },
+ mounted() {},
+ onLoad: function(options) {
+ var data = [];
+ // console.log(options.data);
+ if (options.data == undefined) {
+ data = JSON.stringify({
+ appenUrl: "http://192.168.0.108:83/",
+ butCT: "begin",
+ buttype: 0,
+ captain: "我",
+ city: "南昌市",
+ content: "测试",
+ district: "西湖区",
+ id: 37,
+ integral: "222",
+ iscation: "1",
+ jnum: 3,
+ line: "LINESTRING(115.8995839881188 28.687205773173343,115.89391916267935 28.678966027079593,115.90404718391959 28.673644524394046,115.91211526863638 28.681369286356936)",
+ num: 1,
+ nums: 0,
+ province: "江西省",
+ publisher: "管理",
+ raddress: null,
+ rname: "测试1",
+ rtype: "0",
+ serid: "1123598821738675201,",
+ team: "你,他,它",
+ time: "2022-02-18 14:15:52",
+ type: "2",
+ url: "http://223.82.109.183:2081/zhba/upload/20220218/67f0c8bf3e7b5024c64133691f265072.ico",
+ })
+
+ } else {
+ data = options.data;
+ }
+ // console.log(data);
+ // return
+ // console.log(options.html)
+ // var a = options.html != undefined ? options.html : "xcxMapJQ/xcxmap.html";
+ // console.log(a)
+ // let a = "grabOrdersMap/xcxmap.html";
+ // this.urls = "http://223.82.109.183:2082/" + a + "?data=" + data;
+ let name = 1; //1是本地 2是服务器
+ // let name = 1;
+ let b = this.$store.state.piAPI;
+ if (b == '/api') {
+ name = 1;
+ }
+ let a = name == 1 ? "http://127.0.0.1:8848/qfqk-android/leafletMapOur/" : b.slice(0, b.indexOf('api'));
+ // this.urls = a + "grabOrdersMap/xcxmap.html?data=" + data;
+ // a = a.slice(0, a.indexOf('api'));
+ this.urls = a + "grabOrdersMap/xcxmap.html?data=" + data;
+ // http://127.0.0.1:8848/qfqk-android/grabOrdersMap/xcxmap.html
+ // this.dataList = data;
+ // console.log(this.urls);
+ },
+ beforeDestroy() {
+ this.$store.commit("changegotuGrabOrders");
+ }
+ }
+</script>
+
+<style>
+</style>
diff --git a/pages/grabOrders/map.vue b/pages/grabOrders/map.vue
index 15d2547..afd2994 100644
--- a/pages/grabOrders/map.vue
+++ b/pages/grabOrders/map.vue
@@ -1,5 +1,6 @@
<template>
<view class="content">
+ <u-top-tips ref="uTips"></u-top-tips>
<web-view :src="urls"></web-view>
</view>
</template>
@@ -12,14 +13,56 @@
// dataList: [],
}
},
- methods: {},
+ methods: {
+
+ },
mounted() {},
+ onReady() {
+ let that = this;
+ window.hBackMsg = (val) => {
+ let d = {
+ rid: val.data.id,
+ serid: val.data.serid,
+ type: val.type,
+ that: that,
+ fn: () => {
+ // that.getGrabOrders(that.current); //重获取数据
+ val.fn();
+ }
+ }
+ that.$store.commit('useWebScoketApi', d);
+ }
+ },
onLoad: function(options) {
var data = [];
- // console.log(options.data);
if (options.data == undefined) {
- data =
- '{"id":7,"rname":"无数据","content":"无数据","time":"2021-11-02 16:31:47","province":"江西省","city":"南昌市","district":"青山湖区","jnum":2,"line":"LINESTRING(115.95983713142935 28.674674492655765,115.96086709969107 28.7012820060835,115.97254007332388 28.701625328837405,115.97305505745474 28.68875072556592,115.96704690926138 28.68274257737256,115.96739023201529 28.674674492655765,115.9600087928063 28.674846154032718,115.95983713142935 28.674846154032718)","raddress":null,"rtype":"0","serid":"1416311615662448641,1123598821738675201","num":2,"integral":"100","url":"http://223.82.109.183:2081/zhba/upload/20211102/7050fe68e5d1e9921a3e93329996a943.png","current":0,"buttype":0}'
+ data = JSON.stringify({
+ appenUrl: "http://192.168.0.108:83/",
+ butCT: "begin",
+ buttype: 0,
+ captain: "我",
+ city: "南昌市",
+ content: "测试",
+ district: "西湖区",
+ id: 37,
+ integral: "222",
+ iscation: "1",
+ jnum: 3,
+ line: "LINESTRING(115.8995839881188 28.687205773173343,115.89391916267935 28.678966027079593,115.90404718391959 28.673644524394046,115.91211526863638 28.681369286356936)",
+ num: 1,
+ nums: 0,
+ province: "江西省",
+ publisher: "管理",
+ raddress: null,
+ rname: "测试1",
+ rtype: "0",
+ serid: "1123598821738675201,",
+ team: "你,他,它",
+ time: "2022-02-18 14:15:52",
+ type: "2",
+ url: "http://223.82.109.183:2081/zhba/upload/20220218/67f0c8bf3e7b5024c64133691f265072.ico",
+ })
+
} else {
data = options.data;
}
@@ -33,10 +76,10 @@
let name = 2; //1是本地 2是服务器
// let name = 1;
let b = this.$store.state.piAPI;
- if( b == '/api'){
+ if (b == '/api') {
name = 1;
}
- let a = name == 1 ? "http://127.0.0.1:8848/qfqk-android/leafletMapOur/" :b.slice(0, b.indexOf('api'));
+ let a = name == 1 ? "http://127.0.0.1:8848/qfqk-android/leafletMapOur/" : b.slice(0, b.indexOf('api'));
// this.urls = a + "grabOrdersMap/xcxmap.html?data=" + data;
// a = a.slice(0, a.indexOf('api'));
this.urls = a + "grabOrdersMap/xcxmap.html?data=" + data;
@@ -51,4 +94,8 @@
</script>
<style>
+ .content {
+ flex: 1;
+ height: 100%;
+ }
</style>
diff --git a/store/actions.js b/store/actions.js
index 1c5a8aa..47c7c4c 100644
--- a/store/actions.js
+++ b/store/actions.js
@@ -1,5 +1,8 @@
import md5 from 'js-md5'
import axios from 'axios'
+
+import websocket from "./websocket.js"
+import positions from "./positions.js"
const actions = {
loging(store, data) {
var user = [{
@@ -44,16 +47,16 @@
// // dataType: 'JSON',
success: (res) => {
if (res.statusCode == 200) {
- if(res.data.error_code == "400"){
+ if (res.data.error_code == "400") {
uni.hideNavigationBarLoading();
uni.showToast({
title: '密码错误,请重试',
- icon:'none',
+ icon: 'none',
duration: 2000
});
return;
}
- store.commit('getUserData',res.data)
+ store.commit('getUserData', res.data)
// console.log(res.data,123542);
data.isit = true;
data.userName = res.data.nick_name; //警袁姓名
@@ -63,8 +66,8 @@
data.pass = data.pass;
// data.userPhon = res.user_id;
store.commit('login', data);
-
- }
+
+ }
},
fail: (res) => {
console.log('失去连接 请稍等');
@@ -86,7 +89,9 @@
// store.commit('login', data);
// }, 2000)
- }
+ },
+ ...websocket.actions,
+ ...positions.actions
}
export default actions
diff --git a/store/lid/getPosition.js b/store/lid/getPosition.js
new file mode 100644
index 0000000..cd23adf
--- /dev/null
+++ b/store/lid/getPosition.js
@@ -0,0 +1,180 @@
+class $getPositions {
+ constructor(arg) {
+ this.id = arg.id || 0; //任务id
+ this.fn = arg.fn ? function(data) {
+ arg.fn(data);
+ } : function(data) {
+ console.log("未设置输出回调")
+ return data;
+ };
+ this.ourPosition = []; //全部位置
+ this.nowPosition = []; //当前位置
+ this.onceNowPosition = []; //当前一次位置
+ this.getOnceSPosition = null;
+ this.state = false;
+ this.isContinued = false;
+ this.isContinuedTimeInt = null;
+ this.isContinuedTimeOut = null;
+ return this;
+ }
+ //开始获取
+ init() {
+ //判断权限
+ return this;
+
+ }
+ continued() {
+ //开始持续获取定位
+ console.log("开始持续定位")
+ let that = this;
+ this.isContinued = true;
+ if (this.isContinuedTimeInt) {
+ console.log("重复开始持续定位")
+ return;
+ } else {
+ that.once(function(res) {
+ if (res.state == false) {
+ console.log(res.intlat)
+ }
+ })
+ this.isContinuedTimeInt = setInterval(() => {
+ that.once(function(res) {
+ if (res.state == false) {
+ console.log(res.intlat)
+ }
+ })
+ }, 5000)
+ }
+ }
+ continuedTime(val) {
+ //开始持续获取定位
+ let that = this;
+ if (val != 1) {
+ // console.log(that.id,"开始持续定位")
+ this.isContinued = true;
+ that.once(function(res) {
+ if (res.state == false) {
+ // console.log(res.intlat)
+ that.outData();
+ }
+ })
+ if (this.isContinuedTimeOut) {
+ // console.log("重复开始持续定位")
+ return;
+ }
+ }
+ this.isContinuedTimeOut = setTimeout(() => {
+ that.once(function(res) {
+ if (res.state == false) {
+ // console.log(res.intlat)
+ that.outData();
+ if (res.ok) {
+ //返回成功
+ that.continuedTime(1);
+ } else {
+ //返回失败
+ that.continuedTime(1);
+ }
+ }
+ })
+ }, 3000)
+
+ }
+ overContinued() {
+ // console.log("结束持续定位")
+ let that = this;
+ if (this.isContinued) {
+ this.isContinued = false;
+ if (this.isContinuedTimeInt) {
+ clearInterval(that.isContinuedTimeInt);
+ this.isContinuedTimeInt = null;
+ }
+ if (this.isContinuedTimeOut) {
+ clearTimeout(that.isContinuedTimeOut);
+ this.isContinuedTimeOut = null;
+ }
+ }
+ this.isContinued = false;
+ that.outData('out');
+ }
+ once(fn) {
+ // console.log("开始获取一次定位");
+ this.state = true;
+ let ok = true;
+ let that = this,
+ fns = fn || '',
+ outit = function() {
+ if (fns) {
+ fns({
+ state: that.state,
+ intlat: that.onceNowPosition,
+ ok: ok
+ })
+ } else {
+ that.outData();
+ }
+ };
+ outit();
+ let success = function(position) {
+ // console.log(position);
+ var lat = position.coords.latitude;
+ var lon = position.coords.longitude;
+ // console.log("成功返回经纬度信息");
+ // console.log(lon, lat, "成功");
+ that.onceNowPosition = [lat, lon];
+ that.state = false;
+ ok = true;
+ outit();
+ };
+ let error = function(error) {
+ // console.log(error, "失败");
+ let msg = "none";
+ switch (error.code) {
+ case error.PERMISSION_DENIED:
+ msg = "User denied the request for Geolocation.";
+ break;
+ case error.POSITION_UNAVAILABLE:
+ msg = "Location information is unavailable.";
+ break;
+ case error.TIMEOUT:
+ msg = "The request to get user location timed out.";
+ break;
+ case error.UNKNOWN_ERROR:
+ msg = "An unknown error occurred.";
+ break;
+ }
+ that.onceNowPosition = msg;
+ that.state = false;
+ ok = false;
+ outit();
+ };
+ let options = {
+ enableHighAccuracy: true,
+ // timeout: 5000,
+ timeout: Infinity,
+ maximumAge: 0,
+ };
+ this.getOnceSPosition = navigator.geolocation.getCurrentPosition(
+ success,
+ error,
+ options
+ );
+ }
+ //结束获取
+ outInit() {
+
+ }
+ //抛出数据
+ outData(val) {
+ let d = {
+ state: this.state,
+ intlat: this.onceNowPosition
+ }
+ if (val) {
+ d[val] = val
+ }
+ this.fn(d)
+ }
+}
+
+export default $getPositions;
diff --git a/store/lid/websocketL.js b/store/lid/websocketL.js
new file mode 100644
index 0000000..64a2ab7
--- /dev/null
+++ b/store/lid/websocketL.js
@@ -0,0 +1,128 @@
+// uniapp版本websocket总控制
+
+function Wst(url) {
+ this.url = url || "";
+ this.ws = "";
+ this.ourControl = true; //总控
+ this.state = false;
+ this.timeIntval = false;
+ this.timeIntvalTime = 5000;
+ this.WebSocketValue = "";
+ this.backValue = function(res) {
+ console.log(res, "未设置msg返回函数");
+ };
+ this.getws = "";
+ this.Data = "";
+ this.heartBeat = "";
+ this.loginData = "";
+
+ this.ids = '';
+ return this;
+}
+
+Wst.prototype.$callBack = function(getValue, getState, getws, ids) {
+ this.backValue = function(res) {
+ if (!getValue && !getState) {
+ console.log(res, "未设置msg返回函数");
+ } else {
+ if (getValue) {
+ getValue(res);
+ }
+ if (getState) {
+ getState(this.state);
+ }
+ }
+ };
+ this.getws = getws;
+ this.ids = ids;
+ return this;
+};
+
+Wst.prototype.$connect = function(Data) {
+ this.ourControl = true;
+ let that = this;
+ this.Data = Data;
+ this.loginData = {
+ id: this.ids,
+ type: 'login'
+ };
+ this.heartBeat = 'ping';
+ this.ws = uni.connectSocket({
+ url: that.url,
+ success(data) {
+ // console.log(data, "websocket连接成功");
+ },
+ });
+ // console.log(that.url)
+ this.ws.onOpen((res) => {
+ // 注:只有连接正常打开中 ,才能正常成功发送消息
+ that.ws.send({
+ data: JSON.stringify(that.loginData),
+ async success(res) {
+ // console.log(res, "登入成功"); //设置登入成功状态 并开启心跳
+ that.state = true;
+ that.$heartbeat();
+ },
+ });
+ // 注:只有连接正常打开中 ,才能正常收到消息
+ that.ws.onMessage((res) => {
+ // console.log("收到服务器内容:", JSON.parse(res.data));
+ let d = res.data;
+ try {
+ d = JSON.parse(res.data);
+ } catch (e) {}
+ that.WebSocketValue = d;
+ // that.state = true;
+ // this.$heartbeat();
+ that.backValue(d);
+ });
+ });
+ // this.ws.onClose((e) => {
+ // console.log(11111111111111111)
+ // that.state = false;
+ // that.backValue(e);
+ // });
+ // this.$heartbeat();
+ this.getws(this.ws);
+ return this;
+};
+
+Wst.prototype.$heartbeat = function() {
+ let that = this;
+ let open = function() {
+ // console.log('开启心跳');
+
+ that.ws.send({
+ data: that.heartBeat,
+ });
+ };
+ let rel = function() {
+ console.log('重新连接');
+ that.$connect(that.Data);
+ };
+ if (that.timeIntval) {
+ clearInterval(that.timeIntval);
+ }
+ that.timeIntval = setInterval(() => {
+ if (!this.ourControl) {
+ return;
+ }
+ // console.log(that.state)
+ if (that.state) {
+ open();
+ } else {
+ rel();
+ }
+ }, that.timeIntvalTime);
+};
+
+Wst.prototype.$outws = function() {
+ this.ourControl = false;
+ clearInterval(this.timeIntval);
+ this.timeIntval = false;
+ this.WebSocketValue = {};
+ this.state = false;
+ // this.backValue({});
+};
+
+export default Wst;
diff --git a/store/mutations.js b/store/mutations.js
index 9b8da45..0622fe1 100644
--- a/store/mutations.js
+++ b/store/mutations.js
@@ -1,5 +1,9 @@
import WxStorage from "../static/lib/wxStorage.js" //微信Storage
+import websocket from "./websocket.js"
+import positions from "./positions.js"
+
+import $store from './index.js'
const mutations = {
login(state, data) {
// console.log(data);
@@ -10,6 +14,7 @@
state.puserID = data.userID;
state.avatar = data.avatar;
}
+ $store.dispatch("connectws");
//储存用户
WxStorage.set("init", "true");
WxStorage.set("name", data.userName);
@@ -32,7 +37,9 @@
changegotuGrabOrders(state, data) {
// console.log(2123131)
state.gotuGrabOrders = !state.gotuGrabOrders;
- }
+ },
+ ...websocket.mutations,
+ ...positions.mutations
}
export default mutations
diff --git a/store/positions.js b/store/positions.js
new file mode 100644
index 0000000..9889f89
--- /dev/null
+++ b/store/positions.js
@@ -0,0 +1,113 @@
+// import $store from '../index.js'
+// import vueconfig from '../../vue.config.js'
+import $getPositions from './lid/getPosition.js'
+import WxStorage from "../static/lib/wxStorage.js" //微信Storage
+import $store from './index.js'
+
+let positions = {
+ state: {
+ isBeginTask: {},
+ isOnTask: {},
+ },
+ actions: {
+ // connectws({
+ // state,
+ // commit
+ // }) {
+ // console.log("开启websocket")
+ // },
+ },
+ mutations: {
+ addTask(state, value) {
+ let id = value;
+ state.isOnTask[id] = {
+ id: id,
+ position: new $getPositions({
+ id: id,
+ fn: function(res) {
+ // console.log(res);
+ $store.commit("setMsg", {
+ id: id,
+ intlat: res.intlat
+ })
+ }
+ })
+ }
+ setTimeout(() => {
+ $store.commit("startTask", id)
+ }, 1000)
+ },
+ startTask(state, value) {
+ if (!state.isOnTask[value]) {
+ console.log("未创建该任务:", value)
+ return
+ }
+ if (!state.isOnTask[value].position.isContinued) {
+ state.isOnTask[value].position.continuedTime();
+ }
+ },
+ stopTask(state, value) {
+ if (!state.isOnTask[value]) {
+ console.log("未创建该任务:", value)
+ return
+ }
+ if (state.isOnTask[value].position.isContinued) {
+ state.isOnTask[value].position.overContinued();
+ }
+ },
+ setMsg(state, value) {
+ //发送任务位置
+ //uid ;自己id,rid: 任务id,jd,wd经度纬度
+ // console.log(value)
+ let d = {
+ uid: WxStorage.get("ids"),
+ rid: value.id,
+ jd: value.intlat[0],
+ wd: value.intlat[1],
+ }
+ uni.request({
+ url: $store.state.piAPI + "trar/submit",
+ method: "POST",
+ data: d,
+ success(res) {
+ // console.log(res.data.msg);
+ },
+ });
+ },
+ useWebScoketApi(state, val) {
+ let rid = val.rid,
+ serid = val.serid,
+ type = val.type,
+ that = val.that,
+ tips = (type, title) => {
+ that.$refs.uTips.show({
+ title: title,
+ type: type,
+ duration: '2300'
+ })
+ // that.getGrabOrders(that.current); //重获取数据
+ }
+ uni.request({
+ url: $store.state.piAPI + "taskqd/startTask?" +
+ `rid=${rid}&serid=${serid}&type=${type}`,
+ method: "GET",
+ success(res) {
+ let type = res.data.data.type;
+ if (val.fn) {
+ val.fn();
+ }
+ if (type == 'start') { //开启成功
+ tips('success', '开启任务成功')
+ return;
+ }
+ if (type == 'stop') { //开启成功
+ tips('success', '反馈任务成功')
+ return;
+ }
+ },
+ });
+ },
+ }
+}
+
+export default positions
diff --git a/store/state.js b/store/state.js
index 635fb38..1025ada 100644
--- a/store/state.js
+++ b/store/state.js
@@ -1,3 +1,5 @@
+import websocket from "./websocket.js"
+import positions from "./positions.js"
const state = {
loging: false,
message: {
@@ -12,38 +14,40 @@
avatar: "../../static/logo.png",
UserData: {},
tabbar: [{
- pagePath: "/pages/home/home",
- text: "首页",
- iconPath: "/static/tabbar/index01.png",
- selectedIconPath: "/static/tabbar/index02.png"
- },
- {
- pagePath: "/pages/article/article",
- text: "资讯",
- iconPath: "/static/tabbar/article.png",
- selectedIconPath: "/static/tabbar/articleH.png"
- },
- {
- pagePath: "/pages/issue/issue",
- iconPath: "/static/tabbar/addIcon.png",
- selectedIconPath: "/static/tabbar/addSelectedIcon.png",
- text: "发布",
- midButton: true,
- },
- {
- pagePath: "/pages/business/business",
- text: "工作台",
- iconPath: "/static/tabbar/workbench.png",
- selectedIconPath: "/static/tabbar/workbenchH.png"
- },
- {
- pagePath: "/pages/myself/myself",
- text: "我的",
- iconPath: "/static/tabbar/my.png",
- selectedIconPath: "/static/tabbar/my-blue.png"
- }
+ pagePath: "/pages/home/home",
+ text: "首页",
+ iconPath: "/static/tabbar/index01.png",
+ selectedIconPath: "/static/tabbar/index02.png"
+ },
+ {
+ pagePath: "/pages/article/article",
+ text: "资讯",
+ iconPath: "/static/tabbar/article.png",
+ selectedIconPath: "/static/tabbar/articleH.png"
+ },
+ {
+ pagePath: "/pages/issue/issue",
+ iconPath: "/static/tabbar/addIcon.png",
+ selectedIconPath: "/static/tabbar/addSelectedIcon.png",
+ text: "发布",
+ midButton: true,
+ },
+ {
+ pagePath: "/pages/business/business",
+ text: "工作台",
+ iconPath: "/static/tabbar/workbench.png",
+ selectedIconPath: "/static/tabbar/workbenchH.png"
+ },
+ {
+ pagePath: "/pages/myself/myself",
+ text: "我的",
+ iconPath: "/static/tabbar/my.png",
+ selectedIconPath: "/static/tabbar/my-blue.png"
+ }
],
- gotuGrabOrders: false
+ gotuGrabOrders: false,
+ ...websocket.state,
+ ...positions.state
}
export default state
diff --git a/store/websocket.js b/store/websocket.js
new file mode 100644
index 0000000..cc5120c
--- /dev/null
+++ b/store/websocket.js
@@ -0,0 +1,84 @@
+// import $store from '../index.js'
+// import vueconfig from '../../vue.config.js'
+import Wst from './lid/websocketL.js'
+import WxStorage from "../static/lib/wxStorage.js" //微信Storage
+
+// var url = 'ws://' + vueconfig.devServer.proxy["/cloud"].target.substring(5) + '/websocket';
+
+let url = 'ws://192.168.0.108:9034/websocket';
+
+const webSockets = new Wst(url);
+
+let websocket = {
+ state: {
+ webSockets: webSockets, //websocket实例
+ socket: '', //websoclet主体
+ socketValue: '', //接收的数据
+ socketState: false, // 当前连接websocket状态
+ socketInterval: false, //心跳
+ socketTimeout: false, //检测服务器是否连接成功timeout
+ socketInterTime: 5000, //心跳时间 秒*1000
+ socketStateMY: true, //总控 在退出登入时,强行关闭心跳
+ },
+ actions: {
+ connectws({
+ state,
+ commit
+ }) {
+ console.log("开启websocket")
+ var getValue = function(res) { // 消息回调
+ commit("setSocketValue", res);
+ }
+ var getState = function(res) { // 状态回调
+ commit("setState", res);
+ }
+ var getws = function(res) { // 主体回调
+ commit("setSocket", res);
+ }
+ let equipmentInformation = navigator.userAgent;
+ // var Data = {
+ // router: "share",
+ // res: {
+ // ...$store.state.logs.user,
+ // equipmentInformation: equipmentInformation
+ // },
+ // }
+ var ws = webSockets.$callBack(getValue, getState, getws, state.puserID || WxStorage.get("ids"))
+ .$connect();
+
+ },
+ },
+ mutations: {
+ wsOut(state, value) {
+ webSockets.$outws();
+ },
+ setSocket(state, value) { //websocket主体
+ state.socket = value;
+ },
+ setSocketValue(state, value) {
+ // console.log(value)
+ // if (value.router) { //正常数据返回
+ // //去除心跳数据
+ // if (value.router == 'share/heartbeat') {
+ // return;
+ // }
+ state.socketValue = value;
+ // console.log(value, 'websocket信息')
+ // } else { //异常数据返回
+ // console.log(value, '异常')
+ // }
+ },
+ //本地建造数据传递
+ setMyvalue(state, value) {
+ state.socketValue = value;
+ },
+ setsocketStateMY(state, value) {
+ state.socketStateMY = value;
+ },
+ setState(state, value) {
+ state.socketState = value;
+ },
+ }
+}
+
+export default websocket
--
Gitblit v1.9.3