فهرست منبع

修复无法获取地理位置

gcz 3 روز پیش
والد
کامیت
08317a1767
1فایلهای تغییر یافته به همراه108 افزوده شده و 59 حذف شده
  1. 108 59
      pages/bookticket.vue

+ 108 - 59
pages/bookticket.vue

@@ -520,6 +520,7 @@ import {
 				}
 				
 				// 发起提交订单请求
+				console.log('submitOrderV2',params)
 				this.$u.api.submitOrderV2(params, {custom:{toast:false}})
 					.then(res => {
 						this.orderId = res.data.orderId;
@@ -601,63 +602,65 @@ import {
 			  });
 			},
 			// 设置小程序订阅消息
-			async setTemplate() {
-				if(this.needIdcardNumber&&this.needIdcardNumber!==this.visitors.length){
-					uni.showToast({
-						title:'观影人信息不正确',
-						icon:'none'
-					})
-					return false
-				}
+			// async setTemplate() {
+			// 	console.log('setTemplate=============')
+			// 	if(this.needIdcardNumber&&this.needIdcardNumber!==this.visitors.length){
+			// 		uni.showToast({
+			// 			title:'观影人信息不正确',
+			// 			icon:'none'
+			// 		})
+			// 		return false
+			// 	}
 				
-				try {
-				    const location = await this.getUserLocation();
-				    this.longitude = location.longitude;
-				    this.latitude = location.latitude;
-				    if (!this.longitude || !this.latitude) {
-				      uni.showToast({
-				        title: '无法获取地理位置',
-				        icon: 'none'
-				      });
-				      return;
-				    }
-				    console.log('location', location);
-				  } catch (err) {
-				    if (err.errMsg === 'getLocation:fail auth deny') {
-				      // 用户拒绝授权,提示用户打开位置权限
-				      this.showOpenLocationSettings();
-				    } else {
-				      uni.showToast({
-				        title: '获取地理位置失败',
-				        icon: 'none'
-				      });
-				    }
-					return
-				  }
+			// 	try {
+			// 	    const location = await this.getUserLocation();
+			// 	    this.longitude = location.longitude;
+			// 	    this.latitude = location.latitude;
+			// 	    if (!this.longitude || !this.latitude) {
+			// 	      uni.showToast({
+			// 	        title: '无法获取地理位置',
+			// 	        icon: 'none'
+			// 	      });
+			// 	      return;
+			// 	    }
+				    
+			// 	  } catch (err) {
+			// 	    if (err.errMsg === 'getLocation:fail auth deny') {
+			// 	      // 用户拒绝授权,提示用户打开位置权限
+			// 	      this.showOpenLocationSettings();
+			// 	    } else {
+			// 	      uni.showToast({
+			// 	        title: '获取地理位置失败',
+			// 	        icon: 'none'
+			// 	      });
+			// 	    }
+			// 		return
+			// 	  }
+			// 	  console.log('location', location);
 				
-				let that = this;
-				// console.log('templateIdList', this.templateIdList);
-				// #ifdef MP
-				uni.requestSubscribeMessage({
-					tmplIds: that.templateIdList,
-					success(res) {
-						// that.gotoPay();
-						console.log("设置小程序订阅消息 success:", res);
-					},
-					fail(res) {
-						console.log("设置小程序订阅消息 fail:", res);
-					},
-					complete(res) {
-						// that.gotoPay();
-						that.submitorder();
-						console.log("设置小程序订阅消息 complete:", res);
-					}
-				})
-				// #endif
-				// #ifdef H5
-				that.gotoPay()
-				// #endif
-			},
+			// 	let that = this;
+			// 	// console.log('templateIdList', this.templateIdList);
+			// 	// #ifdef MP
+			// 	uni.requestSubscribeMessage({
+			// 		tmplIds: that.templateIdList,
+			// 		success(res) {
+			// 			// that.gotoPay();
+			// 			console.log("设置小程序订阅消息 success:", res);
+			// 		},
+			// 		fail(res) {
+			// 			console.log("设置小程序订阅消息 fail:", res);
+			// 		},
+			// 		complete(res) {
+			// 			// that.gotoPay();
+			// 			that.submitorder();
+			// 			console.log("设置小程序订阅消息 complete:", res);
+			// 		}
+			// 	})
+			// 	// #endif
+			// 	// #ifdef H5
+			// 	that.gotoPay()
+			// 	// #endif
+			// },
 			gotoPay() {
 				this.$u.api.gotoPayV2({
 					orderId: this.orderId,
@@ -877,8 +880,8 @@ import {
 
 				this.visitorShow = false;
 			},
-			// 修改支付按钮点击方法
-			setTemplate() {
+			// 设置小程序订阅消息
+			async setTemplate() {
 				// 检查是否所有商品都选择了足够的观影人
 				const isValid = this.pageContent.goodsList.every(goods => {
 					// 如果没有realList或realList[0]为空,则不需要验证观影人数量
@@ -899,8 +902,54 @@ import {
 					return;
 				}
 
-				// 继续原有的支付逻辑
-				this.submitorder();
+				try {
+				    const location = await this.getUserLocation();
+				    this.longitude = location.longitude;
+				    this.latitude = location.latitude;
+				    if (!this.longitude || !this.latitude) {
+				      uni.showToast({
+				        title: '无法获取地理位置',
+				        icon: 'none'
+				      });
+				      return;
+				    }
+				    console.log('location', location);
+				  } catch (err) {
+				    if (err.errMsg === 'getLocation:fail auth deny') {
+				      // 用户拒绝授权,提示用户打开位置权限
+				      this.showOpenLocationSettings();
+				    } else {
+				      uni.showToast({
+				        title: '获取地理位置失败',
+				        icon: 'none'
+				      });
+				    }
+					return
+				  }
+				  
+				
+				let that = this;
+				// console.log('templateIdList', this.templateIdList);
+				// #ifdef MP
+				uni.requestSubscribeMessage({
+					tmplIds: that.templateIdList,
+					success(res) {
+						// that.gotoPay();
+						console.log("设置小程序订阅消息 success:", res);
+					},
+					fail(res) {
+						console.log("设置小程序订阅消息 fail:", res);
+					},
+					complete(res) {
+						// that.gotoPay();
+						that.submitorder();
+						console.log("设置小程序订阅消息 complete:", res);
+					}
+				})
+				// #endif
+				// #ifdef H5
+				that.gotoPay()
+				// #endif
 			}
 		}
 	}