lin
2024-04-03 4d8796769c39ae848a0e154184b92854f146efd1
定位代码优化
2 files modified
40 ■■■■■ changed files
pages/home/index.vue 26 ●●●●● patch | view | raw | blame | history
subPackage/police/onLine.vue 14 ●●●● patch | view | raw | blame | history
pages/home/index.vue
@@ -306,6 +306,10 @@
        getUser,
        updateUserInfo
    } from "@/api/user.js"
    import {
        add as addPolicTrajectoryPoint
    } from "@/api/police/policTrajectoryPoint.js"
    import {
        getPage
    } from "@/api/article/article";
@@ -1340,16 +1344,14 @@
                                        success: (tip) => {
                                            if (tip.confirm) {
                                                uni.openSetting({
                                                    success: (
                                                        data) => {
                                                    success: (data) => {
                                                        if (data
                                                            .authSetting[
                                                                "scope.userLocationBackground"
                                                            ] ==
                                                            true
                                                        ) {
                                                                ] == true
                                                            ) {
                                                            this
                                                                .getBackgroundLocation();
                                                        .getBackgroundLocation();
                                                        }
                                                    }
                                                });
@@ -1389,10 +1391,9 @@
                if (wx.onLocationChange && this.userGPS != false) {
                    wx.onLocationChange((data) => {
                        console.log('onLocationChange***************', data)
                        //微信开发工具上面只能触发一次,真机上面是循环获取
                        //设置一个公共时间,原因是时间间隔太短,自己设置时间,然后去操作相应的逻辑
                        if (this.time == 11) {
                        if (this.time == 20) {
                            // 调取实时位置
                            this.reportLocation(this.location);
                            this.time = 0;
@@ -1414,6 +1415,15 @@
                updateUserInfo(param).then(res => {
                    console.log(res)
                })
                let params = {
                    userId: uni.getStorageSync("userInfo").user_id,
                    deptId: uni.getStorageSync("userInfo").dept_id,
                    longitude: location.longitude,
                    latitude: location.latitude,
                }
                addPolicTrajectoryPoint(params).then(res => {
                    console.log(res)
                })
                console.log('********************location****************************************', location)
            },
subPackage/police/onLine.vue
@@ -79,7 +79,10 @@
                                this.userInfo.status = 1
                            }
                            updateUserInfo(this.userInfo).then(res => {
                                console.log(res)
                                console.log("**********userInfo*************", res)
                                let userInfo = uni.getStorageSync("userInfo")
                                userInfo.status = this.userInfo.status
                                uni.setStorageSync("userInfo", userInfo)
                            })
                        }
                    }
@@ -97,16 +100,7 @@
                    } else {
                        this.onLine = false
                    }
                    // console.log(data)
                });
                // data.forEach((item, index) => {
                //     if (item.roleName == "居民") {
                //         item.icon = "/static/icon/user-01.png"
                //     }
                // })
                // this.roleData = data;
                this.loading = !this.loading
            },