zhangdan 4 years ago
parent
commit
7ba1b8cfb9
1 changed files with 50 additions and 10 deletions
  1. 50 10
      pages/index/order.vue

+ 50 - 10
pages/index/order.vue

@@ -322,18 +322,58 @@
 			},
 			// 选择通信地址
 			selectAddress(){
-				wx.chooseLocation({
-					success:(res)=>{
-						if(res){
-							console.log(res,'========ditu')
-							this.getArea(res.address)
-							this.reverseReceiveAddress.lat=res.latitude
-							this.reverseReceiveAddress.lng=res.longitude
-							this.reverseReceiveAddress.receiveAreasName= res.address
-							this.getHasRider()
-						}
+				uni.authorize({
+					scope: 'scope.userLocation',
+					success:()=>{
+						wx.chooseLocation({
+							success:(res)=>{
+								if(res){
+									console.log(res,'========ditu')
+									this.getArea(res.address)
+									this.reverseReceiveAddress.lat=res.latitude
+									this.reverseReceiveAddress.lng=res.longitude
+									this.reverseReceiveAddress.receiveAreasName= res.address
+									this.getHasRider()
+								}
+							},
+						})
+					},
+					fail() {
+						uni.getSetting({
+							success(res) {
+								console.log(res.authSetting, 'gggggggggg')
+								if (!res.authSetting['scope.userLocation']) {
+									uni.showModal({
+										title: '提示',
+										content: '无法选择通信地址,请开启定位功能!',
+										success: (res) => {
+											if (res.confirm) {
+												uni.openSetting({
+													success(res) {
+														console.log(res.authSetting,
+															'res.authSetting')
+													},
+													fail(err) {
+														console.log(err, 'eeeeeeeee')
+													}
+												})
+											} else if (res.cancel) {
+												console.log('用户点击取消');
+											}
+										}
+									});
+					
+								}
+							},
+							fail() {
+								console.log('获取失败')
+							}
+						})
+					
 					}
+					
 				})
+				
 			},
 			// 扫码下单 自主下单
 			getSaomaInfo(){