瀏覽代碼

fix: 门诊缴费详情支付成功后返回并刷新列表页

carver 2 年之前
父節點
當前提交
4c73f24378

+ 13 - 6
antbuilder/industry/hospitalV2/components/hospital-payment-detail/index.js

@@ -3,6 +3,8 @@ import { tradePay } from "../../utils/tradePay";
 import history from "../../utils/history";
 import { reportApi, reportCmPV_YL } from "../../utils/cloudMonitorHelper";
 import { getSubscribeAuth } from "../../../../core/utils/ywtService";
+import { createSubscribe } from "applet-page-component";
+
 Component({
 	props: {},
 	data: {
@@ -148,13 +150,14 @@ Component({
 		async onPay(e) {
 			const { medicareBinded = false } = e.target.dataset;
 			const { order: oreder } = this.data;
+			let result = false;
 			try {
 				my.showLoading();
 				// 获取授权
 				await getSubscribeAuth();
 
 				if (oreder.type === 1) {
-					await tradePay(
+					result = await tradePay(
 						{
 							type: oreder.type,
 							idNum: oreder.outTradeNo,
@@ -166,7 +169,7 @@ Component({
 					);
 				} else if (oreder.type === 2) {
 					// 充值
-					await tradePay(
+					result = await tradePay(
 						{
 							type: oreder.type,
 							idNum: oreder.outTradeNo,
@@ -193,7 +196,7 @@ Component({
 						name,
 						prescribeDate,
 					} = oreder;
-					await tradePay(
+					result = await tradePay(
 						{
 							useBalance: !medicareBinded,
 							useMedicare: medicareBinded,
@@ -218,12 +221,16 @@ Component({
 					);
 				}
 			} catch (error) {
+				console.log("error ===>", error);
 			} finally {
 				my.hideLoading();
-				// 支付成功刷新页面
-				this.payDetail(this.$page.data.query); // 支付成功以后,发起消息订阅
 			}
-			// this.subscribe.subscribeMessage();
+			// 支付成功刷新页面
+			this.payDetail(this.$page.data.query);
+			if (result) {
+				// 支付成功后返回列表页
+				my.navigateBack();
+			}
 		},
 
 		hrefTo() {

+ 224 - 216
antbuilder/industry/hospitalV2/components/hospital-payment/index.js

@@ -3,238 +3,246 @@ import history from "../../utils/history";
 import { tradePay } from "../../utils/tradePay";
 import { reportCmPV_YL } from "../../utils/cloudMonitorHelper";
 import { getSubscribeAuth } from "../../../../core/utils/ywtService";
-Component({
-	props: {},
-	data: {
-		empty: true,
-		clinicCard: {},
-		filterParams: {
-			type: "9",
-			cardNum: "",
-			endTime: "",
-			startTime: "",
-			medicCards: [],
-			timeShow: false,
-		},
-
-		/* 赛选项目 */
-		typeOptions: [],
-		statusOptions: [
-			{
-				value: "0",
-				label: "待支付",
-			},
-			{
-				value: "1",
-				label: "已支付",
-			},
-		],
-		showAll: false,
-		showTimeSelector: true,
-		showCardSelector: false,
-		defaultLabel: "待支付",
-		defaultName: "待支付",
-		defaultStatus: "待支付",
-	},
-
-	didMount() {
-		/* 服务预警,缴费记录查询 */
-		reportCmPV_YL({
-			title: "门诊缴费",
-		});
-	},
-	onInit() {},
-
-	methods: {
-		onFilterHandel(filters) {
-			const { status: prevStatus } = this.filters || {};
-			const { status: curStatus } = filters || {};
-			console.log("status ===>", prevStatus, curStatus);
-			if (!this.hisPatientId) return;
-			this.filters = filters;
-			const { status, startTime, endTime } = this.filters || {};
-
-			// 当状态未改变时,做时间筛选校验,拦截请求;当状态被改变时,做时间校验的同时,不拦截请求
-
-			// 状态:已支付
-			if (status && status === "1") {
-				if (!startTime || this.getTimeChange(startTime, endTime, 15)) {
-					my.showToast({
-						type: "fail",
-						content: "请选择15天以内的时间",
-						duration: 1500,
-					});
-					if (prevStatus === curStatus) return;
-				}
-			}
-
-			// 状态:未支付
-			if (!status || status === "0") {
-				if (!startTime || this.getTimeChange(startTime, endTime, 3)) {
-					my.showToast({
-						type: "fail",
-						content: "请选择3天以内的时间",
-						duration: 1500,
-					});
-					if (prevStatus === curStatus) return;
-				}
-			}
+import { createSubscribe } from "applet-page-component";
 
+Component(
+	createSubscribe({
+		async onShow() {
 			this.scrollRef.refresh();
 		},
+	})({
+		props: {},
+		data: {
+			empty: true,
+			clinicCard: {},
+			filterParams: {
+				type: "9",
+				cardNum: "",
+				endTime: "",
+				startTime: "",
+				medicCards: [],
+				timeShow: false,
+			},
 
-		saveRef(ref) {
-			this.scrollRef = ref;
+			/* 赛选项目 */
+			typeOptions: [],
+			statusOptions: [
+				{
+					value: "0",
+					label: "待支付",
+				},
+				{
+					value: "1",
+					label: "已支付",
+				},
+			],
+			showAll: false,
+			showTimeSelector: true,
+			showCardSelector: false,
+			defaultLabel: "待支付",
+			defaultName: "待支付",
+			defaultStatus: "待支付",
 		},
 
-		saveSubscribe(ref) {
-			this.subscribe = ref;
+		didMount() {
+			/* 服务预警,缴费记录查询 */
+			reportCmPV_YL({
+				title: "门诊缴费",
+			});
 		},
+		onInit() {},
 
-		getTimeChange(startTime, endTime, len) {
-			if (!startTime || !endTime) {
-				return true;
-			}
-			const time1 = Date.parse(startTime);
-			const time2 = Date.parse(endTime);
-			const timeDiff = time2 - time1;
-			const duration = len * 24 * 60 * 60 * 1000;
-			return timeDiff < 0 || timeDiff > duration;
-		},
+		methods: {
+			onFilterHandel(filters) {
+				const { status: prevStatus } = this.filters || {};
+				const { status: curStatus } = filters || {};
+				if (!this.hisPatientId) return;
+				this.filters = filters;
+				const { status, startTime, endTime } = this.filters || {};
 
-		onService(page) {
-			const { status, startTime, endTime } = this.filters || {};
-			if (!this.hisPatientId) return;
-			return payHistory({
-				...this.filters,
-				status: status || "0",
-				...page,
-				hisPatientId: this.hisPatientId,
-			});
-		},
+				// 当状态未改变时,做时间筛选校验,拦截请求;当状态被改变时,做时间校验的同时,不拦截请求
+
+				// 状态:已支付
+				if (status && status === "1") {
+					if (!startTime || this.getTimeChange(startTime, endTime, 15)) {
+						my.showToast({
+							type: "fail",
+							content: "请选择15天以内的时间",
+							duration: 1500,
+						});
+						if (prevStatus === curStatus) return;
+					}
+				}
+
+				// 状态:未支付
+				if (!status || status === "0") {
+					if (!startTime || this.getTimeChange(startTime, endTime, 3)) {
+						my.showToast({
+							type: "fail",
+							content: "请选择3天以内的时间",
+							duration: 1500,
+						});
+						if (prevStatus === curStatus) return;
+					}
+				}
 
-		onAutoFilter(patient) {
-			if (patient) {
-				this.hisPatientId = patient.hisPatientId;
 				this.scrollRef.refresh();
-			}
-		},
+			},
 
-		// 进入详情
-		toDetail(e) {
-			const {
-				item: {
-					type,
-					outTradeNo,
-					status,
-					tradeNo,
-					invoiceNo,
-					hisPatientId,
-					date,
-					depName,
-					amount,
-					name,
-					age,
-					sex,
-					prescribeDate,
-					hisOrderNo,
-					doctorName,
-					doctorCode,
-					total,
-					hisClinicCode,
-					deptName,
-					orderItems,
-				},
-			} = e.target.dataset;
-			history.push({
-				title: "缴费详情",
-				query: {
-					type: type || 0,
-					outTradeNo,
-					status,
-					tradeNo,
-					invoiceNo,
-					hisPatientId,
-					date,
-					depName,
-					amount,
-					name,
-					age,
-					sex,
-					prescribeDate,
-					hisOrderNo,
-					doctorName,
-					doctorCode,
-					total,
-					hisClinicCode,
-					deptName,
-					orderItems: encodeURIComponent(JSON.stringify(orderItems || "")),
-				},
-				pageType: "hospital-payment-detail",
-			});
-		},
+			saveRef(ref) {
+				this.scrollRef = ref;
+			},
 
-		// 付款
-		async onPayment(e) {
-			const { medicareBinded = false, item } = e.target.dataset; // 同意订阅消息后发起支付
-			try {
-				my.showLoading();
-				// 获取智能消息推送授权
-				await getSubscribeAuth();
-				// 挂号
-				if (item.type === 1) {
-					await tradePay(
-						{
-							type: item.type,
-							idNum: item.outTradeNo,
-							depName: item.depName,
-						},
-						{
-							tradeType: "Appointment",
-						}
-					);
-				} else if (item.type === 2) {
-					// 充值
-					await tradePay(
-						{
-							type: item.type,
-							idNum: item.outTradeNo,
-							amount: item.amount,
-						},
-						{
-							tradeType: "Appointment",
-						}
-					);
-				} else {
-					// 门诊订单
-					await tradePay(
-						{
-							useBalance: !medicareBinded,
-							useMedicare: medicareBinded,
+			saveSubscribe(ref) {
+				this.subscribe = ref;
+			},
+
+			getTimeChange(startTime, endTime, len) {
+				if (!startTime || !endTime) {
+					return true;
+				}
+				const time1 = Date.parse(startTime);
+				const time2 = Date.parse(endTime);
+				const timeDiff = time2 - time1;
+				const duration = len * 24 * 60 * 60 * 1000;
+				return timeDiff < 0 || timeDiff > duration;
+			},
+
+			onService(page) {
+				const { status, startTime, endTime } = this.filters || {};
+				if (!this.hisPatientId) return;
+				return payHistory({
+					...this.filters,
+					status: status || "0",
+					...page,
+					hisPatientId: this.hisPatientId,
+				});
+			},
+
+			onAutoFilter(patient) {
+				if (patient) {
+					this.hisPatientId = patient.hisPatientId;
+					this.scrollRef.refresh();
+				}
+			},
+
+			// 进入详情
+			toDetail(e) {
+				const {
+					item: {
+						type,
+						outTradeNo,
+						status,
+						tradeNo,
+						invoiceNo,
+						hisPatientId,
+						date,
+						depName,
+						amount,
+						name,
+						age,
+						sex,
+						prescribeDate,
+						hisOrderNo,
+						doctorName,
+						doctorCode,
+						total,
+						hisClinicCode,
+						deptName,
+						orderItems,
+					},
+				} = e.target.dataset;
+				history.push({
+					title: "缴费详情",
+					query: {
+						type: type || 0,
+						outTradeNo,
+						status,
+						tradeNo,
+						invoiceNo,
+						hisPatientId,
+						date,
+						depName,
+						amount,
+						name,
+						age,
+						sex,
+						prescribeDate,
+						hisOrderNo,
+						doctorName,
+						doctorCode,
+						total,
+						hisClinicCode,
+						deptName,
+						orderItems: encodeURIComponent(JSON.stringify(orderItems || "")),
+					},
+					pageType: "hospital-payment-detail",
+				});
+			},
+
+			// 付款
+			async onPayment(e) {
+				const { medicareBinded = false, item } = e.target.dataset; // 同意订阅消息后发起支付
+				try {
+					my.showLoading();
+					// 获取智能消息推送授权
+					await getSubscribeAuth();
+					// 挂号
+					if (item.type === 1) {
+						await tradePay(
+							{
+								type: item.type,
+								idNum: item.outTradeNo,
+								depName: item.depName,
+							},
+							{
+								tradeType: "Appointment",
+							}
+						);
+					} else if (item.type === 2) {
+						// 充值
+						await tradePay(
+							{
+								type: item.type,
+								idNum: item.outTradeNo,
+								amount: item.amount,
+							},
+							{
+								tradeType: "Appointment",
+							}
+						);
+					} else {
+						// 门诊订单
+						await tradePay(
+							{
+								useBalance: !medicareBinded,
+								useMedicare: medicareBinded,
+								outTradeNo: item.outTradeNo,
+								...item,
+							},
+							{
+								tradeType: "Outpatient",
+							}
+						);
+					}
+				} catch (error) {
+				} finally {
+					my.hideLoading();
+				}
+				this.scrollRef.refresh();
+				// 支付成功去订单详情页
+				this.toDetail({
+					target: {
+						dataset: {
 							outTradeNo: item.outTradeNo,
+							type: item.type ? item.type : 0,
 							...item,
 						},
-						{
-							tradeType: "Outpatient",
-						}
-					);
-				}
-			} catch (error) {
-			} finally {
-				my.hideLoading();
-			}
-			// 支付成功去订单详情页
-			this.toDetail({
-				target: {
-					dataset: {
-						outTradeNo: item.outTradeNo,
-						type: item.type ? item.type : 0,
-						...item,
 					},
-				},
-			}); // 发起消息订阅
+				}); // 发起消息订阅
 
-			// this.subscribe.subscribeMessage();
+				// this.subscribe.subscribeMessage();
+			},
 		},
-	},
-});
+	})
+);