调用微信支付接口实现
This commit is contained in:
parent
7bc48c1328
commit
702d1cdc36
|
|
@ -2,7 +2,7 @@
|
||||||
export const DEV_CONFIG = {
|
export const DEV_CONFIG = {
|
||||||
// 临时token,用于开发测试
|
// 临时token,用于开发测试
|
||||||
TEMP_TOKEN:
|
TEMP_TOKEN:
|
||||||
'eyJhbGciOiJIUzUxMiJ9.eyJsb2dpbl91c2VyX2tleSI6IjIwNTJiNTYxLWExYmYtNDhmZi04YzgxLTUxOTQwOTkzNGNkMyJ9.GtV24rNuYHsxmyzA8Di6Sy_QaK2wWTouhhEH8vmTk6pJKdhHrnnNev-SF8tSsOB-QVlBQ2mjX22-4znaERwmcg',
|
'eyJhbGciOiJIUzUxMiJ9.eyJsb2dpbl91c2VyX2tleSI6IjQzMjljNzhjLTFmN2YtNGRkMS1iMDllLTZjNGRhZGI4MWUzZSJ9.S6TisMbcX1V1LqGilCG9BGye-p_36pWzgaF67O3DxN2exLR48oZLEAxYdbjNU5cqEtg4x5WJ3rpVs2gQer3xig',
|
||||||
|
|
||||||
// 是否使用临时token
|
// 是否使用临时token
|
||||||
USE_TEMP_TOKEN: true,
|
USE_TEMP_TOKEN: true,
|
||||||
|
|
|
||||||
|
|
@ -343,7 +343,7 @@ export default {
|
||||||
suitId: this.selectedPackage.id,
|
suitId: this.selectedPackage.id,
|
||||||
appId: '1', // 应用ID,根据实际情况调整
|
appId: '1', // 应用ID,根据实际情况调整
|
||||||
payAmount: this.selectedPackage.price || this.selectedPackage.amount,
|
payAmount: this.selectedPackage.price || this.selectedPackage.amount,
|
||||||
channelId: '2', // 渠道ID,根据实际情况调整
|
channelId: '3', // 渠道ID,根据实际情况调整
|
||||||
devId: this.selectedDevice.id,
|
devId: this.selectedDevice.id,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -351,16 +351,42 @@ export default {
|
||||||
|
|
||||||
const response = await renewDevice(renewData)
|
const response = await renewDevice(renewData)
|
||||||
|
|
||||||
uni.hideLoading()
|
|
||||||
|
|
||||||
if (response.code === 200) {
|
if (response.code === 200) {
|
||||||
uni.showToast({
|
const data = response.data
|
||||||
title: '续费成功',
|
const wxpPayParams = data.payParams
|
||||||
icon: 'success',
|
console.log(data)
|
||||||
|
|
||||||
|
const payParams = {
|
||||||
|
package: wxpPayParams.packageVal, // 后端返回的字段名
|
||||||
|
timeStamp: wxpPayParams.timeStamp,
|
||||||
|
nonceStr: wxpPayParams.nonceStr,
|
||||||
|
signType: wxpPayParams.signType,
|
||||||
|
paySign: wxpPayParams.paySign,
|
||||||
|
}
|
||||||
|
console.log('支付后端回调数据', payParams)
|
||||||
|
|
||||||
|
wx.requestPayment({
|
||||||
|
...payParams,
|
||||||
|
success: function (res) {
|
||||||
|
uni.showToast({
|
||||||
|
title: '支付成功',
|
||||||
|
icon: 'success',
|
||||||
|
duration: 2000,
|
||||||
|
})
|
||||||
|
uni.navigateTo({
|
||||||
|
url: `/pages/myOrder/orderDetail?id=${data.pay.bstId}`,
|
||||||
|
})
|
||||||
|
},
|
||||||
|
fail: function (res) {
|
||||||
|
uni.showToast({
|
||||||
|
title: '支付失败',
|
||||||
|
icon: 'fail',
|
||||||
|
})
|
||||||
|
},
|
||||||
|
complete: function (res) {
|
||||||
|
console.log('微信支付调用结束')
|
||||||
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
await sleep(1000)
|
|
||||||
|
|
||||||
// 关闭弹窗
|
// 关闭弹窗
|
||||||
this.closeRenewModal()
|
this.closeRenewModal()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -165,7 +165,7 @@ export default {
|
||||||
devTypeId: '', // 设备类型ID
|
devTypeId: '', // 设备类型ID
|
||||||
period: '',
|
period: '',
|
||||||
suitId: '', // 租赁周期ID
|
suitId: '', // 租赁周期ID
|
||||||
channelId: '2', //渠道id
|
channelId: '3', //渠道id
|
||||||
payAmount: 0,
|
payAmount: 0,
|
||||||
},
|
},
|
||||||
showDetails: false,
|
showDetails: false,
|
||||||
|
|
@ -382,14 +382,48 @@ export default {
|
||||||
success: async res => {
|
success: async res => {
|
||||||
if (res.confirm) {
|
if (res.confirm) {
|
||||||
// 这里可以调用支付API
|
// 这里可以调用支付API
|
||||||
|
|
||||||
const response = await createLeaseOrder(this.formData)
|
const response = await createLeaseOrder(this.formData)
|
||||||
|
//"17318322273"
|
||||||
if (response.code === 200) {
|
if (response.code === 200) {
|
||||||
uni.showToast({
|
const data = response.data
|
||||||
title: '支付成功',
|
console.log(data)
|
||||||
icon: 'success',
|
|
||||||
|
const payParams = {
|
||||||
|
package: response.data.payParams.packageVal, // 后端返回的字段名
|
||||||
|
timeStamp: response.data.payParams.timeStamp,
|
||||||
|
nonceStr: response.data.payParams.nonceStr,
|
||||||
|
signType: response.data.payParams.signType,
|
||||||
|
paySign: response.data.payParams.paySign,
|
||||||
|
}
|
||||||
|
console.log('支付后端回调数据', payParams)
|
||||||
|
|
||||||
|
wx.requestPayment({
|
||||||
|
...payParams,
|
||||||
|
success: function (res) {
|
||||||
|
uni.showToast({
|
||||||
|
title: '支付成功',
|
||||||
|
icon: 'success',
|
||||||
|
duration: 2000,
|
||||||
|
})
|
||||||
|
uni.navigateTo({
|
||||||
|
url: `/pages/myOrder/orderDetail?id=${data.pay.bstId}`,
|
||||||
|
})
|
||||||
|
},
|
||||||
|
fail: function (res) {
|
||||||
|
uni.showToast({
|
||||||
|
title: '支付失败',
|
||||||
|
icon: 'fail',
|
||||||
|
})
|
||||||
|
},
|
||||||
|
complete: function (res) {
|
||||||
|
console.log('微信支付调用结束')
|
||||||
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// uni.showToast({
|
||||||
|
// title: '支付成功',
|
||||||
|
// icon: 'success',
|
||||||
|
// })
|
||||||
} else {
|
} else {
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: response.msg || '添加失败',
|
title: response.msg || '添加失败',
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user