优惠券相关修改更新
This commit is contained in:
@@ -80,7 +80,7 @@
|
||||
<view>{{packFee.toFixed(2)}}</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="cell-item" v-if="shopTableInfo&&shopTableInfo.seatNum&&sendType=='table'">
|
||||
<view class="cell-item" v-if="shopTableInfo&&shopTableInfo.seatNum&&sendType=='table'&&storeInfo.registerType == 'munchies'">
|
||||
<view class="label">餐位费</view>
|
||||
<view class="val">
|
||||
<view>X{{shopTableInfo.seatNum}}</view>
|
||||
@@ -88,20 +88,25 @@
|
||||
<view>{{(shopTableInfo.seatNum*storeInfo.tableFee).toFixed(2)}}</view>
|
||||
</view>
|
||||
</view>
|
||||
<view v-for="(item,index) in favorable" :key="index" >
|
||||
<view class="favorable" v-if="item.type!='points'" @click="goUrl(item)">
|
||||
<view v-for="(item,index) in favorable" :key="index" v-if="storeInfo.registerType == 'munchies'">
|
||||
<view class="favorable" :class="{column:item.value.length>0&&item.type=='product'}" @click="goUrl(item)">
|
||||
<view class="favorable_left">
|
||||
<image class="icon" :src="item.url" mode="aspectFill"/>
|
||||
<!-- <image class="icon" :src="item.url" mode="aspectFill"/> -->
|
||||
<text class="name"> {{ item.name }} </text>
|
||||
</view>
|
||||
<view class="favorable_right" ><text class="favorable_right_text">{{item.value}}</text> <u-icon name="arrow-right" color="#575B66" size="28"></u-icon></view>
|
||||
</view>
|
||||
<view class="favorable" v-else-if="item.type=='points'">
|
||||
<view class="favorable_left">
|
||||
<image class="icon" :src="item.url" mode="aspectFill"/>
|
||||
<text class="name"> {{ item.name }} </text>
|
||||
<view class="favorable_right" v-if="item.type=='coupon'">
|
||||
<text class="favorable_right_text">{{item.value}}</text>
|
||||
<u-icon name="arrow-right" color="#575B66" size="28"></u-icon>
|
||||
</view>
|
||||
<view class="favorable_right" @click.stop="pointsChange">
|
||||
<view class="favorable_right" :class="{column:item.value.length>0}" v-if="item.type=='product'">
|
||||
<view class="favorable_right_text" v-for="(items,indexs) in item.value" :key="indexs">
|
||||
<text>{{items.name}}</text>
|
||||
<text>X{{items.num}}</text>
|
||||
<text>-¥{{items.discountAmount || 0}}</text>
|
||||
</view>
|
||||
<u-icon v-if="item.value.length <= 0" name="arrow-right" color="#575B66" size="28"></u-icon>
|
||||
</view>
|
||||
<view class="favorable_right" v-if="item.type=='points'" @click.stop="pointsChange">
|
||||
<text class="favorable_right_text" style="color: #666;margin-right: 16rpx;" v-if="calcUsablePointsData.usable">
|
||||
使用 {{ calcUsablePointsData.pointsNum}} 积分抵扣¥{{calcUsablePointsData.pointsNum/calcUsablePointsData.equivalentPoints}}
|
||||
</text>
|
||||
@@ -115,6 +120,7 @@
|
||||
</u-checkbox-group>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
</view>
|
||||
|
||||
<view class="totalPrice">
|
||||
@@ -207,6 +213,7 @@
|
||||
eatModel: [],
|
||||
favorable: [
|
||||
{ name: "优惠券", type: "coupon",value: "", url: "https://czg-qr-order.oss-cn-beijing.aliyuncs.com/confirmOrder/coupon.png"},
|
||||
{ name: "商品券", type: "product",value: [], url: "https://czg-qr-order.oss-cn-beijing.aliyuncs.com/confirmOrder/coupon.png"},
|
||||
// { name: "团购优惠", type: "group",value: "", url: "https://czg-qr-order.oss-cn-beijing.aliyuncs.com/confirmOrder/groupOffer.png"},
|
||||
{ name: "积分抵扣", type: "points",value: "", url: "https://czg-qr-order.oss-cn-beijing.aliyuncs.com/confirmOrder/points.png" }
|
||||
],
|
||||
@@ -216,7 +223,7 @@
|
||||
order: {
|
||||
phone: "",
|
||||
},
|
||||
userCouponInfos: null,
|
||||
userCouponInfos: [],
|
||||
shopTableInfo: null,
|
||||
freeDingConfig: null,
|
||||
cartLists: [],
|
||||
@@ -294,33 +301,107 @@
|
||||
if ( this.storeInfo.eatModel.indexOf(item.val) != -1) {
|
||||
item.show = true;
|
||||
}
|
||||
})
|
||||
uni.$on('couponItem',function(data){
|
||||
})
|
||||
uni.$on('couponItem',this.changeCoupon)
|
||||
},
|
||||
methods: {
|
||||
/**
|
||||
* 监听优惠券/商品券选择
|
||||
* @param {Object} data
|
||||
*/
|
||||
changeCoupon ( data ) {
|
||||
let _this = this;
|
||||
// uni.$off('couponItem')
|
||||
let couponData = JSON.parse(data)
|
||||
console.log('监听到事件来自返回的参数:' , couponData);
|
||||
_this.userCouponInfos = {
|
||||
userCouponId: couponData.id,
|
||||
discountAmount: couponData.discountAmount,
|
||||
num: 1,
|
||||
}
|
||||
console.log('监听到事件来自返回的参数:' , _this.favorable);
|
||||
if ( couponData.discountAmount < _this.listinfo.payAmount) {
|
||||
_this.listinfo.payAmount = _this.listinfo.payAmount - _this.userCouponInfos.discountAmount
|
||||
_this.favorable[0].value = ('-¥'+couponData.discountAmount)
|
||||
if ( couponData.type == 1 ) { //满减优惠券
|
||||
let couponList = _this.userCouponInfos.filter(v => v.type == 1);
|
||||
//不包含优惠券的金额
|
||||
let currentPayAmount = (couponList.length > 0 ? _this.listinfo.payAmount + couponList[0].discountAmount : _this.listinfo.payAmount)
|
||||
// 判断优惠金额不能大于支付金额
|
||||
if ( couponData.discountAmount < currentPayAmount) {
|
||||
_this.listinfo.payAmount = ( currentPayAmount - couponData.discountAmount).toFixed(2)
|
||||
_this.favorable[0].value = ('-¥'+couponData.discountAmount)
|
||||
if ( couponList.length > 0) {
|
||||
_this.userCouponInfos.map(item => {
|
||||
if ( item.type == 1 ) {
|
||||
item.userCouponId = couponData.id
|
||||
item.type = couponData.type
|
||||
item.discountAmount = couponData.discountAmount
|
||||
item.num = couponData.type == 1 ? 1 : couponData.num
|
||||
}
|
||||
})
|
||||
} else {
|
||||
_this.favorable[0].value = ('-¥'+couponData.discountAmount)
|
||||
_this.userCouponInfos.push({
|
||||
userCouponId: couponData.id,
|
||||
type: couponData.type,
|
||||
discountAmount: couponData.discountAmount,
|
||||
num: couponData.type == 1 ? 1 : couponData.num,
|
||||
})
|
||||
}
|
||||
if ( _this.isPointsChecked) {
|
||||
_this.pointsChange()
|
||||
_this.getCalcUsablePoints()
|
||||
}
|
||||
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: "优惠券满减金额大于订单金额不可使用",
|
||||
icon: "none",
|
||||
})
|
||||
}
|
||||
} else { //商品券
|
||||
// this.listinfo.details
|
||||
// 筛选选中商品券商品列表
|
||||
let couponList = _this.listinfo.details.filter(v => v.productId == couponData.proId);
|
||||
//金额从小到大排序
|
||||
let minCouponList = couponList.sort((a, b) => (a.memberPrice > 0 ? a.memberPrice : a.salePrice) - (b.memberPrice > 0 ? b.memberPrice : b.salePrice))
|
||||
let productTicketList = _this.userCouponInfos.filter(v => v.productId == couponData.proId);
|
||||
//商品券抵扣的数量
|
||||
let productNum = couponData.num;
|
||||
let productPayAmount = 0;
|
||||
let productTicketNum = 0;
|
||||
let productNumber = 0;
|
||||
productTicketList.map((item,index) => {
|
||||
productTicketNum += item.num
|
||||
})
|
||||
console.log(productTicketNum)
|
||||
minCouponList.map((item,index) => {
|
||||
productNumber += item.number
|
||||
if ( productNum > 0 && productNumber > productTicketNum) {
|
||||
let num = productNum >= item.number ? item.number : productNum
|
||||
productNum = (productNum - item.number) >= 0 ? (productNum - item.number) : 0;
|
||||
console.log(num)
|
||||
console.log(item.salePrice)
|
||||
productPayAmount = productPayAmount + (num*(item.memberPrice > 0 ? item.memberPrice : item.salePrice))
|
||||
}
|
||||
})
|
||||
console.log(minCouponList)
|
||||
_this.userCouponInfos.push({
|
||||
userCouponId: couponData.id,
|
||||
type: couponData.type,
|
||||
productId: couponData.proId,
|
||||
discountAmount: productPayAmount,
|
||||
num: productNum == 0 ? couponData.num : (couponData.num - productNum),
|
||||
})
|
||||
_this.favorable[1].value.push({
|
||||
userCouponId: couponData.id,
|
||||
name: couponData.name,
|
||||
type: couponData.type,
|
||||
productId: couponData.proId,
|
||||
discountAmount: productPayAmount,
|
||||
num: productNum == 0 ? couponData.num : (couponData.num - productNum),
|
||||
})
|
||||
|
||||
if ( _this.isPointsChecked) {
|
||||
_this.pointsChange()
|
||||
_this.getCalcUsablePoints()
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
}
|
||||
// TODO 下面执行刷新的方法
|
||||
})
|
||||
},
|
||||
methods: {
|
||||
uni.$off('couponItem')
|
||||
},
|
||||
setPayAmount ( cartLists ) {
|
||||
console.log(cartLists)
|
||||
let tableFee;
|
||||
if ( this.is_type == 0 ) {
|
||||
tableFee = this.shopTableInfo?(this.shopTableInfo.seatNum*this.storeInfo.tableFee):0
|
||||
@@ -332,6 +413,22 @@
|
||||
} else {
|
||||
this.listinfo.payAmount = (cartLists.amount+tableFee).toFixed(2)
|
||||
}
|
||||
if ( this.userCouponInfos.length > 0 ) {
|
||||
console.log(this.userCouponInfos)
|
||||
this.userCouponInfos.forEach(item => {
|
||||
if ( item.type == 1 ) {
|
||||
if ( item.discountAmount && item.discountAmount > 0 ) {
|
||||
this.listinfo.payAmount = (this.listinfo.payAmount - item.discountAmount).toFixed(2)
|
||||
}
|
||||
} else {
|
||||
if ( item.discountAmount && item.discountAmount > 0 ) {
|
||||
this.listinfo.payAmount = (this.listinfo.payAmount - item.discountAmount).toFixed(2)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
this.isPointsChecked = false;
|
||||
this.getCalcUsablePoints()
|
||||
},
|
||||
@@ -369,10 +466,27 @@
|
||||
goUrl(item){
|
||||
switch (item.type){
|
||||
case 'coupon':
|
||||
let payAmount = this.listinfo.payAmount;
|
||||
let couponList = this.userCouponInfos.filter(v => v.type == 1);
|
||||
if ( couponList.length > 0 ) {
|
||||
payAmount = payAmount + couponList.discountAmount;
|
||||
}
|
||||
uni.pro.navigateTo('/pages/user/coupon', {
|
||||
type: "confirm_order"
|
||||
type: "confirm_order_coupon",
|
||||
payAmount: payAmount,
|
||||
shoppingCart: JSON.stringify(this.listinfo.details)
|
||||
})
|
||||
break;
|
||||
case 'product':
|
||||
let productList = this.userCouponInfos.filter(v => v.type == 2);
|
||||
uni.pro.navigateTo('/pages/user/coupon', {
|
||||
type: "confirm_order_product",
|
||||
payAmount: this.listinfo.payAmount,
|
||||
shoppingCart: JSON.stringify(this.listinfo.details),
|
||||
productList: JSON.stringify(productList)
|
||||
})
|
||||
break;
|
||||
|
||||
|
||||
}
|
||||
},
|
||||
@@ -390,7 +504,6 @@
|
||||
if ( this.calcUsablePointsData.usable && this.listinfo.payAmount >= this.calcUsablePointsData.minPaymentAmount) {
|
||||
this.calcUsablePointsData.pointsNum = this.calcUsablePointsData.accountPoints >= this.calcUsablePointsData.maxUsablePoints ? this.calcUsablePointsData.maxUsablePoints : this.calcUsablePointsData.accountPoints
|
||||
}
|
||||
console.log(this.calcUsablePointsData)
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -421,7 +534,6 @@
|
||||
lat: uni.cache.get('getLocationstorage').lat ? uni.cache.get('getLocationstorage').lat :
|
||||
'',
|
||||
}
|
||||
console.log(this.shopId)
|
||||
if (this.tableCode) {params.code = this.tableCode}
|
||||
if (this.shopId) {params.shopId = this.shopId}
|
||||
let res = await this.api.productqueryShop(params)
|
||||
@@ -552,7 +664,6 @@
|
||||
if ( this.shopTableInfo && this.shopTableInfo.seatNum ) { params.num = this.shopTableInfo.seatNum; }
|
||||
let res = await this.api.choseEatModel(params)
|
||||
|
||||
console.log(index)
|
||||
if ( type == 'tabClick') {
|
||||
if ( index == 1 ) {
|
||||
if ( res.data.info.length > 0) {
|
||||
@@ -697,7 +808,6 @@
|
||||
params.userCouponInfos = this.userCouponInfos
|
||||
}
|
||||
let res = await this.api.creatOrder(params)
|
||||
console.log(res)
|
||||
this.listinfoid = res.data.id;
|
||||
if ( this.storeInfo.registerType == 'restaurant') {
|
||||
uni.redirectTo({
|
||||
@@ -1274,7 +1384,9 @@
|
||||
justify-content: space-between;
|
||||
padding: 0 30rpx;
|
||||
box-sizing: border-box;
|
||||
margin-bottom: 32rpx;
|
||||
padding-bottom: 26rpx;
|
||||
padding-top: 26rpx;
|
||||
border-bottom: 2rpx solid #E5E5E5;
|
||||
.favorable_left{
|
||||
display: flex;
|
||||
align-items: center;
|
||||
@@ -1299,6 +1411,30 @@
|
||||
}
|
||||
|
||||
}
|
||||
.favorable_right.column{
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
.favorable_right_text{
|
||||
margin-bottom: 10rpx;
|
||||
text:nth-child(1){
|
||||
font-size: 26rpx;
|
||||
color: #999;
|
||||
}
|
||||
text:nth-child(2){
|
||||
font-size: 26rpx;
|
||||
color: #999;
|
||||
margin: 0 30rpx;
|
||||
}
|
||||
text:nth-child(3){
|
||||
font-size: 26rpx;
|
||||
color: #333;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
.favorable.column{
|
||||
align-items: flex-start;
|
||||
}
|
||||
.cell-item{
|
||||
display: flex;
|
||||
@@ -1327,11 +1463,13 @@
|
||||
color: #333333;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
.totalPrice{
|
||||
padding: 32rpx 30rpx;
|
||||
box-sizing: border-box;
|
||||
border-top: 2rpx solid #E5E5E5;
|
||||
// border-top: 2rpx solid #E5E5E5;
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
align-items: flex-end;
|
||||
|
||||
Reference in New Issue
Block a user