From 659d09ec24dab6c451220c8f3bb3943b0fdb3ba1 Mon Sep 17 00:00:00 2001 From: quanyawei <401863037@qq.com> Date: Mon, 08 Jan 2024 16:16:12 +0800 Subject: [PATCH] fix:地图导航 --- pages/actionChange/newPage/index.vue | 91 +++++++++++++++++++++++++++++++++++++++++++++ manifest.json | 8 +++ pages/actionChange/components/rectificationInfor.vue | 2 pages/actionChange/components/basicInfor.vue | 16 ++++++++ 4 files changed, 114 insertions(+), 3 deletions(-) diff --git a/manifest.json b/manifest.json index 3c45bf9..9298203 100644 --- a/manifest.json +++ b/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 diff --git a/pages/actionChange/components/basicInfor.vue b/pages/actionChange/components/basicInfor.vue index ca19e88..87811da 100644 --- a/pages/actionChange/components/basicInfor.vue +++ b/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 diff --git a/pages/actionChange/components/rectificationInfor.vue b/pages/actionChange/components/rectificationInfor.vue index ec93b2c..cd7a7ee 100644 --- a/pages/actionChange/components/rectificationInfor.vue +++ b/pages/actionChange/components/rectificationInfor.vue @@ -109,7 +109,7 @@ value: 0, }, ], form: { - isChange: 0, + isChange: 1, changeName: '', changeDescribe: '', }, diff --git a/pages/actionChange/newPage/index.vue b/pages/actionChange/newPage/index.vue index 3c53e01..6c34083 100644 --- a/pages/actionChange/newPage/index.vue +++ b/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 -- Gitblit v1.8.0