|
|
@@ -24,11 +24,11 @@ import NavBar from '@/components/navBar/index.vue'
|
|
|
import VanButton from '@/components/button/index'
|
|
|
import VanCell from '@/components/cell/index'
|
|
|
import VanCellGroup from '@/components/cell-group/index'
|
|
|
-import Util from "@/utils/utils";
|
|
|
+import Utils from "@/utils/utils";
|
|
|
import $http from "@/utils/https";
|
|
|
import httpConfig from '@/utils/httpConfig';
|
|
|
+import { wxpay } from '@/utils/pay'
|
|
|
const app = getApp();
|
|
|
-
|
|
|
export default {
|
|
|
components: {
|
|
|
'nav-bar': NavBar,
|
|
|
@@ -56,6 +56,8 @@ export default {
|
|
|
prePayAmt: '', // 最小充值金额(下限),由上游 advancePayment 透传
|
|
|
prePayIDInfo: '', // 押金账户信息,从 order.vue turnTrans 透传,传给 99070016
|
|
|
prescribeTradeNum: '', // 处方流水号,从 order.vue turnTrans 透传,传给 99070016
|
|
|
+ infoByTrandNoFlag: false,
|
|
|
+ infoByTrandNo: 0,
|
|
|
}
|
|
|
},
|
|
|
onLoad: function (options) {
|
|
|
@@ -116,7 +118,7 @@ export default {
|
|
|
/**
|
|
|
* 支付
|
|
|
*/
|
|
|
- becomeStronger: Util.debounce(function (code) {
|
|
|
+ becomeStronger: Utils.debounce(function (code) {
|
|
|
let userData = this.$cache.get('userData');
|
|
|
let {
|
|
|
rechargeAmount,
|
|
|
@@ -191,7 +193,12 @@ export default {
|
|
|
success: function (res) {
|
|
|
uni.hideLoading();
|
|
|
if (+res.errorCode === 0) {
|
|
|
- this.unifyPay(res.result)
|
|
|
+ console.log("01050002 res.result", res.result)
|
|
|
+ this.setData({
|
|
|
+ payTradeNum: res.result.payTradeNum
|
|
|
+ },() => {
|
|
|
+ this.unifyPay({...res.result})
|
|
|
+ })
|
|
|
} else {
|
|
|
setTimeout((
|
|
|
uni.showToast({
|
|
|
@@ -205,91 +212,248 @@ export default {
|
|
|
});
|
|
|
}),
|
|
|
|
|
|
- ////微信支付调用
|
|
|
- wechatPay(data) {
|
|
|
- let _this = this;
|
|
|
- wx.requestPayment({
|
|
|
- timeStamp: data.timeStamp + "",
|
|
|
- nonceStr: data.nonceStr,
|
|
|
- package: data.package,
|
|
|
- signType: data.signType,
|
|
|
- paySign: data.paySign,
|
|
|
- success(res) {
|
|
|
- uni.navigateTo({
|
|
|
- url: '../prepaymentRechargeSuccessful/prepaymentRechargeSuccessful?amt=' + _this.rechargeAmount,
|
|
|
- })
|
|
|
- },
|
|
|
- fail(res) { }
|
|
|
- })
|
|
|
- },
|
|
|
-
|
|
|
// 微信、支付宝支付调用
|
|
|
unifyPay(data) {
|
|
|
let self = this;
|
|
|
return new Promise((resolve, reject) => {
|
|
|
- const { platform, provider } = self
|
|
|
- const obj = {}
|
|
|
- obj['provider'] = provider
|
|
|
- if (platform == 'alipay') {
|
|
|
- obj['orderInfo'] = data.trade_no
|
|
|
- } else if (platform == 'weixin') {
|
|
|
- obj['orderInfo'] = {
|
|
|
- timeStamp: data.timeStamp + "",
|
|
|
- nonceStr: data.nonceStr,
|
|
|
- package: data.package,
|
|
|
- signType: data.signType,
|
|
|
- paySign: data.paySign
|
|
|
- }
|
|
|
- }
|
|
|
- self.paySubmitService(data, obj).then(res => {
|
|
|
- uni.navigateTo({
|
|
|
- url: '../prepaymentRechargeSuccessful/prepaymentRechargeSuccessful?amt=' + _this.rechargeAmount,
|
|
|
+ const {
|
|
|
+ platform,
|
|
|
+ provider
|
|
|
+ } = self
|
|
|
+ data['provider'] = provider
|
|
|
+
|
|
|
+ // #ifdef MP-WEIXIN || H5
|
|
|
+ // 微信公众号支付
|
|
|
+ wxpay(data)
|
|
|
+ .then(async (res) => {
|
|
|
+ this.getPayStatus("wechatPay");
|
|
|
+ resolve()
|
|
|
})
|
|
|
- resolve()
|
|
|
- }).catch(err => {
|
|
|
- reject(err)
|
|
|
- })
|
|
|
- })
|
|
|
- },
|
|
|
+ .catch((errMsg) => {
|
|
|
+ Utils.abnormalOrderDeal(data) // 取消未支付订单
|
|
|
+ reject(errMsg)
|
|
|
+ })
|
|
|
+ // #endif
|
|
|
|
|
|
- paySubmitService(data, obj) {
|
|
|
- const self = this
|
|
|
- return new Promise((resolve, reject) => {
|
|
|
- uni.requestPayment({
|
|
|
- ...obj,
|
|
|
- success(res) {
|
|
|
- console.log('pay success', res)
|
|
|
- if (obj.provider == 'wxpay') {
|
|
|
- self.getPayStatus("wechatPay");
|
|
|
- } else if (obj.provider == 'alipay') {
|
|
|
- console.log(obj.provider, res.resultCode)
|
|
|
+ // #ifdef MP-ALIPAY
|
|
|
+ // 支付宝小程序支付
|
|
|
+ if (platform == 'alipay') {
|
|
|
+ data['orderInfo'] = data.trade_no
|
|
|
+ }
|
|
|
+ alipay(data)
|
|
|
+ .then(res => {
|
|
|
+ if (provider == 'alipay') {
|
|
|
+ console.log(provider, res.resultCode)
|
|
|
if (res.resultCode == '9000') {
|
|
|
- // self.getPayStatus("aliPay");
|
|
|
uni.showToast({
|
|
|
title: '支付成功'
|
|
|
+ }, () => {
|
|
|
+ self.getPayStatus("aliPay");
|
|
|
})
|
|
|
resolve()
|
|
|
} else if (res.resultCode == '6001') {
|
|
|
uni.showToast({
|
|
|
title: res.memo
|
|
|
+ }, () => {
|
|
|
+ Utils.abnormalOrderDeal(data) // 取消未支付订单
|
|
|
})
|
|
|
- // Util.abnormalOrderDeal(data) // 取消未支付订单
|
|
|
reject(res.memo)
|
|
|
} else {
|
|
|
- // Util.abnormalOrderDeal(data) // 取消未支付订单
|
|
|
+ Utils.abnormalOrderDeal(data) // 取消未支付订单
|
|
|
reject()
|
|
|
}
|
|
|
}
|
|
|
- },
|
|
|
- fail(err) {
|
|
|
- // isPayment = true;
|
|
|
- console.log('pay fail', err)
|
|
|
- // Util.abnormalOrderDeal(data) // 取消未支付订单
|
|
|
- reject()
|
|
|
- }
|
|
|
+ }).catch(err => {
|
|
|
+ console.log('调用支付失败', err)
|
|
|
+ Utils.abnormalOrderDeal(data) // 取消未支付订单
|
|
|
+ reject(err)
|
|
|
+ })
|
|
|
+ // #endif
|
|
|
+ })
|
|
|
+ },
|
|
|
+
|
|
|
+ // 获取支付状态
|
|
|
+ getPayStatus(btnType) {
|
|
|
+ let self = this;
|
|
|
+ let userData = this.$cache.get('userData');
|
|
|
+ let {
|
|
|
+ infoByTrandNo,
|
|
|
+ infoByTrandNoFlag,
|
|
|
+ payTradeNum,
|
|
|
+ platform
|
|
|
+ } = self;
|
|
|
+ // console.log(infoByTrandNoFlag)
|
|
|
+ if (!infoByTrandNoFlag) {
|
|
|
+ infoByTrandNo++
|
|
|
+ self.setData({
|
|
|
+ infoByTrandNo
|
|
|
})
|
|
|
+ if (infoByTrandNo > 5) {
|
|
|
+ uni.hideLoading();
|
|
|
+ self.setData({
|
|
|
+ infoByTrandNo: 0
|
|
|
+ })
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+ let data = {
|
|
|
+ params: [{
|
|
|
+ hospitalCode: userData.hisHospID || '',
|
|
|
+ payTradeNum: payTradeNum,
|
|
|
+ userCode: platform === "alipay" ? "alisf" : "wxsf",
|
|
|
+ }]
|
|
|
+ }
|
|
|
+ console.log('状态查询入参', data)
|
|
|
+ // 保存入参,用于复制调试
|
|
|
+ self.setData({
|
|
|
+ payStatusRequest: JSON.stringify(data)
|
|
|
})
|
|
|
- }
|
|
|
+ uni.showLoading({
|
|
|
+ title: '订单状态查询中',
|
|
|
+ mask: true
|
|
|
+ })
|
|
|
+ $http.post("urlS", self, {
|
|
|
+ code: "130980",
|
|
|
+ data: data,
|
|
|
+ namespace: "UPP",
|
|
|
+ success: function (res) {
|
|
|
+ // console.log(res)
|
|
|
+ self.setData({
|
|
|
+ payStatusResult: JSON.stringify(res)
|
|
|
+ })
|
|
|
+ // 弹出调试弹窗,展示入参/出参并提供复制按钮
|
|
|
+ uni.showModal({
|
|
|
+ title: '状态查询调试',
|
|
|
+ content: '入参:' + JSON.stringify(data) + '\n\n出参:' + JSON.stringify(res),
|
|
|
+ showCancel: true,
|
|
|
+ cancelText: '关闭',
|
|
|
+ confirmText: '复制出入参',
|
|
|
+ confirmColor: '#333333',
|
|
|
+ success: function (modalRes) {
|
|
|
+ if (modalRes.confirm) {
|
|
|
+ uni.setClipboardData({
|
|
|
+ data: '【入参】\n' + JSON.stringify(data, null, 2) + '\n\n【出参】\n' + JSON.stringify(res, null, 2),
|
|
|
+ success: function () {
|
|
|
+ uni.showToast({
|
|
|
+ title: '已复制到剪切板',
|
|
|
+ icon: 'none'
|
|
|
+ })
|
|
|
+ },
|
|
|
+ fail: function (err) {
|
|
|
+ uni.showToast({
|
|
|
+ title: '复制失败,请手动复制',
|
|
|
+ icon: 'none'
|
|
|
+ })
|
|
|
+ console.error('复制到剪切板失败:', err)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ if (+res.errorCode === 0) {
|
|
|
+ uni.hideLoading();
|
|
|
+ self.setData({
|
|
|
+ infoByTrandNoFlag: true
|
|
|
+ }, () => {
|
|
|
+ if (["wechatPay", "healthPay", "aliPay"].indexOf(btnType) > -1) {
|
|
|
+ uni.showToast({
|
|
|
+ title: "支付成功",
|
|
|
+ success(res) {
|
|
|
+ uni.redirectTo({
|
|
|
+ url: "/pages/order/pages/prepaymentRechargeSuccessful/prepaymentRechargeSuccessful?amt=" + self.rechargeAmount
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ } else if (res.errorCode == 'UN') { // 医保支付成功,HIS保存未成功,跳转账单已付款页面
|
|
|
+ uni.switchTab({
|
|
|
+ url: '/pages/tabBar/order/order?tab=1',
|
|
|
+ })
|
|
|
+ } else if (res.errorCode == 'NOTPAY') {
|
|
|
+ self.resetData(res.errorMessage)
|
|
|
+ } else {
|
|
|
+ if (infoByTrandNo == 5) {
|
|
|
+ self.resetData(res.errorMessage)
|
|
|
+ } else {
|
|
|
+ self.getPayStatus(btnType)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ error: function (error) {
|
|
|
+ self.resetData("失败,稍后重试")
|
|
|
+ },
|
|
|
+ callback: function (res) {
|
|
|
+ self.setData({
|
|
|
+ payStatusParams: res
|
|
|
+ })
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+
|
|
|
+ // 微信、支付宝支付调用-old
|
|
|
+ // unifyPay(data) {
|
|
|
+ // let self = this;
|
|
|
+ // return new Promise((resolve, reject) => {
|
|
|
+ // const { platform, provider } = self
|
|
|
+ // const obj = {}
|
|
|
+ // obj['provider'] = provider
|
|
|
+ // if (platform == 'alipay') {
|
|
|
+ // obj['orderInfo'] = data.trade_no
|
|
|
+ // } else if (platform == 'weixin') {
|
|
|
+ // obj['orderInfo'] = {
|
|
|
+ // timeStamp: data.timeStamp + "",
|
|
|
+ // nonceStr: data.nonceStr,
|
|
|
+ // package: data.package,
|
|
|
+ // signType: data.signType,
|
|
|
+ // paySign: data.paySign
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // self.paySubmitService(data, obj).then(res => {
|
|
|
+
|
|
|
+ // }).catch(err => {
|
|
|
+ // reject(err)
|
|
|
+ // })
|
|
|
+ // })
|
|
|
+ // },
|
|
|
+
|
|
|
+ // paySubmitService(data, obj) {
|
|
|
+ // const self = this
|
|
|
+ // return new Promise((resolve, reject) => {
|
|
|
+ // uni.requestPayment({
|
|
|
+ // ...obj,
|
|
|
+ // success(res) {
|
|
|
+ // console.log('pay success', res)
|
|
|
+ // if (obj.provider == 'wxpay') {
|
|
|
+ // self.getPayStatus("wechatPay");
|
|
|
+ // } else if (obj.provider == 'alipay') {
|
|
|
+ // console.log(obj.provider, res.resultCode)
|
|
|
+ // if (res.resultCode == '9000') {
|
|
|
+ // // self.getPayStatus("aliPay");
|
|
|
+ // uni.showToast({
|
|
|
+ // title: '支付成功'
|
|
|
+ // })
|
|
|
+ // resolve()
|
|
|
+ // } else if (res.resultCode == '6001') {
|
|
|
+ // uni.showToast({
|
|
|
+ // title: res.memo
|
|
|
+ // })
|
|
|
+ // // Util.abnormalOrderDeal(data) // 取消未支付订单
|
|
|
+ // reject(res.memo)
|
|
|
+ // } else {
|
|
|
+ // // Util.abnormalOrderDeal(data) // 取消未支付订单
|
|
|
+ // reject()
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // },
|
|
|
+ // fail(err) {
|
|
|
+ // console.log('pay fail', err)
|
|
|
+ // // Util.abnormalOrderDeal(data) // 取消未支付订单
|
|
|
+ // reject()
|
|
|
+ // }
|
|
|
+ // })
|
|
|
+ // })
|
|
|
+ // },
|
|
|
}
|
|
|
}
|
|
|
</script>
|