Explorar o código

扫码页面高德定位更改成百度定位经纬度,实时获取定位,防止骚操作

caojunjie %!s(int64=4) %!d(string=hai) anos
pai
achega
c5f889ca34
Modificáronse 3 ficheiros con 88 adicións e 34 borrados
  1. 1 1
      manifest.json
  2. 43 16
      pages/home/scancode/index.vue
  3. 44 17
      pages/home/scancode/scancodeout.vue

+ 1 - 1
manifest.json

@@ -2,7 +2,7 @@
     "name" : "耀灵全钢店管家",
     "appid" : "__UNI__0C3473D",
     "description" : "测试",
-    "versionName" : "0.0.0.0.0.8",
+    "versionName" : "0.0.0.0.0.9",
     "versionCode" : "100",
     "transformPx" : false,
     "app-plus" : {

+ 43 - 16
pages/home/scancode/index.vue

@@ -152,6 +152,8 @@
 				console.log(res.errCode);
 			});
 			this.coord = ''
+		},
+		onShow(){
 			this.mounteds()
 		},
 		methods: {
@@ -162,8 +164,7 @@
 					geocode: true,
 					success: function(res) {
 						console.log(res)
-						this.addd = res
-						that.tishi(that.coord, res)
+						that.tishi(res)
 					},
 					fail: function(e) {
 						uni.showToast({
@@ -173,10 +174,10 @@
 					}
 				})
 			},
