商品券相关优化更新

This commit is contained in:
GaoHao
2024-11-21 09:46:04 +08:00
parent 8c5e03d6c4
commit f7a2f588ef
11 changed files with 613 additions and 578 deletions

View File

@@ -22,11 +22,11 @@
</view>
</view>
<view class="listStyle " v-for="(item,i) in list" :key="i">
<image class="head_img" :src="item.head_img?item.head_img:'https://czg-qr-order.oss-cn-beijing.aliyuncs.com/menber/head_default.png'" style="width: 76rpx;height: 76rpx;float: left;" mode=""></image>
<!-- <image class="head_img" :src="item.head_img?item.head_img:'https://czg-qr-order.oss-cn-beijing.aliyuncs.com/menber/head_default.png'" style="width: 76rpx;height: 76rpx;float: left;" mode=""></image> -->
<view class="flex-start">
<view class="listStyle_left">
<view class="listrigth">
<view>{{active == 1 ? item.biz_name : item.memberName}}</view>
<view>{{active == 1 ? item.biz_name : item.content}}</view>
<view :class="[item.type == '+'?'colorStyle':'']">
{{ active == 1 ? item.type : (item.floatType == 'add'?'+':'')}}
{{active == 1 ? item.amount : item.floatPoints}}

View File

@@ -68,6 +68,10 @@
<u-loadmore :status="form.status" iconSize='24' fontSize='24' height='40' />
</view>
</view>
<view class="btnBox" v-if="type == 'confirm_order_coupon' || type == 'confirm_order_product'">
<view class="btn" @click="cancelCoupon" >暂不使用券</view>
</view>
</view>
</template>
@@ -133,7 +137,7 @@
userId: uni.cache.get('userInfo').id,
status: this.status
}
if ( this.type == 'confirm_order_coupon' || this.type == 'confirm_order_product' ) {
if ( this.type == 'confirm_order_coupon' || this.type == 'confirm_order_product' || this.type == 'orderInfo_coupon' || this.type == 'orderInfo_product' ) {
params.orderId = -1;
}
if ( this.shopId ) {
@@ -163,7 +167,7 @@
*/
navigatorGo ( item ) {
uni.cache.set('shopId',item.shopId)
if ( this.type == 'confirm_order_coupon' || this.type == 'confirm_order_product') {
if ( this.type == 'confirm_order_coupon' || this.type == 'confirm_order_product' || this.type == 'orderInfo_coupon' || this.type == 'orderInfo_product' ) {
if ( item.type == 1 ) {
if( this.payAmount < item.fullAmount) {
uni.showToast({
@@ -173,6 +177,20 @@
return;
}
uni.$emit('couponItem', JSON.stringify(item))
let selectCouponData = uni.cache.get('selectCouponData') || [];
let couponList = selectCouponData.filter(v => v.type == 1);
if ( couponList.length > 0) {
couponList.map(items => {
if ( item.type == 1 ) {
for(var v in items){
items[v] = item[v]
}
}
})
} else {
selectCouponData.push(item)
}
uni.cache.set('selectCouponData',selectCouponData)
uni.navigateBack();
} else {
let productNum = 0;//商品购物车数量
@@ -208,7 +226,45 @@
})
return;
}
let isNum = 0;
let isProductItem;
// 确认订单
if ( this.type == 'confirm_order_product' ) {
product.forEach(item => {
for (let i = 0; i < item.number; i++){
isNum++
if ( isNum == productTicketNum+1 ) {
isProductItem = item;
}
}
})
if ( this.payAmount < (isProductItem.memberPrice > 0 ? isProductItem.memberPrice : isProductItem.salePrice)) {
uni.showToast({
title: `当前金额不足商品抵扣`,
icon: "none",
})
return;
}
}
// 订单详情
if ( this.type == 'orderInfo_product' ) {
product.forEach(item => {
for (let i = 0; i < item.num; i++){
isNum++
if ( isNum == productTicketNum+1 ) {
isProductItem = item;
}
}
})
if ( this.payAmount < (isProductItem.memberPrice > 0 ? isProductItem.memberPrice : isProductItem.price)) {
uni.showToast({
title: `当前金额不足商品抵扣`,
icon: "none",
})
return;
}
}
// let productNum = 0;
@@ -226,6 +282,9 @@
// }
uni.$emit('couponItem', JSON.stringify(item))
let selectCouponData = uni.cache.get('selectCouponData') || [];
selectCouponData.push(item)
uni.cache.set('selectCouponData',selectCouponData)
uni.navigateBack();
}
@@ -237,6 +296,27 @@
}
},
/**
* 取消使用优惠券/商品券
*/
cancelCoupon () {
let selectCouponData = uni.cache.get('selectCouponData')
if ( this.type == 'confirm_order_coupon' || this.type == 'orderInfo_coupon' ) {
let couponList = selectCouponData.filter(v => v.type == 1);
let productList = selectCouponData.filter(v => v.type == 2);
if ( couponList.length > 0 ) {
uni.cache.set('selectCouponData',productList)
}
} else if ( this.type == 'confirm_order_product' || this.type == 'orderInfo_product' ) {
let couponList = selectCouponData.filter(v => v.type == 1);
let productList = selectCouponData.filter(v => v.type == 2);
if ( productList.length > 0 ) {
uni.cache.set('selectCouponData',couponList)
}
}
uni.navigateBack();
},
}
};
</script>
@@ -311,7 +391,7 @@
height: 192rpx;
background: #E3AD7F;
border-radius: 18rpx 0rpx 0rpx 18rpx;
padding: 0 20rpx;
// ::before {
@@ -463,7 +543,25 @@
}
}
.btnBox{
width: 100%;
position: absolute;
bottom: 0;
left: 0;
background-color: #fff;
padding: 30rpx 30rpx 50rpx 30rpx;
.btn{
width: 100%;
height: 90rpx;
line-height: 90rpx;
text-align: center;
font-weight: bold;
font-size: 36rpx;
color: #FFFFFF;
border-radius: 12rpx;
background: #E3AD7F;
}
}
}
</style>

