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

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

@@ -251,6 +251,7 @@
})
this.phonetitle = res.data.substr(0, 3) + "****" + res.data.substr(7)
this.mobile = res.data;
console.log(this.phonetitle)
}
});
}

View File

@@ -109,12 +109,10 @@
type: 'index',
})
} else {
// uni.pro.navigateTo('member/memberdetails', {
// shopId: item.shopId
// })
uni.pro.navigateTo('/pages/order_food/order_food', {
uni.pro.navigateTo('member/memberdetails', {
shopId: item.shopId
})
}
}

View File

@@ -133,7 +133,9 @@
*/
navigatorGo ( item ) {
if ( item.type == 2 ) {
uni.pro.navigateTo('/pages/order_food/order_food', {
shopId: item.shopId
})
}
},
}

View File

@@ -6,7 +6,7 @@
<u-radio-group v-model="radiovalue" iconPlacement="right" @change="groupChange" :size="28"
placement="column">
<block v-for="(item,index) in paymentMethodList" :key="index">
<view class="method_list" @click="groupChange(index+1)">
<view class="method_list" @click="groupChange(item.type,item.name)">
<view class="method_list_top">
<view class="method_list_top_left">
<image class="icon" :src="item.url" mode="aspectFill"/>
@@ -18,7 +18,7 @@
</view>
</view>
</view>
<u-radio activeColor="#E8AD7B" icon-size="36" size="36" :name="index+1">
<u-radio activeColor="#E8AD7B" icon-size="36" size="36" :name="item.type">
</u-radio>
</view>
@@ -36,12 +36,12 @@
data() {
return {
paymentMethodList:[
{ name: "余额支付", type: "1", url: "https://czg-qr-order.oss-cn-beijing.aliyuncs.com/drder/wechat.png"},
{ 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"},
{ 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"},
{ name: "支付宝支付", type: 3, url: "https://czg-qr-order.oss-cn-beijing.aliyuncs.com/confirmOrder/alipay.png"},
// #endif
],
radiovalue: 1, // 支付方式
@@ -61,11 +61,11 @@
methods: {
/**
* 监听支付方式切换
* @param {Object} n
* @param {Object}
*/
groupChange(n) {
this.radiovalue = n;
this.$emit("groupChange",n)
groupChange(type,name) {
this.radiovalue = type;
this.$emit("groupChange",{type:type ,name:name })
},

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;

View File

@@ -8,9 +8,13 @@
<view class="title_tabNum">桌号A2</view>
</view>
<view class="num" :class="{'active':numIndex==-1}">
<view class="num_item" :class="{'active':numIndex==index }" @click="tabCut(index)" v-for="(item,index) in 9" :key="index">{{item+1}}</view>
<view class="item" @click="tabCut(index)" v-for="(item,index) in 9" :key="index">
<view class="num_item" :class="{'active':numIndex==index }">{{index+1}}</view>
</view>
<view class="item">
<u--input custom-class="num_item" v-model="otherNum" :class="{'active':numIndex==-1 }" @focus="tabCut(-1)" @blur="blur()" border="none" type="number" maxlength="3"></u--input>
</view>
<!-- <view class="num_item" v-else :class="{'active':numIndex==-1 }"></view> -->
<u--input custom-class="num_item" v-model="otherNum" :class="{'active':numIndex==-1 }" @focus="tabCut(-1)" @blur="blur()" border="none" type="number" maxlength="3"></u--input>
</view>
<view class="startBtn" @click="start">
开始点餐
@@ -109,7 +113,7 @@
z-index: 2;
display: flex;
flex-direction: column;
padding: 48rpx 32rpx 32rpx 32rpx;
padding: 48rpx 0 32rpx 32rpx;
background: #FFFFFF;
border-radius: 44rpx 44rpx 44rpx 44rpx;
.title{
@@ -117,6 +121,7 @@
align-items: center;
justify-content: space-between;
margin-bottom: 48rpx;
padding-right: 32rpx;
.title_text{
font-weight: bold;
font-size: 32rpx;
@@ -131,8 +136,12 @@
.num{
display: flex;
flex-wrap: wrap;
.item{
width: 20%;
padding-right: 32rpx;
}
.num_item{
width: 104rpx;
width: 100%;
height: 56rpx;
line-height: 56rpx;
text-align: center;
@@ -148,7 +157,7 @@
margin-right: 0;
}
::v-deep .u-input{
width: 104rpx;
width: 100%;
height: 56rpx;
line-height: 56rpx;
text-align: center;
@@ -159,9 +168,11 @@
}
::v-deep input{
font-weight: 400;
border-radius: 12rpx;
font-size: 28rpx!important;
color: #333333!important;
text-align: center!important;
background-color: #FEF4EB!important;
}
.active{
color: #fff;
@@ -170,7 +181,7 @@
}
::v-deep .num.active .u-input{
width: 104rpx;
width: 100%;
height: 56rpx;
line-height: 56rpx;
text-align: center;
@@ -180,6 +191,8 @@
}
::v-deep .num.active input{
color: #fff!important;
border-radius: 12rpx;
background-color: #E8AD7B!important;
}
}

View File

@@ -94,10 +94,9 @@
}
},
groupChange (n) {
console.log(n)
this.radiovalue = n;
this.paymentBtnText = n==1?'余额支付':'微信支付'
groupChange (e) {
this.radiovalue = e.type;
this.paymentBtnText = e.name;
},
/**
* 获取订单信息
@@ -133,14 +132,14 @@
* 去支付
*/
goToPay(){
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'
})
return;
}
if (this.radiovalue == 2) {
if (this.radiovalue == 2 || this.radiovalue == 3) {
this.wechatPay() //微信支付
} else {
// 先判断是否设置支付密码。0是没设置。没设置的情况下跳转到设置页面。有的话输入支付密码