food_wechat/pages/shop/pay.vue
sszdot 44a4d393c6 【类 型】:fix
【原  因】:传值到 付款页面  由于提前清空购物车  导致商品价格没有累计
【过  程】:清空购物车前 记录商品总价格 到一个变量
【影  响】:

# 类型 包含:
# feat:新功能(feature)
# fix:修补bug
# docs:文档(documentation)
# style: 格式(不影响代码运行的变动)
# refactor:重构(即不是新增功能,也不是修改bug的代码变动)
# test:增加测试
# chore:构建过程或辅助工具的变动
2024-12-12 19:40:48 +08:00

91 lines
2.0 KiB
Vue

<template>
<view>
<!-- topbar -->
<u-navbar title="收银台" bgColor="#d43030" :titleStyle="{ color: '#FFF'}" :autoBack="true" placeholder>
<view class="u-nav-slot" slot="left">
<u-icon name="arrow-left" color="#fff" size="19"></u-icon>
</view>
</u-navbar>
<!-- 价格 -->
<view>{{fullPrice | formatPrice}}</view>
<button @click="pay" type="primary" style="margin-top:200rpx;">确认支付</button>
</view>
</template>
<script>
import {
formatPrice
} from '@/utils/index.js'
export default {
data() {
return {
order_sn: '', //订单号
fullPrice: 0,//总价格 包括附加费用
}
},
onLoad(options) {
this.order_sn = options.order_sn; // 从提交订单页面传递过来的订单号
this.fullPrice = Number(options.fullPrice); // 从提交订单页面传递过来的订单号
},
computed(){
},
filters: {
formatPrice, //格式化价格
},
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) => {
if (res.data.status === 1) {
// 调用微信支付接口
this.requestPayment(res.data.payMsg);
}else{
uni.showToast({
title: '支付失败',
icon: 'error'
});
console.error(res.data.msg)
}
})
},
// 调用微信支付接口
requestPayment(payMsg) {
uni.requestPayment({
timeStamp: payMsg.timeStamp,
nonceStr: payMsg.nonceStr,
package: payMsg.package,
signType: payMsg.signType,
paySign: payMsg.paySign,
success: (res) => {
if(res.status===1){
uni.showToast({
title: '支付成功',
icon: 'success'
})
}
},
fail: (err) => {
uni.showToast({
title: '支付失败',
icon: 'error'
});
console.error(err)
}
});
},
}
}
</script>
<style>
</style>