Browse Source

fix: 修复模板数据解析

carver 1 year ago
parent
commit
0dc5fb660d

+ 85 - 61
antbuilder/industry/hospitalV2/components/hospital-payment-detail-yibao/index.js

@@ -9,11 +9,24 @@ import {
 import history from "../../utils/history";
 import { createSubscribe } from "applet-page-component";
 
+const parseDetailItems = (detailItems) => {
+	const list = detailItems
+		? JSON.parse(decodeURIComponent(detailItems || ""))
+		: [];
+	const newList = list.map((item) => {
+		return {
+			label: `${item.itemName}*${item.itemNum}`,
+			// subLabel: `${item.unit || ""}`,
+			value: `${item.amount || 0}元`,
+		};
+	});
+	return newList || [];
+};
+
 Component(
 	createSubscribe({
 		onShow() {
 			this.init("onShow");
-			console.log("onShow this._paying", this._paying);
 		},
 	})({
 		props: {},
@@ -29,7 +42,6 @@ Component(
 
 		didMount() {
 			this.init("didMount");
-			console.log("didMount this._paying", this._paying);
 		},
 
 		didUnmount() {
@@ -38,7 +50,33 @@ Component(
 
 		methods: {
 			init(type) {
-				this.getPayDetail(this.$page.data.query);
+				console.log("type ===>", type, this, this.$page.data.query);
+				// this.getPayDetail1(this.$page.data.query);
+				let infoList = [];
+				const query = this.$page.data.query;
+				if (query) {
+					infoList = [
+						{
+							title: "就诊信息",
+							list: [
+								// { label: "门诊类别", value: info.deptName },
+								{ label: "门诊科室", value: query.deptName },
+								{ label: "医生姓名", value: query.doctorName },
+								{ label: "处方时间", value: query.prescribeDate },
+								{
+									label: "费用总额",
+									value: parseFloat(query.total / 100, 2) || 0 + "元",
+									highlight: true,
+								},
+							],
+						},
+						{
+							title: "费用信息",
+							list: parseDetailItems(query.orderItems),
+						},
+					];
+					this.setData({ prescriptionList: infoList });
+				}
 				this.hanldeGetPayAuthInfo(type);
 			},
 
@@ -162,9 +200,12 @@ Component(
 					medicalCardId,
 					consumeType: isUserPersonalAccount ? 0 : 2,
 				});
+				console.log("result ===>", result);
 				if (!err) {
 					// 预结算成功
+					console.log("111");
 					const ybData = await getYbParams(result);
+					console.log("ybData ===>", ybData);
 					this.setData(
 						{
 							preConfirmInfo: Object.assign(result, ybData),
@@ -189,20 +230,6 @@ Component(
 			},
 		},
 
-		parseDetailItems(detailItems) {
-			const list = detailItems
-				? JSON.parse(decodeURIComponent(detailItems || ""))
-				: [];
-			const newList = list.map((item) => {
-				return {
-					label: `${item.itemName}*${item.itemNum}`,
-					// subLabel: `${item.unit || ""}`,
-					value: `${item.amount || 0}元`,
-				};
-			});
-			return newList || [];
-		},
-
 		async handleIsUserPersonalAccount(e) {
 			const _this = this;
 			const { valuex } = e.currentTarget.dataset;
@@ -239,7 +266,7 @@ Component(
 			);
 		},
 
-		getPayDetail(query) {
+		getPayDetail1(query) {
 			let infoList = [];
 			if (query) {
 				infoList = [
@@ -259,7 +286,7 @@ Component(
 					},
 					{
 						title: "费用信息",
-						list: this.parseDetailItems(query.orderItems),
+						list: parseDetailItems(query.orderItems),
 					},
 				];
 				this.setData({ prescriptionList: infoList });
@@ -288,6 +315,7 @@ Component(
 		// 发起支付
 		async onPay(e) {
 			const { canPay } = this.data;
+			console.log("canPay ==>", canPay);
 			if (!canPay) return;
 			this._paying = true;
 			const {
@@ -317,48 +345,44 @@ Component(
 				isUserPersonalAccount,
 			} = this.data;
 			let result = false;
-			try {
-				my.showLoading();
-				// 门诊订单
-				result = await tradePay(
-					{
-						useBalance: false,
-						useMedicare: true,
-						outTradeNo,
-						hisPatientId,
-						age,
-						sex,
-						orderId,
-						hisOrderNo,
-						amount,
-						deptName,
-						doctorName,
-						doctorCode,
-						total,
-						hisClinicCode,
-						name,
-						prescribeDate,
-						orderInsType,
-						payInsType,
-						totalFee: total,
-						medInsFee,
-						selfFee,
-						payName,
-						patName,
-						invoiceNo,
-						insuAdmDr,
-						insUploadFeeResp,
-						consumeType: isUserPersonalAccount ? 0 : 2,
-					},
-					{
-						tradeType: "Outpatient",
-					}
-				);
-			} catch (error) {
-				console.log("error ===>", error);
-			} finally {
-				my.hideLoading();
-			}
+			my.showLoading();
+			// 门诊订单
+			result = await tradePay(
+				{
+					useBalance: false,
+					useMedicare: true,
+					outTradeNo,
+					hisPatientId,
+					age,
+					sex,
+					orderId,
+					hisOrderNo,
+					amount,
+					deptName,
+					doctorName,
+					doctorCode,
+					total,
+					hisClinicCode,
+					name,
+					prescribeDate,
+					orderInsType,
+					payInsType,
+					totalFee: total,
+					medInsFee,
+					selfFee,
+					payName,
+					patName,
+					invoiceNo,
+					insuAdmDr,
+					insUploadFeeResp,
+					consumeType: isUserPersonalAccount ? 0 : 2,
+				},
+				{
+					tradeType: "Outpatient",
+				}
+			);
+
+			my.hideLoading();
 
 			if (result) {
 				this._paying = false;

+ 42 - 20
antbuilder/industry/hospitalV2/components/hospital-payment-detail-yibao/service.js

@@ -21,23 +21,34 @@ function getYbParams(obj) {
 		// 个人支付:psnAcctPay
 		// 现金支付:ownPayAmt
 
+		console.log("list ===>", list);
 		list.map((i, index) => {
 			if (i.includes("feeSumamt")) {
+				console.log("feeSumamt ==>", 1111);
 				let innerList = i.split(",");
+				console.log("innerList", innerList);
 				let value = "";
 				if (innerList[0].includes("feeSumamt")) {
+					console.log("innerList[1]", innerList[1]);
 					value = innerList[1];
 				} else {
+					console.log("list[index + 1]", list[index + 1]);
 					value = list[index + 1].split(",")[0];
 				}
-				params.feeSumamt = value
-					.replaceAll('"', "")
-					.replaceAll("}", "")
-					.replaceAll("{", "")
-					.replaceAll("\\", "");
+				console.log("value ===>", value, typeof value);
+				value = value.replace(/\\/g, "");
+				value = value.replace(/\'/g, "");
+				value = value.replace(/\"/g, "");
+				value = value.replace(/\}/g, "");
+				value = value.replace(/\{/g, "");
+				console.log("newValue", value);
+				params.feeSumamt = value;
+				console.log("params.feeSumamt", params.feeSumamt);
 			}
 
 			if (i.includes("fundPay")) {
+				console.log("fundPay ==>", 1111);
+
 				let innerList = i.split(",");
 				let value = "";
 				if (innerList[0].includes("fundPay")) {
@@ -45,14 +56,18 @@ function getYbParams(obj) {
 				} else {
 					value = list[index + 1].split(",")[0];
 				}
-				params.fundPay = value
-					.replaceAll('"', "")
-					.replaceAll("}", "")
-					.replaceAll("{", "")
-					.replaceAll("\\", "");
+				value = value.replace(/\\/g, "");
+				value = value.replace(/\'/g, "");
+				value = value.replace(/\"/g, "");
+				value = value.replace(/\}/g, "");
+				value = value.replace(/\{/g, "");
+				params.fundPay = value;
+				console.log("params.fundPay", params.fundPay);
 			}
 
 			if (i.includes("ownPayAmt")) {
+				console.log("ownPayAmt ==>", 1111);
+
 				let innerList = i.split(",");
 				let value = "";
 				if (innerList[0].includes("ownPayAmt")) {
@@ -60,14 +75,18 @@ function getYbParams(obj) {
 				} else {
 					value = list[index + 1].split(",")[0];
 				}
-				params.ownPayAmt = value
-					.replaceAll('"', "")
-					.replaceAll("}", "")
-					.replaceAll("{", "")
-					.replaceAll("\\", "");
+				value = value.replace(/\\/g, "");
+				value = value.replace(/\'/g, "");
+				value = value.replace(/\"/g, "");
+				value = value.replace(/\}/g, "");
+				value = value.replace(/\{/g, "");
+				params.ownPayAmt = value;
+				console.log("params.ownPayAmt", params.ownPayAmt);
 			}
 
 			if (i.includes("psnAcctPay")) {
+				console.log("psnAcctPay ==>", 1111);
+
 				let innerList = i.split(",");
 				let value = "";
 				if (innerList[0].includes("psnAcctPay")) {
@@ -75,13 +94,16 @@ function getYbParams(obj) {
 				} else {
 					value = list[index + 1].split(",")[0];
 				}
-				params.psnAcctPay = value
-					.replaceAll('"', "")
-					.replaceAll("}", "")
-					.replaceAll("{", "")
-					.replaceAll("\\", "");
+				value = value.replace(/\\/g, "");
+				value = value.replace(/\'/g, "");
+				value = value.replace(/\"/g, "");
+				value = value.replace(/\}/g, "");
+				value = value.replace(/\{/g, "");
+				params.psnAcctPay = value;
+				console.log("params.psnAcctPay", params.psnAcctPay);
 			}
 		});
+		console.log("resolve ==>", params);
 		resolve(params);
 	});
 }