This commit is contained in:
曹辉 2023-04-27 09:17:34 +08:00
parent 0df7c7feb4
commit b2808b4223

View File

@ -64,7 +64,6 @@
}, },
onLoad(options) { onLoad(options) {
this.baseurl = baseurl this.baseurl = baseurl
console.log(options)
this.list = JSON.parse(options.list) this.list = JSON.parse(options.list)
var ordertimes = this.list.trainingOrderTime.replaceAll(/\-/gi, "/") var ordertimes = this.list.trainingOrderTime.replaceAll(/\-/gi, "/")
var time = new Date(this.list.trainingOrderTime).getTime() / 1000 + (60 * 60 * 2) var time = new Date(this.list.trainingOrderTime).getTime() / 1000 + (60 * 60 * 2)
@ -79,65 +78,48 @@
// //
tobuy() { tobuy() {
var that = this var that = this
var obj = { if (this.list.trainingItemPrice > 0) {
"trainingItemId": undefined, let objs = {
"nurseStationId": undefined, "openid": uni.getStorageSync('openid'),
"nurseStationPersonId": undefined, "nurseStationPersonId": this.list.nurseStationPersonId,
"trainingOrderAmount": undefined, "orderNo": this.list.trainingOrderNo,
"nursePersonName": undefined, "payType": "WECHAT_PAY",
} "orderChannel": "WECHAT_APPLET",
obj.trainingItemId = this.list.trainingItemId "buySource": "TRAINING",
obj.nurseStationId = uni.getStorageSync('nurseStationId'); "paymentPrice": this.list.trainingItemPrice,
obj.nurseStationPersonId = uni.getStorageSync('nursePersonId'); }
obj.nursePersonName = uni.getStorageSync('nursePersonName'); appletTrainingOrderPay(objs).then(response => {
obj.trainingOrderAmount = this.list.trainingItemPrice if (response.code == 200) {
trainingItemOrder(obj).then(res => { uni.requestPayment({
if (res.code == 200) { timeStamp: response.data.timeStamp,
if (res.data.trainingOrderAmount > 0) { nonceStr: response.data.nonceStr,
let objs = { package: response.data.prepayId,
"openid": uni.getStorageSync('openid'), signType: response.data.signType,
"nurseStationPersonId": res.data.nurseStationPersonId, paySign: response.data.paySign,
"orderNo": res.data.trainingOrderNo, success: function(res) {
"payType": "WECHAT_PAY", that.$refs.uToast.show({
"orderChannel": "WECHAT_APPLET", title: '支付成功',
"buySource": "TRAINING", type: 'success',
"paymentPrice": res.data.trainingOrderAmount, duration: 1500,
} })
appletTrainingOrderPay(objs).then(response => { },
if (response.code == 200) { fail: function(err) {
uni.requestPayment({ that.$refs.uToast.show({
timeStamp: response.data.timeStamp, title: '取消支付',
nonceStr: response.data.nonceStr,
package: response.data.prepayId,
signType: response.data.signType,
paySign: response.data.paySign,
success: function(res) {
that.$refs.uToast.show({
title: '支付成功',
type: 'success',
duration: 1500,
})
},
fail: function(err) {
that.$refs.uToast.show({
title: '取消支付',
type: 'error',
duration: 1500,
})
}
});
} else {
this.$refs.uToast.show({
title: response.msg,
type: 'error', type: 'error',
duration: 2000 duration: 1500,
}) })
} }
});
} else {
this.$refs.uToast.show({
title: response.msg,
type: 'error',
duration: 2000
}) })
} }
})
} }
})
}, },
} }
} }