123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214 |
- import { getYbParams } from "./service";
- 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: {
- authCode: undefined,
- canPay: true,
- prescriptionList: [
- ],
- actionsheetVisible: false,
- isUserPersonalAccount: true,
- isCulculate: false
- },
- didMount() {
- this.getPayDetail(this.$page.data.query);
- },
- methods: {
- saveSubscribe(ref) {
- this.subscribe = ref;
- },
- 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 || [];
- },
- 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)
- })
- },
- 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: () => {
- // 根据自己的业务场景来进行错误处理
- },
- });
- }
- },
- });
- },
- // 查看更多
- 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 { medicareBinded = false } = e.target.dataset;
- const { order: oreder } = this.data;
- let result = false;
- try {
- my.showLoading();
- if (oreder.type === 1) {
- result = await tradePay(
- {
- type: oreder.type,
- idNum: oreder.outTradeNo,
- depName: oreder.depName,
- },
- {
- tradeType: "Appointment",
- }
- );
- } else if (oreder.type === 2) {
- // 充值
- result = await tradePay(
- {
- type: oreder.type,
- idNum: oreder.outTradeNo,
- amount: oreder.amount,
- },
- {
- tradeType: "Appointment",
- }
- );
- } else {
- // 门诊订单
- 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,
- hisPatientId,
- age,
- sex,
- orderId,
- hisOrderNo,
- amount,
- deptName,
- doctorName,
- doctorCode,
- total,
- hisClinicCode,
- name,
- prescribeDate,
- },
- {
- tradeType: "Outpatient",
- }
- );
- }
- } catch (error) {
- console.log("error ===>", error);
- } finally {
- my.hideLoading();
- }
- if (result) {
- // 支付成功后返回列表页
- my.navigateBack();
- }
- },
- },
- });
|