blob: 52266e6bd4bf62990649d402879bb8ae34e62f45 [file] [log] [blame]
<template>
<view class="pay">
<u-cell-group>
<u-cell-item :title="msg.mergingName" :title-style="tstyle" :arrow="false">
<u-image slot="icon" src="./images/cush.png" width="60" height="60" mode="aspectFit"></u-image>
</u-cell-item>
<u-cell-item title="缴费金额" :arrow="false" :value="msg.mergingSubtotal+'元'" :value-style="vstyle"></u-cell-item>
</u-cell-group>
<u-cell-group>
<u-cell-item title="医院名称" :arrow="false" :value="msg.hospitalName"></u-cell-item>
<u-cell-item title="订单号" :arrow="false" :value="msg.billNo"></u-cell-item>
<u-cell-item title="就诊日期" :arrow="false" :value="msg.date"></u-cell-item>
<!-- <u-cell-item title="截止日期" :arrow="false" value="2020/10/28 23:29:29"></u-cell-item> -->
<u-cell-item title="交易状态" :arrow="false" :value="msg.status_ok" :value-style="msg.status=='wip'|| msg.status==undefined?status_style:vstyle"></u-cell-item>
<u-cell-item title="退款状态" :arrow="false" :value="msg.refundflag_ok" :value-style="msg.refundflag=='refund'?status_style:vstyle"
v-if="msg.refundflag == 'wip' || msg.refundflag == 'refund'"></u-cell-item>
</u-cell-group>
<u-button @click="msg.status=='wip'?query():payInit()" :custom-style="payBtn" v-if="kind =='unpay'">{{msg.status=='wip'?'查询订单状态':'立即支付'}}</u-button>
<u-button @click="notify_hosiptal" :custom-style="payBtn" v-if="kind =='payed'&& msg.notifyStatus == false">通知医院</u-button>
<u-button @click="refund" :custom-style="payBtn" v-if="kind =='payed'">申请退款</u-button>
<!-- 支付密码弹框 -->
<!-- <uni-popup ref="showPassword" class="pwd-wrapper">
<view class="uni-tip uni-pwd">
<text class="uni-tip-title">请输入支付密码</text>
<view class="pwd-text-wrap">
<password-input @tap="openKeyBoard('number')" :length="length" :gutter="0" :list="numberList"></password-input>
</view>
</view>
</uni-popup>
<keyboard-package ref="number" @onInput="onInput" @onDelete="onDelete" @onConfirm="onConfirm" :disableDot="true" /> -->
</view>
</template>
<script>
// import keyboardPackage from "./components/keyboard-package/keyboard-package.vue"
// import passwordInput from "./components/password-input/password-input.vue"
// import uniPopup from './components/uni-popup/uni-popup.vue'
// #ifdef APP-PLUS
const Ynrcc = uni.requireNativePlugin('ynrcc-pay')
// console.log(Ynrcc)
// #endif
export default {
// components: {
// uniPopup,
// keyboardPackage,
// passwordInput
// },
data() {
return {
// numberList: [],
// length: 6,
// type: 'number',
tstyle: {
marginLeft: '10rpx',
fontWeight: 'bold'
},
vstyle: {
color: '#FF6F6F',
fontSize: '30rpx'
},
status_style: {
color: '#18B566',
fontSize: '30rpx'
},
payBtn: {
backgroundColor: ' #2FA8E1',
padding: '50rpx 0',
color: '#FFFFFF',
width: ' 600rpx',
fontSize: '30rpx',
border: '1px solid #2FA8E1',
marginTop: '50rpx'
},
msg: {},
kind: ''
}
},
methods: {
// // 呼起键盘
// openKeyBoard(key) {
// this.type = key;
// this.$refs[key].open();
// },
// // 输入密码
// onInput(val) {
// this.numberList.push(val)
// if (this.numberList.length == this.length) {
// this.$refs.showPassword.close()
// this.$refs[this.type].close()
// this.payInit()
// }
// },
// //完成输入点击完成
// onConfirm() {
// let length = this.numberList.length
// if (length == this.length) {
// this.$refs.showPassword.close()
// this.$refs[this.type].close()
// } else {
// this.numberList = []
// uni.showToast({
// title: '密码错误',
// icon: 'none'
// })
// }
// },
// //删除密码
// onDelete(val) {
// this.numberList.pop(val)
// },
// //打开密码输入框
// open() {
// this.numberList = []
// this.$refs.showPassword.open()
// this.openKeyBoard('number')
// },
payInit() {
let that = this
// let pwd = ''
let billno = that.msg.billNo
// that.numberList.forEach(item => {
// pwd += item + ''
// })
let param = {
// paypwd: pwd,
billno
}
that.$u.post('/medicalapi/quickpay/payinit', param).then(res => {
let code = res.code
console.log(res)
if(code == 501){
uni.showModal({
title:'提示',
content:'您还未与银行进行签约,暂时无法支付',
confirmText:'去签约',
success(res) {
if(res.confirm){
that.getCardsiInfor()
}
}
})
}else{
let plain_payInit = res.data.plain
let signature_payInit = res.data.signature
let billno = res.data.billno
that.pay(billno,plain_payInit,signature_payInit)
}
})
},
pay(billno,plain,signature) {
let that = this
let params = {
plain,
signature
}
console.log(params)
Ynrcc.pay(params, res => {
console.log(res)
let plain_payConfirm = res.plain
let signature_payConfirm = res.signature
if(!plain_payConfirm && !signature_payConfirm){
let obj = res ,code,msg
for(let key in obj){
code = key
msg = obj[key]
}
uni.showModal({
title:'提示',
content:code + ':' +msg,
showCancel:false
})
return
}
that.pay_confirm(billno,plain_payConfirm,signature_payConfirm)
})
},
pay_confirm(billno,plain,signature){
let that = this
let params = {
billno,
plain,
signature
}
that.$u.post('/medicalapi/quickpay/confirm',params).then(res=>{
let status = res.status
let obj = that.msg
let date = res.transdate.substr(0, 4) +
"-" + res.transdate.substr(4, 2) + "-" + res.transdate.substr(6, 2) + " " + res.transtime.substr(0, 2) + ":" +
res.transtime.substr(2, 2) + ":" + res.transtime.substr(4, 2)
setTimeout(() => {
uni.navigateTo({
url: `/pages/sub_medical/payResult?status=${status}&msg=${JSON.stringify(obj)}&date=${date}`
})
}, 1500)
})
},
getCardsiInfor() {
let that = this
that.$u.post("/medicalapi/quickpay/signinfo").then((res) => {
console.log(res)
console.log(that.msg.hospitalcode)
let bankno = res.bankcardno
that.sign_init(bankno,that.msg.hospitalcode)
})
},
sign_init(bankcardno,hospitalcode){
let that = this
let params = {
hospitalcode,
bankcardno
}
that.$u.post('/medicalapi/quickpay/signinit',params).then(res=>{
console.log(res)
let authsign = res.data.authSign
let signature = res.data.signature
let user = res.data.signUserData
let plain = res.data.plain
let signno = res.data.signNo
if(!!!authsign){
that.sign(plain,signature,user,signno)
}else{
that.auth_sign(plain,signature,signno)
}
})
},
sign(plain,signature,user,signno) {
let that = this
let params = {
plain,
signature,
name: user.name,
id_type: user.idType,
id_no: user.idNo,
ac_no: user.acNo
}
Ynrcc.sign(params, res => {
let plain_sign = res.plain
let signature_sign = res.signature
if(!plain_sign && !signature_sign){
let obj = res ,code,msg
for(let key in obj){
code = key
msg = obj[key]
}
uni.showModal({
title:'提示',
content:code + ':' +msg,
showCancel:false
})
return
}
that.sign_confirm(plain_sign,signature_sign,signno)
})
},
auth_sign(plain,signature,signno) {
let that = this
let params = {
plain,
signature,
}
Ynrcc.authSign(params, res => {
console.log(res)
let plain_authSign = res.plain
let signature_authSign = res.signature
if(!plain_authSign && !signature_authSign){
let obj = res ,code,msg
for(let key in obj){
code = key
msg = obj[key]
}
uni.showModal({
title:'提示',
content:code + ':' +msg,
showCancel:false
})
return
}
that.sign_confirm(plain_authSign,signature_authSign,signno)
})
},
sign_confirm(plain,signature,signno){
let that = this
let params = {
signno,
plain,
signature
}
that.$u.post('/medicalapi/quickpay/signconfirm',params).then(res=>{
uni.showModal({
title:'提示',
content:'签约成功',
showCancel:false,
confirmText:'继续支付',
success(res){
if(res.confirm){
// that.open()
that.payInit()
}
}
})
})
},
query() {
let that = this
let billno = that.msg.billNo
that.$u.post('/medicalapi/pay/query/' + billno, {}).then(res => {
let status = res.status
if (status == 'wip') {
uni.showToast({
icon: 'none',
title: '订单正在支付中,请稍等...'
})
} else {
let status = res.status
let obj = that.msg
let date = res.transdate.substr(0, 4) +
"-" + res.transdate.substr(4, 2) + "-" + res.transdate.substr(6, 2) + " " + res.transtime.substr(0, 2) + ":" +
res.transtime.substr(2, 2) + ":" + res.transtime.substr(4, 2)
setTimeout(() => {
uni.navigateTo({
url: `/pages/sub_medical/payResult?status=${status}&msg=${JSON.stringify(obj)}&date=${date}`
})
}, 1500)
}
})
},
notify_hosiptal() {
let that = this
let billno = that.msg.billno
that.$u.post('/medicalapi/pay/notify/' + billno).then(res => {
uni.showToast({
title: res.msg,
icon: 'none',
duration:800,
success(ret) {
setTimeout(() => {
uni.navigateBack({
delta: 1
})
}, 1500)
}
})
})
},
refund(){
let that = this
let billno = that.msg.billno
let param = {
billno
}
that.$u.post('/medicalapi/medical/quickpay/refund/test',param).then(res=>{
uni.showModal({
title:'提示',
content:'退款成功',
showCancel:false,
})
})
},
},
onLoad(options) {
let msg = JSON.parse(options.msg)
//console.log(msg)
let id = options.id
this.kind = id
if (id == 'unpay') {
msg.date = msg.medicalDate.substr(0, 4) + '-' + msg.medicalDate.substr(4, 2) + '-' + msg.medicalDate.substr(6, 2) +
' ' + msg.medicalDate.substr(8, 2) + ':' + msg.medicalDate.substr(10, 2) + ':' + msg.medicalDate.substr(12, 2)
switch (msg.status) {
case 'init':
msg.status_ok = '未支付';
break
case 'wip':
msg.status_ok = '订单正在支付中...'
break
}
this.msg = msg
} else if (id == 'payed') {
msg.date = msg.medicaldate.substr(0, 4) + '-' + msg.medicaldate.substr(4, 2) + '-' + msg.medicaldate.substr(6, 2) +
' ' + msg.medicaldate.substr(8, 2) + ':' + msg.medicaldate.substr(10, 2) + ':' + msg.medicaldate.substr(12, 2)
msg.billNo = msg.billno
msg.mergingSubtotal = msg.mergingsubtotal
msg.mergingName = msg.mergingname
msg.status_ok = '已完成'
switch (msg.refundflag) {
case 'wip':
msg.refundflag_ok = '退款处理中...';
break
case 'refund':
msg.refundflag_ok = '已退款';
}
this.msg = msg
}
}
}
</script>
<style lang="scss" scoped>
.u-cell-box {
margin-bottom: 30rpx;
}
.pay {
font-family: "PingFang-SC-Medium";
}
.pwd-wrapper {
background: rgba(0, 0, 0, .4);
z-index: 1;
/deep/.uni-popup__wrapper.uni-custom.center {
.uni-popup__wrapper-box {
position: unset;
max-width: none;
max-height: none;
overflow-y: hidden;
background: none;
margin-top: -70rpx;
padding: 60rpx 30rpx 30rpx;
}
.pwd-text-wrap {
width: 100%;
padding: 50rpx 43rpx 60rpx;
box-sizing: border-box;
}
}
.uni-tip {
/* #ifndef APP-NVUE */
display: flex;
flex-direction: column;
/* #endif */
margin-top: -60rpx;
width: 570rpx;
background-color: #fff;
border-radius: 12rpx;
position: relative;
}
.uni-pwd {
width: 630rpx;
}
.uni-tip-icon-wrap {
text-align: center;
}
.uni-tip-content {
padding: 31rpx 40rpx 60rpx;
font-size: 30rpx;
color: #6F737A;
}
}
.uni-tip-title {
margin-top: 30rpx;
text-align: center;
font-weight: 500;
font-size: 34rpx;
color: $uni-text-color;
}
</style>