liuyg
2022-02-23 623ec0ef9d86812885839e7fbe6380a8f162bd18
+路由处理放入websocket
2 files modified
188 ■■■■■ changed files
App.vue 140 ●●●● patch | view | raw | blame | history
store/websocket.js 48 ●●●●● patch | view | raw | blame | history
App.vue
@@ -27,77 +27,77 @@
                }
            }
        },
        computed: {
            socketValue() {
                return this.$store.state.socketValue;
            }
        },
        watch: {
            socketValue() {
                console.log(this.socketValue);
                let that = this;
                if (that.socketValue.type === "start") {
                    // console.log("任务开启vuevueveu")
                    // this.$store.commit("addTask", this.socketValue.rid);
                    // uni.request({
                    //     url: this.$store.state.piAPI + "taskqd/selectLi?id=" + this.socketValue.rid,
                    //     method: "get",
                    //     header: {
                    //         "content-type": "application/x-www-form-urlencoded",
                    //     },
                    //     success(res) {
                    // let vals = res.data.data.records[0];
                    let types = uni.getSystemInfoSync().platform;
                    let that = this,
                        d = {
                            serid: uni.getStorageSync("ids") || that.$store.state.puserID,
                            type: 0,
                        };
                    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;
                            for (let k in data) {
                                if (data[k].id == that.socketValue.rid) {
                                    let val = JSON.stringify({
                                        ...data[k],
                                        butCT: "beginUp",
                                        buttype: 0,
                                        myid: d.serid,
                                        myName: uni.getStorageSync("name") || that.$store.state.puserName,
                                        appenUrl: that.$store.state.piAPI,
                                        isOn: true
                                    });
                                    if(types == "android"){
                                        uni.navigateTo({
                                            url: "/pages/grabOrders/map?data=" + JSON.stringify(val),
                                        });
                                        return
                                    }
                                    uni.redirectTo({
                                        url: "/pages/grabOrders/map?data=" + JSON.stringify(val),
                                    });
                                } else {
                                    continue;
                                }
                            }
                        },
                    });
        // computed: {
        //     socketValue() {
        //         return this.$store.state.socketValue;
        //     }
        // },
        // watch: {
        //     socketValue() {
        //         console.log(this.socketValue);
        //         let that = this;
        //         if (that.socketValue.type === "start") {
        //             // console.log("任务开启vuevueveu")
        //             // this.$store.commit("addTask", this.socketValue.rid);
        //             // uni.request({
        //             //     url: this.$store.state.piAPI + "taskqd/selectLi?id=" + this.socketValue.rid,
        //             //     method: "get",
        //             //     header: {
        //             //         "content-type": "application/x-www-form-urlencoded",
        //             //     },
        //             //     success(res) {
        //             // let vals = res.data.data.records[0];
        //             let types = uni.getSystemInfoSync().platform;
        //             let that = this,
        //                 d = {
        //                     serid: uni.getStorageSync("ids") || that.$store.state.puserID,
        //                     type: 0,
        //                 };
        //             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;
        //                     for (let k in data) {
        //                         if (data[k].id == that.socketValue.rid) {
        //                             let val = JSON.stringify({
        //                                 ...data[k],
        //                                 butCT: "beginUp",
        //                                 buttype: 0,
        //                                 myid: d.serid,
        //                                 myName: uni.getStorageSync("name") || that.$store.state.puserName,
        //                                 appenUrl: that.$store.state.piAPI,
        //                                 isOn: true
        //                             });
        //                             if(types == "android"){
        //                                 uni.navigateTo({
        //                                     url: "/pages/grabOrders/map?data=" + JSON.stringify(val),
        //                                 });
        //                                 return
        //                             }
        //                             uni.redirectTo({
        //                                 url: "/pages/grabOrders/map?data=" + JSON.stringify(val),
        //                             });
        //                         } else {
        //                             continue;
        //                         }
        //                     }
        //                 },
        //             });
                } else if (that.socketValue.type === "stop") {
                    // console.log("任务结束vuevueveu")
                    // this.$store.commit("stopTask", this.socketValue.rid);
                    // uni.reLaunch({
                    //     url: "/pages/home/home"
                    // });
                }
            }
        },
        //         } else if (that.socketValue.type === "stop") {
        //             // console.log("任务结束vuevueveu")
        //             // this.$store.commit("stopTask", this.socketValue.rid);
        //             // uni.reLaunch({
        //             //     url: "/pages/home/home"
        //             // });
        //         }
        //     }
        // },
        mounted() {
            // console.log("登入状态", this.$store.state.loging)
            // if (this.$store.state.loging) {
store/websocket.js
@@ -72,10 +72,58 @@
            // } else { //异常数据返回
            //     console.log(value, '异常')
            // }
            if (state.socketValue.type === "start") {
                let types = uni.getSystemInfoSync().platform;
                let
                    d = {
                        serid: uni.getStorageSync("ids") || $store.state.puserID,
                        type: 0,
                    };
                uni.request({
                    url: $store.state.piAPI + "taskqd/selectLi",
                    method: "POST",
                    data: d,
                    header: {
                        "content-type": "application/x-www-form-urlencoded",
                    },
                    success(res) {
                        const data = res.data.data;
                        for (let k in data) {
                            if (data[k].id == state.socketValue.rid) {
                                let val = JSON.stringify({
                                    ...data[k],
                                    butCT: "beginUp",
                                    buttype: 0,
                                    myid: d.serid,
                                    myName: uni.getStorageSync("name") || $store.state
                                        .puserName,
                                    appenUrl: $store.state.piAPI,
                                    isOn: true
                                });
                                console.log(val)
                                if (types == "android") {
                                    uni.navigateTo({
                                        url: "/pages/grabOrders/map?data=" + JSON.stringify(val),
                                    });
                                    return
                                }
                                uni.redirectTo({
                                    url: "/pages/grabOrders/map?data=" + JSON.stringify(val),
                                });
                            } else {
                                continue;
                            }
                        }
                    },
                });
            }
        },
        //本地建造数据传递
        setMyvalue(state, value) {
            state.socketValue = value;
        },
        setsocketStateMY(state, value) {
            state.socketStateMY = value;