blob: 52266e6bd4bf62990649d402879bb8ae34e62f45 [file] [log] [blame]
guangchao.xu070005a2020-12-07 09:56:40 +08001<template>
2 <view class="pay">
3 <u-cell-group>
guangchao.xu50e42382021-01-04 17:53:47 +08004 <u-cell-item :title="msg.mergingName" :title-style="tstyle" :arrow="false">
guangchao.xu070005a2020-12-07 09:56:40 +08005 <u-image slot="icon" src="./images/cush.png" width="60" height="60" mode="aspectFit"></u-image>
6 </u-cell-item>
guangchao.xu50e42382021-01-04 17:53:47 +08007 <u-cell-item title="缴费金额" :arrow="false" :value="msg.mergingSubtotal+'元'" :value-style="vstyle"></u-cell-item>
guangchao.xu070005a2020-12-07 09:56:40 +08008 </u-cell-group>
9 <u-cell-group>
guangchao.xu50e42382021-01-04 17:53:47 +080010 <u-cell-item title="医院名称" :arrow="false" :value="msg.hospitalName"></u-cell-item>
11 <u-cell-item title="订单号" :arrow="false" :value="msg.billNo"></u-cell-item>
12 <u-cell-item title="就诊日期" :arrow="false" :value="msg.date"></u-cell-item>
13 <!-- <u-cell-item title="截止日期" :arrow="false" value="2020/10/28 23:29:29"></u-cell-item> -->
guangchao.xuc43cf972021-01-18 13:37:55 +080014 <u-cell-item title="交易状态" :arrow="false" :value="msg.status_ok" :value-style="msg.status=='wip'|| msg.status==undefined?status_style:vstyle"></u-cell-item>
15 <u-cell-item title="退款状态" :arrow="false" :value="msg.refundflag_ok" :value-style="msg.refundflag=='refund'?status_style:vstyle"
16 v-if="msg.refundflag == 'wip' || msg.refundflag == 'refund'"></u-cell-item>
guangchao.xu070005a2020-12-07 09:56:40 +080017 </u-cell-group>
guangchao.xu6cdd45e2021-04-16 17:44:30 +080018 <u-button @click="msg.status=='wip'?query():payInit()" :custom-style="payBtn" v-if="kind =='unpay'">{{msg.status=='wip'?'查询订单状态':'立即支付'}}</u-button>
guangchao.xuc43cf972021-01-18 13:37:55 +080019 <u-button @click="notify_hosiptal" :custom-style="payBtn" v-if="kind =='payed'&& msg.notifyStatus == false">通知医院</u-button>
guangchao.xu6cdd45e2021-04-16 17:44:30 +080020 <u-button @click="refund" :custom-style="payBtn" v-if="kind =='payed'">申请退款</u-button>
guangchao.xu50e42382021-01-04 17:53:47 +080021 <!-- 支付密码弹框 -->
guangchao.xu6cdd45e2021-04-16 17:44:30 +080022 <!-- <uni-popup ref="showPassword" class="pwd-wrapper">
guangchao.xu50e42382021-01-04 17:53:47 +080023 <view class="uni-tip uni-pwd">
24 <text class="uni-tip-title">请输入支付密码</text>
25 <view class="pwd-text-wrap">
26 <password-input @tap="openKeyBoard('number')" :length="length" :gutter="0" :list="numberList"></password-input>
27 </view>
28 </view>
29 </uni-popup>
guangchao.xu6cdd45e2021-04-16 17:44:30 +080030 <keyboard-package ref="number" @onInput="onInput" @onDelete="onDelete" @onConfirm="onConfirm" :disableDot="true" /> -->
guangchao.xu070005a2020-12-07 09:56:40 +080031 </view>
32</template>
33
34<script>
guangchao.xu6cdd45e2021-04-16 17:44:30 +080035 // import keyboardPackage from "./components/keyboard-package/keyboard-package.vue"
36 // import passwordInput from "./components/password-input/password-input.vue"
37 // import uniPopup from './components/uni-popup/uni-popup.vue'
38 // #ifdef APP-PLUS
39 const Ynrcc = uni.requireNativePlugin('ynrcc-pay')
40 // console.log(Ynrcc)
41 // #endif
guangchao.xu50e42382021-01-04 17:53:47 +080042 export default {
guangchao.xu6cdd45e2021-04-16 17:44:30 +080043 // components: {
44 // uniPopup,
45 // keyboardPackage,
46 // passwordInput
47 // },
guangchao.xu50e42382021-01-04 17:53:47 +080048 data() {
49 return {
guangchao.xu6cdd45e2021-04-16 17:44:30 +080050 // numberList: [],
51 // length: 6,
52 // type: 'number',
guangchao.xu070005a2020-12-07 09:56:40 +080053 tstyle: {
54 marginLeft: '10rpx',
55 fontWeight: 'bold'
56 },
57 vstyle: {
guangchao.xu50e42382021-01-04 17:53:47 +080058 color: '#FF6F6F',
guangchao.xuc43cf972021-01-18 13:37:55 +080059 fontSize: '30rpx'
guangchao.xu50e42382021-01-04 17:53:47 +080060 },
61 status_style: {
62 color: '#18B566',
guangchao.xuc43cf972021-01-18 13:37:55 +080063 fontSize: '30rpx'
guangchao.xu070005a2020-12-07 09:56:40 +080064 },
65 payBtn: {
66 backgroundColor: ' #2FA8E1',
67 padding: '50rpx 0',
68 color: '#FFFFFF',
69 width: ' 600rpx',
70 fontSize: '30rpx',
71 border: '1px solid #2FA8E1',
72 marginTop: '50rpx'
73 },
guangchao.xu50e42382021-01-04 17:53:47 +080074 msg: {},
guangchao.xuc43cf972021-01-18 13:37:55 +080075 kind: ''
guangchao.xu070005a2020-12-07 09:56:40 +080076 }
77 },
guangchao.xu50e42382021-01-04 17:53:47 +080078 methods: {
guangchao.xu6cdd45e2021-04-16 17:44:30 +080079 // // 呼起键盘
80 // openKeyBoard(key) {
81 // this.type = key;
82 // this.$refs[key].open();
83 // },
84 // // 输入密码
85 // onInput(val) {
86 // this.numberList.push(val)
87 // if (this.numberList.length == this.length) {
88 // this.$refs.showPassword.close()
89 // this.$refs[this.type].close()
90 // this.payInit()
91 // }
92 // },
93 // //完成输入点击完成
94 // onConfirm() {
95 // let length = this.numberList.length
96 // if (length == this.length) {
97 // this.$refs.showPassword.close()
98 // this.$refs[this.type].close()
99 // } else {
100 // this.numberList = []
101 // uni.showToast({
102 // title: '密码错误',
103 // icon: 'none'
104 // })
105 // }
106 // },
107 // //删除密码
108 // onDelete(val) {
109 // this.numberList.pop(val)
110 // },
111 // //打开密码输入框
112 // open() {
113 // this.numberList = []
114 // this.$refs.showPassword.open()
115 // this.openKeyBoard('number')
116 // },
117 payInit() {
guangchao.xu50e42382021-01-04 17:53:47 +0800118 let that = this
guangchao.xu6cdd45e2021-04-16 17:44:30 +0800119 // let pwd = ''
guangchao.xu50e42382021-01-04 17:53:47 +0800120 let billno = that.msg.billNo
guangchao.xu6cdd45e2021-04-16 17:44:30 +0800121 // that.numberList.forEach(item => {
122 // pwd += item + ''
123 // })
guangchao.xu50e42382021-01-04 17:53:47 +0800124 let param = {
guangchao.xu6cdd45e2021-04-16 17:44:30 +0800125 // paypwd: pwd,
guangchao.xu50e42382021-01-04 17:53:47 +0800126 billno
127 }
guangchao.xu6cdd45e2021-04-16 17:44:30 +0800128 that.$u.post('/medicalapi/quickpay/payinit', param).then(res => {
129 let code = res.code
130 console.log(res)
131 if(code == 501){
132 uni.showModal({
133 title:'提示',
134 content:'您还未与银行进行签约,暂时无法支付',
135 confirmText:'去签约',
136 success(res) {
137 if(res.confirm){
138 that.getCardsiInfor()
139 }
140 }
141 })
142 }else{
143 let plain_payInit = res.data.plain
144 let signature_payInit = res.data.signature
145 let billno = res.data.billno
146 that.pay(billno,plain_payInit,signature_payInit)
147 }
148 })
149 },
150 pay(billno,plain,signature) {
151 let that = this
152 let params = {
153 plain,
154 signature
155 }
156 console.log(params)
157 Ynrcc.pay(params, res => {
158 console.log(res)
159 let plain_payConfirm = res.plain
160 let signature_payConfirm = res.signature
161 if(!plain_payConfirm && !signature_payConfirm){
162 let obj = res ,code,msg
163 for(let key in obj){
164 code = key
165 msg = obj[key]
166 }
167 uni.showModal({
168 title:'提示',
169 content:code + ':' +msg,
170 showCancel:false
171 })
172 return
173 }
174 that.pay_confirm(billno,plain_payConfirm,signature_payConfirm)
175 })
176 },
177 pay_confirm(billno,plain,signature){
178 let that = this
179 let params = {
180 billno,
181 plain,
182 signature
183 }
184 that.$u.post('/medicalapi/quickpay/confirm',params).then(res=>{
guangchao.xu50e42382021-01-04 17:53:47 +0800185 let status = res.status
186 let obj = that.msg
187 let date = res.transdate.substr(0, 4) +
188 "-" + res.transdate.substr(4, 2) + "-" + res.transdate.substr(6, 2) + " " + res.transtime.substr(0, 2) + ":" +
guangchao.xuc43cf972021-01-18 13:37:55 +0800189 res.transtime.substr(2, 2) + ":" + res.transtime.substr(4, 2)
190 setTimeout(() => {
191 uni.navigateTo({
192 url: `/pages/sub_medical/payResult?status=${status}&msg=${JSON.stringify(obj)}&date=${date}`
193 })
194 }, 1500)
guangchao.xu50e42382021-01-04 17:53:47 +0800195 })
196 },
guangchao.xu6cdd45e2021-04-16 17:44:30 +0800197 getCardsiInfor() {
198 let that = this
199 that.$u.post("/medicalapi/quickpay/signinfo").then((res) => {
200 console.log(res)
201 console.log(that.msg.hospitalcode)
202 let bankno = res.bankcardno
203 that.sign_init(bankno,that.msg.hospitalcode)
204 })
205 },
206 sign_init(bankcardno,hospitalcode){
207 let that = this
208 let params = {
209 hospitalcode,
210 bankcardno
211 }
212 that.$u.post('/medicalapi/quickpay/signinit',params).then(res=>{
213 console.log(res)
214 let authsign = res.data.authSign
215 let signature = res.data.signature
216 let user = res.data.signUserData
217 let plain = res.data.plain
218 let signno = res.data.signNo
219 if(!!!authsign){
220 that.sign(plain,signature,user,signno)
221 }else{
222 that.auth_sign(plain,signature,signno)
223 }
224 })
225 },
226 sign(plain,signature,user,signno) {
227 let that = this
228 let params = {
229 plain,
230 signature,
231 name: user.name,
232 id_type: user.idType,
233 id_no: user.idNo,
234 ac_no: user.acNo
235 }
236 Ynrcc.sign(params, res => {
237 let plain_sign = res.plain
238 let signature_sign = res.signature
239 if(!plain_sign && !signature_sign){
240 let obj = res ,code,msg
241 for(let key in obj){
242 code = key
243 msg = obj[key]
244 }
245 uni.showModal({
246 title:'提示',
247 content:code + ':' +msg,
248 showCancel:false
249 })
250 return
251 }
252 that.sign_confirm(plain_sign,signature_sign,signno)
253 })
254 },
255 auth_sign(plain,signature,signno) {
256 let that = this
257 let params = {
258 plain,
259 signature,
260 }
261 Ynrcc.authSign(params, res => {
262 console.log(res)
263 let plain_authSign = res.plain
264 let signature_authSign = res.signature
265 if(!plain_authSign && !signature_authSign){
266 let obj = res ,code,msg
267 for(let key in obj){
268 code = key
269 msg = obj[key]
270 }
271 uni.showModal({
272 title:'提示',
273 content:code + ':' +msg,
274 showCancel:false
275 })
276 return
277 }
278 that.sign_confirm(plain_authSign,signature_authSign,signno)
279 })
280 },
281 sign_confirm(plain,signature,signno){
282 let that = this
283 let params = {
284 signno,
285 plain,
286 signature
287 }
288 that.$u.post('/medicalapi/quickpay/signconfirm',params).then(res=>{
289 uni.showModal({
290 title:'提示',
291 content:'签约成功',
292 showCancel:false,
293 confirmText:'继续支付',
294 success(res){
295 if(res.confirm){
296 // that.open()
297 that.payInit()
298 }
299 }
300 })
301 })
302 },
guangchao.xu50e42382021-01-04 17:53:47 +0800303 query() {
304 let that = this
305 let billno = that.msg.billNo
306 that.$u.post('/medicalapi/pay/query/' + billno, {}).then(res => {
307 let status = res.status
guangchao.xuc43cf972021-01-18 13:37:55 +0800308 if (status == 'wip') {
guangchao.xu50e42382021-01-04 17:53:47 +0800309 uni.showToast({
guangchao.xuc43cf972021-01-18 13:37:55 +0800310 icon: 'none',
311 title: '订单正在支付中,请稍等...'
guangchao.xu50e42382021-01-04 17:53:47 +0800312 })
guangchao.xuc43cf972021-01-18 13:37:55 +0800313 } else {
guangchao.xu50e42382021-01-04 17:53:47 +0800314 let status = res.status
315 let obj = that.msg
316 let date = res.transdate.substr(0, 4) +
317 "-" + res.transdate.substr(4, 2) + "-" + res.transdate.substr(6, 2) + " " + res.transtime.substr(0, 2) + ":" +
guangchao.xuc43cf972021-01-18 13:37:55 +0800318 res.transtime.substr(2, 2) + ":" + res.transtime.substr(4, 2)
319 setTimeout(() => {
320 uni.navigateTo({
321 url: `/pages/sub_medical/payResult?status=${status}&msg=${JSON.stringify(obj)}&date=${date}`
322 })
323 }, 1500)
guangchao.xu50e42382021-01-04 17:53:47 +0800324 }
325 })
guangchao.xuc43cf972021-01-18 13:37:55 +0800326 },
327 notify_hosiptal() {
328 let that = this
329 let billno = that.msg.billno
330 that.$u.post('/medicalapi/pay/notify/' + billno).then(res => {
331 uni.showToast({
332 title: res.msg,
333 icon: 'none',
334 duration:800,
335 success(ret) {
336 setTimeout(() => {
337 uni.navigateBack({
338 delta: 1
339 })
340 }, 1500)
341 }
342 })
343 })
guangchao.xu6cdd45e2021-04-16 17:44:30 +0800344 },
345 refund(){
346 let that = this
347 let billno = that.msg.billno
348 let param = {
349 billno
350 }
351 that.$u.post('/medicalapi/medical/quickpay/refund/test',param).then(res=>{
352 uni.showModal({
353 title:'提示',
354 content:'退款成功',
355 showCancel:false,
356 })
357 })
358 },
guangchao.xu070005a2020-12-07 09:56:40 +0800359 },
guangchao.xu50e42382021-01-04 17:53:47 +0800360 onLoad(options) {
361 let msg = JSON.parse(options.msg)
guangchao.xu6cdd45e2021-04-16 17:44:30 +0800362 //console.log(msg)
guangchao.xu50e42382021-01-04 17:53:47 +0800363 let id = options.id
364 this.kind = id
guangchao.xuc43cf972021-01-18 13:37:55 +0800365 if (id == 'unpay') {
guangchao.xu50e42382021-01-04 17:53:47 +0800366 msg.date = msg.medicalDate.substr(0, 4) + '-' + msg.medicalDate.substr(4, 2) + '-' + msg.medicalDate.substr(6, 2) +
367 ' ' + msg.medicalDate.substr(8, 2) + ':' + msg.medicalDate.substr(10, 2) + ':' + msg.medicalDate.substr(12, 2)
368 switch (msg.status) {
369 case 'init':
370 msg.status_ok = '未支付';
371 break
372 case 'wip':
373 msg.status_ok = '订单正在支付中...'
374 break
375 }
376 this.msg = msg
guangchao.xuc43cf972021-01-18 13:37:55 +0800377 } else if (id == 'payed') {
guangchao.xu50e42382021-01-04 17:53:47 +0800378 msg.date = msg.medicaldate.substr(0, 4) + '-' + msg.medicaldate.substr(4, 2) + '-' + msg.medicaldate.substr(6, 2) +
379 ' ' + msg.medicaldate.substr(8, 2) + ':' + msg.medicaldate.substr(10, 2) + ':' + msg.medicaldate.substr(12, 2)
guangchao.xuc43cf972021-01-18 13:37:55 +0800380 msg.billNo = msg.billno
381 msg.mergingSubtotal = msg.mergingsubtotal
382 msg.mergingName = msg.mergingname
383 msg.status_ok = '已完成'
384 switch (msg.refundflag) {
385 case 'wip':
386 msg.refundflag_ok = '退款处理中...';
387 break
388 case 'refund':
389 msg.refundflag_ok = '已退款';
390 }
guangchao.xu50e42382021-01-04 17:53:47 +0800391 this.msg = msg
392 }
guangchao.xu070005a2020-12-07 09:56:40 +0800393 }
394 }
395</script>
396
397<style lang="scss" scoped>
guangchao.xu50e42382021-01-04 17:53:47 +0800398 .u-cell-box {
guangchao.xu070005a2020-12-07 09:56:40 +0800399 margin-bottom: 30rpx;
400 }
guangchao.xu50e42382021-01-04 17:53:47 +0800401
402 .pay {
guangchao.xu070005a2020-12-07 09:56:40 +0800403 font-family: "PingFang-SC-Medium";
404 }
guangchao.xu50e42382021-01-04 17:53:47 +0800405
406 .pwd-wrapper {
407 background: rgba(0, 0, 0, .4);
408 z-index: 1;
409
410 /deep/.uni-popup__wrapper.uni-custom.center {
411 .uni-popup__wrapper-box {
412 position: unset;
413 max-width: none;
414 max-height: none;
415 overflow-y: hidden;
416 background: none;
417 margin-top: -70rpx;
418 padding: 60rpx 30rpx 30rpx;
419 }
420
421 .pwd-text-wrap {
422 width: 100%;
423 padding: 50rpx 43rpx 60rpx;
424 box-sizing: border-box;
425 }
426 }
427
428 .uni-tip {
429 /* #ifndef APP-NVUE */
430 display: flex;
431 flex-direction: column;
432 /* #endif */
433 margin-top: -60rpx;
434 width: 570rpx;
435 background-color: #fff;
436 border-radius: 12rpx;
437 position: relative;
438 }
439
440 .uni-pwd {
441 width: 630rpx;
442 }
443
444 .uni-tip-icon-wrap {
445 text-align: center;
446 }
447
448 .uni-tip-content {
449 padding: 31rpx 40rpx 60rpx;
450 font-size: 30rpx;
451 color: #6F737A;
452 }
453 }
454
455 .uni-tip-title {
456 margin-top: 30rpx;
457 text-align: center;
458 font-weight: 500;
459 font-size: 34rpx;
460 color: $uni-text-color;
461 }
guangchao.xu070005a2020-12-07 09:56:40 +0800462</style>