Sfoglia il codice sorgente

fix: 在支付之前进行订阅授权

carver 2 anni fa
parent
commit
604dd897ae

+ 3 - 3
antbuilder/industry/hospitalV2/components/appointment-result/index.js

@@ -202,6 +202,7 @@ Component({
 						content: "消息订阅成功",
 					});
 				}
+				return [error, result];
 			}
 		},
 
@@ -230,9 +231,10 @@ Component({
 		},
 
 		// onPay
-		onPay() {
+		async onPay() {
 			const { query = {} } = this.$page.data;
 			const { result } = this.data;
+			await this.grantSubscribe(query.orderId); // 授权需要前置
 			tradePay(
 				{
 					type: 1,
@@ -246,8 +248,6 @@ Component({
 				}
 			).then(() => {
 				this.orderDetail(); // 支付成功之后发起消息订阅授权
-
-				this.grantSubscribe(query.orderId);
 				// this.subscribe.subscribeMessage();
 			});
 			/* 服务办结,挂号缴费 */

+ 20 - 21
antbuilder/industry/hospitalV2/components/hospital-project/index.js

@@ -297,7 +297,26 @@ Component(
 						doctorCode,
 						fee,
 					}); // 区分支持线上支付 和 不支持线上支付
-
+					const [err, authResult] = await getAuthUser([
+						"auth_user",
+						"hospital_order",
+					]);
+					if (err) {
+						my.showToast({
+							type: "fail",
+							content: "智能消息推送授权失败",
+						});
+					} else {
+						const [error, result] = await submitAuthCode({
+							authCode: authResult.authCode,
+						});
+						if (!error) {
+							my.showToast({
+								type: "success",
+								content: "消息订阅成功",
+							});
+						}
+					}
 					if (res.amount && onlinePay) {
 						// const orderRes = await tradeNoQuery({
 						//   type: 1,
@@ -370,26 +389,6 @@ Component(
 								});
 							});
 					} else {
-						const [err, authResult] = await getAuthUser([
-							"auth_user",
-							"hospital_order",
-						]);
-						if (err) {
-							my.showToast({
-								type: "fail",
-								content: "智能消息推送授权失败",
-							});
-						} else {
-							const [error, result] = await submitAuthCode({
-								authCode: authResult.authCode,
-							});
-							if (!error) {
-								my.showToast({
-									type: "success",
-									content: "消息订阅成功",
-								});
-							}
-						}
 						history.replace({
 							query: {
 								hospitalDistrictId,