商品券相关优化更新
This commit is contained in:
@@ -27,13 +27,15 @@
|
||||
</view>
|
||||
|
||||
<!-- 先下单后支付 -->
|
||||
<orderInfoAfter ref="orderInfoAfterRef" :amountVIP="amountVIP" :listinfo="listinfo" @setPayAmount="setPayAmount" v-if="listinfo.useType == 'dine-in-after'"></orderInfoAfter>
|
||||
<orderInfoAfter ref="orderInfoAfterRef" :amountVIP="amountVIP" :rechargeFreeChecked="rechargeFreeChecked" :freeCheck="freeCheck" :listinfo="listinfo" @setPayAmount="setPayAmount" v-if="listinfo.useType == 'dine-in-after'"></orderInfoAfter>
|
||||
<!-- 先支付后下单 -->
|
||||
<orderInfoBefore ref="orderInfoBefore" :listinfo="listinfo" v-else></orderInfoBefore>
|
||||
<!-- 积分兑换订单详情 -->
|
||||
<!-- <orderInfoPoints ref="orderInfoPoints" :listinfo="listinfo" ></orderInfoPoints> -->
|
||||
<!-- 充值免单 -->
|
||||
<rechargeFree v-if="listinfo.freeDingConfig.enable == 1&&(listinfo.status == 'unpaid' || listinfo.status == 'paying')" ref="rechargeFree" :freeDisabled="freeDisabled" :payAmount="listinfo.payAmount" :freeDingConfig="listinfo.freeDingConfig" :shopUserInfo="amountVIP" @changeFree="changeFree"></rechargeFree>
|
||||
|
||||
<paymentMethod ref="paymentMethod" v-if="amountVIP&&listinfo.status == 'unpaid' || listinfo.status == 'paying'" :amountVIP="amountVIP" @groupChange="groupChange"></paymentMethod>
|
||||
<paymentMethod ref="paymentMethod" v-if="amountVIP&&listinfo.status == 'unpaid' || listinfo.status == 'paying'" :freeCheck="freeCheck" :amountVIP="amountVIP" @groupChange="groupChange"></paymentMethod>
|
||||
|
||||
<view class="fixedview">
|
||||
<view class="flex-between" v-if="listinfo.status == 'unpaid' || listinfo.status == 'paying'">
|
||||
@@ -72,6 +74,7 @@
|
||||
import orderInfoAfter from '../components/orderInfoAfter.vue'
|
||||
import orderInfoBefore from '../components/orderInfoBefore.vue'
|
||||
import orderInfoPoints from '../components/orderInfoPoints.vue'
|
||||
import rechargeFree from '../components/rechargeFree.vue'
|
||||
import paymentMethod from '../components/paymentMethod.vue'
|
||||
export default {
|
||||
components: {
|
||||
@@ -79,6 +82,7 @@
|
||||
orderInfoAfter,
|
||||
orderInfoBefore,
|
||||
orderInfoPoints,
|
||||
rechargeFree,
|
||||
paymentMethod,
|
||||
},
|
||||
data() {
|
||||
@@ -93,6 +97,9 @@
|
||||
status: [],
|
||||
amountVIP: null,
|
||||
couopnInfo: null,
|
||||
freeDisabled: false,
|
||||
freeCheck: false,
|
||||
rechargeFreeChecked: false,
|
||||
srcimge: 'https://czg-qr-order.oss-cn-beijing.aliyuncs.com/wx.jpg'
|
||||
};
|
||||
},
|
||||
@@ -121,10 +128,66 @@
|
||||
console.log(e)
|
||||
},
|
||||
methods: {
|
||||
|
||||
setPayAmount(data) {
|
||||
console.log(data)
|
||||
// this.changeFree(this.freeDisabled)
|
||||
this.listinfo.payAmount = data.payAmount
|
||||
this.couopnInfo = data;
|
||||
this.freeDisabled = data.freeDisabled
|
||||
this.freeCheck = data.freeCheck
|
||||
if ( this.listinfo.payAmount < this.listinfo.freeDingConfig.rechargeThreshold ) {
|
||||
this.freeDisabled = true
|
||||
} else {
|
||||
this.freeDisabled = false
|
||||
}
|
||||
},
|
||||
/**
|
||||
* 免单状态监听
|
||||
* @param {Object} val
|
||||
*/
|
||||
changeFree ( val ) {
|
||||
this.freeCheck = val;
|
||||
this.rechargeFreeChecked = val
|
||||
if ( this.couopnInfo && val) {
|
||||
if ( this.couopnInfo.isPointsChecked ) {
|
||||
this.listinfo.payAmount = (Number(this.listinfo.payAmount)+(this.couopnInfo.calcUsablePointsData.pointsNum/this.couopnInfo.calcUsablePointsData.equivalentPoints)).toFixed(2);
|
||||
}
|
||||
let couponList = this.couopnInfo.userCouponInfos.filter(v => v.type == 1);
|
||||
if ( couponList.length > 0) {
|
||||
this.listinfo.payAmount = (couponList.length > 0 ? Number(this.listinfo.payAmount) + couponList[0].discountAmount : this.listinfo.payAmount)
|
||||
}
|
||||
let productList = this.couopnInfo.userCouponInfos.filter(v => v.type == 2);
|
||||
if ( productList .length > 0 ) {
|
||||
productList.map(item=> {
|
||||
|
||||
this.listinfo.payAmount = Number(this.listinfo.payAmount) + item.discountAmount
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ( val ) {
|
||||
this.listinfo.payAmount = (this.listinfo.payAmount*this.listinfo.freeDingConfig.rechargeTimes).toFixed(2)
|
||||
} else {
|
||||
this.listinfo.payAmount = (this.listinfo.payAmount/this.listinfo.freeDingConfig.rechargeTimes).toFixed(2)
|
||||
}
|
||||
|
||||
if ( this.couopnInfo && !val) {
|
||||
|
||||
let couponList = this.couopnInfo.userCouponInfos.filter(v => v.type == 1);
|
||||
if ( couponList.length > 0) {
|
||||
this.listinfo.payAmount = (couponList.length > 0 ? Number(this.listinfo.payAmount) - couponList[0].discountAmount : this.listinfo.payAmount)
|
||||
}
|
||||
let productList = this.couopnInfo.userCouponInfos.filter(v => v.type == 2);
|
||||
if ( productList .length > 0 ) {
|
||||
productList.map(item=> {
|
||||
this.listinfo.payAmount = Number(this.listinfo.payAmount) - item.discountAmount
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
console.log(this.freeCheck)
|
||||
},
|
||||
saveImage (url) {
|
||||
uni.saveImage({
|
||||
@@ -172,6 +235,10 @@
|
||||
if (this.listinfo.useType == " ") {
|
||||
//堂食先付费
|
||||
}
|
||||
if ( this.listinfo.payAmount < this.listinfo.freeDingConfig.rechargeThreshold ) {
|
||||
this.freeDisabled = true
|
||||
}
|
||||
console.log(this.listinfo)
|
||||
if ( this.listinfo.useType == "dine-in-after") {
|
||||
this.$nextTick(()=>{
|
||||
this.$refs.orderInfoAfterRef.childOnShow();
|
||||
@@ -193,7 +260,7 @@
|
||||
/**
|
||||
* 去支付
|
||||
*/
|
||||
goToPay(){
|
||||
async goToPay(){
|
||||
if ( (this.radiovalue == 2 || this.radiovalue == 3) && this.listinfo.payAmount <= 0 ) {
|
||||
uni.showToast({
|
||||
title: "支付金额必须大于0",
|
||||
@@ -201,6 +268,18 @@
|
||||
})
|
||||
return;
|
||||
}
|
||||
if ( this.couopnInfo ) {
|
||||
let params = {
|
||||
shopId: this.listinfo.shopId,
|
||||
orderId: this.listinfo.orderId,
|
||||
userCouponInfos: this.couopnInfo.userCouponInfos,
|
||||
}
|
||||
if ( this.couopnInfo.isPointsChecked && this.couopnInfo.calcUsablePointsData.pointsNum && this.couopnInfo.calcUsablePointsData.pointsNum > 0) {
|
||||
params.pointsNum = this.couopnInfo.calcUsablePointsData.pointsNum;
|
||||
}
|
||||
let res = await this.api.useCoupon(params)
|
||||
}
|
||||
|
||||
if (this.radiovalue == 2 || this.radiovalue == 3) {
|
||||
this.wechatPay() //微信支付
|
||||
} else {
|
||||
@@ -245,7 +324,6 @@
|
||||
if (res.data == 1) {
|
||||
uni.showToast({ title: "支付成功",icon:'none'})
|
||||
let _this = this
|
||||
|
||||
uni.requestSubscribeMessage({
|
||||
tmplIds:["z0fUG7-jhSfYCrw6poOvSRzh4_hgnPkm_5C7E5s5bCQ","AV-KybUHaK3KtFVLqpy6PHccHBS7XeX__mOM4RbufnQ"],
|
||||
complete() {
|
||||
@@ -254,7 +332,6 @@
|
||||
});
|
||||
},
|
||||
})
|
||||
|
||||
} else if (res.data == 2) {
|
||||
uni.showToast({ title: "余额不足",icon:'none'})
|
||||
setTimeout(() => {
|
||||
@@ -285,15 +362,34 @@
|
||||
* 微信支付
|
||||
*/
|
||||
async wechatPay() {
|
||||
let res = await this.api.orderPay({
|
||||
orderId: this.orderId,
|
||||
// #ifdef MP-WEIXIN
|
||||
payType: 'wechatPay',
|
||||
// #endif
|
||||
// #ifdef MP-ALIPAY
|
||||
payType: 'aliPay',
|
||||
// #endif
|
||||
}) //判断是否支付成功
|
||||
let res;
|
||||
console.log(this.freeCheck)
|
||||
if ( !this.freeCheck ) {
|
||||
res = await this.api.orderPay({
|
||||
orderId: this.orderId,
|
||||
// #ifdef MP-WEIXIN
|
||||
payType: 'wechatPay',
|
||||
// #endif
|
||||
// #ifdef MP-ALIPAY
|
||||
payType: 'aliPay',
|
||||
// #endif
|
||||
// payType: this.radiovalue == 2 ? 'wechatPay' : 'aliPay'
|
||||
}) //判断是否支付成功
|
||||
} else {
|
||||
console.log(this.listinfo.payAmount)
|
||||
res = await this.api.paymemeberIn({
|
||||
shopId: uni.cache.get('shopId'),
|
||||
amount: this.listinfo.payAmount,
|
||||
orderld: this.orderId,
|
||||
// #ifdef MP-WEIXIN
|
||||
payType: 'wechatPay',
|
||||
// #endif
|
||||
// #ifdef MP-ALIPAY
|
||||
payType: 'aliPay',
|
||||
// #endif
|
||||
// payType: this.radiovalue == 2 ? 'wechatPay' : 'aliPay'
|
||||
}) //判断是否支付成功
|
||||
}
|
||||
if (res.code == 0) {
|
||||
uni.showLoading({
|
||||
title: '加载中',
|
||||
@@ -369,16 +465,6 @@
|
||||
let res = await this.api.paymodfiyOrderInfo({
|
||||
orderId: this.listinfo.orderId,
|
||||
})
|
||||
// this.couopnInfo
|
||||
let params = {
|
||||
shopId: this.listinfo.shopId,
|
||||
orderId: this.listinfo.orderId,
|
||||
userCouponInfos: this.couopnInfo.userCouponInfos,
|
||||
}
|
||||
if ( this.couopnInfo.isPointsChecked && this.couopnInfo.calcUsablePointsData.pointsNum && this.couopnInfo.calcUsablePointsData.pointsNum > 0) {
|
||||
params.pointsNum = this.couopnInfo.calcUsablePointsData.pointsNum;
|
||||
}
|
||||
let ress = await this.api.useCoupon(params)
|
||||
},
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user