优惠券相关更新
This commit is contained in:
@@ -235,6 +235,7 @@
|
||||
}
|
||||
let isNum = 0;
|
||||
let isProductItem;
|
||||
|
||||
// 确认订单
|
||||
if ( this.type == 'confirm_order_product' ) {
|
||||
product.forEach(item => {
|
||||
@@ -245,6 +246,7 @@
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
if ( this.payAmount < (isProductItem.memberPrice > 0 ? isProductItem.memberPrice : isProductItem.salePrice)) {
|
||||
uni.showToast({
|
||||
title: `当前金额不足商品抵扣`,
|
||||
@@ -264,6 +266,7 @@
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
if ( this.payAmount < (isProductItem.memberPrice > 0 ? isProductItem.memberPrice : isProductItem.price)) {
|
||||
uni.showToast({
|
||||
title: `当前金额不足商品抵扣`,
|
||||
@@ -273,7 +276,13 @@
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ( !isProductItem ) {
|
||||
uni.showToast({
|
||||
title: `当前订单无可抵扣商品`,
|
||||
icon: "none",
|
||||
})
|
||||
return;
|
||||
}
|
||||
// let productNum = 0;
|
||||
// product.map(item => {
|
||||
// productNum += item.number
|
||||
|
||||
@@ -234,6 +234,57 @@
|
||||
this.payAmount = this.listinfo.payAmount;
|
||||
uni.cache.set('selectCouponData',[])
|
||||
this.isShow = true;
|
||||
console.log(this.listinfo.orderInfo.couponInfoList)
|
||||
if ( this.listinfo.orderInfo.couponInfoList ) {
|
||||
if ( this.listinfo.orderInfo.couponInfoList.fullReductionCoupon.length > 0) {
|
||||
let couponData = this.listinfo.orderInfo.couponInfoList.fullReductionCoupon[0]
|
||||
this.favorable[0].value = '-¥'+couponData.discountAmount
|
||||
this.payAmount = this.payAmount + couponData.discountAmount
|
||||
this.userCouponInfos.push({
|
||||
userCouponId: couponData.id,
|
||||
type: couponData.type,
|
||||
discountAmount: couponData.discountAmount,
|
||||
num: couponData.num,
|
||||
})
|
||||
let selectCouponData = uni.cache.get('selectCouponData') || [];
|
||||
selectCouponData.push(couponData)
|
||||
uni.cache.set('selectCouponData',selectCouponData)
|
||||
}
|
||||
if ( this.listinfo.orderInfo.couponInfoList.productCoupon.length > 0) {
|
||||
this.listinfo.orderInfo.couponInfoList.productCoupon.map(item=>{
|
||||
this.userCouponInfos.push({
|
||||
userCouponId: item.id,
|
||||
type: item.type,
|
||||
productId: item.proId,
|
||||
discountAmount: item.finalDiscountAmount,
|
||||
num: item.finalUseNum,
|
||||
})
|
||||
this.favorable[1].value.push({
|
||||
userCouponId: item.id,
|
||||
name: item.name,
|
||||
type: item.type,
|
||||
productId: item.proId,
|
||||
discountAmount: item.finalDiscountAmount,
|
||||
num: item.finalUseNum,
|
||||
})
|
||||
this.payAmount = this.payAmount + item.finalDiscountAmount
|
||||
let selectCouponData = uni.cache.get('selectCouponData') || [];
|
||||
selectCouponData.push(item)
|
||||
uni.cache.set('selectCouponData',selectCouponData)
|
||||
})
|
||||
|
||||
}
|
||||
}
|
||||
if ( this.listinfo.orderInfo.pointsDiscountAmount ) {
|
||||
this.payAmount = this.payAmount + this.listinfo.orderInfo.pointsDiscountAmount
|
||||
this.isPointsChecked = true;
|
||||
}
|
||||
this.$emit("setPayAmount",{
|
||||
payAmount: this.listinfo.payAmount,
|
||||
userCouponInfos: this.userCouponInfos,
|
||||
freeCheck: this.freeCheck,
|
||||
isPointsChecked: this.isPointsChecked,
|
||||
})
|
||||
},
|
||||
methods: {
|
||||
childOnShow() {
|
||||
@@ -248,6 +299,8 @@
|
||||
this.listinfo.payAmount = this.payAmount
|
||||
this.selectCouponData = uni.cache.get('selectCouponData') || []
|
||||
this.changeCoupon();
|
||||
|
||||
|
||||
},
|
||||
/**
|
||||
* 监听优惠券/商品券选择
|
||||
@@ -259,7 +312,6 @@
|
||||
let couponList = this.selectCouponData.filter(v => v.type == 1);
|
||||
// 商品券列表
|
||||
let productList = this.selectCouponData.filter(v => v.type == 2);
|
||||
|
||||
// 优惠券处理
|
||||
if ( couponList.length > 0 ) {
|
||||
let couponData = couponList[0]
|
||||
@@ -302,22 +354,24 @@
|
||||
if ( productList.length > 0 ) {
|
||||
//商品券使用数量
|
||||
|
||||
// 商品数量
|
||||
let productAllNum = 0;
|
||||
|
||||
productList.map((item,index)=>{
|
||||
// 筛选选中商品券商品列表
|
||||
let productDetails = this.listinfo.details.filter(v => v.productId == item.proId);
|
||||
//金额从小到大排序
|
||||
let minCouponList = productDetails.sort((a, b) => (a.memberPrice > 0 ? a.memberPrice : a.salePrice) - (b.memberPrice > 0 ? b.memberPrice : b.salePrice))
|
||||
let productNum = 0;
|
||||
let productPayAmount = 0;
|
||||
let productDetailsNum = 0;
|
||||
productDetails.map((v,indexs) => {
|
||||
productDetailsNum += v.num;
|
||||
})
|
||||
|
||||
// 商品数量
|
||||
let productAllNum = 0;
|
||||
let productNum = 0
|
||||
let productPayAmount = 0
|
||||
minCouponList.map((v,indexs) => {
|
||||
productNum = 0;
|
||||
productPayAmount = 0;
|
||||
let productDetailsNum = 0;
|
||||
productDetails.map((v,indexs) => {
|
||||
productDetailsNum += v.num;
|
||||
})
|
||||
console.log(minCouponList)
|
||||
for (let i = 0; i < v.num; i++){
|
||||
if ( productAllNum < productDetailsNum && productNum < item.num && ((v.memberPrice > 0 ? v.memberPrice : v.price) <= (this.listinfo.payAmount - productPayAmount) )) {
|
||||
productNum++
|
||||
@@ -357,7 +411,6 @@
|
||||
let tableFee;
|
||||
// this.storeInfo.registerType == 'munchies'
|
||||
|
||||
|
||||
if ( this.userCouponInfos.length > 0 ) {
|
||||
console.log(this.userCouponInfos)
|
||||
this.userCouponInfos.forEach(item => {
|
||||
@@ -368,8 +421,6 @@
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
this.isPointsChecked = false;
|
||||
this.getCalcUsablePoints()
|
||||
this.$emit("setPayAmount",{
|
||||
@@ -393,7 +444,6 @@
|
||||
} else {
|
||||
this.listinfo.payAmount = (Number(this.listinfo.payAmount)+(this.calcUsablePointsData.pointsNum/this.calcUsablePointsData.equivalentPoints)).toFixed(2);
|
||||
}
|
||||
console.log(this.listinfo.payAmount)
|
||||
this.$emit("setPayAmount",{
|
||||
payAmount: this.listinfo.payAmount,
|
||||
userCouponInfos: this.userCouponInfos,
|
||||
@@ -444,7 +494,11 @@
|
||||
async getCalcUsablePoints() {
|
||||
let params = {
|
||||
memberId: this.listinfo.orderInfo.memberId,
|
||||
orderAmount: this.listinfo.payAmount,
|
||||
}
|
||||
if ( this.listinfo.orderInfo.pointsDiscountAmount ) {
|
||||
params.orderAmount = this.listinfo.payAmount + this.listinfo.orderInfo.pointsDiscountAmount
|
||||
} else {
|
||||
params.orderAmount = this.listinfo.payAmount
|
||||
}
|
||||
let res = await this.api.calcUsablePoints(params)
|
||||
this.calcUsablePointsData = res.data;
|
||||
|
||||
@@ -91,8 +91,8 @@
|
||||
<view>{{listinfo.orderInfo.seatAmount}}</view>
|
||||
</view>
|
||||
</view>
|
||||
<block v-for="(item,index) in listinfo.orderInfo.couponInfoList.fullReductionCoupon" :key="index">
|
||||
<view class="cell-item" v-if="item.type == 1">
|
||||
<block v-if="listinfo.orderInfo&&listinfo.orderInfo.couponInfoList && listinfo.orderInfo.couponInfoList.fullReductionCoupon">
|
||||
<view class="cell-item" v-for="(item,index) in listinfo.orderInfo.couponInfoList.fullReductionCoupon" :key="index">
|
||||
<view class="label">优惠券</view>
|
||||
<view class="val">
|
||||
<view></view>
|
||||
@@ -101,7 +101,7 @@
|
||||
</view>
|
||||
</view>
|
||||
</block>
|
||||
<view class="cell-item column" v-if="listinfo.orderInfo&&listinfo.orderInfo.couponInfoList && listinfo.orderInfo.couponInfoList.productCoupon.length > 0">
|
||||
<view class="cell-item column" v-if="listinfo.orderInfo&&listinfo.orderInfo.couponInfoList && listinfo.orderInfo.couponInfoList.productCoupon">
|
||||
<view class="label">商品券</view>
|
||||
<view class="val column">
|
||||
<view class="productCoupon" v-for="(item,index) in listinfo.orderInfo.couponInfoList.productCoupon" :key="index">
|
||||
|
||||
@@ -362,26 +362,27 @@
|
||||
if ( productList.length > 0 ) {
|
||||
//商品券使用数量
|
||||
|
||||
// 商品数量
|
||||
let productAllNum = 0;
|
||||
|
||||
|
||||
productList.map((item,index)=>{
|
||||
// 筛选选中商品券商品列表
|
||||
let productDetails = this.listinfo.details.filter(v => v.productId == item.proId);
|
||||
//金额从小到大排序
|
||||
let minCouponList = productDetails.sort((a, b) => (a.memberPrice > 0 ? a.memberPrice : a.salePrice) - (b.memberPrice > 0 ? b.memberPrice : b.salePrice))
|
||||
// 商品数量
|
||||
let productAllNum = 0;
|
||||
let productNum = 0;
|
||||
let productPayAmount = 0;
|
||||
let productDetailsNum = 0;
|
||||
productDetails.map((v,indexs) => {
|
||||
productDetailsNum += v.number;
|
||||
})
|
||||
|
||||
|
||||
minCouponList.map((v,indexs) => {
|
||||
productNum = 0;
|
||||
productPayAmount = 0;
|
||||
let productDetailsNum = 0;
|
||||
productDetails.map((v,indexs) => {
|
||||
productDetailsNum += v.number;
|
||||
})
|
||||
for (let i = 0; i < v.number; i++){
|
||||
if ( ((v.memberPrice > 0 ? v.memberPrice : v.salePrice) < (this.listinfo.payAmount - productPayAmount) ) ){
|
||||
|
||||
}
|
||||
if ( productAllNum < productDetailsNum && productNum < item.num && ((v.memberPrice > 0 ? v.memberPrice : v.salePrice) <= (this.listinfo.payAmount - productPayAmount) )) {
|
||||
productNum++
|
||||
productAllNum++
|
||||
|
||||
@@ -31,13 +31,25 @@
|
||||
<!-- 先支付后下单 -->
|
||||
<orderInfoBefore ref="orderInfoBefore" :listinfo="listinfo" v-else></orderInfoBefore>
|
||||
<!-- 充值免单 -->
|
||||
<rechargeFree
|
||||
:rechargeFreeChecked="rechargeFreeChecked"
|
||||
v-if="listinfo.freeDingConfig.enable == 1&&(!listinfo.orderInfo.couponInfoList&&listinfo.orderInfo.pointsDiscountAmount<=0)&&(listinfo.status == 'unpaid' || listinfo.status == 'paying')"
|
||||
ref="rechargeFree"
|
||||
:freeDisabled="freeDisabled"
|
||||
:payAmount="listinfo.payAmount"
|
||||
:freeDingConfig="listinfo.freeDingConfig" :shopUserInfo="amountVIP" @changeFree="changeFree"></rechargeFree>
|
||||
<block v-if="listinfo.useType == 'dine-in-after'">
|
||||
<rechargeFree
|
||||
:rechargeFreeChecked="rechargeFreeChecked"
|
||||
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>
|
||||
</block>
|
||||
<block v-else>
|
||||
<rechargeFree
|
||||
:rechargeFreeChecked="rechargeFreeChecked"
|
||||
v-if="listinfo.freeDingConfig.enable == 1&&(!listinfo.orderInfo.couponInfoList&&listinfo.orderInfo.pointsDiscountAmount<=0)&&(listinfo.status == 'unpaid' || listinfo.status == 'paying')"
|
||||
ref="rechargeFree"
|
||||
:freeDisabled="freeDisabled"
|
||||
:payAmount="listinfo.payAmount"
|
||||
:freeDingConfig="listinfo.freeDingConfig" :shopUserInfo="amountVIP" @changeFree="changeFree"></rechargeFree>
|
||||
|
||||
</block>
|
||||
|
||||
<paymentMethod ref="paymentMethod" :rechargeFreeChecked="rechargeFreeChecked" v-if="amountVIP&&listinfo.status == 'unpaid' || listinfo.status == 'paying'" :freeCheck="freeCheck" :payAmount="listinfo.payAmount" :amountVIP="amountVIP" @groupChange="groupChange"></paymentMethod>
|
||||
|
||||
@@ -55,10 +67,10 @@
|
||||
</view>
|
||||
</view>
|
||||
<view style="width: 100%;height: 200rpx;"> </view>
|
||||
<u-popup :show="ispws" :round="20" mode="bottom" @close="ispws = false" height="500" :safeAreaInsetBottom="false">
|
||||
<u-popup :show="ispws" :round="20" mode="bottom" @close="payClose" height="500" :safeAreaInsetBottom="false">
|
||||
<view class="pay-info-wrap">
|
||||
<view class="info-wrap flex-between">
|
||||
<view class="close" @click="ispws = false">
|
||||
<view class="close" @click="payClose">
|
||||
<u-icon name="close" color="#999999" size="40"></u-icon>
|
||||
</view>
|
||||
<text class="title">请输入支付密码</text>
|
||||
@@ -102,7 +114,8 @@
|
||||
freeDisabled: false,
|
||||
freeCheck: false,
|
||||
rechargeFreeChecked: false,
|
||||
srcimge: 'https://czg-qr-order.oss-cn-beijing.aliyuncs.com/wx.jpg'
|
||||
srcimge: 'https://czg-qr-order.oss-cn-beijing.aliyuncs.com/wx.jpg',
|
||||
|
||||
};
|
||||
},
|
||||
onLoad(e) {
|
||||
@@ -114,8 +127,8 @@
|
||||
this.$nextTick(()=>{
|
||||
this.$refs.orderInfoAfterRef.childOnShow();
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
},
|
||||
onUnload() {
|
||||
this.ispws = false
|
||||
@@ -132,7 +145,7 @@
|
||||
methods: {
|
||||
|
||||
setPayAmount(data) {
|
||||
// this.changeFree(this.freeDisabled)
|
||||
console.log(data)
|
||||
this.listinfo.payAmount = data.payAmount
|
||||
this.couopnInfo = data;
|
||||
this.freeDisabled = data.freeDisabled
|
||||
@@ -142,6 +155,7 @@
|
||||
} else {
|
||||
this.freeDisabled = false
|
||||
}
|
||||
|
||||
},
|
||||
/**
|
||||
* 免单状态监听
|
||||
@@ -251,7 +265,17 @@
|
||||
this.getAount();
|
||||
}
|
||||
|
||||
|
||||
let params = {
|
||||
userId: uni.cache.get('userInfo').id,
|
||||
status: 1,
|
||||
orderId: -1,
|
||||
shopId: this.shopId
|
||||
}
|
||||
console.log("params",params)
|
||||
let ress = await this.api.conponList(params)
|
||||
if (ress.code == 0) {
|
||||
let list = ress.data;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -310,13 +334,29 @@
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* 取消支付
|
||||
*/
|
||||
payClose () {
|
||||
this.ispws = false;
|
||||
console.log(2)
|
||||
uni.showToast({
|
||||
icon: 'none',
|
||||
title: '取消支付'
|
||||
})
|
||||
setTimeout(res => {
|
||||
uni.switchTab({
|
||||
url: '/pages/order/order'
|
||||
});
|
||||
}, 500)
|
||||
},
|
||||
|
||||
/**
|
||||
* 余额支付
|
||||
* @param {Object} pwd
|
||||
*/
|
||||
async accountPayevent(pwd) {
|
||||
this.ispws = false;
|
||||
console.log(pwd)
|
||||
let res = await this.api.accountPay({
|
||||
orderId: this.listinfoid,
|
||||
memberId: this.amountVIP.id,
|
||||
|
||||
Reference in New Issue
Block a user