food_wechat/pages/shop/pay.vue
2024-05-29 22:14:36 +08:00

68 lines
1.5 KiB
Vue

<template>
<view>
<button @click="pay">确认支付</button>
</view>
</template>
<script>
export default {
data() {
return {
order_sn: '' //订单号
}
},
onLoad(options) {
this.order_sn = options.order_sn; // 从提交订单页面传递过来的订单号
},
methods: {
// 支付方法
pay() {
uni.$u.http.post('/Api/Pay/pay', {
order_sn: this.order_sn
}, {
header: {
'Token': this.$store.state.userInfo.token,
'Content-Type': 'application/x-www-form-urlencoded'
}
}).then((res)=>{
console.log(res)
// if (res.data.status === 1) {
// const payData = res.data.data
// uni.requestPayment({
// timeStamp: payData.timeStamp,
// nonceStr: payData.nonceStr,
// package: payData.package,
// signType: payData.signType,
// paySign: payData.paySign,
// success: (paymentRes) => {
// console.log('支付成功', paymentRes)
// // 在这里处理支付成功后的逻辑
// uni.showToast({
// title: '支付成功',
// icon: 'success'
// })
// },
// fail: (paymentErr) => {
// console.error('支付失败', paymentErr)
// // 在这里处理支付失败后的逻辑
// uni.showToast({
// title: '支付失败',
// icon: 'none'
// })
// }
// })
// } else {
// uni.showToast({
// title: res.data.msg || '支付请求失败',
// icon: 'none'
// })
// }
})
}
}
}
</script>
<style>
</style>