潘超林 hai 1 semana
pai
achega
234415ebf2
Modificáronse 4 ficheiros con 71 adicións e 137 borrados
  1. 9 9
      api/index.js
  2. 3 7
      api/request.js
  3. 55 116
      pages/index/pay-zfb.vue
  4. 4 5
      pages/index/pay.vue

+ 9 - 9
api/index.js

@@ -29,22 +29,22 @@ export default {
     },
     sendSms(data) {
         return request({
-            url: "/external/third/sms/sendSms",
-            method: "post",
+            url: "/external/third/sms/sendSmsH5",
+            method: "get",
             data: data,
-            header: {
-                'Content-Type': 'application/json'
-            }
+            // header: {
+            //     'Content-Type': 'application/json'
+            // },
         });
     },
     bindH5Phone(data) {
         return request({
             url: "/user/userInfo/bindH5Phone",
-            method: "post",
+            method: "get",
             data: data,
-            header: {
-                'Content-Type': 'application/json'
-            }
+            // header: {
+            //     'Content-Type': 'application/json'
+            // },
         });
     },
 

+ 3 - 7
api/request.js

@@ -155,11 +155,6 @@ class Request {
 		if (token && !headers['Authorization']) {
 			headers['Authorization'] = 'Bearer ' + token;
 		}
-
-		// 流式请求需要特殊处理
-		if (param.isStream) {
-			headers['Accept'] = 'text/event-stream';
-		}
 		console.log(requestConfig);
 
 		// 构建请求URL
@@ -183,6 +178,7 @@ class Request {
 		return new Promise((resolve, reject) => {
 			try {
 				const requestConfig = this.buildRequestConfig(param);
+				// alert(JSON.stringify(requestConfig));
 				// 从参数中获取是否显示错误提示的标志
 				const showToast = param.showToast !== undefined ? param.showToast : true;
 				let isAborted = false;
@@ -213,7 +209,7 @@ class Request {
 
 								uni.reLaunch({
 									url:
-										"/pages/index/index?shopId=" + uni.getStorageSync('shopId'),
+										"/pages/index/index?shopId=" + uni.getStorageSync('shopId') + '&storeId=' + uni.getStorageSync('storeId'),
 								});
 								localStorage.clear();
 							} else if (res.data.code === 400 && res.data.msg === '登录凭证不为空') {
@@ -223,7 +219,7 @@ class Request {
 								// if (showToast) {
 								uni.reLaunch({
 									url:
-										"/pages/index/index?shopId=" + uni.getStorageSync('shopId'),
+										"/pages/index/index?shopId=" + uni.getStorageSync('shopId') + '&storeId=' + uni.getStorageSync('storeId'),
 								});
 								localStorage.clear();
 								// }

+ 55 - 116
pages/index/pay-zfb.vue

@@ -26,12 +26,12 @@
 				</view>
 
 				<view class="login-contont-button">
-					<button class="btn" @click="Pay">立即支付</button>
+					<button class="btn" @tap="Pay">立即支付</button>
 
 					<view style="padding: 0 30rpx">
 						<view class="cell-item">
 							<u-cell-group :border="false">
-								<u-cell title="代金券折扣" :border="false" isLink @click="voucher">
+								<u-cell title="代金券折扣" :border="false" isLink @tap="voucher">
 									<template slot="value">
 										<text style="color: orange;">{{ CellText }}</text>
 									</template>
@@ -70,7 +70,7 @@
 				</view>
 
 				<view class="footer">
-					<u-button type="primary" class="btn" text="确定" @click="submitOk"></u-button>
+					<u-button type="primary" class="btn" text="确定" @tap="submitOk"></u-button>
 				</view>
 			</view>
 		</u-popup>
@@ -79,14 +79,14 @@
 			<view class="coupon-popup">
 				<view class="popup-header">
 					<text class="title">店铺代金券</text>
-					<u-icon name="close" size="22" @click="showPopup = false" />
+					<u-icon name="close" size="22" @tap="showPopup = false" />
 				</view>
 
 				<view class="coupon-list">
 					<u-radio-group v-model="voucherRadio" placement="column" @change="groupChange" iconSize="30"
 						size="40">
 						<view class="coupon-item" :class="item.status === 0 ? 'disabled' : 'active'"
-							v-for="(item, index) in couponList" :key="index" @click="selectCoupon(index)">
+							v-for="(item, index) in couponList" :key="index" @tap="selectCoupon(index)">
 							<view class="left">
 								<view class="tag" :class="item.voucherType === 1 ? 'independent' : 'chain'">
 									{{ item.voucherType === 1 ? '独立券' : item.voucherType === 2 ? '连锁券' : '联合券' }}
@@ -139,84 +139,7 @@ export default {
 			shopInfo: {},
 			zfbInfo: {},
 			localUserInfo: null,
-			couponList: [
-				{
-					"amount": 2,
-					"applyAllProducts": 1,
-					"applyProductIds": [],
-					"bizType": 14,
-					"claimTime": "2026-04-11 09:56:51",
-					"createTime": "2026-04-11 09:56:51",
-					"discountAmount": null,
-					"endTime": "2026-04-30 10:33:38",
-					"id": "2042783907267350530",
-					"isApply": 0,
-					"minOrderAmount": null,
-					"orderNo": "",
-					"productIds": [],
-					"ruleDisplay": "无门槛",
-					"startTime": "2026-04-10 10:33:26",
-					"status": 1,
-					"storeCount": 1,
-					"storeId": "2018881434293329922",
-					"storeList": [
-						{
-							"isCreator": 1,
-							"storeId": "2018881434293329922",
-							"storeName": "医药one店",
-							"voucherId": "2042068417733718017"
-						}
-					],
-					"storeName": "",
-					"unApplyReason": "",
-					"updateTime": "2026-04-11 09:56:47",
-					"useTime": null,
-					"userId": "1965353825816576001",
-					"voucherId": "2042068417733718017",
-					"voucherName": "2元代金券",
-					"voucherRule": 1,
-					"voucherType": 3,
-					"voucherTypeDesc": "联合券"
-				},
-				{
-					"amount": 2,
-					"applyAllProducts": 1,
-					"applyProductIds": [],
-					"bizType": 14,
-					"claimTime": "2026-04-11 09:56:50",
-					"createTime": "2026-04-11 09:56:50",
-					"discountAmount": null,
-					"endTime": "2026-04-16 21:21:31",
-					"id": "2042783902674587650",
-					"isApply": 0,
-					"minOrderAmount": null,
-					"orderNo": "",
-					"productIds": [],
-					"ruleDisplay": "无门槛",
-					"startTime": "2026-04-07 15:14:37",
-					"status": 1,
-					"storeCount": 1,
-					"storeId": "2018881434293329922",
-					"storeList": [
-						{
-							"isCreator": 1,
-							"storeId": "2018881434293329922",
-							"storeName": "医药one店",
-							"voucherId": "2042139544933875713"
-						}
-					],
-					"storeName": "",
-					"unApplyReason": "",
-					"updateTime": "2026-04-11 09:56:46",
-					"useTime": null,
-					"userId": "1965353825816576001",
-					"voucherId": "2042139544933875713",
-					"voucherName": "联合券",
-					"voucherRule": 1,
-					"voucherType": 3,
-					"voucherTypeDesc": "联合券"
-				}
-			],
+			couponList: [],
 			couponId: "",
 			CellText: "暂无代金券",
 			payment: "",
@@ -229,7 +152,7 @@ export default {
 		this.shopId = options.shopId || "";
 		this.storeId = options.storeId || "";
 		// 读取本地支付宝用户信息
-		let info = localStorage.getItem("aliPayUserInfo");
+		let info = uni.getStorageSync("aliPayUserInfo");
 		if (info) {
 			this.localUserInfo = JSON.parse(info);
 		}
@@ -312,7 +235,7 @@ export default {
 		},
 
 		// 支付宝授权登录
-		async getInfo() {
+		getInfo() {
 			uni.showLoading({ title: "登录中..." });
 			api.weChatH5Login({
 				code: this.zfbInfo.auth_code,
@@ -321,8 +244,10 @@ export default {
 				uni.hideLoading();
 				if (res.code == 200) {
 					this.userInfo = res.data;
-					localStorage.setItem("token", this.userInfo.access_token);
-					localStorage.setItem("aliPayUserInfo", JSON.stringify(this.userInfo));
+					uni.setStorageSync("token", this.userInfo.access_token)
+					uni.setStorageSync("aliPayUserInfo", JSON.stringify(this.userInfo))
+					// localStorage.setItem("token", this.userInfo.access_token);
+					// localStorage.setItem("aliPayUserInfo", JSON.stringify(this.userInfo));
 					this.getShopInfo();
 					this.getVoucher();
 					this.getPhoneBind();
@@ -338,7 +263,7 @@ export default {
 		},
 
 		// 支付
-		async Pay() {
+		Pay() {
 			if (!this.price || Number(this.price) <= 0) {
 				return uni.$u.toast("请输入支付金额");
 			}
@@ -368,7 +293,7 @@ export default {
 		},
 
 		// 获取店铺信息
-		async getShopInfo() {
+		getShopInfo() {
 			if (!this.shopId) return;
 			api.getStoreInfoByScan({
 				shopId: this.shopId,
@@ -389,41 +314,54 @@ export default {
 			}).then((res) => {
 				if (res.code == 200) {
 					this.userInfo = res.data;
-					localStorage.setItem("token", this.userInfo.access_token);
-					localStorage.setItem("aliPayUserInfo", JSON.stringify(this.userInfo));
+					uni.setStorageSync("token", this.userInfo.access_token)
+					uni.setStorageSync("aliPayUserInfo", JSON.stringify(this.userInfo));
 					this.getPhoneBind()
 				}
-			}).catch((err) => {
-			});
+			})
 		},
-		// 绑定手机号提交
-		async submitOk() {
+		// 绑定手机号提交(支付宝浏览器完美修复版)
+		submitOk() {
+			// 防重复提交
+			if (this.isSubmitting) return;
+			this.isSubmitting = true;
+
 			if (!this.phone) return uni.$u.toast("请输入手机号");
 			if (!this.yzm) return uni.$u.toast("请输入验证码");
-			uni.showLoading({ title: "正在绑定中..." });
-			api.bindH5Phone({
-				mobile: this.phone,
-				code: this.yzm,
-				password: 123456,
-				confirmPassword: 123456,
-				type: 0,
-			}).then((res) => {
-				if (res.code == 200) {
-					uni.$u.toast("绑定成功");
-					this.showPhone = false;
-					this.restLogin()
+
+			// 支付宝浏览器核心修复:延迟请求
+			setTimeout(() => {
+				uni.showLoading({ title: "正在绑定中..." });
+				let params = {
+					mobile: this.phone,
+					code: this.yzm,
+					password: "123456",
+					confirmPassword: "123456",
+					type: 0,
+				};
+
+				api.bindH5Phone(params).then((res) => {
 					uni.hideLoading();
-				} else {
-					uni.$u.toast(res.msg);
-				}
-			}).catch((err) => {
-				uni.$u.toast(err.data.msg);
-			});
+					this.isSubmitting = false;
+					if (res.code == 200) {
+						uni.$u.toast("绑定成功");
+						this.showPhone = false;
+						this.restLogin();
+					} else {
+						uni.$u.toast(res.msg || "绑定失败");
+					}
+				}).catch((err) => {
+					uni.hideLoading();
+					this.isSubmitting = false;
+					console.error("绑定错误:", err);
+					uni.$u.toast("绑定失败,请重试");
+				});
+			}, 200);
 		},
 		codeChange(text) {
 			this.tips = text;
 		},
-		// 获取验证码
+		// 获取验证码(支付宝终极修复版)
 		async getCode() {
 			if (!this.$refs.uCode.canGetCode) return;
 			if (!this.phone) return uni.$u.toast("请输入手机号");
@@ -434,12 +372,13 @@ export default {
 				} else {
 					uni.$u.toast(res.msg || "发送失败");
 				}
-			}).catch(() => {
+			}).catch((err) => {
+				alert(JSON.stringify(err));
 				uni.hideLoading();
 				uni.$u.toast("发送失败");
 			});
 		},
-	},
+	}
 };
 </script>
 

+ 4 - 5
pages/index/pay.vue

@@ -26,14 +26,13 @@
 				<view style="padding: 20rpx" v-if="voucherRadio">
 					<text style="font-size: 25rpx;">抵扣代金券后,实付金额</text><text
 						style="color: orange;font-size: 40rpx;margin-left: 10rpx;"> {{ payment }}</text>
-
 				</view>
 				<view class="login-contont-button">
-					<button class="btn" @click="Pay">立即支付</button>
+					<button class="btn" @tap="Pay">立即支付</button>
 					<view style="padding: 0px 30rpx">
 						<view style="margin-top: 66rpx; background: #fff7f6">
 							<u-cell-group :border="false">
-								<u-cell title="代金券折扣" :border="false" isLink @click="voucher">
+								<u-cell title="代金券折扣" :border="false" isLink @tap="voucher">
 									<template slot="value">
 										<text style="color: orange;">{{ CellText }}</text>
 									</template>
@@ -52,14 +51,14 @@
 			<view class="coupon-popup">
 				<view class="popup-header">
 					<text class="title">店铺代金券</text>
-					<u-icon name="close" size="22" @click="showPopup = false" />
+					<u-icon name="close" size="22" @tap="showPopup = false" />
 				</view>
 
 				<view class="coupon-list">
 					<u-radio-group v-model="voucherRadio" placement="column" @change="groupChange" iconSize="30"
 						size="40">
 						<view class="coupon-item" :class="item.status === 0 ? 'disabled' : 'active'"
-							v-for="(item, index) in couponList" :key="index" @click="selectCoupon(index)">
+							v-for="(item, index) in couponList" :key="index" @tap="selectCoupon(index)">
 							<view class="left">
 								<view class="tag" :class="item.voucherType === 1 ? 'independent' : 'chain'">
 									{{ item.voucherType === 1 ? '独立券' : item.voucherType === 2 ? '连锁券' : '联合券' }}