增加:商品兑换 额度区分为瓶装酒和封坛酒;商品区分瓶装酒和封坛酒

This commit is contained in:
wuhui_zzw 2024-06-04 11:58:26 +08:00
parent b0eef8c887
commit 166b0237c1
2 changed files with 182 additions and 103 deletions

View File

@ -51,18 +51,23 @@
</view>
</view>
<view class="buy">
<!--<view class="left" @click="changeBatchType(item.product_id)">
<template v-if="item.is_batch == 1">
<view v-if="(batch_list[item.product_id] || 0) == 1" class="buy-unit">{{ item.batch_unit }}购买</view>
<view v-else class="buy-unit">{{ item.unit_name }}购买</view>
<text class="iconfont icon-jiantou_shangxiaqiehuan_o"></text>
</template>
</view>-->
<view class="left"></view>
<!--酒类型0=未知1=瓶装酒2=封坛酒-->
<view class="left">
<view class="left-text wine-type-one" v-if="item.wine_type == 1">瓶装酒</view>
<view class="left-text wine-type-two" v-if="item.wine_type == 2">封坛酒</view>
</view>
<view class="right">
<template v-if="!buyList[item.product_id]">
<text v-if="Number(surplus_available) >= (Number(item.price) * (Number(item.once_min_count) || 1))" @click="buyFlowAddBuyNum('add', item)" class="iconfont icon-gengduozhankai1"></text>
<view v-else class="lack_available">额度不足</view>
<!--瓶装酒-->
<template v-if="item.wine_type == 1">
<text v-if="Number(surplus_available) >= (Number(item.price) * (Number(item.once_min_count) || 1))" @click="buyFlowAddBuyNum('add', item)" class="iconfont icon-gengduozhankai1"></text>
<view v-else class="lack_available">额度不足</view>
</template>
<!--封坛酒-->
<template v-if="item.wine_type == 2">
<text v-if="Number(surplus_wine_available) >= (Number(item.price) * (Number(item.once_min_count) || 1))" @click="buyFlowAddBuyNum('add', item)" class="iconfont icon-gengduozhankai1"></text>
<view v-else class="lack_available">额度不足</view>
</template>
</template>
<template v-else>
<view class="buy-num">
@ -90,18 +95,23 @@
</view>
<!--结算按钮-->
<view class="settlement">
<view class="left">
<text class="iconfont icon-gouwuche-mendian">
<text class="total-num" v-if="totalNum > 0">{{ totalNum > 99 ? '99+' : totalNum }}</text>
</text>
<view class="total">
合计<text class="total-price">{{ totalPrice }}积分</text>
<view class="top">
<view class="left">
<text class="iconfont icon-gouwuche-mendian">
<text class="total-num" v-if="totalNum > 0">{{ totalNum > 99 ? '99+' : totalNum }}</text>
</text>
<view class="total">
合计<text class="total-price">{{ totalPrice }}积分</text>
</view>
</view>
<view class="right">
<view class="settlement-btn" @click="settlementCart" v-if="Object.values(buyList).length > 0">立即结算</view>
<view class="settlement-btn not-btn" v-else>立即结算</view>
</view>
</view>
<view class="right">
<view class="settlement-btn" @click="settlementCart" v-if="Object.values(buyList).length > 0">立即结算</view>
<view class="settlement-btn not-btn" v-else>立即结算</view>
<view class="available">剩余额度:{{ surplus_available }}</view>
<view class="quota-info">
<view class="available-line">可用瓶装酒额度:{{ surplus_available || 0 }}</view>
<view class="available-line">可用封坛酒额度:{{ surplus_wine_available || 0 }}</view>
</view>
</view>
</view>
@ -277,6 +287,8 @@ export default {
userInfoNow: {},
available: 0,
surplus_available: 0,
wine_available: 0,
surplus_wine_available: 0,
}
},
onLoad(options) {
@ -401,8 +413,12 @@ export default {
let _this = this;
getUserInfo().then(res => {
_this.$set(_this, 'userInfoNow', res.data);
_this.$set(_this, 'available', res.data.available)
_this.$set(_this, 'surplus_available', res.data.surplus_available)
_this.$set(_this, 'available', res.data.available_quota)
_this.$set(_this, 'surplus_available', res.data.available_quota)
_this.$set(_this, 'wine_available', res.data.wine_available_quota)
_this.$set(_this, 'surplus_wine_available', res.data.wine_available_quota)
});
},
//
@ -426,7 +442,7 @@ export default {
_this.$set(_this, 'list', oldList);
}).catch(err => {
this.$util.Tips({title: err});
this.$util.tips({ content: err });
});
},
//
@ -495,14 +511,7 @@ export default {
let currentNum = currentSpec.cart_num || 0;
let changeNum = Number(oldNum) - Number(currentNum);
//
if(type != 'reduce'){
let surplus_available = this.surplus_available || 0;
if(Number(surplus_available) < (Math.abs(Number(changeNum)) * Number(currentSpec.price))){
this.$util.Tips({ title: '额度不足!'});
this.cartGetList();
return false;
}
}
if(type !== 'reduce' && this.quotaIsAdequate(changeNum, currentSpec.price)) return false;
// 0
if(currentSpec.cart_num <= 0) {
this.cartDel(currentSpec);
@ -512,6 +521,7 @@ export default {
//
currentSpec.batch_num = this.currentGoods.batch_num || '';
currentSpec.is_batch = this.currentGoods.is_batch || 0;
this.cartSubmitEdit(currentSpec);
}
//
@ -536,6 +546,8 @@ export default {
let stock = spec.stock || 0;
if(isBatch == 1) stock = Math.floor(stock / (this.currentGoods.batch_num || ''));//
if(Number(stock) < Number(spec.cart_num)) spec.cart_num = stock;
//
if(this.quotaIsAdequate(spec.cart_num, spec.price)) return false;
//
this.$set(this.buyList, spec.product_id, {
//
@ -546,11 +558,11 @@ export default {
product_id: spec.product_id,
total_num: spec.cart_num,
store_name: this.currentGoods.store_name,
wine_type: this.currentGoods.wine_type || 0,
specs: {
[spec.unique]: spec,
},
});
//
spec.batch_num = this.currentGoods.batch_num || '';
spec.is_batch = this.currentGoods.is_batch || 0;
@ -559,6 +571,28 @@ export default {
this.$forceUpdate();
},
// -
quotaIsAdequate(num, price){
let wineType = this.currentGoods.wine_type || 0;
let surplus_available = 0;
let tips = '额度不足!';
// 0=1=2=
if(Number(wineType) === 1) {
surplus_available = this.surplus_available || 0;
tips = '瓶装酒额度不足!'
}
else if(Number(wineType) === 2) {
surplus_available = this.surplus_wine_available || 0;
tips = '封坛酒额度不足!'
}
//
if(Number(surplus_available) < (Math.abs(Number(num)) * Number(price))){
this.$util.tips({ content: tips });
this.cartGetList();
return true;
}
return false;
},
// -
closeMoreSpecsSelect(){
this.$refs.moreSpecsSelect.close();
@ -608,8 +642,11 @@ export default {
},
// -
BuyFlowComputeTotal(){
let totalNum = 0;
let totalPrice = 0.00;
let totalNum = 0;//
let totalPrice = 0.00;//
let needAvailable = 0;//
let needWindAvailable = 0;//
//
Object.values(this.buyList).forEach(item => {
totalNum += item.total_num;
Object.values(item.specs).forEach(value => {
@ -617,6 +654,9 @@ export default {
let currentBatchType = this.batch_list[value.product_id] || 0;
//
if(currentBatchType == 1) price = price * item.batch_num;
// 0=1=2=
if(Number(item.wine_type) === 1) needAvailable += price;
else if(Number(item.wine_type) === 2) needWindAvailable += price;
totalPrice += price;
})
@ -624,10 +664,14 @@ export default {
//
this.totalNum = totalNum.toFixed(0);
this.totalPrice = totalPrice.toFixed(2);
//
//
let surplusAvailable = this.available || 0;
surplusAvailable = (Number(surplusAvailable) - Number(this.totalPrice)).toFixed(2);
surplusAvailable = (Number(surplusAvailable) - Number(needAvailable)).toFixed(2);
this.$set(this, 'surplus_available', surplusAvailable);
//
let surplusWineAvailable = this.wine_available || 0;
surplusWineAvailable = (Number(surplusWineAvailable) - Number(needWindAvailable)).toFixed(2);
this.$set(this, 'surplus_wine_available', surplusWineAvailable);
this.$forceUpdate();
},
@ -662,6 +706,7 @@ export default {
product_id: item.product_id,
total_num: item.cart_num,
store_name: item.product.store_name,
wine_type: item.product.wine_type || 0,
specs: {
[item.product_attr_unique]: spec,
},
@ -673,10 +718,11 @@ export default {
_this.buyList = Object.assign({}, buyList);
_this.batch_list = Object.assign({}, batchList);
_this.forceUpdate();
_this.$forceUpdate();
}
}).catch(err => {
_this.$util.Tips({title: err});
_this.$util.tips({ content: err});
});
},
// -
@ -695,7 +741,7 @@ export default {
// console.log(res)
}).catch(err => {
_this.cartGetList();
this.$util.Tips({title: err});
_this.$util.tips({ content: err});
});
},
// -
@ -710,7 +756,7 @@ export default {
// console.log(res)
}).catch(err => {
_this.cartGetList();
this.$util.Tips({title: err});
_this.$util.tips({ content: err});
});
},
//
@ -721,7 +767,7 @@ export default {
if(res.status == 200){
let data = res.data || {};
if(Object.values(data).length <= 0){
_this.$util.Tips({title: '请选择商品!'});
_this.$util.tips({ content: '请选择商品!'});
return false;
}
//
@ -730,7 +776,7 @@ export default {
});
}
}).catch(err => {
_this.$util.Tips({title: err});
_this.$util.tips({ content: err});
});
},
// -
@ -821,7 +867,7 @@ export default {
this.getGoodsList( 1);
break;
}
}
},
},
//
onReachBottom() {
@ -1004,19 +1050,12 @@ export default {
justify-content: space-between;
align-items: center;
.left{
display: inline-flex;
flex-direction: row;
flex-wrap: nowrap;
justify-content: flex-start;
align-items: center;
.buy-unit{
font-size: 26rpx;
.left-text{}
.wine-type-one{
color: #409eff;
}
.icon-jiantou_shangxiaqiehuan_o{
transform: rotate(90deg);
font-size: 36rpx;
font-weight: bold;
margin-left: 15rpx;
.wine-type-two{
color: #e6a23c;
}
}
.right{
@ -1082,67 +1121,85 @@ export default {
background: #FFFFFF;
padding: 20rpx 20rpx 50rpx 20rpx;
box-shadow: 0 0 10px 0 #f3f3f3;
display: inline-flex;
flex-direction: row;
flex-wrap: nowrap;
justify-content: space-between;
align-items: center;
.left{
z-index: 9;
.top{
width: 100%;
display: inline-flex;
flex-direction: row;
flex-wrap: nowrap;
justify-content: flex-start;
justify-content: space-between;
align-items: center;
.icon-gouwuche-mendian{
font-size: 30rpx;
margin-right: 20rpx;
border: 2rpx solid #000000;
border-radius: 50%;
padding: 15rpx;
position: relative;
.total-num{
position: absolute;
top: -5px;
right: -5px;
font-size: 20rpx;
background: #ef2c1c;
color: #ffffff;
.left{
display: inline-flex;
flex-direction: row;
flex-wrap: nowrap;
justify-content: flex-start;
align-items: center;
.icon-gouwuche-mendian{
font-size: 30rpx;
margin-right: 20rpx;
border: 2rpx solid #000000;
border-radius: 50%;
width: 35rpx;
height: 35rpx;
text-align: center;
line-height: 35rpx;
padding: 15rpx;
position: relative;
.total-num{
position: absolute;
top: -5px;
right: -5px;
font-size: 20rpx;
background: #ef2c1c;
color: #ffffff;
border-radius: 50%;
width: 35rpx;
height: 35rpx;
text-align: center;
line-height: 35rpx;
}
}
.total{
font-size: 30rpx;
.total-price{
font-weight: bold;
color: #ef2c1c;
}
}
}
.total{
font-size: 30rpx;
.total-price{
font-weight: bold;
color: #ef2c1c;
.right{
.available{
font-size: 24rpx;
color: #828282;
height: 40rpx;
line-height: 50rpx;
}
.settlement-btn{
background: #ef2c1c;
color: #FFFFFF;
height: 55rpx;
line-height: 55rpx;
width: 200rpx;
text-align: center;
border-radius: 100rpx;
}
.not-btn{
background-color: #909399!important;
border-color: #909399!important;
color: #fff!important;
}
}
}
.right{
.available{
.quota-info{
width: 100%;
display: inline-flex;
flex-direction: row;
flex-wrap: nowrap;
justify-content: space-between;
align-items: center;
.available-line{
font-size: 24rpx;
color: #828282;
height: 40rpx;
line-height: 50rpx;
}
.settlement-btn{
background: #ef2c1c;
color: #FFFFFF;
height: 55rpx;
line-height: 55rpx;
width: 200rpx;
text-align: center;
border-radius: 100rpx;
}
.not-btn{
background-color: #909399!important;
border-color: #909399!important;
color: #fff!important;
}
}
}
}

View File

@ -26,6 +26,7 @@ export default {
return obj;
},
/**
* 提示信息 微提示
* opt object | string
* to_url object | string
* :
@ -119,6 +120,26 @@ export default {
}
}
},
// 提示信息 确认弹框
tips(config, confirmFun, confirmData) {
uni.showModal({
title: config.title || '提示',// 弹框标题
content: config.content || '',// 提示
confirmText: config.confirmText || '关闭',// 确认按钮文字
editable: config.editable || false,//是否显示输入框
placeholderText: config.placeholderText || '请输入内容',//输入框提示内容
showCancel: config.showCancel || false, // 是否显示取消按钮
cancelText: '取消', // 取消按钮文字
success(res) {
if (res.confirm) {
// console.log('点击确认按钮')
if(typeof confirmFun === "function") confirmFun(confirmData);
} else {
// console.log('点击关闭按钮')
}
}
})
},
/**
* 移除数组中的某个数组并组成新的数组返回
* @param array array 需要移除的数组
@ -849,14 +870,15 @@ export default {
// 获取地理位置;
$L: {
async getLocation() {
let status = 0;
// #ifdef APP-PLUS
let status = await this.checkPermission();
status = await this.checkPermission();
if (status !== 1) {
return;
}
// #endif
// #ifdef MP-WEIXIN || MP-TOUTIAO || MP-QQ
let status = await this.getSetting();
status = await this.getSetting();
if (status === 2) {
this.openSetting();
return;