1. 医生线下接诊创建就诊人、患者端扫码认领就诊人
2. 生成处方后医生代付码
This commit is contained in:
李琦
2026-08-09 14:36:22 +08:00
parent 53c6f3fcfd
commit 206f0aaa50
12 changed files with 558 additions and 119 deletions

View File

@@ -0,0 +1,147 @@
<template>
<!-- 居中模态框确认认领(非底部抽屉) -->
<u-modal
v-model="show"
title="认领就诊人"
:content="modalContent"
:show-cancel-button="true"
confirm-text="确认认领"
cancel-text="取消"
confirm-color="#0d9488"
:mask-close-able="false"
@confirm="onConfirm"
@cancel="onClose"
></u-modal>
</template>
<script>
import { claimPatientApi } from '@/request/api/patient.js'
import { unwrapXkApi } from '@/utils/api-response.js'
import { registePay } from '@/request/api/api.js'
/**
* 扫码认领医生创建的就诊人(居中 u-modal)
* App.vue 写入 claim_user_patient_id 后弹出
*/
export default {
name: 'ClaimPatientModal',
data() {
return {
show: false,
userPatientId: 0,
needPay: false,
price: '0',
registerId: 0,
claiming: false,
}
},
computed: {
modalContent() {
const id = this.userPatientId || '—'
let text = '医生为您创建了就诊人档案(就诊人ID:' + id + '),确认后绑定到当前微信账号。'
if (this.needPay) {
text += '需支付挂号费:¥' + this.price + '。'
}
return text
},
},
methods: {
/**
* 对外打开:读取 storage 中的认领 ID
*/
openFromStorage() {
const id = Number(uni.getStorageSync('claim_user_patient_id') || 0)
if (id < 1) return
const token = uni.getStorageSync('token')
if (!token) return
this.userPatientId = id
this.needPay = false
this.price = '0'
this.registerId = 0
this.show = true
},
/**
* 取消认领:关闭并清理扫码标记
*/
onClose() {
this.show = false
uni.removeStorageSync('claim_user_patient_id')
},
/**
* 确认认领;若有未付挂号费则拉起支付
*/
async onConfirm() {
if (this.claiming || this.userPatientId < 1) return
this.claiming = true
try {
const res = await claimPatientApi({ user_patient_id: this.userPatientId })
const { ok, payload, message } = unwrapXkApi(res)
if (!ok) {
uni.showToast({ title: message || '认领失败', icon: 'none' })
// 失败重新打开,允许重试
this.show = true
return
}
const needPay = Number(payload && payload.need_pay_register) === 1
const registerId = Number(payload && payload.register_id) || 0
const price = (payload && payload.price) || '0'
uni.removeStorageSync('claim_user_patient_id')
if (needPay && registerId > 0) {
this.needPay = true
this.registerId = registerId
this.price = String(price)
this.show = false
await this.payRegister(registerId)
} else {
uni.showToast({ title: '认领成功', icon: 'success' })
this.show = false
}
} catch (e) {
uni.showToast({ title: (e && e.message) || '认领失败', icon: 'none' })
this.show = true
} finally {
this.claiming = false
}
},
/**
* 认领后支付挂号费(xk-api register/pay)
*/
async payRegister(registerId) {
try {
const res = await registePay({
method: 'post',
data: { register_id: registerId },
})
if (res.data && (res.data.errcode == 0 || res.data.errcode === '0')) {
const data = res.data.data || {}
if (data.is_paid == 1 || data.is_pay == 1) {
uni.showToast({ title: '认领成功', icon: 'success' })
return
}
uni.requestPayment({
provider: data.appId,
timeStamp: data.timestamp || data.timeStamp,
nonceStr: data.nonceStr,
package: data.package,
signType: data.signType,
paySign: data.paySign,
success: () => {
uni.showToast({ title: '支付成功', icon: 'success' })
},
fail: () => {
uni.showToast({ title: '已认领,挂号费未支付', icon: 'none' })
},
})
} else {
uni.showToast({
title: (res.data && (res.data.message || res.data.msg)) || '获取支付参数失败',
icon: 'none',
})
}
} catch (e) {
uni.showToast({ title: '支付发起失败', icon: 'none' })
}
},
},
}
</script>

View File

@@ -0,0 +1,83 @@
<template>
<!-- 居中模态框确认代付(非底部抽屉) -->
<u-modal
v-model="show"
title="医生代付确认"
:content="modalContent"
:show-cancel-button="true"
confirm-text="确认代付"
cancel-text="取消代付"
confirm-color="#0d9488"
:mask-close-able="false"
@confirm="onConfirm"
@cancel="onCancel"
></u-modal>
</template>
<script>
/**
* 扫码代付前确认模态框
* App.vue 写入 proxy_pay_order_id 后弹出;取消则清理 storage
*/
export default {
name: 'ProxyPayConfirmModal',
data() {
return {
show: false,
orderId: 0,
}
},
computed: {
modalContent() {
const id = this.orderId || '—'
return '医生邀请您代为支付药品订单(订单ID:' + id + ')。确认后进入支付页;取消则清除本次扫码,下次进入小程序不会再跳转。'
},
},
methods: {
/**
* 清理本次代付扫码会话(storage)
*/
clearProxyPaySession() {
uni.removeStorageSync('proxy_pay_order_id')
uni.removeStorageSync('proxy_pay_confirmed')
},
/**
* 对外打开:读取 storage 中的代付订单 ID
*/
openFromStorage() {
const id = Number(uni.getStorageSync('proxy_pay_order_id') || 0)
if (id < 1) return
// 已确认过并进过支付页:不再弹窗(避免首页 onShow 反复打断)
if (Number(uni.getStorageSync('proxy_pay_confirmed') || 0) === 1) return
const token = uni.getStorageSync('token')
if (!token) return
this.orderId = id
this.show = true
},
/**
* 取消代付:清理扫码标记,下次进小程序不再跳转
*/
onCancel() {
this.clearProxyPaySession()
this.show = false
uni.showToast({ title: '已取消代付', icon: 'none' })
},
/**
* 确认后进入订单支付页(保留 proxy_pay_order_id 供支付接口使用)
*/
onConfirm() {
const orderId = this.orderId || Number(uni.getStorageSync('proxy_pay_order_id') || 0)
if (orderId < 1) {
this.clearProxyPaySession()
this.show = false
return
}
uni.setStorageSync('proxy_pay_confirmed', 1)
this.show = false
uni.navigateTo({
url: '/subPackages/my/record-pay?order_id=' + orderId + '&proxy_pay=1',
})
},
},
}
</script>