View File

@@ -40,9 +40,9 @@
<view class="tabContent">
<view class="tabContent_item" v-for="(item,index) in shareRecordData.list" :key="index">
<view class="top">
<view class="name">{{item.invitedName}}</view>
<view class="status" :style="{color: isSuccess ? '#333' : '#FF534B'}">{{
isSuccess ? '邀请成功' : '未邀请成功'
<view class="name">{{item.invitedName||""}}</view>
<view class="status" :style="{color: item.success ? '#333' : '#FF534B'}">{{
item.success ? '邀请成功' : '未邀请成功'
}}</view>
</view>
<view class="time">{{item.createTime}}</view>
@@ -162,11 +162,11 @@
shareId : this.InviteFriendsData.id,
invitedId : uni.cache.get('userInfo').id,
shopId : this.shopId,
success : this.isSuccess,
success : this.tabAcitve == 1 ? true : false,
}
let res = await this.api.shareRecord(params)
if ( res.code == 0 ) {
this.shareRecordData = res.data;
this.shareRecordData = res.data.records;
this.tabList[0].num = res.data.isSuccess;
this.tabList[1].num = res.data.isFail;
}

View File

@@ -53,40 +53,74 @@
<view>{{listinfo.orderInfo.seatAmount}}</view>
</view>
</view>
<view v-for="(item,indexe) in favorable" :key="indexe">
<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"/> -->
<text class="name"> {{ item.name }} </text>
<block v-if="listinfo.status == 'unpaid' || listinfo.status == 'paying'">
<view v-for="(item,indexe) in favorable" :key="indexe" >
<view v-if="!rechargeFreeChecked" 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"/> -->
<text class="name"> {{ item.name }} </text>
</view>
<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" v-if="listinfo.status == 'unpaid' || listinfo.status == 'paying'"></u-icon>
</view>
<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 && (listinfo.status == 'unpaid' || listinfo.status == 'paying')" 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>
<text class="favorable_right_text" style="color: #666;margin-right: 16rpx;color: #DE4D3A;" v-else>
{{calcUsablePointsData.unusableReason}}
</text>
<u-checkbox-group iconPlacement="right" @change="pointsChange">
<u-checkbox v-model="isPointsChecked" :disabled="freeCheck||!calcUsablePointsData.usable" :checked="isPointsChecked" activeColor="#E8AD7B" shape="circle" icon-size="36" size="36">
</u-checkbox>
</u-checkbox-group>
</view>
</view>
<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" v-if="listinfo.status == 'unpaid' || listinfo.status == 'paying'"></u-icon>
</view>
</block>
<block v-else>
<block v-for="(item,index) in listinfo.orderInfo.couponInfoList.fullReductionCoupon" :key="index">
<view class="cell-item" v-if="item.type == 1">
<view class="label">优惠券</view>
<view class="val">
<view></view>
<view style="font-size: 28rpx;">-</view>
<view>{{item.discountAmount}}</view>
</view>
</view>
<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 && (listinfo.status == 'unpaid' || listinfo.status == 'paying')" 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>
<text class="favorable_right_text" style="color: #666;margin-right: 16rpx;color: #DE4D3A;" v-else>
{{calcUsablePointsData.unusableReason}}
</text>
<u-checkbox-group iconPlacement="right" @change="pointsChange">
<u-checkbox v-model="isPointsChecked" :disabled="freeCheck||!calcUsablePointsData.usable" :checked="isPointsChecked" activeColor="#E8AD7B" shape="circle" icon-size="36" size="36">
</u-checkbox>
</u-checkbox-group>
</block>
<view class="cell-item column" v-if="listinfo.orderInfo.couponInfoList.productCoupon.length > 0">
<view class="label">商品券</view>
<view class="val column">
<view class="productCoupon" v-for="(item,index) in listinfo.orderInfo.couponInfoList.productCoupon" :key="index">
<view class="name">{{item.name}}</view>
<view class="num">X{{item.finalUseNum}}</view>
<view class="amount">-{{item.finalDiscountAmount}}</view>
</view>
</view>
</view>
</view>
<view class="cell-item" v-if="listinfo.orderInfo && listinfo.orderInfo.pointsDiscountAmount && listinfo.orderInfo.pointsDiscountAmount > 0">
<view class="label">积分抵扣</view>
<view class="val">
<view></view>
<view style="font-size: 28rpx;"></view>
<view>{{listinfo.orderInfo.pointsDiscountAmount.toFixed(2)}}</view>
</view>
</view>
</block>
<view class="total-wrap">
<view>总计</view>
<view class="price"> {{listinfo.payAmount}} </view>
@@ -139,13 +173,21 @@
{ name: "积分抵扣", type: "points",value: "", url: "https://czg-qr-order.oss-cn-beijing.aliyuncs.com/confirmOrder/points.png" }
],
calcUsablePointsData: null,
isShow: false,
payAmount: 0,
isPointsChecked: false,
freeCheck: false,
freeDisabled: false,
userCouponInfos: [],
selectCouponData: [],
}
},
props:{
rechargeFreeChecked: {
type: Boolean
},
freeCheck: {
type: Boolean
},
listinfo:{
type: Object
},
@@ -161,59 +203,93 @@
this.$forceUpdate()
}
},
rechargeFreeChecked:{
immediate: true,
handler (newVal) {
console.log(this.isPointsChecked)
if ( newVal ) {
// let couponList = this.userCouponInfos.filter(v => v.type == 1);
// this.listinfo.payAmount = (couponList.length > 0 ? Number(this.listinfo.payAmount) + couponList[0].discountAmount : this.listinfo.payAmount)
// let productList = this.userCouponInfos.filter(v => v.type == 2);
// productList.map(item=> {
// this.listinfo.payAmount += item.productPayAmount
// })
this.isPointsChecked = false
this.$emit("setPayAmount",{
payAmount: this.listinfo.payAmount,
userCouponInfos: this.userCouponInfos,
freeCheck: this.freeCheck,
calcUsablePointsData: this.calcUsablePointsData,
isPointsChecked: this.isPointsChecked,
})
}
// this.userCouponInfos = []
}
},
},
mounted() {
this.payAmount = this.listinfo.payAmount;
uni.cache.set('selectCouponData',[])
this.isShow = true;
},
methods: {
childOnShow() {
console.log(222)
uni.$on('couponItem',this.changeCoupon)
this.getCalcUsablePoints()
this.getCalcUsablePoints()
if (!this.isShow ) {
return;
}
// uni.$on('couponItem',this.changeCoupon)
this.userCouponInfos = [];
this.favorable[0].value = ""
this.favorable[1].value = []
this.listinfo.payAmount = this.payAmount
this.selectCouponData = uni.cache.get('selectCouponData') || []
this.changeCoupon();
},
/**
* 监听优惠券/商品券选择
* @param {Object} data
*/
changeCoupon ( data ) {
let _this = this;
// uni.$off('couponItem')
let couponData = JSON.parse(data)
console.log('监听到事件来自返回的参数:' , couponData);
if ( couponData.type == 1 ) { //满减优惠券
let couponList = _this.userCouponInfos.filter(v => v.type == 1);
// 优惠券数据
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]
//不包含优惠券的金额
let currentPayAmount = (couponList.length > 0 ? Number(_this.listinfo.payAmount) + couponList[0].discountAmount : _this.listinfo.payAmount)
let currentPayAmount = (this.userCouponInfos.filter(v => v.type == 1).length > 0 ? Number(this.listinfo.payAmount) + couponData.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
}
})
if ( this.isPointsChecked ) {
this.listinfo.payAmount = (this.listinfo.payAmount-(this.calcUsablePointsData.pointsNum/this.calcUsablePointsData.equivalentPoints)).toFixed(2);
} else {
_this.favorable[0].value = ('-¥'+couponData.discountAmount)
_this.userCouponInfos.push({
this.listinfo.payAmount = (Number(this.listinfo.payAmount)+(this.calcUsablePointsData.pointsNum/this.calcUsablePointsData.equivalentPoints)).toFixed(2);
}
this.listinfo.payAmount = ( currentPayAmount - couponData.discountAmount).toFixed(2)
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,
})
}
console.log(currentPayAmount)
console.log(_this.listinfo.payAmount)
if ( _this.isPointsChecked ) {
_this.pointsChange()
_this.getCalcUsablePoints()
if ( this.isPointsChecked ) {
this.isPointsChecked = !this.isPointsChecked
this.getCalcUsablePoints()
}
this.$emit("setPayAmount",{
payAmount: this.listinfo.payAmount,
userCouponInfos: this.userCouponInfos,
freeCheck: this.freeCheck,
calcUsablePointsData: this.calcUsablePointsData,
isPointsChecked: this.isPointsChecked,
})
@@ -223,76 +299,65 @@
icon: "none",
})
}
} else { //商品券
//不包含商品券的金额
let currentPayAmount = 0;
// 筛选选中商品券商品列表
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 num = 0;
let productPayAmount = 0;
let productTicketNum = 0;
let productNumber = 0;
productTicketList.map((item,index) => {
console.log(item)
productTicketNum += item.num
_this.listinfo.payAmount = Number(_this.listinfo.payAmount) + item.discountAmount
})
console.log(productTicketNum)
let productTicketNumber = 0;
minCouponList.map((item,index) => {
// productNumber += item.num
console.log("productTicketNum==",productTicketNum)
if ( productNum > 0 && productTicketNum > 0) {
productTicketNumber = productTicketNum
productTicketNum = (item.num - productTicketNum) <= 0 ? (productTicketNum - item.num) : item.num - productTicketNum
console.log("item.num - productTicketNumber===",item.num - productTicketNumber)
}
if ( productNum > 0 && productTicketNum > 0) {
item.num = (item.num - productTicketNumber) <= 0 ? 0 : (item.num - productTicketNumber)
}
console.log("productTicketNum==",productTicketNum)
console.log("item.num===",item.num)
if ( productNum > 0 && item.num > 0) {
console.log("index===",index)
let num = productNum >= item.num ? item.num : productNum
productNum = (productNum - item.num) >= 0 ? (productNum - item.num) : 0;
productPayAmount = productPayAmount + (num*(item.memberPrice > 0 ? item.memberPrice : item.price))
}
})
if ( productPayAmount > _this.listinfo.payAmount) {
}
_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),
})
console.log(productNum)
if ( _this.isPointsChecked) {
_this.pointsChange()
}
}
// 商品券处理
if ( productList.length > 0 ) {
//商品券使用数量
_this.setPayAmount()
}
uni.$off('couponItem')
// 商品数量
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;
})
minCouponList.map((v,indexs) => {
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++
productAllNum++
productPayAmount += v.memberPrice > 0 ? v.memberPrice : v.price
}
}
})
if ( productNum > 0 ) {
this.userCouponInfos.push({
userCouponId: item.id,
type: item.type,
productId: item.proId,
discountAmount: productPayAmount,
num: productNum ,
})
this.favorable[1].value.push({
userCouponId: item.id,
name: item.name,
type: item.type,
productId: item.proId,
discountAmount: productPayAmount,
num: productNum,
})
}
})
if ( this.isPointsChecked) {
this.isPointsChecked = !this.isPointsChecked
this.getCalcUsablePoints()
}
}
this.setPayAmount()
},
setPayAmount ( cartLists ) {
let tableFee;
@@ -302,11 +367,7 @@
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.type == 2 ) {
if ( item.discountAmount && item.discountAmount > 0 ) {
this.listinfo.payAmount = (this.listinfo.payAmount - item.discountAmount).toFixed(2)
}
@@ -320,6 +381,7 @@
this.$emit("setPayAmount",{
payAmount: this.listinfo.payAmount,
userCouponInfos: this.userCouponInfos,
freeCheck: this.freeCheck,
calcUsablePointsData: this.calcUsablePointsData,
isPointsChecked: this.isPointsChecked,
})
@@ -333,17 +395,16 @@
}
this.isPointsChecked = !this.isPointsChecked
if ( this.isPointsChecked ) {
this.freeDisabled = true
this.listinfo.payAmount = (this.listinfo.payAmount-(this.calcUsablePointsData.pointsNum/this.calcUsablePointsData.equivalentPoints)).toFixed(2);
} else {
this.freeDisabled = false
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,
freeDisabled: this.freeDisabled,
freeCheck: this.freeCheck,
calcUsablePointsData: this.calcUsablePointsData,
isPointsChecked: this.isPointsChecked,
})
@@ -359,16 +420,17 @@
}
uni.pro.navigateTo('/pages/user/coupon', {
type: "confirm_order_coupon",
type: "orderInfo_coupon",
shopId: this.listinfo.shopId,
payAmount: payAmount,
shoppingCart: JSON.stringify(this.listinfo.details)
shoppingCart: JSON.stringify(this.listinfo.details),
productList: JSON.stringify(couponList)
})
break;
case 'product':
let productList = this.userCouponInfos.filter(v => v.type == 2);
uni.pro.navigateTo('/pages/user/coupon', {
type: "confirm_order_product",
type: "orderInfo_product",
shopId: this.listinfo.shopId,
payAmount: this.listinfo.payAmount,
shoppingCart: JSON.stringify(this.listinfo.details),
@@ -624,6 +686,33 @@
color: #333333;
}
}
.val.column{
display: flex;
flex-direction: column;
.productCoupon{
display: flex;
align-items: flex-end;
margin: 0 0 10rpx 0;
.name{
font-weight: 400;
font-size: 26rpx;
color: #999;
margin: 0;
}
.num{
font-weight: 400;
font-size: 26rpx;
color: #999;
margin: 0 30rpx;
line-height: 20rpx;
}
.amount{
font-weight: bold;
font-size: 26rpx;
color: #333;
}
}
}
}
.favorable{
@@ -684,7 +773,9 @@
.favorable.column{
align-items: flex-start;
}
.cell-item.column{
align-items: flex-start;
}
.total-wrap {
width: 100%;
display: flex;

View File

@@ -1,300 +0,0 @@
<template>
<view>
<view class="card_box">
<view class="card_head_box">
<view class="card_head_item" v-for="(item,index) in 8" :key="index"></view>
</view>
<view class="card">
<!-- 订单头部 -->
<view class="top">
<view class="title">
<view>自提凭证</view>
</view>
</view>
<view class="card_item">
<view>
<view class="code">提货码241578956432</view>
<tki-qrcode ref="tkiQrcode" show :size="qrcodeSize"></tki-qrcode>
</view>
<view class="semicircle_icon" >
<view class="semicircle_left_icon"></view>
<view class="semicircle_right_icon"></view>
</view>
</view>
<view class="total-wrap">
<view class="info">
<u-icon name="map" color="#666" size="28"></u-icon>
<view class="shopName">自取店{{ listinfo.name }}</view>
<u-icon name="phone" color="#666" size="28"></u-icon>
<view class="phone">15303589754</view>
</view>
<view class="address">
<view class="lable">门店地址</view>
<view>门店地址门店地址门店地址门店地址门店地址门店地址门店地址门店地址</view>
</view>
</view>
</view>
</view>
<view class="product">
<view></view>
<view class="product_info">
<view class="name">DIMO联名马克杯</view>
<view class="numBox"><view class="points">100积分</view><view class="num">X1</view></view>
</view>
<!-- <view class="productInfo"></view> -->
</view>
<view class="orderInfo">
<view class="row">
<text class="t">支付方式</text>
<text class="info">{{listinfo.name}}</text>
</view>
<view class="row">
<text class="t">兑换时间</text>
<text class="info">{{$u.timeFormat(listinfo.time, 'yyyy-mm-dd hh:MM:ss')}}</text>
</view>
<view class="row" @click="copyHandle(listinfo.orderNo)">
<text class="t">订单编号</text>
<text class="info">{{listinfo.orderNo}}点击复制</text>
</view>
</view>
</view>
</template>
<script>
import tkiQrcode from '@/components/tki-qrcode/tki-qrcode.vue';
export default {
data() {
return {
qrcodeSize: 200,
}
},
props:{
listinfo:{
type: Object
}
},
mounted() {
this.setQrcode();
},
methods: {
setQrcode () {
this.$refs.tkiQrcode.setval('241578956432') //操作属性
},
/**
* 复制订单号
* @param {Object} e
*/
copyHandle(e) {
uni.setClipboardData({
data: e,
success() {
uni.showToast({
title: '复制成功',
icon: 'none'
});
}
});
},
}
}
</script>
<style lang="scss">
.card_box{
background-color: #fff;
// box-shadow: 0rpx 8rpx 12rpx 2rpx rgba(87,86,86,0.35);
position: relative;
width: 100%;
height: 100%;
// box-shadow: 0rpx 4rpx 12rpx 2rpx rgba(87,86,86,0.35);
border-radius: 18rpx;
padding-bottom: 32rpx;
.card_head_box{
width: 100%;
display: flex;
justify-content: space-between;
position: absolute;
top: -22.5rpx;
padding: 0 44rpx;
.card_head_item{
width: 45rpx;
height: 45rpx;
background-color: #f9f9f9;
border-radius: 50%;
// box-shadow: inset 0rpx -13rpx 18rpx -16rpx rgba(87, 86, 86, 0.35);
}
}
.card {
// background-color: #fff;
border-radius: 20upx;
margin-bottom: 28upx;
position: relative;
.top{
padding: 0 34rpx;
}
.title{
font-weight: 500;
font-size: 24rpx;
color: #333333;
border-bottom: 2rpx dashed #E3E3E3;
padding-bottom: 36rpx;
padding-top: 50rpx;
}
.card_item{
display: flex;
flex-direction: column;
position: relative;
padding: 32rpx 34rpx 48rpx 34rpx;
border-bottom: 2rpx dashed #E3E3E3;
align-items: center;
.code{
font-weight: bold;
font-size: 28rpx;
color: #333333;
margin-bottom: 48rpx;
}
::v-deep.vue-ref{
display: flex;
justify-content: center;
}
.semicircle_icon{
width: 100%;
position: absolute;
bottom: -22.5rpx;
left: 0;
display: flex;
justify-content: space-between;
.semicircle_left_icon{
width: 45rpx;
height: 45rpx;
margin-left: -22.5rpx;
background-color: #f9f9f9;
border-radius: 50%;
// box-shadow: inset -20rpx 0rpx 22rpx -20rpx rgba(87, 86, 86, 0.35);
}
.semicircle_right_icon{
width: 45rpx;
height: 45rpx;
margin-right: -22.5rpx;
background-color: #f9f9f9;
border-radius: 50%;
// box-shadow: inset 13rpx 0rpx 16rpx -9rpx rgba(87, 86, 86, 0.35);
}
}
}
.total-wrap {
width: 100%;
display: flex;
flex-direction: column;
padding: 0 34rpx;
font-weight: bold;
font-size: 28rpx;
color: #333333;
margin-top: 38rpx;
.info{
display: flex;
align-items: center;
font-weight: bold;
font-size: 24rpx;
color: #333333;
.shopName{
margin-right: 48rpx;
margin-left: 16rpx;
}
.phone{
margin-left: 16rpx;
}
}
.address{
margin-left: 36rpx;
align-self: center;
display: flex;
font-weight: 400;
font-size: 24rpx;
color: #666666;
margin-top: 24rpx;
align-self: center;
.lable{
flex-shrink: 0;
}
}
}
}
}
.product{
padding: 32rpx 34rpx;
background-color: #FFFFFF;
margin-top: 32rpx;
.product_info{
display: flex;
flex-direction: column;
margin-left: 16rpx;
.name{
font-weight: bold;
font-size: 24rpx;
color: #333333;
margin-bottom: 24rpx;
}
.numBox{
display: flex;
align-items: center;
justify-content: space-between;
font-weight: 500;
font-size: 24rpx;
.points{
color: #F7853D;
}
.num{
color: #999999
}
}
}
}
.orderInfo{
background: #FFFFFF;
border-radius: 18rpx 18rpx 18rpx 18rpx;
margin-top: 32rpx;
padding: 32rpx 34rpx;
// box-shadow: 0rpx 4rpx 12rpx 2rpx rgba(87,86,86,0.35);
.row {
display: flex;
justify-content: space-between;
margin-bottom: 32rpx;
.t {
font-weight: bold;
font-size: 28rpx;
color: #333333;
}
.info {
font-weight: 400;
font-size: 28rpx;
color: #666666;
}
}
.row:last-child{
margin-bottom: none;
}
}
</style>

View File

@@ -64,18 +64,35 @@
},
watch: {
freeCheck(newVal,oldVal) {
if ( newVal ) {
// #ifdef MP-WEIXIN
this.radiovalue = 2
// #endif
// #ifdef MP-ALIPAY
this.radiovalue = 3
// #endif
let name = this.paymentMethodName[this.radiovalue-1].name;
this.$emit("groupChange",{type:this.radiovalue ,name: name })
// freeCheck(newVal,oldVal) {
// if ( newVal ) {
// // #ifdef MP-WEIXIN
// this.radiovalue = 2
// // #endif
// // #ifdef MP-ALIPAY
// this.radiovalue = 3
// // #endif
// let name = this.paymentMethodName[this.radiovalue-1].name;
// console.log({type:this.radiovalue ,name: name })
// this.$emit("groupChange",{type:this.radiovalue ,name: name })
// }
// }
freeCheck:{
immediate: true,
handler (newVal) {
if ( newVal ) {
// #ifdef MP-WEIXIN
this.radiovalue = 2
// #endif
// #ifdef MP-ALIPAY
this.radiovalue = 3
// #endif
let name = this.paymentMethodName[this.radiovalue-1].name;
console.log({type:this.radiovalue ,name: name })
this.$emit("groupChange",{type:this.radiovalue ,name: name })
}
}
}
},
},
mounted() {
console.log(this.amountVIP)

View File

@@ -4,7 +4,7 @@
<view class="rechargeFree_bg" @click="changeFree">
<view class="left">
<view class="icon">优惠</view>
<view class="text">充值消费{{freeDingConfig.rechargeTimes}}{{freeDingConfig.rechargeThreshold}}本单立享免单</view>
<view class="text">充值消费{{freeDingConfig.rechargeTimes}}订单满{{freeDingConfig.rechargeThreshold}}远可用本单立享免单</view>
</view>
<u-checkbox-group iconPlacement="right" >
<u-checkbox :disabled="freeDisabled" v-model="rechargeFreeChecked" :checked="rechargeFreeChecked" @change="changeFree" activeColor="#E8AD7B" shape="circle" icon-size="36" size="36">
@@ -41,6 +41,11 @@
if ( this.payAmount < this.freeDingConfig.rechargeThreshold ) {
this.freeDisabled = true
}
},
payAmount (newVal) {
if ( this.payAmount < this.freeDingConfig.rechargeThreshold ) {
this.freeDisabled = true
}
}
},
mounted() {
@@ -69,7 +74,7 @@
<style lang="scss">
// 充值免单
.rechargeFree{
padding: 0 20rpx;
// padding: 0 20rpx;
margin-top: 32rpx;
.rechargeFree_bg{
display: flex;
@@ -94,6 +99,7 @@
margin-right: 12rpx;
}
.text{
width: 90%;
font-weight: 500;
font-size: 28rpx;
color: #333333;

View File

@@ -139,7 +139,9 @@
</view>
<!-- 充值免单 -->
<rechargeFree v-if="freeDingConfig.enable == 1&&storeInfo.registerType == 'munchies'" ref="rechargeFree" :freeDisabled="freeDisabled" :payAmount="listinfo.payAmount" :freeDingConfig="freeDingConfig" :shopUserInfo="amountVIP" @changeFree="changeFree"></rechargeFree>
<view style="padding: 0 20rpx;">
<rechargeFree v-if="freeDingConfig.enable == 1&&storeInfo.registerType == 'munchies'" ref="rechargeFree" :freeDisabled="freeDisabled" :payAmount="listinfo.payAmount" :freeDingConfig="freeDingConfig" :shopUserInfo="amountVIP" @changeFree="changeFree"></rechargeFree>
</view>
<!-- 充值活动 -->
<topUpActivity v-if="storeInfo.registerType == 'munchies'" ref="topUpActivity" :shopUserInfo="amountVIP" ></topUpActivity>
<!-- 支付方式 -->
@@ -224,6 +226,7 @@
phone: "",
},
userCouponInfos: [],
selectCouponData: [],
shopTableInfo: null,
freeDingConfig: null,
cartLists: [],
@@ -250,6 +253,7 @@
storeInfo: {},
tableCode: null,
packFee: null,
isShow: false,
}
},
computed: {
@@ -288,9 +292,9 @@
}
this.getProductqueryShop();
this.getchoseEatModel('index',0);
uni.cache.set('selectCouponData',[])
},
onShow() {
let _this = this;
if (this.listinfoid) {
uni.$on('message', this.getMessage)
this.orderorderInfo()
@@ -302,7 +306,12 @@
item.show = true;
}
})
uni.$on('couponItem',this.changeCoupon)
this.userCouponInfos = [];
this.favorable[0].value = ""
this.favorable[1].value = []
this.selectCouponData = uni.cache.get('selectCouponData') || []
},
methods: {
/**
@@ -310,40 +319,36 @@
* @param {Object} data
*/
changeCoupon ( data ) {
let _this = this;
// uni.$off('couponItem')
let couponData = JSON.parse(data)
console.log('监听到事件来自返回的参数:' , couponData);
if ( couponData.type == 1 ) { //满减优惠券
let couponList = _this.userCouponInfos.filter(v => v.type == 1);
// 优惠券数据
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]
//不包含优惠券的金额
let currentPayAmount = (couponList.length > 0 ? _this.listinfo.payAmount + couponList[0].discountAmount : _this.listinfo.payAmount)
let currentPayAmount = (this.userCouponInfos.filter(v => v.type == 1).length > 0 ? Number(this.listinfo.payAmount) + couponData.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
}
})
if ( this.isPointsChecked ) {
this.listinfo.payAmount = (this.listinfo.payAmount-(this.calcUsablePointsData.pointsNum/this.calcUsablePointsData.equivalentPoints)).toFixed(2);
} 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()
this.listinfo.payAmount = (Number(this.listinfo.payAmount)+(this.calcUsablePointsData.pointsNum/this.calcUsablePointsData.equivalentPoints)).toFixed(2);
}
this.listinfo.payAmount = ( currentPayAmount - couponData.discountAmount).toFixed(2)
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,
})
} else {
uni.showToast({
@@ -351,55 +356,76 @@
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()
}
// 商品券处理
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.number;
})
minCouponList.map((v,indexs) => {
for (let i = 0; i < v.number; i++){
if ( productAllNum < productDetailsNum && productNum < item.num && ((v.memberPrice > 0 ? v.memberPrice : v.salePrice) < (this.listinfo.payAmount - productPayAmount) )) {
productNum++
productAllNum++
productPayAmount += v.memberPrice > 0 ? v.memberPrice : v.salePrice
}
}
})
if ( productNum > 0 ) {
this.userCouponInfos.push({
userCouponId: item.id,
type: item.type,
productId: item.proId,
discountAmount: productPayAmount,
num: productNum ,
})
this.favorable[1].value.push({
userCouponId: item.id,
name: item.name,
type: item.type,
productId: item.proId,
discountAmount: productPayAmount,
num: productNum,
})
}
})
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)
}
}
if ( item.type == 2 ) {
if ( item.discountAmount && item.discountAmount > 0 ) {
// this.listinfo.payAmount = (this.listinfo.payAmount - item.discountAmount).toFixed(2)
}
}
})
}
}
uni.$off('couponItem')
}
},
setPayAmount ( cartLists ) {
let tableFee;
@@ -412,24 +438,28 @@
if ( this.amountVIP.isVip == 1 && cartLists.memberAmount > 0 ) {
this.listinfo.payAmount = (cartLists.memberAmount+tableFee).toFixed(2)
} else {
this.listinfo.payAmount = (cartLists.amount+tableFee).toFixed(2)
this.listinfo.payAmount = (Number(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)
this.listinfo.payAmount = ( this.listinfo.payAmount - item.discountAmount).toFixed(2)
}
} else {
}
if ( item.type == 2 ) {
if ( item.discountAmount && item.discountAmount > 0 ) {
this.listinfo.payAmount = (this.listinfo.payAmount - item.discountAmount).toFixed(2)
}
}
})
}
if ( this.freeDingConfig && this.listinfo.payAmount < this.freeDingConfig.rechargeThreshold ) {
this.freeDisabled = true
}
this.changeCoupon()
this.isPointsChecked = false;
this.getCalcUsablePoints()
},
@@ -439,7 +469,6 @@
*/
changeFree ( val ) {
this.freeCheck = val;
if ( val ) {
this.listinfo.payAmount = (this.listinfo.payAmount*this.freeDingConfig.rechargeTimes).toFixed(2)
} else {
@@ -464,6 +493,7 @@
this.listinfo.payAmount = (Number(this.listinfo.payAmount)+(this.calcUsablePointsData.pointsNum/this.calcUsablePointsData.equivalentPoints)).toFixed(2);
}
},
goUrl(item){
switch (item.type){
case 'coupon':
@@ -505,7 +535,7 @@
}
let res = await this.api.calcUsablePoints(params)
this.calcUsablePointsData = res.data;
if ( this.calcUsablePointsData.usable && this.listinfo.payAmount >= this.calcUsablePointsData.minPaymentAmount) {
if ( this.calcUsablePointsData && this.calcUsablePointsData.usable && this.listinfo.payAmount >= this.calcUsablePointsData.minPaymentAmount) {
this.calcUsablePointsData.pointsNum = this.calcUsablePointsData.accountPoints >= this.calcUsablePointsData.maxUsablePoints ? this.calcUsablePointsData.maxUsablePoints : this.calcUsablePointsData.accountPoints
}
},

View File

@@ -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)
},
/**

View File

@@ -4,7 +4,7 @@
<view class="listItem " v-for="(item,index) in list" :key="index">
<view class="top">
<view class="title">{{item.content}}</view>
<view class="num">{{item.floatPoints}}</view>
<view class="num">{{item.floatType == 'add' ? '+' : ''}}{{item.floatPoints}}</view>
</view>
<view class="time">{{item.createTime}}</view>
</view>

View File

@@ -26,8 +26,15 @@
</view>
<view class="card_item status" v-else>
<view class="status_left">
<view class="status_title">已使用</view>
<view class="status_code">{{orderInfo.couponCode}}</view>
<view class="status_title">
{{
orderInfo.status == 'unpaid' ? '待支付' :
orderInfo.status == 'waiting' ? '待自取' :
orderInfo.status == 'done' ? '已使用' :
orderInfo.status == 'cancel' ? '已取消' : ""
}}
</view>
<view class="status_code" v-if="orderInfo.status == 'done'">{{orderInfo.couponCode}}</view>
</view>
<view class="status_qrcode" >