quanyawei
2024-01-08 659d09ec24dab6c451220c8f3bb3943b0fdb3ba1
fix:地图导航
4 files modified
117 ■■■■■ changed files
manifest.json 8 ●●●● patch | view | raw | blame | history
pages/actionChange/components/basicInfor.vue 16 ●●●●● patch | view | raw | blame | history
pages/actionChange/components/rectificationInfor.vue 2 ●●● patch | view | raw | blame | history
pages/actionChange/newPage/index.vue 91 ●●●●● patch | view | raw | blame | history
manifest.json
@@ -49,7 +49,13 @@
            "postcss": true,
            "minified": true
        },
        "usingComponents": true
        "usingComponents": true,
        "permission": {
            "scope.userLocation": {
                "desc": "测试"
            }
        },
        "requiredPrivateInfos": ["getLocation", "chooseLocation"]
    },
    "mp-alipay": {
        "usingComponents": true
pages/actionChange/components/basicInfor.vue
@@ -85,6 +85,8 @@
                        <view class="wholeLine">
                            <text class="rowTipContenetLabel">污染位置:</text>
                            <text class="rowTipContenetAll">{{ basicInfor.pollutePosition ||'' }}</text>
                            <u-icon name="map" color="#2979ff" size="28" @tap="toNavigation()"
                                v-if="basicInfor.longitude !==null"></u-icon>
                        </view>
                    </p>
                    <p class="rowTip">
@@ -159,6 +161,20 @@
            }
        },
        methods: {
            //导航--传终点的坐标即可
            toNavigation: function() {
                //根据终点地址调起地图导航
                uni.openLocation({
                    longitude: parseFloat(this.basicInfor.longitude), // 经度,范围为-180~180,负数表示西经
                    latitude: parseFloat(this.basicInfor.latitude), // 纬度,范围为-90~90,负数表示南纬
                    scale: 28, // 缩放比例
                    name: this.basicInfor.name, //终点名称
                    address: this.basicInfor.address, //终点详细地址
                    success: function(res) {
                        console.log('success:', res)
                    }
                })
            },
            getUnitList() {
                this.$http.httpGet('/allocation/unit').then(res => {
                    this.unitList = res.data
pages/actionChange/components/rectificationInfor.vue
@@ -109,7 +109,7 @@
                    value: 0,
                }, ],
                form: {
                    isChange: 0,
                    isChange: 1,
                    changeName: '',
                    changeDescribe: '',
                },
pages/actionChange/newPage/index.vue
@@ -10,7 +10,11 @@
                    @confirm="checkTime" @cancel='showeEscalationTime=false' />
            </u-form-item>
            <u-form-item border-bottom label="污染位置:" prop="pollutePosition" required>
                <u-input v-model="form.pollutePosition" border="none" placeholder="请输入" type="text" />
                <u-input v-model="form.pollutePosition" border="none" placeholder="请输入" type="text">
                    <template slot="suffix">
                        <u-button @tap="authVerification()" text="地图选择" type="success" size="mini"></u-button>
                    </template>
                </u-input>
            </u-form-item>
            <u-form-item border-bottom label="责任主体:" prop="unitId" required @click="
                    showCheckBox = true;
@@ -95,6 +99,7 @@
                labelStyle: {
                    fontSize: '30.77rpx'
                },
                addressInfor: {},
                showeEscalationTime: false,
                actionOptionList: [],
                rules: {
@@ -190,6 +195,86 @@
            return false
        },
        methods: {
            authVerification() {
                uni.getSetting({
                    success: res => {
                        if (res.authSetting['scope.userLocation']) {
                            /* 用户授权成功时走这里 */
                            this.handerLocation()
                        } else if (res.authSetting['scope.userLocation'] === undefined) {
                            /* 用户未授权时走这里 */
                            console.log('没有授权', res)
                            this.handleOpenSetting()
                        } else {
                            /* 用户拒绝了授权后走这里 */
                            console.log('拒绝了授权 false')
                            this.handleOpenSetting()
                        }
                    },
                })
            },
            handerChooseLocation(latitude, longitude) {
                uni.chooseLocation({
                    latitude: latitude || '',
                    longitude: longitude || '',
                    success: res => {
                        console.log('取消按钮', res)
                        this.addressInfor = res
                        this.form.pollutePosition = res.address
                    },
                    fail: function(err) {
                        console.log('取消按钮', err)
                    }
                })
            },
            handerLocation() {
                let that = this
                uni.getLocation({
                    type: 'wgs84',
                    success: function(res) {
                        console.log('111', res)
                        that.handerChooseLocation(res.latitude, res.longitude)
                    },
                    fail(error) {
                        console.log('失败', error)
                    }
                })
            },
            handleOpenSetting() {
                let that = this
                uni.authorize({
                    scope: 'scope.userLocation',
                    success() {
                        console.log('res', '1111')
                        //点击允许后--就一直会进入成功授权的回调 就可以使用获取的方法了
                        that.handerLocation()
                    },
                    fail(error) {
                        //点击了拒绝授权后--就一直会进入失败回调函数--此时就可以在这里重新拉起授权窗口
                        console.log('拒绝授权', error)
                        uni.showModal({
                            title: '提示',
                            content: '若点击不授权,将无法使用位置功能',
                            cancelText: '不授权',
                            confirmText: '授权',
                            success(res) {
                                console.log(res)
                                if (res.confirm) {
                                    // 选择弹框内授权
                                    uni.openSetting({
                                        success(res) {
                                            that.handerLocation()
                                        }
                                    })
                                } else if (res.cancel) {
                                    // 选择弹框内 不授权
                                    console.log('用户点击不授权')
                                }
                            }
                        })
                    }
                })
            },
            handleFile(data) {
                console.log('datadata', data)
                this.fileBaseList = data
@@ -242,6 +327,10 @@
                this.$refs.uForm.validate().then(res => {
                    this.sumbitForm.problemDescribe = this.form.problemDescribe
                    this.sumbitForm.pollutePosition = this.form.pollutePosition
                    this.sumbitForm.address = this.addressInfor.address
                    this.sumbitForm.latitude = this.addressInfor.latitude
                    this.sumbitForm.longitude = this.addressInfor.longitude
                    this.sumbitForm.name = this.addressInfor.name
                    this.sumbitForm.changeDay = this.form.changeDay
                    this.sumbitForm.escalationName = this.form.escalationName
                    this.sumbitForm.investigationType = this.form.investigationType