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 +++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 90 insertions(+), 1 deletions(-)

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