|
@@ -1,214 +1,298 @@
|
|
|
-import { getYbParams } from "./service";
|
|
|
+import qs from "qs";
|
|
|
+import { getYbParams, generateRandomFourDigitNumber } from "./service";
|
|
|
import { tradePay } from "../../utils/tradePay";
|
|
|
-import { prePayConfirm } from "../../../../core/utils/ywtService";
|
|
|
+import {
|
|
|
+ prePayConfirm,
|
|
|
+ getPayAuthInfo,
|
|
|
+} from "../../../../core/utils/ywtService";
|
|
|
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: {
|
|
|
- authCode: undefined,
|
|
|
- canPay: true,
|
|
|
- prescriptionList: [
|
|
|
-
|
|
|
- ],
|
|
|
- actionsheetVisible: false,
|
|
|
- isUserPersonalAccount: true,
|
|
|
- isCulculate: false
|
|
|
- },
|
|
|
-
|
|
|
- didMount() {
|
|
|
- this.getPayDetail(this.$page.data.query);
|
|
|
- this.handlePrePayConfirm()
|
|
|
- },
|
|
|
-
|
|
|
- methods: {
|
|
|
- saveSubscribe(ref) {
|
|
|
- this.subscribe = ref;
|
|
|
- },
|
|
|
+import { createSubscribe } from "applet-page-component";
|
|
|
|
|
|
- async handlePrePayConfirm() {
|
|
|
- my.showLoading({ mask: true });
|
|
|
- try {
|
|
|
- const { hisOrderNo: hisOrdNum, hisPatientId: patientId, hisClinicCode: clinicCode, authCode, total: orderSum, orderInsType } = this.$page.data.query
|
|
|
- const [err, result] = await prePayConfirm({
|
|
|
- patientId,
|
|
|
- clinicCode,
|
|
|
- hisOrdNum,
|
|
|
- orderSum,
|
|
|
- payInsType: '2',
|
|
|
- orderInsType,
|
|
|
- authCode,
|
|
|
- })
|
|
|
- if (!err) {
|
|
|
- // 预结算成功
|
|
|
- this.setData({
|
|
|
- });
|
|
|
- } else {
|
|
|
- throw `${err}`
|
|
|
- }
|
|
|
- } catch (error) {
|
|
|
- console.log('error ===>', error)
|
|
|
- } finally {
|
|
|
- my.hideLoading()
|
|
|
- }
|
|
|
+Component(
|
|
|
+ createSubscribe({
|
|
|
+ onShow() {
|
|
|
+ this.init('onShow')
|
|
|
+ },
|
|
|
+ })({
|
|
|
+ props: {},
|
|
|
+ data: {
|
|
|
+ authCode: undefined,
|
|
|
+ canPay: false,
|
|
|
+ prescriptionList: [],
|
|
|
+ actionsheetVisible: false,
|
|
|
+ isUserPersonalAccount: true,
|
|
|
+ isCulculate: false,
|
|
|
+ preConfirmInfo: {}
|
|
|
},
|
|
|
|
|
|
- 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 || [];
|
|
|
+ didMount() {
|
|
|
+ this.init('didMount')
|
|
|
},
|
|
|
|
|
|
- handleIsUserPersonalAccount(e) {
|
|
|
- my.showLoading();
|
|
|
- const _this = this
|
|
|
- const { valuex } = e.currentTarget.dataset;
|
|
|
- this.setData({
|
|
|
- isUserPersonalAccount: valuex,
|
|
|
- isCulculate: true
|
|
|
- }, () => {
|
|
|
- setTimeout(() => {
|
|
|
- my.hideLoading()
|
|
|
- _this.setData({
|
|
|
- isCulculate: false
|
|
|
- })
|
|
|
- }, 3000)
|
|
|
- })
|
|
|
+ didUnmount() {
|
|
|
+
|
|
|
},
|
|
|
|
|
|
- getPayDetail(query) {
|
|
|
- console.log("query ==>", query);
|
|
|
- let infoList = [];
|
|
|
- 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: this.parseDetailItems(query.orderItems),
|
|
|
- },
|
|
|
- ];
|
|
|
- this.setData({ prescriptionList: infoList });
|
|
|
- }
|
|
|
- return;
|
|
|
- my.getAuthCode({
|
|
|
- scopes: ["nhsamp", "auth_user"], // 主动授权:auth_user,静默授权:auth_base。或者其它scopes
|
|
|
- success: (res) => {
|
|
|
- if (res.authCode) {
|
|
|
- // 认证成功
|
|
|
- // 调用自己的服务端接口,让服务端进行后端的授权认证,并且利用session,需要解决跨域问题
|
|
|
- my.request({
|
|
|
- url: "https://isv.com/auth", // 该url是您自己的服务地址,实现的功能是服务端拿到authcode去开放平台进行token验证
|
|
|
- data: {
|
|
|
- authcode: res.authCode,
|
|
|
- },
|
|
|
- success: () => {
|
|
|
- // 授权成功并且服务器端登录成功
|
|
|
- },
|
|
|
- fail: () => {
|
|
|
- // 根据自己的业务场景来进行错误处理
|
|
|
- },
|
|
|
+ methods: {
|
|
|
+
|
|
|
+ init(type) {
|
|
|
+ this.getPayDetail(this.$page.data.query);
|
|
|
+ this.hanldeGetPayAuthInfo(type);
|
|
|
+ },
|
|
|
+
|
|
|
+ saveSubscribe(ref) {
|
|
|
+ this.subscribe = ref;
|
|
|
+ },
|
|
|
+
|
|
|
+ async hanldeGetPayAuthInfo(type) {
|
|
|
+ const app = getApp();
|
|
|
+ const {
|
|
|
+ hisOrderNo: hisOrdNum,
|
|
|
+ authCode,
|
|
|
+ reqBizNo,
|
|
|
+ } = this.$page.data.query;
|
|
|
+ const _this = this
|
|
|
+ const ramdonNum = generateRandomFourDigitNumber();
|
|
|
+ const queryReqBizNo = reqBizNo || `${hisOrdNum}-${userId}-${ramdonNum}`;
|
|
|
+ const query = Object.assign(this.$page.data.query, { reqBizNo: queryReqBizNo })
|
|
|
+ const qsResult = `?${qs.stringify(query)}`;
|
|
|
+ const callUrl = encodeURIComponent(
|
|
|
+ `antbuilder/industry/hospitalV2/pages/page-no-pull/index${qsResult}`
|
|
|
+ );
|
|
|
+ const userId = app.globalData.ywtUserId || "";
|
|
|
+ if (type === 'onShow') {
|
|
|
+ my.getAuthCode({
|
|
|
+ scopes: ["nhsamp", "auth_user"], // 主动授权:auth_user,静默授权:auth_base。或者其它scopes
|
|
|
+ success: (res) => {
|
|
|
+ if (res.authCode) {
|
|
|
+ _this.requestGetPayAuthInfo(res.authCode, callUrl, queryReqBizNo)
|
|
|
+ }
|
|
|
+ },
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ this.requestGetPayAuthInfo(authCode, callUrl, queryReqBizNo)
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ async requestGetPayAuthInfo(authCode, callUrl, reqBizNo) {
|
|
|
+ const _this = this
|
|
|
+ const [err, result] = await getPayAuthInfo({
|
|
|
+ authCode,
|
|
|
+ callUrl,
|
|
|
+ reqBizNo,
|
|
|
+ });
|
|
|
+ if (!err) {
|
|
|
+ console.log("result ==>", result);
|
|
|
+ const { payAuthNo, authNo, medicalCardInstId, medicalCardId } =
|
|
|
+ result;
|
|
|
+ if (result.authNo) {
|
|
|
+ this.setData({
|
|
|
+ payAuthNo,
|
|
|
+ authNo,
|
|
|
+ medicalCardInstId,
|
|
|
+ medicalCardId,
|
|
|
+ isCulculate: true
|
|
|
+ }, () => {
|
|
|
+ _this.handlePrePayConfirm()
|
|
|
});
|
|
|
+ return
|
|
|
}
|
|
|
- },
|
|
|
- });
|
|
|
- },
|
|
|
+ if (result.authUrl) {
|
|
|
+ my.ap.openURL({ url: result.authUrl });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
|
|
|
- // 查看更多
|
|
|
- openForm() {
|
|
|
- this.setData({
|
|
|
- expand: !this.data.expand,
|
|
|
- });
|
|
|
- },
|
|
|
+ async handlePrePayConfirm() {
|
|
|
+ my.showLoading({ mask: true });
|
|
|
+ try {
|
|
|
+ const {
|
|
|
+ hisOrderNo: hisOrdNum,
|
|
|
+ hisPatientId: patientId,
|
|
|
+ hisClinicCode: clinicCode,
|
|
|
+ total: orderSum,
|
|
|
+ orderInsType,
|
|
|
+ } = this.$page.data.query;
|
|
|
+ const { payAuthNo, authNo, medicalCardInstId, medicalCardId } =
|
|
|
+ this.data;
|
|
|
|
|
|
- medicareExpand() {
|
|
|
- this.setData({
|
|
|
- medicareExpand: !this.data.medicareExpand,
|
|
|
- });
|
|
|
- },
|
|
|
+ const [err, result] = await prePayConfirm({
|
|
|
+ patientId,
|
|
|
+ clinicCode,
|
|
|
+ hisOrdNum,
|
|
|
+ orderSum,
|
|
|
+ payInsType: "2",
|
|
|
+ orderInsType,
|
|
|
+ payAuthNo,
|
|
|
+ authNo,
|
|
|
+ medicalCardInstId,
|
|
|
+ medicalCardId,
|
|
|
+ });
|
|
|
+ if (!err) {
|
|
|
+ // 预结算成功
|
|
|
+ const ybData = getYbParams(result);
|
|
|
+ this.setData({
|
|
|
+ preConfirmInfo: Object.assign(result, ybData),
|
|
|
+ isCulculate: false,
|
|
|
+ canPay: true
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ throw `${err}`;
|
|
|
+ }
|
|
|
+ } catch (error) {
|
|
|
+ console.log("error ===>", error);
|
|
|
+ } finally {
|
|
|
+ my.hideLoading();
|
|
|
+ }
|
|
|
+ },
|
|
|
|
|
|
- handleActionsheet() {
|
|
|
- this.setData({
|
|
|
- actionsheetVisible: !this.data.actionsheetVisible,
|
|
|
- });
|
|
|
- },
|
|
|
+ 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 onPay(e) {
|
|
|
- const { medicareBinded = false } = e.target.dataset;
|
|
|
- const { order: oreder } = this.data;
|
|
|
- let result = false;
|
|
|
- try {
|
|
|
+ handleIsUserPersonalAccount(e) {
|
|
|
my.showLoading();
|
|
|
+ const _this = this;
|
|
|
+ const { valuex } = e.currentTarget.dataset;
|
|
|
+ this.setData(
|
|
|
+ {
|
|
|
+ isUserPersonalAccount: valuex,
|
|
|
+ isCulculate: true,
|
|
|
+ },
|
|
|
+ () => {
|
|
|
+ setTimeout(() => {
|
|
|
+ my.hideLoading();
|
|
|
+ _this.setData({
|
|
|
+ isCulculate: false,
|
|
|
+ });
|
|
|
+ }, 3000);
|
|
|
+ }
|
|
|
+ );
|
|
|
+ },
|
|
|
|
|
|
- if (oreder.type === 1) {
|
|
|
- result = await tradePay(
|
|
|
+ getPayDetail(query) {
|
|
|
+ let infoList = [];
|
|
|
+ if (query) {
|
|
|
+ infoList = [
|
|
|
{
|
|
|
- type: oreder.type,
|
|
|
- idNum: oreder.outTradeNo,
|
|
|
- depName: oreder.depName,
|
|
|
+ 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,
|
|
|
+ },
|
|
|
+ ],
|
|
|
},
|
|
|
{
|
|
|
- tradeType: "Appointment",
|
|
|
- }
|
|
|
- );
|
|
|
- } else if (oreder.type === 2) {
|
|
|
- // 充值
|
|
|
- result = await tradePay(
|
|
|
- {
|
|
|
- type: oreder.type,
|
|
|
- idNum: oreder.outTradeNo,
|
|
|
- amount: oreder.amount,
|
|
|
+ title: "费用信息",
|
|
|
+ list: this.parseDetailItems(query.orderItems),
|
|
|
},
|
|
|
- {
|
|
|
- tradeType: "Appointment",
|
|
|
- }
|
|
|
- );
|
|
|
- } else {
|
|
|
+ ];
|
|
|
+ this.setData({ prescriptionList: infoList });
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ // 查看更多
|
|
|
+ openForm() {
|
|
|
+ this.setData({
|
|
|
+ expand: !this.data.expand,
|
|
|
+ });
|
|
|
+ },
|
|
|
+
|
|
|
+ medicareExpand() {
|
|
|
+ this.setData({
|
|
|
+ medicareExpand: !this.data.medicareExpand,
|
|
|
+ });
|
|
|
+ },
|
|
|
+
|
|
|
+ handleActionsheet() {
|
|
|
+ this.setData({
|
|
|
+ actionsheetVisible: !this.data.actionsheetVisible,
|
|
|
+ });
|
|
|
+ },
|
|
|
+
|
|
|
+ // 发起支付
|
|
|
+ async onPay(e) {
|
|
|
+ const { canPay } = this.data
|
|
|
+ if (!canPay) return
|
|
|
+ const {
|
|
|
+ hisPatientId,
|
|
|
+ age,
|
|
|
+ sex,
|
|
|
+ orderId,
|
|
|
+ hisOrderNo,
|
|
|
+ amount,
|
|
|
+ deptName,
|
|
|
+ doctorName,
|
|
|
+ doctorCode,
|
|
|
+ hisClinicCode,
|
|
|
+ total,
|
|
|
+ name,
|
|
|
+ orderInsType,
|
|
|
+ prescribeDate,
|
|
|
+ payInsType = '2',
|
|
|
+ consumeType = '0',
|
|
|
+ medInsFee,
|
|
|
+ selfFee,
|
|
|
+ payName,
|
|
|
+ patName,
|
|
|
+ outTradeNo
|
|
|
+ } = this.$page.data.query;
|
|
|
+ const { preConfirmInfo: { invoiceNo, insuAdmDr, insUploadFeeResp } } = this.data
|
|
|
+ console.log('this.$page.data.query ==>', this.$page.data.query)
|
|
|
+ let result = false;
|
|
|
+ console.log('requset data ==>', {
|
|
|
+ useBalance: false,
|
|
|
+ useMedicare: true,
|
|
|
+ outTradeNo,
|
|
|
+ hisPatientId,
|
|
|
+ age,
|
|
|
+ sex,
|
|
|
+ orderId,
|
|
|
+ hisOrderNo,
|
|
|
+ amount,
|
|
|
+ deptName,
|
|
|
+ doctorName,
|
|
|
+ doctorCode,
|
|
|
+ total,
|
|
|
+ hisClinicCode,
|
|
|
+ name,
|
|
|
+ prescribeDate,
|
|
|
+ orderInsType,
|
|
|
+ payInsType,
|
|
|
+ consumeType,
|
|
|
+ totalFee: total,
|
|
|
+ medInsFee,
|
|
|
+ selfFee,
|
|
|
+ payName,
|
|
|
+ patName,
|
|
|
+ invoiceNo,
|
|
|
+ insuAdmDr,
|
|
|
+ insUploadFeeResp
|
|
|
+ },)
|
|
|
+ try {
|
|
|
+ my.showLoading();
|
|
|
// 门诊订单
|
|
|
- const {
|
|
|
- hisPatientId,
|
|
|
- age,
|
|
|
- sex,
|
|
|
- orderId,
|
|
|
- hisOrderNo,
|
|
|
- amount,
|
|
|
- deptName,
|
|
|
- doctorName,
|
|
|
- doctorCode,
|
|
|
- total,
|
|
|
- hisClinicCode,
|
|
|
- name,
|
|
|
- prescribeDate,
|
|
|
- } = oreder;
|
|
|
result = await tradePay(
|
|
|
{
|
|
|
- useBalance: !medicareBinded,
|
|
|
- useMedicare: medicareBinded,
|
|
|
- outTradeNo: oreder.outTradeNo,
|
|
|
+ useBalance: false,
|
|
|
+ useMedicare: true,
|
|
|
+ outTradeNo,
|
|
|
hisPatientId,
|
|
|
age,
|
|
|
sex,
|
|
@@ -222,22 +306,33 @@ Component({
|
|
|
hisClinicCode,
|
|
|
name,
|
|
|
prescribeDate,
|
|
|
+ orderInsType,
|
|
|
+ payInsType,
|
|
|
+ consumeType,
|
|
|
+ totalFee: total,
|
|
|
+ medInsFee,
|
|
|
+ selfFee,
|
|
|
+ payName,
|
|
|
+ patName,
|
|
|
+ invoiceNo,
|
|
|
+ insuAdmDr,
|
|
|
+ insUploadFeeResp
|
|
|
},
|
|
|
{
|
|
|
tradeType: "Outpatient",
|
|
|
}
|
|
|
);
|
|
|
+ } catch (error) {
|
|
|
+ console.log("error ===>", error);
|
|
|
+ } finally {
|
|
|
+ my.hideLoading();
|
|
|
+ }
|
|
|
+
|
|
|
+ if (result) {
|
|
|
+ // 支付成功后返回列表页
|
|
|
+ my.navigateBack();
|
|
|
}
|
|
|
- } catch (error) {
|
|
|
- console.log("error ===>", error);
|
|
|
- } finally {
|
|
|
- my.hideLoading();
|
|
|
- }
|
|
|
-
|
|
|
- if (result) {
|
|
|
- // 支付成功后返回列表页
|
|
|
- my.navigateBack();
|
|
|
- }
|
|
|
+ },
|
|
|
},
|
|
|
- },
|
|
|
-});
|
|
|
+ })
|
|
|
+);
|