-			async tishi(x, res) {
+			async tishi(res) {
 				console.log(res)
 				let this_ = this
-				this_.coord = x
+				this_.baidu = res
 				qqmapsdk.reverseGeocoder({
 					location: {
 						latitude: res.latitude,
@@ -185,33 +186,59 @@
 					success(res) {
 						var newCity = ''
 						// 取到用户的定位地址,赋值传递出去
-						let aress = res.result.address_component.nation + res.result.address_component.province + res.result.address_component.city + res.result.formatted_addresses.recommend
-							console.log(res)
-						this_.addreev(res,aress)
+						let aress = res.result.address_component.nation + res.result.address_component.province + res.result.address_component
+							.city + res.result.formatted_addresses.recommend
+						request({
+							url: '/baseReq/getBaiDuMapMsg',
+							method: 'get',
+							params: {
+								longitude: this_.baidu.longitude,
+								latitude: this_.baidu.latitude
+							}
+						}).then(res => {
+							console.log(res.data.data.result)
+							console.log(res.data)
+							if(res.data.code != 0){
+								uni.showToast({
+									icon: 'none',
+									title: '获取定位失败,请稍后再试~'
+								})
+							}else{
+								this_.baidu = res.data.data.result
+								this_.addreev(this_.baidu, aress)
+							}
+						}).catch(err => {
+							console.log(err)
+							uni.showToast({
+								icon: 'none',
+								title: '网络繁忙请稍后再试~'
+							})
+						}).finally(() => {
+							// Loading.close()
+						})
 					}
 				})
 			},
-			async addreev(res,x) {
+			async addreev(res, x) {
 				this.address = x
-				this.addd = res.result.location
-				console.log(this.addd)
+				this.degree = res
+				console.log(res)
+				console.log(x)
 			},
 			//手动录入调用
 			manualentry() {
-				console.log(this.coord)
-				console.log(this.address)
 				if (this.number_a.length != 0) {
 					request({
 							url: '/storeScan/storeScanGetTyre',
 							method: 'Post',
-							data:{
+							data: {
 								storeId: this.$store.state.storeInfo.storeId,
 								userId: this.$store.state.storeInfo.userId,
 								tyreNum: this.number_a,
-								scanType: 1,
+								scanType: 2,
 								scanWay: 0,
-								longitude: this.addd.lng,
-								latitude: this.addd.lat,
+								longitude: this.degree.x,
+								latitude: this.degree.y,
 								scanAddress: this.address
 							}
 						}).then(res => {

+ 44 - 17
pages/home/scancode/scancodeout.vue

@@ -12,7 +12,7 @@
 				</view>
 				<view class="lnput" v-if="show==false">
 					<input type="text" v-model="number_a" :placeholder="content" clearable="true" focus="true" />
-					<u-button type="primary" size="medium" @click="manualentry" >确认录入</u-button>
+					<u-button type="primary" size="medium" @click="manualentry">确认录入</u-button>
 				</view>
 				<view class="" v-else>
 					<view>{{tips}}:{{number}}</view>
@@ -103,7 +103,7 @@
 				point: '',
 				coord: '',
 				address: '',
-				addd:''
+				addd: ''
 			}
 		},
 		onBackPress(options) {
@@ -152,6 +152,8 @@
 				console.log(res.errCode);
 			});
 			this.coord = ''
+		},
+		onShow(){
 			this.mounteds()
 		},
 		methods: {
@@ -162,8 +164,7 @@
 					geocode: true,
 					success: function(res) {
 						console.log(res)
-						this.addd = res
-						that.tishi(that.coord, res)
+						that.tishi(res)
 					},
 					fail: function(e) {
 						uni.showToast({
@@ -173,10 +174,10 @@
 					}
 				})
 			},
-			async tishi(x, res) {
+			async tishi(res) {
 				console.log(res)
 				let this_ = this
-				this_.coord = x
+				this_.baidu = res
 				qqmapsdk.reverseGeocoder({
 					location: {
 						latitude: res.latitude,
@@ -187,31 +188,57 @@
 						// 取到用户的定位地址,赋值传递出去
 						let aress = res.result.address_component.nation + res.result.address_component.province + res.result.address_component
 							.city + res.result.formatted_addresses.recommend
-						this_.addreev(res,aress)
+						request({
+							url: '/baseReq/getBaiDuMapMsg',
+							method: 'get',
+							params: {
+								longitude: this_.baidu.longitude,
+								latitude: this_.baidu.latitude
+							}
+						}).then(res => {
+							console.log(res.data.data.result)
+							console.log(res.data)
+							if(res.data.code != 0){
+								uni.showToast({
+									icon: 'none',
+									title: '获取定位失败,请稍后再试~'
+								})
+							}else{
+								this_.baidu = res.data.data.result
+								this_.addreev(this_.baidu, aress)
+							}
+						}).catch(err => {
+							console.log(err)
+							uni.showToast({
+								icon: 'none',
+								title: '网络繁忙请稍后再试~'
+							})
+						}).finally(() => {
+							// Loading.close()
+						})
 					}
 				})
 			},
-			async addreev(res,x) {
+			async addreev(res, x) {
 				this.address = x
-				this.addd = res.result.location
-				console.log(this.addd)
+				this.degree = res
+				console.log(res)
+				console.log(x)
 			},
 			//手动录入调用
 			manualentry() {
-				console.log(this.coord)
-				console.log(this.address)
 				if (this.number_a.length != 0) {
 					request({
 							url: '/storeScan/storeScanGetTyre',
 							method: 'Post',
-							data:{
+							data: {
 								storeId: this.$store.state.storeInfo.storeId,
 								userId: this.$store.state.storeInfo.userId,
 								tyreNum: this.number_a,
 								scanType: 2,
 								scanWay: 0,
-								longitude: this.addd.lng,
-								latitude: this.addd.lat,
+								longitude: this.degree.x,
+								latitude: this.degree.y,
 								scanAddress: this.address
 							}
 						}).then(res => {
@@ -463,7 +490,7 @@
 						}
 						// console.log(this.lisi)
 					}).catch(err => {
-						if (err.code == 400) {//谁给我删了......
+						if (err.code == 400) { //谁给我删了......
 							this.$refs.repeat.show({
 								title: "无网络",
 								type: 'default',
@@ -678,4 +705,4 @@
 		width: 100%;
 		background-color: #0095FF;
 	}
-</style>
+</style>