订单逻辑修改,支付宝兼容

This commit is contained in:
GaoHao
2024-09-27 10:12:32 +08:00
parent 1e420a9c2a
commit a77a7ab716
7 changed files with 103 additions and 45 deletions

View File

@@ -74,6 +74,10 @@
</view>
<view class="price"> {{ item.totalAmount || item.priceAmount || 0}} </view>
</view>
<view class="cell_item" v-if="dinersNum">
<view class="label">餐位费</view>
<view class="value"><view>X{{dinersNum}}</view><view>X{{dinersNum*storeInfo.tableFee}}</view></view>
</view>
<!-- <view class="favorable" v-for="(item,index) in favorable" :key="index">
<view class="favorable_left">
<image class="icon" :src="item.url" mode="aspectFill"/>
@@ -125,7 +129,7 @@
</view>
</view> -->
<paymentMethod ref="paymentMethod" :amountVIP="amountVIP" v-if="storeInfo.registerType == 'munchies'"></paymentMethod>
<paymentMethod ref="paymentMethod" :amountVIP="amountVIP" v-if="storeInfo.registerType == 'munchies'" @groupChange="groupChange"></paymentMethod>
<view class="bottom">
@@ -193,15 +197,6 @@
{ name: "优惠券", url: "https://czg-qr-order.oss-cn-beijing.aliyuncs.com/confirmOrder/coupon.png"},
{ name: "团购优惠", url: "https://czg-qr-order.oss-cn-beijing.aliyuncs.com/confirmOrder/groupOffer.png"},
],
paymentMethodList:[
{ name: "余额支付", type: "1", url: "https://czg-qr-order.oss-cn-beijing.aliyuncs.com/drder/wechat.png"},
// #ifdef MP-WEIXIN
{ name: "微信支付", type: "2", url: "https://czg-qr-order.oss-cn-beijing.aliyuncs.com/confirmOrder/weChat.png"},
// #endif
// #ifdef MP-ALIPAY
{ name: "支付宝支付", type: "3", url: "https://czg-qr-order.oss-cn-beijing.aliyuncs.com/confirmOrder/alipay.png"},
// #endif
],
order: {
phone: "",
},
@@ -255,10 +250,14 @@
console.log(this.storeInfo)
this.shopId =this.storeInfo.shopId;
this.listinfo.name = this.storeInfo.shopName;
if ( e.tableCode ) { this.tableCode = e.tableCode; }
if ( e.dinersNum ) { this.dinersNum = e.dinersNum; }
this.listinfo.details = JSON.parse(e.cartLists).data;
this.listinfo.payAmount = JSON.parse(e.cartLists).amount;
if ( e.tableCode ) { this.tableCode = e.tableCode; }
if ( e.dinersNum ) {
this.dinersNum = e.dinersNum;
this.listinfo.payAmount = (this.listinfo.payAmount + this.dinersNum * this.storeInfo.tableFee).toFixed(2);
}
if ( this.storeInfo.eatModel.indexOf("dine-in") != -1 ) {
this.eatModel = ["dine-in"]
} else {
@@ -364,6 +363,9 @@
this.listinfoid = msg.data.id
this.listinfo.details = msg.data.detailList;
this.listinfo.payAmount = msg.data.amount;
if ( this.dinersNum ) {
this.listinfo.payAmount = (this.listinfo.payAmount + this.dinersNum * this.storeInfo.tableFee).toFixed(2);
}
uni.$off('getMessage')
this.orderorderInfo(1)
break;
@@ -375,6 +377,9 @@
} else {
this.listinfo.details = msg.data;
this.listinfo.payAmount = msg.amount;
if ( this.dinersNum ) {
this.listinfo.payAmount = (this.listinfo.payAmount + this.dinersNum * this.storeInfo.tableFee).toFixed(2);
}
}
break;
case 'order':
@@ -391,6 +396,9 @@
} else {
this.listinfo.details = msg.data;
this.listinfo.payAmount = msg.amount;
if ( this.dinersNum ) {
this.listinfo.payAmount = (this.listinfo.payAmount + this.dinersNum * this.storeInfo.tableFee).toFixed(2);
}
}
this.isSocket = true;
break;
@@ -406,6 +414,7 @@
*/
tabClick ( index,val ) {
this.is_type = index;
this.eatModel = [];
this.eatModel.push(val);
},
@@ -413,9 +422,10 @@
* 监听支付方式切换
* @param {Object} n
*/
groupChange(n) {
this.radiovalue = n;
this.paymentBtnText = n==1?'余额支付':'微信支付'
groupChange(e) {
console.log(e)
this.radiovalue = e.type;
this.paymentBtnText = e.name;
},
/**
@@ -518,6 +528,7 @@
"isYhq": 0, // 是否使用优惠券( 1 使用, 0 不使用),
"isBuyYhq": 0, // 是否购买优惠券( 1 购买, 0 不够买)
"productId": '', //商品id
"tableId": this.tableCode , //商品id
"dinersNum": this.dinersNum, //就餐人数
"eatModel": this.eatModel, //就餐模式
"shopId": uni.cache.get('shopId'),
@@ -531,7 +542,7 @@
*/
showpopupclickdd() {
console.log(this.radiovalue)
if ( this.radiovalue == 2 && this.listinfo.payAmount <= 0 ) {
if ( this.radiovalue == 2 || this.radiovalue == 3 && this.listinfo.payAmount <= 0 ) {
uni.showToast({
title: "支付金额必须大于0",
icon: 'none'
@@ -543,7 +554,7 @@
mask: true
})
// radiovalue为2是微信支付
if (this.radiovalue == 2) {
if (this.radiovalue == 2||this.radiovalue == 3) {
this.showpopupclickdds() //微信支付
} else {
// 先判断是否设置支付密码。0是没设置。没设置的情况下跳转到设置页面。有的话输入支付密码
@@ -577,7 +588,14 @@
async showpopupclickdds() {
let res = await this.api.payorderPay({
orderId: this.listinfoid
orderId: this.listinfoid,
// #ifdef MP-WEIXIN
payType: 'wechatPay',
// #endif
// #ifdef MP-ALIPAY
payType: 'aliPay',
// #endif
// payType: this.radiovalue == 2 ? 'wechatPay' : 'aliPay'
}) //判断是否支付成功
if (res.code == 0) {
@@ -617,7 +635,7 @@
// #ifdef MP-ALIPAY
uni.requestPayment({
provider: 'alipay', //支付类型-固定值
orderInfo: res.data.appId, // 微信支付商户号
orderInfo: res.data.tradeNo, // 微信支付商户号
success: (res) => {
let _this = this
@@ -1036,6 +1054,33 @@
font-weight: 500;
}
}
.cell_item{
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 32rpx;
padding: 0 30rpx;
.lable{
font-weight: 500;
font-size: 28rpx;
color: #333333;
}
.value{
display: flex;
align-items: flex-end;
view:nth-child(1){
font-weight: 400;
font-size: 24rpx;
color: #999999;
margin-right: 16rpx;
}
view:nth-child(2){
font-weight: bold;
font-size: 28rpx;
color: #333333;
}
}
}
.favorable{
display: flex;
align-items: center;