123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199 |
- // import { payDetail } 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: [
- {
- title: "就诊信息",
- list: [
- { label: "门诊类别", value: "门(急)诊" },
- { label: "门诊科室", value: "普通内科" },
- { label: "医生姓名", value: "张三" },
- { label: "处方时间", value: "2021/06/08 14:54:00" },
- { label: "费用总额", value: "368.50元", highlight: true },
- ],
- },
- {
- title: "诊断信息",
- list: [
- { label: "诊断名称", value: "外伤肿胀" },
- { label: "诊断编号", value: "E3D.25" },
- ],
- },
- {
- title: "费用信息",
- list: [
- { label: "万通胫骨贴*1", subLabel: "8g/片/3", value: "37.80元" },
- { label: "阿莫西林*1", subLabel: "8g/片/3", value: "7.80元" },
- ],
- },
- ],
- actionsheetVisible: false,
- },
- didMount() {
- this.payDetail(this.$page.data.query);
- },
- methods: {
- saveSubscribe(ref) {
- this.subscribe = ref;
- },
- payDetail(query) {
- console.log("query ==>", query);
- 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();
- // 获取授权
- await getSubscribeAuth();
- 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();
- }
- // 支付成功刷新页面
- this.payDetail(this.$page.data.query);
- if (result) {
- // 支付成功后返回列表页
- my.navigateBack();
- }
- },
- hrefTo() {
- my.ap.navigateToAlipayPage({
- path: "alipays://platformapi/startapp?appId=77700284&page=pages/medical/index?chInfo=YY_xiaochengxu",
- });
- },
- toH5(e) {
- const { url } = e.target.dataset;
- history.toH5(url);
- },
- },
- });
- function numFix(val) {
- const num = val * 1;
- return num.toFixed(2);
- }
|