Bladeren bron

feat: 添加缴费记录、缴费详情页面支付时消息推送授权

carver 2 jaren geleden
bovenliggende
commit
3152c97a12

+ 24 - 0
antbuilder/industry/hospitalV2/components/hospital-payment-detail/index.js

@@ -2,6 +2,8 @@ import { payDetail } from "./service";
 import { tradePay } from "../../utils/tradePay";
 import history from "../../utils/history";
 import { reportApi, reportCmPV_YL } from "../../utils/cloudMonitorHelper";
+import { getAuthUser } from "../../../../core/utils/jsapi";
+import { submitAuthCode } from "../../../../core/utils/ywtService";
 Component({
 	props: {},
 	data: {
@@ -140,6 +142,28 @@ Component({
 			const { medicareBinded = false } = e.target.dataset;
 			const { order: oreder } = this.data;
 
+			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: "消息订阅成功",
+					});
+				}
+				return [error, result];
+			}
+
 			if (oreder.type === 1) {
 				await tradePay(
 					{

+ 23 - 0
antbuilder/industry/hospitalV2/components/hospital-payment/index.js

@@ -2,6 +2,8 @@ import { payHistory } from "./service";
 import history from "../../utils/history";
 import { tradePay } from "../../utils/tradePay";
 import { reportCmPV_YL } from "../../utils/cloudMonitorHelper";
+import { getAuthUser } from "../../../../core/utils/jsapi";
+import { submitAuthCode } from "../../../../core/utils/ywtService";
 Component({
 	props: {},
 	data: {
@@ -131,6 +133,27 @@ Component({
 		// 付款
 		async onPayment(e) {
 			const { medicareBinded = false, item } = e.target.dataset; // 同意订阅消息后发起支付
+			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: "消息订阅成功",
+					});
+				}
+				return [error, result];
+			}
 			// 挂号
 			if (item.type === 1) {
 				await tradePay(