shuishen
2022-02-21 dfe23ccb24b9531e9fdbe8157e673d1a4d16d343
Merge branch 'master' of http://192.168.0.105:10010/r/qfqk-android
5 files modified
248 ■■■■■ changed files
leafletMapOur/grabOrdersMap/js/getPosition.js 2 ●●● patch | view | raw | blame | history
leafletMapOur/grabOrdersMap/js/vueMain.js 186 ●●●●● patch | view | raw | blame | history
pages/grabOrders/map.vue 42 ●●●●● patch | view | raw | blame | history
store/lid/getPosition.js 2 ●●● patch | view | raw | blame | history
store/positions.js 16 ●●●● patch | view | raw | blame | history
leafletMapOur/grabOrdersMap/js/getPosition.js
@@ -77,7 +77,7 @@
                    }
                }
            })
        }, 3000)
        }, 30000)
    }
    overContinued() {
leafletMapOur/grabOrdersMap/js/vueMain.js
@@ -39,58 +39,58 @@
        onPosition: false, //持续定位指示
    },
    methods: {
        unis(data) {
            //向uniapp传值
            uni.postMessage({
                data: {
                    action: data
                }
            });
        },
        setUniAppMsg(state, data) {
            let that = this;
            if (window.parent) {
                console.log("有window.parent")
                if (state == "hBackMsg") {
                    window.parent.hBackMsg(data);
                }
                if (state == "setIntLat") {
                    window.parent.setIntLat({
                        rid: that.data.id,
                        fn: (out) => {
                            // console.log(out,"1111");
                            // that.addIcon(out);
                            that.addIcon([out[1], out[0]]);
                        }
                    });
                }
                if (state == "showTip") {
                    that.parent.showTip("获取定位失败");
                }
            } else {
                console.log("没window.parent")
                if (state == "hBackMsg") {
                    // window.parent.hBackMsg(data);
                    that.unis("hBackMsg")
                }
                if (state == "setIntLat") {
                    // window.parent.setIntLat({
                    //     rid: that.data.id,
                    //     fn: (out) => {
                    //         // console.log(out,"1111");
                    //         // that.addIcon(out);
                    //         that.addIcon([out[1], out[0]]);
                    //     }
                    // });
                    that.unis("setIntLat")
                }
                if (state == "showTip") {
                    // that.parent.showTip("获取定位失败");
                    that.unis("showTip")
                }
        // unis(data) {
        //     //向uniapp传值
        //     uni.postMessage({
        //         data: {
        //             action: data
        //         }
        //     });
        // },
        // setUniAppMsg(state, data) {
        //     let that = this;
        //     if (window.parent) {
        //         console.log("有window.parent")
        //         if (state == "hBackMsg") {
        //             window.parent.hBackMsg(data);
        //         }
        //         if (state == "setIntLat") {
        //             window.parent.setIntLat({
        //                 rid: that.data.id,
        //                 fn: (out) => {
        //                     // console.log(out,"1111");
        //                     // that.addIcon(out);
        //                     that.addIcon([out[1], out[0]]);
        //                 }
        //             });
        //         }
        //         if (state == "showTip") {
        //             that.parent.showTip("获取定位失败");
        //         }
        //     } else {
        //         console.log("没window.parent")
        //         if (state == "hBackMsg") {
        //             // window.parent.hBackMsg(data);
        //             that.unis("hBackMsg")
        //         }
        //         if (state == "setIntLat") {
        //             // window.parent.setIntLat({
        //             //     rid: that.data.id,
        //             //     fn: (out) => {
        //             //         // console.log(out,"1111");
        //             //         // that.addIcon(out);
        //             //         that.addIcon([out[1], out[0]]);
        //             //     }
        //             // });
        //             that.unis("setIntLat")
        //         }
        //         if (state == "showTip") {
        //             // that.parent.showTip("获取定位失败");
        //             that.unis("showTip")
        //         }
            }
        },
        //     }
        // },
        openAPP(type) {
            // console.log(type)
            let that = this;
@@ -103,20 +103,54 @@
                    });
                } else if (that.data.butCT == "begin") {
                    // 开始任务
                    that.setUniAppMsg("hBackMsg", {
                        type: "start",
                        data: {
                            id: that.data.id,
                            serid: that.data.serid
                        },
                        fn: function(val) {
                            if (val == "success") {
                                // console.log("成功开启任务")
                                that.data.butCT = "beginUp";
                                that.data.rtype = '0';
                                that.data.type = "0";
                    // that.setUniAppMsg("hBackMsg", {
                    //     type: "start",
                    //     data: {
                    //         id: that.data.id,
                    //         serid: that.data.serid
                    //     },
                    //     fn: function(val) {
                    //         if (val == "success") {
                    //             // console.log("成功开启任务")
                    //             that.data.butCT = "beginUp";
                    //             that.data.rtype = '0';
                    //             that.data.type = "0";
                    //         }
                    //     }
                    // })
                    let rid = that.data.id,
                        serid = that.data.serid,
                        type = 'start',
                        url = that.data.appenUrl + "taskqd/startTask?" +
                        `rid=${rid}&serid=${serid}&type=${type}`;
                    axios.get(url).then((res) => {
                        // console.log(res);
                        that.onPosition = new $getPositions({
                            id: rid,
                            fn: function(res) {
                                // console.log(res);
                                // state.isOnTaskValue[id] = {
                                //     id: id,
                                //     intlat: res.intlat
                                // }
                                // state.changes = !state.changes;
                                // console.log(state.isOnTaskValue)
                                // $store.commit("setMsg", {
                                //     id: id,
                                //     intlat: res.intlat
                                // })
                                let out = res.intlat;
                                if (typeof out != "string") {
                                    that.addIcon([out[1], out[0]]);
                                } else {
                                    console.log("获取定位失败")
                                }
                            }
                        }
                        })
                        that.onPosition.continuedTime();
                        that.data.butCT = "beginUp";
                        that.data.rtype = '0';
                        that.data.type = "0";
                    })
                }
            } else {
@@ -409,8 +443,6 @@
                            console.log(res)
                            if (typeof res.intlat === "string") {
                                // that.parent.showTip("获取定位失败")
                                //向uniapp传值
                                that.setUniAppMsg("showTip")
                            } else {
                                that.addIcon([res.intlat[1], res.intlat[0]]);
@@ -716,7 +748,7 @@
        });
        this.domMove.init();
        // console.log(window.parent.setIntLat)
        that.setUniAppMsg("setIntLat")
        // that.setUniAppMsg("setIntLat")
        // window.parent.setIntLat({
        //     rid: this.data.id,
        //     fn: (out) => {
@@ -725,18 +757,18 @@
        //         that.addIcon([out[1], out[0]]);
        //     }
        // })
        window.addEventListener('message', e => {
            console.log(e, 'HTML 接受APP发送过来的消息 (H5端)');
            app.dataList = JSON.parse(e.data.data).navigation
            console.log(app.dataList, '+++++++++');
        }, false)
        // window.addEventListener('message', e => {
        //     console.log(e, 'HTML 接受APP发送过来的消息 (H5端)');
        //     app.dataList = JSON.parse(e.data.data).navigation
        //     console.log(app.dataList, '+++++++++');
        // }, false)
        // HTML 接受APP发送过来的消息 (APP端)
        function requestData(data) {
            console.log(JSON.stringify(data), 'HTML 接受APP发送过来的消息 (APP端)');
            app.dataList = data.navigation // 赋值
        }
        // // HTML 接受APP发送过来的消息 (APP端)
        // function requestData(data) {
        //     console.log(JSON.stringify(data), 'HTML 接受APP发送过来的消息 (APP端)');
        //     app.dataList = data.navigation // 赋值
        // }
    },
    wacth: {}
})
pages/grabOrders/map.vue
@@ -13,12 +13,28 @@
                urls: '',
                // dataList: [],
                fn: null,
                rid: ''
                rid: '',
                webV: null,
                wv: null,
            }
        },
        methods: {
            message(event) {
                console.log(event.detail.data);
                let data = event.detail.data;
                console.log(data);
            },
            sendRequestData(res, plt = 0) {
                let param = JSON.stringify(res)
                console.log(param);
                if (plt == 1) {
                    this.webV.postMessage({
                        type: 'new',
                        data: param
                    })
                } else {
                    this.wv.evalJS(`requestData(${param})`);
                }
            }
        },
        computed: {
@@ -79,7 +95,8 @@
            }
        },
        onLoad: function(options) {
            var data = [];
            var data = [],
                that = this;
            if (options.data == undefined) {
                data = JSON.stringify({
                    appenUrl: "http://192.168.0.108:83/",
@@ -129,9 +146,28 @@
            // this.urls = a + "grabOrdersMap/xcxmap.html?data=" + data;
            // a = a.slice(0, a.indexOf('api'));
            this.urls = a + "grabOrdersMap/xcxmap.html?data=" + data;
            // this.urls = "http://localhost:80?data=" + data;
            // http://127.0.0.1:8848/qfqk-android/grabOrdersMap/xcxmap.html
            // this.dataList = data;
            // console.log(this.urls);
            let type = uni.getSystemInfoSync().platform;
            if (type == "android") {
                //webView传值
                let currentWebview = this.$scope.$getAppWebview();
                setTimeout(() => {
                    that.wv = currentWebview.children()[0];
                    console.log(that.wv)
                }, 1000)
                window.addEventListener('message', e => {
                    console.log(e)
                    that.webV = e.source // window的对象
                    console.log(e.data.data.arg, '接收h5页面发来的消息'); // 接收h5页面发来的消息(11)  ====>H5端
                }, false)
                setTimeout(() => {
                    that.sendRequestData("给html", 1);
                    that.sendRequestData("给html", 2);
                }, 10000)
            }
        },
        beforeDestroy() {
            this.$store.commit("changegotuGrabOrders");
store/lid/getPosition.js
@@ -77,7 +77,7 @@
                    }
                }
            })
        }, 3000)
        }, 30000)
    }
    overContinued() {
store/positions.js
@@ -28,16 +28,16 @@
                    id: id,
                    fn: function(res) {
                        // console.log(res);
                        state.isOnTaskValue[id] = {
                            id: id,
                            intlat: res.intlat
                        }
                        state.changes = !state.changes;
                        console.log(state.isOnTaskValue)
                        // $store.commit("setMsg", {
                        // state.isOnTaskValue[id] = {
                        //     id: id,
                        //     intlat: res.intlat
                        // })
                        // }
                        // state.changes = !state.changes;
                        // console.log(state.isOnTaskValue)
                        $store.commit("setMsg", {
                            id: id,
                            intlat: res.intlat
                        })
                    }
                })
            }