会员修复
This commit is contained in:
@@ -474,7 +474,9 @@
|
|||||||
})
|
})
|
||||||
Object.assign(pointsRes, res)
|
Object.assign(pointsRes, res)
|
||||||
maxPointDiscount.value = res.maxDeductionAmount
|
maxPointDiscount.value = res.maxDeductionAmount
|
||||||
cartStore.setUserPoints(res.maxUsablePoints || 0)
|
if(usePoints.value){
|
||||||
|
cartStore.setUserPoints(res.maxUsablePoints || 0)
|
||||||
|
}
|
||||||
console.log('getMaxPointsDiscount:cartStore.orderCostSummary.pointUsed', cartStore.orderCostSummary.pointUsed);
|
console.log('getMaxPointsDiscount:cartStore.orderCostSummary.pointUsed', cartStore.orderCostSummary.pointUsed);
|
||||||
}
|
}
|
||||||
watch(() => maxMoney.value, (newval) => {
|
watch(() => maxMoney.value, (newval) => {
|
||||||
|
|||||||
@@ -221,10 +221,9 @@
|
|||||||
if (newval && newval.id) {
|
if (newval && newval.id) {
|
||||||
disablePayType.value = ['余额支付']
|
disablePayType.value = ['余额支付']
|
||||||
paymentMethodref.value.groupChanges(2)
|
paymentMethodref.value.groupChanges(2)
|
||||||
} else {
|
return
|
||||||
disablePayType.value = []
|
}
|
||||||
}
|
console.log('orderVIP.value.amount',orderVIP.value.amount);
|
||||||
|
|
||||||
if (!orderVIP.value.amount) {
|
if (!orderVIP.value.amount) {
|
||||||
disablePayType.value = ['余额支付']
|
disablePayType.value = ['余额支付']
|
||||||
if (paymentMethodref.value) {
|
if (paymentMethodref.value) {
|
||||||
|
|||||||
@@ -146,7 +146,8 @@
|
|||||||
import {
|
import {
|
||||||
ref,
|
ref,
|
||||||
reactive,
|
reactive,
|
||||||
computed
|
computed,
|
||||||
|
watch
|
||||||
} from "vue"
|
} from "vue"
|
||||||
import {
|
import {
|
||||||
joinMember,
|
joinMember,
|
||||||
@@ -194,15 +195,15 @@
|
|||||||
const state = reactive({
|
const state = reactive({
|
||||||
openType: 'CONDITION'
|
openType: 'CONDITION'
|
||||||
})
|
})
|
||||||
|
|
||||||
const pay_menus = ref([{
|
const $pay_menus=[{
|
||||||
name: '赠送成长值',
|
name: '赠送成长值',
|
||||||
desc: '赠送成长值',
|
desc: '赠送成长值',
|
||||||
icon: '/user/static/buy-vip/Frame_220.png',
|
icon: '/user/static/buy-vip/Frame_220.png',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: '优惠券',
|
name: '优惠券',
|
||||||
desc: '每月赠送2张优惠券',
|
desc: '',
|
||||||
icon: '/user/static/buy-vip/Frame_221.png'
|
icon: '/user/static/buy-vip/Frame_221.png'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -212,7 +213,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: '会员折扣',
|
name: '会员折扣',
|
||||||
desc: '全店折扣98折',
|
desc: '',
|
||||||
icon: '/user/static/buy-vip/Frame_223.png'
|
icon: '/user/static/buy-vip/Frame_223.png'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -225,7 +226,9 @@
|
|||||||
desc: '',
|
desc: '',
|
||||||
icon: '/user/static/buy-vip/Frame_225.png'
|
icon: '/user/static/buy-vip/Frame_225.png'
|
||||||
}
|
}
|
||||||
])
|
]
|
||||||
|
|
||||||
|
const pay_menus = ref($pay_menus)
|
||||||
|
|
||||||
let tiaojian_menus =ref( [{
|
let tiaojian_menus =ref( [{
|
||||||
name: '享会员价',
|
name: '享会员价',
|
||||||
@@ -295,7 +298,7 @@
|
|||||||
if (res) {
|
if (res) {
|
||||||
if(!res.memberConfig.isMemberPrice){
|
if(!res.memberConfig.isMemberPrice){
|
||||||
tiaojian_menus.value=tiaojian_menus.value.filter(v=>v.name!='享会员价')
|
tiaojian_menus.value=tiaojian_menus.value.filter(v=>v.name!='享会员价')
|
||||||
pay_menus.value=pay_menus.value.filter(v=>v.name!='享会员价')
|
pay_menus.value=$pay_menus.filter(v=>v.name!='享会员价')
|
||||||
}
|
}
|
||||||
if (res.memberConfig.isSubmitInfo && (shopUserInfo.value.sex === null || shopUserInfo.value.sex ===
|
if (res.memberConfig.isSubmitInfo && (shopUserInfo.value.sex === null || shopUserInfo.value.sex ===
|
||||||
undefined || !shopUserInfo.value.nickName || !shopUserInfo.value.birthDay || !shopUserInfo.value
|
undefined || !shopUserInfo.value.nickName || !shopUserInfo.value.birthDay || !shopUserInfo.value
|
||||||
@@ -319,8 +322,9 @@
|
|||||||
configList.value = res.memberConfig.configList
|
configList.value = res.memberConfig.configList
|
||||||
|
|
||||||
Object.assign(state, res.memberConfig)
|
Object.assign(state, res.memberConfig)
|
||||||
memberLevel.value = res.memberLevel
|
const first_lv=(res.memberLevelList||[])[0]
|
||||||
|
memberLevel.value = res.memberLevel||first_lv
|
||||||
|
filterPay_menus()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const returnReward = computed(() => {
|
const returnReward = computed(() => {
|
||||||
@@ -389,6 +393,36 @@
|
|||||||
},1000)
|
},1000)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//过滤掉部分未开启的菜单相
|
||||||
|
function filterPay_menus(){
|
||||||
|
pay_menus.value=$pay_menus.filter(v=>{
|
||||||
|
if(!state.isMemberPrice&&v.name=='享会员价'){
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if (state.isSubmitInfo && (shopUserInfo.value.sex === null || shopUserInfo.value.sex ===
|
||||||
|
undefined || !shopUserInfo.value.nickName || !shopUserInfo.value.birthDay || !shopUserInfo.value
|
||||||
|
.phone)) {
|
||||||
|
memberOpen.value = true;
|
||||||
|
}
|
||||||
|
const viplv= configList.value[vipSel.value]
|
||||||
|
if(viplv.couponList.length==0&&v.name=='优惠券'){
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if((!memberLevel.value||!memberLevel.value.isCostRewardPoints)&&v.name=='消费送积分'){
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if((!memberLevel.value||!memberLevel.value.isCycleReward)&&v.name=='周期福利'){
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
})
|
||||||
|
}
|
||||||
|
watch(()=>vipSel.value,(newval,oldval)=>{
|
||||||
|
console.log('vipSel.value',newval);
|
||||||
|
filterPay_menus()
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
731
user/vip/vip.vue
731
user/vip/vip.vue
@@ -47,7 +47,8 @@
|
|||||||
</view>
|
</view>
|
||||||
<view class="font-14 color-333 text-center u-m-t-4 u-flex u-flex-center">
|
<view class="font-14 color-333 text-center u-m-t-4 u-flex u-flex-center">
|
||||||
<text class="no-wrap u-m-r-4">{{ item.name }}</text>
|
<text class="no-wrap u-m-r-4">{{ item.name }}</text>
|
||||||
<up-icon @click="modelShow(item.name)" size="12" name="question-circle" color="#333" v-if="showQuestion(index)"></up-icon>
|
<up-icon @click="modelShow(item.name)" size="12" name="question-circle" color="#333"
|
||||||
|
v-if="showQuestion(index)"></up-icon>
|
||||||
</view>
|
</view>
|
||||||
<view class="font-12 color-666 text-center">{{ item.desc }}</view>
|
<view class="font-12 color-666 text-center">{{ item.desc }}</view>
|
||||||
</view>
|
</view>
|
||||||
@@ -78,383 +79,423 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import dayjs from 'dayjs';
|
import dayjs from 'dayjs';
|
||||||
import { onLoad } from '@dcloudio/uni-app';
|
import {
|
||||||
import * as vipApi from '@/common/api/market/vip.js';
|
onLoad
|
||||||
import { APIusershopInfodetail, APIshopUserInfo } from '@/common/api/member.js';
|
} from '@dcloudio/uni-app';
|
||||||
import { ref, reactive, computed } from 'vue';
|
import * as vipApi from '@/common/api/market/vip.js';
|
||||||
const model = reactive({
|
import {
|
||||||
show: false,
|
APIusershopInfodetail,
|
||||||
title: ''
|
APIshopUserInfo
|
||||||
});
|
} from '@/common/api/member.js';
|
||||||
|
import {
|
||||||
function modelHide() {
|
ref,
|
||||||
model.show = false;
|
reactive,
|
||||||
}
|
computed
|
||||||
|
} from 'vue';
|
||||||
function toXufei() {
|
const model = reactive({
|
||||||
uni.navigateTo({
|
show: false,
|
||||||
url: '/user/vip/buy-vip?shopId=' + option.shopId
|
title: ''
|
||||||
});
|
});
|
||||||
}
|
|
||||||
|
|
||||||
function modelShow(name) {
|
function modelHide() {
|
||||||
if (name == '消费送积分') {
|
model.show = false;
|
||||||
model.title = '消费送积分';
|
|
||||||
modelContent.value = `每消耗1元赠送${memberLevel.value.costRewardPoints}积分`;
|
|
||||||
}
|
}
|
||||||
if (name == '周期福利') {
|
|
||||||
model.title = '周期福利';
|
|
||||||
modelContent.value = `每${memberLevel.value.cycleUnit}赠送${memberLevel.value.cycleRewardPoints}积分,${memberLevel.value.cycleRewardCouponList.length}张优惠券`;
|
|
||||||
}
|
|
||||||
if (name == '会员说明') {
|
|
||||||
model.title = '会员说明';
|
|
||||||
modelContent.value = state.remark;
|
|
||||||
}
|
|
||||||
if (name == '等级说明') {
|
|
||||||
model.title = '等级说明';
|
|
||||||
modelContent.value = memberLevel.value.remark || '';
|
|
||||||
}
|
|
||||||
model.show = true;
|
|
||||||
}
|
|
||||||
const modelContent = ref(``);
|
|
||||||
const state = reactive({
|
|
||||||
openType: 'CONDITION'
|
|
||||||
});
|
|
||||||
|
|
||||||
let pay_menus = [
|
function toXufei() {
|
||||||
{
|
uni.navigateTo({
|
||||||
name: '赠送成长值',
|
url: '/user/vip/buy-vip?shopId=' + option.shopId
|
||||||
desc: '',
|
|
||||||
icon: '/user/static/Frame_220.png'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: '优惠券',
|
|
||||||
desc: '每月赠送2张优惠券',
|
|
||||||
icon: '/user/static/Frame_221.png'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: '享会员价',
|
|
||||||
desc: '全店会员价',
|
|
||||||
icon: '/user/static/Frame_222.png'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: '会员折扣',
|
|
||||||
desc: '',
|
|
||||||
icon: '/user/static/Frame_223.png'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: '消费送积分',
|
|
||||||
desc: '',
|
|
||||||
icon: '/user/static/Frame_224.png'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: '周期福利',
|
|
||||||
desc: '',
|
|
||||||
icon: '/user/static/Frame_225.png'
|
|
||||||
}
|
|
||||||
];
|
|
||||||
|
|
||||||
let tiaojian_menus = [
|
|
||||||
{
|
|
||||||
name: '享会员价',
|
|
||||||
desc: '全店会员价',
|
|
||||||
icon: '/user/static/Frame_222.png'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: '会员折扣',
|
|
||||||
desc: '',
|
|
||||||
icon: '/user/static/Frame_223.png'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: '消费送积分',
|
|
||||||
desc: '',
|
|
||||||
icon: '/user/static/Frame_224.png'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: '周期福利',
|
|
||||||
desc: '',
|
|
||||||
icon: '/user/static/Frame_225.png'
|
|
||||||
}
|
|
||||||
];
|
|
||||||
|
|
||||||
const menus = ref([]);
|
|
||||||
|
|
||||||
function showQuestion(index) {
|
|
||||||
const len = menus.value.length;
|
|
||||||
if (index >= len - 2) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
function back() {
|
|
||||||
uni.navigateBack();
|
|
||||||
}
|
|
||||||
|
|
||||||
const option = reactive({
|
|
||||||
shopId: ''
|
|
||||||
});
|
|
||||||
|
|
||||||
const memberLevel = ref(null);
|
|
||||||
const shopInfo = reactive({});
|
|
||||||
const shopUserInfo = ref({});
|
|
||||||
const memberLevelList = ref([]);
|
|
||||||
onLoad((opt) => {
|
|
||||||
Object.assign(option, opt);
|
|
||||||
console.log(option);
|
|
||||||
let shopId = option.shopId;
|
|
||||||
init(shopId);
|
|
||||||
});
|
|
||||||
const expProgress = ref(0);
|
|
||||||
async function init(shopId) {
|
|
||||||
const userRes = await APIshopUserInfo({
|
|
||||||
shopId
|
|
||||||
});
|
|
||||||
if (userRes) {
|
|
||||||
shopUserInfo.value = userRes;
|
|
||||||
}
|
|
||||||
const shopRes = await APIusershopInfodetail({
|
|
||||||
shopId
|
|
||||||
});
|
|
||||||
if (shopRes) {
|
|
||||||
Object.assign(shopInfo, shopRes.shopInfo);
|
|
||||||
}
|
|
||||||
const res = await vipApi.config({
|
|
||||||
shopId: shopId
|
|
||||||
});
|
|
||||||
if (res) {
|
|
||||||
Object.assign(state, res.memberConfig);
|
|
||||||
memberLevelList.value = res.memberLevelList;
|
|
||||||
pay_menus = pay_menus.map((v) => {
|
|
||||||
if (v.name == '优惠券') {
|
|
||||||
if (res.memberLevel.cycleRewardCouponList.length) {
|
|
||||||
v.desc = `每${res.memberLevel.cycleUnit}赠送${res.memberLevel.cycleRewardCouponList.length}张优惠券`;
|
|
||||||
} else {
|
|
||||||
v.desc = '';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (v.name == '会员折扣') {
|
|
||||||
v.desc = '全店折扣' + res.memberLevel.discount / 10 + '折';
|
|
||||||
}
|
|
||||||
return v;
|
|
||||||
});
|
});
|
||||||
tiaojian_menus = tiaojian_menus.map((v) => {
|
}
|
||||||
if (v.name == '优惠券') {
|
|
||||||
if (res.memberLevel.cycleRewardCouponList.length) {
|
function modelShow(name) {
|
||||||
v.desc = `每${res.memberLevel.cycleUnit}赠送${res.memberLevel.cycleRewardCouponList.length}张优惠券`;
|
if (name == '消费送积分') {
|
||||||
} else {
|
model.title = '消费送积分';
|
||||||
v.desc = '';
|
modelContent.value = `每消耗1元赠送${memberLevel.value.costRewardPoints}积分`;
|
||||||
}
|
}
|
||||||
}
|
if (name == '周期福利') {
|
||||||
if (v.name == '会员折扣') {
|
model.title = '周期福利';
|
||||||
v.desc = '全店折扣' + res.memberLevel.discount / 10 + '折';
|
modelContent.value =
|
||||||
}
|
`每${memberLevel.value.cycleUnit}赠送${memberLevel.value.cycleRewardPoints}积分,${memberLevel.value.cycleRewardCouponList.length}张优惠券`;
|
||||||
return v;
|
}
|
||||||
|
if (name == '会员说明') {
|
||||||
|
model.title = '会员说明';
|
||||||
|
modelContent.value = state.remark;
|
||||||
|
}
|
||||||
|
if (name == '等级说明') {
|
||||||
|
model.title = '等级说明';
|
||||||
|
modelContent.value = memberLevel.value.remark || '';
|
||||||
|
}
|
||||||
|
model.show = true;
|
||||||
|
}
|
||||||
|
const modelContent = ref(``);
|
||||||
|
const state = reactive({
|
||||||
|
openType: 'CONDITION'
|
||||||
|
});
|
||||||
|
|
||||||
|
let pay_menus = [{
|
||||||
|
name: '赠送成长值',
|
||||||
|
desc: '',
|
||||||
|
icon: '/user/static/Frame_220.png'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: '优惠券',
|
||||||
|
desc: '',
|
||||||
|
icon: '/user/static/Frame_221.png'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: '享会员价',
|
||||||
|
desc: '全店会员价',
|
||||||
|
icon: '/user/static/Frame_222.png'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: '会员折扣',
|
||||||
|
desc: '',
|
||||||
|
icon: '/user/static/Frame_223.png'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: '消费送积分',
|
||||||
|
desc: '',
|
||||||
|
icon: '/user/static/Frame_224.png'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: '周期福利',
|
||||||
|
desc: '',
|
||||||
|
icon: '/user/static/Frame_225.png'
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
|
let tiaojian_menus = [{
|
||||||
|
name: '享会员价',
|
||||||
|
desc: '全店会员价',
|
||||||
|
icon: '/user/static/Frame_222.png'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: '会员折扣',
|
||||||
|
desc: '',
|
||||||
|
icon: '/user/static/Frame_223.png'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: '消费送积分',
|
||||||
|
desc: '',
|
||||||
|
icon: '/user/static/Frame_224.png'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: '周期福利',
|
||||||
|
desc: '',
|
||||||
|
icon: '/user/static/Frame_225.png'
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
|
const menus = ref([]);
|
||||||
|
|
||||||
|
function showQuestion(index) {
|
||||||
|
const len = menus.value.length;
|
||||||
|
if (index >= len - 2) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
function back() {
|
||||||
|
uni.navigateBack();
|
||||||
|
}
|
||||||
|
|
||||||
|
const option = reactive({
|
||||||
|
shopId: ''
|
||||||
|
});
|
||||||
|
|
||||||
|
const memberLevel = ref(null);
|
||||||
|
const shopInfo = reactive({});
|
||||||
|
const shopUserInfo = ref({});
|
||||||
|
const memberLevelList = ref([]);
|
||||||
|
onLoad((opt) => {
|
||||||
|
Object.assign(option, opt);
|
||||||
|
console.log(option);
|
||||||
|
let shopId = option.shopId;
|
||||||
|
init(shopId);
|
||||||
|
});
|
||||||
|
const expProgress = ref(0);
|
||||||
|
async function init(shopId) {
|
||||||
|
const userRes = await APIshopUserInfo({
|
||||||
|
shopId
|
||||||
});
|
});
|
||||||
if (res.memberConfig.openType == 'PAY') {
|
if (userRes) {
|
||||||
menus.value = pay_menus;
|
shopUserInfo.value = userRes;
|
||||||
} else {
|
}
|
||||||
menus.value = tiaojian_menus;
|
const shopRes = await APIusershopInfodetail({
|
||||||
|
shopId
|
||||||
|
});
|
||||||
|
if (shopRes) {
|
||||||
|
Object.assign(shopInfo, shopRes.shopInfo);
|
||||||
|
}
|
||||||
|
const res = await vipApi.config({
|
||||||
|
shopId: shopId
|
||||||
|
});
|
||||||
|
if (res) {
|
||||||
|
res.memberLevel.cycleRewardCouponList = res.memberLevel.cycleRewardCouponList || []
|
||||||
|
res.memberLevel = res.memberLevel || {}
|
||||||
|
Object.assign(state, res.memberConfig);
|
||||||
|
memberLevelList.value = res.memberLevelList;
|
||||||
|
pay_menus = pay_menus.filter(v => {
|
||||||
|
if (!res.memberLevel.isCostRewardPoints && v.name == '消费送积分') {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if (!res.memberLevel.isCycleReward && v.name == '周期福利') {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if (!res.memberLevel.cycleRewardCouponList || res.memberLevel.cycleRewardCouponList.length <=
|
||||||
|
0 && v.name == '优惠券') {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}).map((v) => {
|
||||||
|
if (v.name == '赠送成长值' && res.memberLevel) {
|
||||||
|
v.desc = `赠送${res.memberLevel.experienceValue}成长值`
|
||||||
|
}
|
||||||
|
if (v.name == '优惠券') {
|
||||||
|
if (res.memberLevel.cycleRewardCouponList.length) {
|
||||||
|
v.desc =
|
||||||
|
`每${res.memberLevel.cycleUnit}赠送${res.memberLevel.cycleRewardCouponList.length}张优惠券`;
|
||||||
|
} else {
|
||||||
|
v.desc = '';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (v.name == '会员折扣') {
|
||||||
|
v.desc = '全店折扣' + res.memberLevel.discount / 10 + '折';
|
||||||
|
}
|
||||||
|
return v;
|
||||||
|
});
|
||||||
|
tiaojian_menus = tiaojian_menus.filter(v => {
|
||||||
|
if (!state.isCostRewardPoints && v.name == '消费送积分') {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if (!state.isCycleReward && v.name == '周期福利') {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if (!res.memberLevel.cycleRewardCouponList || res.memberLevel.cycleRewardCouponList.length <=
|
||||||
|
0 && v.name == '优惠券') {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}).map((v) => {
|
||||||
|
if (v.name == '优惠券') {
|
||||||
|
if (res.memberLevel.cycleRewardCouponList.length) {
|
||||||
|
v.desc =
|
||||||
|
`每${res.memberLevel.cycleUnit}赠送${res.memberLevel.cycleRewardCouponList.length}张优惠券`;
|
||||||
|
} else {
|
||||||
|
v.desc = '';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (v.name == '会员折扣') {
|
||||||
|
v.desc = '全店折扣' + res.memberLevel.discount / 10 + '折';
|
||||||
|
}
|
||||||
|
return v;
|
||||||
|
});
|
||||||
|
if (res.memberConfig.openType == 'PAY') {
|
||||||
|
menus.value = pay_menus;
|
||||||
|
} else {
|
||||||
|
menus.value = tiaojian_menus;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const res1 = await vipApi.detail({
|
||||||
|
shopId: shopId
|
||||||
|
});
|
||||||
|
if (res1) {
|
||||||
|
memberLevel.value = {
|
||||||
|
...res1.memberLevel,
|
||||||
|
endTime: res1.endTime,
|
||||||
|
memberName: res1.memberName,
|
||||||
|
experience: res1.experience,
|
||||||
|
nextExperienceValue: res1.nextExperienceValue
|
||||||
|
};
|
||||||
|
const total = res1.experience * 1 + res1.nextExperienceValue * 1;
|
||||||
|
const percent = ((res1.experience * 1) / total) * 100;
|
||||||
|
if (total <= 0 || res1.experience * 1 <= 0) {
|
||||||
|
expProgress.value = 100;
|
||||||
|
}
|
||||||
|
expProgress.value = percent;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const res1 = await vipApi.detail({
|
|
||||||
shopId: shopId
|
const nextName = computed(() => {
|
||||||
});
|
if (memberLevelList.value.length <= 0 || !memberLevel.value) {
|
||||||
if (res1) {
|
return null;
|
||||||
memberLevel.value = {
|
|
||||||
...res1.memberLevel,
|
|
||||||
endTime: res1.endTime,
|
|
||||||
memberName: res1.memberName,
|
|
||||||
experience: res1.experience,
|
|
||||||
nextExperienceValue: res1.nextExperienceValue
|
|
||||||
};
|
|
||||||
const total = res1.experience * 1 + res1.nextExperienceValue * 1;
|
|
||||||
const percent = ((res1.experience * 1) / total) * 100;
|
|
||||||
if (total <= 0 || res1.experience * 1 <= 0) {
|
|
||||||
expProgress.value = 100;
|
|
||||||
}
|
}
|
||||||
expProgress.value = percent;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const nextName = computed(() => {
|
const index = memberLevelList.value.findIndex((v) => v.id == memberLevel.value.id);
|
||||||
if (memberLevelList.value.length <= 0 || !memberLevel.value) {
|
if (index == -1 || index >= memberLevelList.value.length - 1) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
const next = memberLevelList.value[index + 1];
|
||||||
const index = memberLevelList.value.findIndex((v) => v.id == memberLevel.value.id);
|
return next.name;
|
||||||
if (index == -1 || index >= memberLevelList.value.length - 1) {
|
});
|
||||||
return null;
|
|
||||||
}
|
|
||||||
const next = memberLevelList.value[index + 1];
|
|
||||||
return next.name;
|
|
||||||
});
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
page {
|
page {
|
||||||
background: #f9f9f9;
|
background: #f9f9f9;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
.font-700 {
|
.font-700 {
|
||||||
font-weight: 700;
|
|
||||||
}
|
|
||||||
|
|
||||||
.color-one {
|
|
||||||
color: #558abf;
|
|
||||||
}
|
|
||||||
|
|
||||||
.color-2 {
|
|
||||||
color: #273d7a;
|
|
||||||
}
|
|
||||||
|
|
||||||
.top {
|
|
||||||
background: linear-gradient(283deg, #a9cbf8 11.62%, #e5e7eb 74.58%);
|
|
||||||
}
|
|
||||||
|
|
||||||
.top {
|
|
||||||
padding: 208rpx 30rpx 78rpx 30rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
.vip-box {
|
|
||||||
background-size: cover;
|
|
||||||
position: relative;
|
|
||||||
border-radius: 12px;
|
|
||||||
overflow: hidden;
|
|
||||||
padding-left: 6px;
|
|
||||||
padding-right: 64rpx;
|
|
||||||
padding-bottom: 24rpx;
|
|
||||||
position: relative;
|
|
||||||
.bg {
|
|
||||||
width: 100%;
|
|
||||||
height: 100%;
|
|
||||||
position: absolute;
|
|
||||||
top: 0;
|
|
||||||
left: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.icon {
|
|
||||||
position: absolute;
|
|
||||||
right: 42rpx;
|
|
||||||
top: 0;
|
|
||||||
|
|
||||||
.huangguan {
|
|
||||||
width: 214rpx;
|
|
||||||
height: 206rpx;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.tag {
|
|
||||||
position: absolute;
|
|
||||||
top: 0;
|
|
||||||
font-size: 12px;
|
|
||||||
color: #46739f;
|
|
||||||
padding: 2px 12px;
|
|
||||||
background: #c7d0da;
|
|
||||||
border-radius: 0 0 12px 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.shop-name {
|
|
||||||
margin-top: 23px;
|
|
||||||
color: #6988ab;
|
|
||||||
font-size: 16px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.lv {
|
|
||||||
color: #273d7a;
|
|
||||||
font-weight: 700;
|
font-weight: 700;
|
||||||
font-size: 64rpx;
|
|
||||||
letter-spacing: 4rpx;
|
|
||||||
transform: skewX(-10deg);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.time {
|
.color-one {
|
||||||
color: #6988ab;
|
color: #558abf;
|
||||||
font-size: 24rpx;
|
|
||||||
font-weight: 400;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.rule {
|
.color-2 {
|
||||||
.exp {
|
color: #273d7a;
|
||||||
|
}
|
||||||
|
|
||||||
|
.top {
|
||||||
|
background: linear-gradient(283deg, #a9cbf8 11.62%, #e5e7eb 74.58%);
|
||||||
|
}
|
||||||
|
|
||||||
|
.top {
|
||||||
|
padding: 208rpx 30rpx 78rpx 30rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.vip-box {
|
||||||
|
background-size: cover;
|
||||||
|
position: relative;
|
||||||
|
border-radius: 12px;
|
||||||
|
overflow: hidden;
|
||||||
|
padding-left: 6px;
|
||||||
|
padding-right: 64rpx;
|
||||||
|
padding-bottom: 24rpx;
|
||||||
|
position: relative;
|
||||||
|
|
||||||
|
.bg {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.desc {
|
.icon {
|
||||||
|
position: absolute;
|
||||||
|
right: 42rpx;
|
||||||
|
top: 0;
|
||||||
|
|
||||||
|
.huangguan {
|
||||||
|
width: 214rpx;
|
||||||
|
height: 206rpx;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.tag {
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
font-size: 12px;
|
||||||
|
color: #46739f;
|
||||||
|
padding: 2px 12px;
|
||||||
|
background: #c7d0da;
|
||||||
|
border-radius: 0 0 12px 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.shop-name {
|
||||||
|
margin-top: 23px;
|
||||||
|
color: #6988ab;
|
||||||
|
font-size: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.lv {
|
||||||
color: #273d7a;
|
color: #273d7a;
|
||||||
|
font-weight: 700;
|
||||||
|
font-size: 64rpx;
|
||||||
|
letter-spacing: 4rpx;
|
||||||
|
transform: skewX(-10deg);
|
||||||
|
}
|
||||||
|
|
||||||
|
.time {
|
||||||
|
color: #6988ab;
|
||||||
|
font-size: 24rpx;
|
||||||
|
font-weight: 400;
|
||||||
|
}
|
||||||
|
|
||||||
|
.rule {
|
||||||
|
.exp {}
|
||||||
|
|
||||||
|
.desc {
|
||||||
|
color: #273d7a;
|
||||||
|
font-size: 24rpx;
|
||||||
|
font-weight: 400;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.next-tips {
|
||||||
|
color: #6988ab;
|
||||||
font-size: 24rpx;
|
font-size: 24rpx;
|
||||||
font-weight: 400;
|
font-weight: 400;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.next-tips {
|
.progress {
|
||||||
color: #6988ab;
|
margin-top: 8rpx;
|
||||||
font-size: 24rpx;
|
background-color: #bdd5e9;
|
||||||
font-weight: 400;
|
height: 10rpx;
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.progress {
|
|
||||||
margin-top: 8rpx;
|
|
||||||
background-color: #bdd5e9;
|
|
||||||
height: 10rpx;
|
|
||||||
border-radius: 10rpx;
|
|
||||||
|
|
||||||
.block {
|
|
||||||
height: 100%;
|
|
||||||
border-radius: 10rpx;
|
border-radius: 10rpx;
|
||||||
background: linear-gradient(90deg, #f9fbfa 0.03%, #334783 115.59%);
|
|
||||||
|
.block {
|
||||||
|
height: 100%;
|
||||||
|
border-radius: 10rpx;
|
||||||
|
background: linear-gradient(90deg, #f9fbfa 0.03%, #334783 115.59%);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
.vip-quanyi {
|
.vip-quanyi {
|
||||||
background-color: #fff;
|
background-color: #fff;
|
||||||
padding: 36rpx 18rpx 42rpx 38rpx;
|
padding: 36rpx 18rpx 42rpx 38rpx;
|
||||||
border-radius: 40rpx 40rpx 0 0;
|
border-radius: 40rpx 40rpx 0 0;
|
||||||
transform: translateY(-40rpx);
|
transform: translateY(-40rpx);
|
||||||
}
|
}
|
||||||
|
|
||||||
.menus-pays {
|
.menus-pays {
|
||||||
display: grid;
|
display: grid;
|
||||||
/* 每行显示3列,每列宽度相等 */
|
/* 每行显示3列,每列宽度相等 */
|
||||||
grid-template-columns: repeat(3, 1fr);
|
grid-template-columns: repeat(3, 1fr);
|
||||||
/* 列间距 */
|
/* 列间距 */
|
||||||
column-gap: 10px;
|
column-gap: 10px;
|
||||||
/* 行间距 */
|
/* 行间距 */
|
||||||
row-gap: 10px;
|
row-gap: 10px;
|
||||||
/* 可以添加容器的内边距 */
|
/* 可以添加容器的内边距 */
|
||||||
}
|
}
|
||||||
|
|
||||||
.menus-tiaojian {
|
.menus-tiaojian {
|
||||||
display: grid;
|
display: grid;
|
||||||
/* 每行显示3列,每列宽度相等 */
|
/* 每行显示3列,每列宽度相等 */
|
||||||
grid-template-columns: repeat(4, 1fr);
|
grid-template-columns: repeat(4, 1fr);
|
||||||
/* 列间距 */
|
/* 列间距 */
|
||||||
column-gap: 10px;
|
column-gap: 10px;
|
||||||
/* 行间距 */
|
/* 行间距 */
|
||||||
row-gap: 32rpx;
|
row-gap: 32rpx;
|
||||||
/* 可以添加容器的内边距 */
|
/* 可以添加容器的内边距 */
|
||||||
}
|
}
|
||||||
|
|
||||||
.model-box {
|
.model-box {
|
||||||
padding: 32rpx 56rpx;
|
padding: 32rpx 56rpx;
|
||||||
width: 702rpx;
|
width: 702rpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
.up-content {
|
.up-content {
|
||||||
color: #999;
|
color: #999;
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
}
|
}
|
||||||
.buy-btn {
|
|
||||||
margin: 98rpx 48rpx 48rpx 48rpx;
|
.buy-btn {
|
||||||
padding: 32rpx 32rpx;
|
margin: 98rpx 48rpx 48rpx 48rpx;
|
||||||
color: #fff;
|
padding: 32rpx 32rpx;
|
||||||
font-size: 16px;
|
color: #fff;
|
||||||
font-weight: 700;
|
font-size: 16px;
|
||||||
border-radius: 80rpx;
|
font-weight: 700;
|
||||||
line-height: 1;
|
border-radius: 80rpx;
|
||||||
background: linear-gradient(98deg, #fe6d1100 40.64%, #ffd1b4 105.2%), linear-gradient(259deg, #fe6d11 50.14%, #ffd1b4 114.93%);
|
line-height: 1;
|
||||||
box-shadow: 0 14rpx 30.4rpx 0 #fe8b435e;
|
background: linear-gradient(98deg, #fe6d1100 40.64%, #ffd1b4 105.2%), linear-gradient(259deg, #fe6d11 50.14%, #ffd1b4 114.93%);
|
||||||
}
|
box-shadow: 0 14rpx 30.4rpx 0 #fe8b435e;
|
||||||
</style>
|
}
|
||||||
|
</style>
|
||||||
@@ -12,13 +12,13 @@ import _ from "lodash";
|
|||||||
* @param {Object} shopInfo
|
* @param {Object} shopInfo
|
||||||
*/
|
*/
|
||||||
export function returnGoodsPrice(goods, user, shopInfo) {
|
export function returnGoodsPrice(goods, user, shopInfo) {
|
||||||
if(!goods){
|
if (!goods) {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
if (goods.discount_sale_amount * 1 > 0) {
|
if (goods.discount_sale_amount * 1 > 0) {
|
||||||
return goods.discount_sale_amount;
|
return goods.discount_sale_amount;
|
||||||
}
|
}
|
||||||
if(shopInfo&&!shopInfo.isMemberPrice){
|
if (shopInfo && !shopInfo.isMemberPrice) {
|
||||||
return goods.salePrice;
|
return goods.salePrice;
|
||||||
}
|
}
|
||||||
if (user.isVip && goods.memberPrice * 1 <= goods.salePrice * 1 && goods.memberPrice * 1 > 0) {
|
if (user.isVip && goods.memberPrice * 1 <= goods.salePrice * 1 && goods.memberPrice * 1 > 0) {
|
||||||
@@ -68,38 +68,37 @@ export function returnCoupType(coupon) {
|
|||||||
* @param user 用户信息
|
* @param user 用户信息
|
||||||
*/
|
*/
|
||||||
export function returnCanDikouGoodsArr(canDikouGoodsArr, selCoupon, user) {
|
export function returnCanDikouGoodsArr(canDikouGoodsArr, selCoupon, user) {
|
||||||
const types = [2, 4, 6];
|
const types = [2, 4, 6];
|
||||||
// 收集已抵扣商品并关联对应的优惠券类型
|
// 收集已抵扣商品并关联对应的优惠券类型
|
||||||
const goodsCouponGoods = selCoupon
|
const goodsCouponGoods = selCoupon
|
||||||
.filter((v) => types.includes(v.type))
|
.filter((v) => types.includes(v.type))
|
||||||
.reduce((prev, cur) => {
|
.reduce((prev, cur) => {
|
||||||
// 给每个抵扣商品添加所属优惠券类型
|
// 给每个抵扣商品添加所属优惠券类型
|
||||||
const goodsWithType = cur.discount.hasDiscountGoodsArr.map(goods => ({
|
const goodsWithType = cur.discount.hasDiscountGoodsArr.map(goods => ({
|
||||||
...goods,
|
...goods,
|
||||||
couponType: cur.type // 记录该商品是被哪种类型的优惠券抵扣的
|
couponType: cur.type // 记录该商品是被哪种类型的优惠券抵扣的
|
||||||
}));
|
}));
|
||||||
prev.push(...goodsWithType);
|
prev.push(...goodsWithType);
|
||||||
return prev;
|
return prev;
|
||||||
}, []);
|
}, []);
|
||||||
|
const arr = _.cloneDeep(canDikouGoodsArr)
|
||||||
|
.map((v) => {
|
||||||
|
const findCart = goodsCouponGoods.find((carts) => carts.id == v.id);
|
||||||
|
if (findCart) {
|
||||||
|
// 根据优惠券类型判断扣减数量
|
||||||
|
if ([4, 6].includes(findCart.couponType)) {
|
||||||
|
// 类型4(第二件半价)或6(买一送一),数量减2
|
||||||
|
v.num -= 2;
|
||||||
|
} else {
|
||||||
|
// 其他类型(如类型2商品券),按原逻辑扣减对应数量
|
||||||
|
v.num -= findCart.num;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return v;
|
||||||
|
})
|
||||||
|
.filter((v) => v.num > 0); // 过滤掉数量<=0的商品
|
||||||
|
|
||||||
const arr = _.cloneDeep(canDikouGoodsArr)
|
return arr;
|
||||||
.map((v) => {
|
|
||||||
const findCart = goodsCouponGoods.find((carts) => carts.id == v.id);
|
|
||||||
if (findCart) {
|
|
||||||
// 根据优惠券类型判断扣减数量
|
|
||||||
if ([4, 6].includes(findCart.couponType)) {
|
|
||||||
// 类型4(第二件半价)或6(买一送一),数量减2
|
|
||||||
v.num -= 2;
|
|
||||||
} else {
|
|
||||||
// 其他类型(如类型2商品券),按原逻辑扣减对应数量
|
|
||||||
v.num -= findCart.num;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return v;
|
|
||||||
})
|
|
||||||
.filter((v) => v.num > 0); // 过滤掉数量<=0的商品
|
|
||||||
|
|
||||||
return arr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -135,25 +134,24 @@ export function returnCouponCanUse(args) {
|
|||||||
reason: "优惠券未启用"
|
reason: "优惠券未启用"
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// 计算门槛金额
|
// 计算门槛金额
|
||||||
let fullAmount = goodsOrderPrice;
|
let fullAmount = goodsOrderPrice;
|
||||||
canDikouGoodsArr = returnCanDikouGoodsArr(canDikouGoodsArr, selCoupon, user,shopInfo);
|
canDikouGoodsArr = returnCanDikouGoodsArr(canDikouGoodsArr, selCoupon, user, shopInfo);
|
||||||
|
|
||||||
//优惠券指定门槛商品列表
|
//优惠券指定门槛商品列表
|
||||||
let canCalcGoodsArr=[...canDikouGoodsArr]
|
let canCalcGoodsArr = [...canDikouGoodsArr]
|
||||||
//部分商品参与门槛计算
|
//部分商品参与门槛计算
|
||||||
if(coupon.thresholdFoods.length){
|
if (coupon.thresholdFoods.length) {
|
||||||
canCalcGoodsArr = canDikouGoodsArr.filter((v) => {
|
canCalcGoodsArr = canDikouGoodsArr.filter((v) => {
|
||||||
return coupon.thresholdFoods.find((food) => food.id == v.productId);
|
return coupon.thresholdFoods.find((food) => food.id == v.productId);
|
||||||
});
|
});
|
||||||
fullAmount = canCalcGoodsArr.reduce((pre, cur) => {
|
fullAmount = canCalcGoodsArr.reduce((pre, cur) => {
|
||||||
return pre + returnGoodsPrice(cur, user,shopInfo) * cur.num;
|
return pre + returnGoodsPrice(cur, user, shopInfo) * cur.num;
|
||||||
}, 0);
|
}, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// 是否全部商品可用
|
// 是否全部商品可用
|
||||||
const isDikouAll = coupon.useFoods.length === 0;
|
const isDikouAll = coupon.useFoods.length === 0;
|
||||||
// 订单可用商品列表
|
// 订单可用商品列表
|
||||||
@@ -163,27 +161,27 @@ export function returnCouponCanUse(args) {
|
|||||||
return coupon.useFoods.find((food) => food.id == v.productId);
|
return coupon.useFoods.find((food) => food.id == v.productId);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if(user.isVip&&!coupon.vipPriceShare){
|
if (user.isVip && !coupon.vipPriceShare) {
|
||||||
return {
|
return {
|
||||||
canUse: false,
|
canUse: false,
|
||||||
reason: "非会员可用"
|
reason: "非会员可用"
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
if(selCoupon.length>0&&!selCoupon[0].otherCouponShare){
|
if (selCoupon.length > 0 && !selCoupon[0].otherCouponShare) {
|
||||||
return {
|
return {
|
||||||
canUse: false,
|
canUse: false,
|
||||||
reason: "当前选中的券不可与其他券同享"
|
reason: "当前选中的券不可与其他券同享"
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
if(selCoupon.length>0&&!coupon.otherCouponShare){
|
if (selCoupon.length > 0 && !coupon.otherCouponShare) {
|
||||||
return {
|
return {
|
||||||
canUse: false,
|
canUse: false,
|
||||||
reason: "当前选中的券不可与其他券同享"
|
reason: "当前选中的券不可与其他券同享"
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
// 满减券和折扣券计算门槛金额是否满足
|
// 满减券和折扣券计算门槛金额是否满足
|
||||||
if([1,3].includes(coupon.type)){
|
if ([1, 3].includes(coupon.type)) {
|
||||||
if(canCalcGoodsArr.length<=0){
|
if (canCalcGoodsArr.length <= 0) {
|
||||||
return {
|
return {
|
||||||
canUse: false,
|
canUse: false,
|
||||||
reason: "没有可参与计算门槛的商品"
|
reason: "没有可参与计算门槛的商品"
|
||||||
@@ -198,9 +196,15 @@ export function returnCouponCanUse(args) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 商品兑换券,第二件半价和买一送一判断是否有可用商品
|
// 商品兑换券,第二件半价和买一送一判断是否有可用商品
|
||||||
if([2,4,5].includes(coupon.type)){
|
if ([2, 4, 5].includes(coupon.type)) {
|
||||||
// 没有符合条件的商品
|
// 没有符合条件的商品
|
||||||
if (!isDikouAll && canCalcGoodsArr.length === 0) {
|
if (isDikouAll && canDikouGoodsArr.length === 0) {
|
||||||
|
return {
|
||||||
|
canUse: false,
|
||||||
|
reason: "没有符合条件的商品"
|
||||||
|
};
|
||||||
|
}
|
||||||
|
if (!isDikouAll && canUseGoodsArr.length === 0) {
|
||||||
return {
|
return {
|
||||||
canUse: false,
|
canUse: false,
|
||||||
reason: "没有符合条件的商品"
|
reason: "没有符合条件的商品"
|
||||||
@@ -208,7 +212,7 @@ export function returnCouponCanUse(args) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
//商品兑换券是否达到门槛金额
|
//商品兑换券是否达到门槛金额
|
||||||
if(coupon.type==2&&goodsOrderPrice<coupon.fullAmount){
|
if (coupon.type == 2 && goodsOrderPrice < coupon.fullAmount) {
|
||||||
return {
|
return {
|
||||||
canUse: false,
|
canUse: false,
|
||||||
reason: `满${coupon.fullAmount}元可用,当前可参与金额${fullAmount}元`
|
reason: `满${coupon.fullAmount}元可用,当前可参与金额${fullAmount}元`
|
||||||
@@ -264,7 +268,7 @@ export function returnCouponCanUse(args) {
|
|||||||
* @param user 用户信息
|
* @param user 用户信息
|
||||||
* @param {Object} shopInfo 店铺信息
|
* @param {Object} shopInfo 店铺信息
|
||||||
*/
|
*/
|
||||||
export function calcDiscountGoodsArrPrice(discountGoodsArr, discountNum, user,shopInfo) {
|
export function calcDiscountGoodsArrPrice(discountGoodsArr, discountNum, user, shopInfo) {
|
||||||
let hasCountNum = 0;
|
let hasCountNum = 0;
|
||||||
let discountPrice = 0;
|
let discountPrice = 0;
|
||||||
let hasDiscountGoodsArr = [];
|
let hasDiscountGoodsArr = [];
|
||||||
@@ -275,7 +279,7 @@ export function calcDiscountGoodsArrPrice(discountGoodsArr, discountNum, user,sh
|
|||||||
const goods = discountGoodsArr[i];
|
const goods = discountGoodsArr[i];
|
||||||
const shengyuNum = discountNum - hasCountNum;
|
const shengyuNum = discountNum - hasCountNum;
|
||||||
const num = Math.min(goods.num, shengyuNum);
|
const num = Math.min(goods.num, shengyuNum);
|
||||||
discountPrice += returnGoodsPrice(goods, user,shopInfo) * num;
|
discountPrice += returnGoodsPrice(goods, user, shopInfo) * num;
|
||||||
hasCountNum += num;
|
hasCountNum += num;
|
||||||
hasDiscountGoodsArr.push({
|
hasDiscountGoodsArr.push({
|
||||||
...goods,
|
...goods,
|
||||||
@@ -297,14 +301,14 @@ export function calcDiscountGoodsArrPrice(discountGoodsArr, discountNum, user,sh
|
|||||||
* @param selCoupon 已选择的优惠券列表
|
* @param selCoupon 已选择的优惠券列表
|
||||||
* @param shopInfo 店铺信息
|
* @param shopInfo 店铺信息
|
||||||
*/
|
*/
|
||||||
export function returnCouponDiscount(arr, coupon, user, goodsOrderPrice, selCoupon,shopInfo) {
|
export function returnCouponDiscount(arr, coupon, user, goodsOrderPrice, selCoupon, shopInfo) {
|
||||||
const canDikouGoodsArr = returnCanDikouGoodsArr(arr, selCoupon, user);
|
const canDikouGoodsArr = returnCanDikouGoodsArr(arr, selCoupon, user);
|
||||||
console.log('canDikouGoodsArr', canDikouGoodsArr);
|
|
||||||
if (coupon.type == 2) {
|
if (coupon.type == 2) {
|
||||||
return returnCouponProductDiscount(canDikouGoodsArr, coupon, user, shopInfo);
|
return returnCouponProductDiscount(canDikouGoodsArr, coupon, user, shopInfo);
|
||||||
}
|
}
|
||||||
if (coupon.type == 6) {
|
if (coupon.type == 6) {
|
||||||
return returnCouponBuyOneGiveOneDiscount(canDikouGoodsArr, coupon, user, shopInfo);
|
const result = returnCouponBuyOneGiveOneDiscount(canDikouGoodsArr, coupon, user, shopInfo);
|
||||||
|
return result
|
||||||
}
|
}
|
||||||
if (coupon.type == 4) {
|
if (coupon.type == 4) {
|
||||||
return returnSecoendDiscount(canDikouGoodsArr, coupon, user, shopInfo);
|
return returnSecoendDiscount(canDikouGoodsArr, coupon, user, shopInfo);
|
||||||
@@ -341,19 +345,19 @@ export function returnCouponZhekouDiscount(
|
|||||||
.reduce((prve, cur) => {
|
.reduce((prve, cur) => {
|
||||||
return new BigNumber(prve).plus(new BigNumber(cur.discount.discountPrice));
|
return new BigNumber(prve).plus(new BigNumber(cur.discount.discountPrice));
|
||||||
}, new BigNumber(0));
|
}, new BigNumber(0));
|
||||||
|
|
||||||
// 将商品订单价格转换为BigNumber并减去优惠券折扣
|
// 将商品订单价格转换为BigNumber并减去优惠券折扣
|
||||||
const adjustedGoodsOrderPrice = new BigNumber(goodsOrderPrice).minus(goodsCouponDiscount);
|
const adjustedGoodsOrderPrice = new BigNumber(goodsOrderPrice).minus(goodsCouponDiscount);
|
||||||
console.log('adjustedGoodsOrderPrice', adjustedGoodsOrderPrice.toNumber());
|
console.log('adjustedGoodsOrderPrice', adjustedGoodsOrderPrice.toNumber());
|
||||||
|
|
||||||
// 计算优惠比例:(100 - 折扣率) / 100
|
// 计算优惠比例:(100 - 折扣率) / 100
|
||||||
const discountAmountRatio = new BigNumber(100).minus(discountRate).dividedBy(100);
|
const discountAmountRatio = new BigNumber(100).minus(discountRate).dividedBy(100);
|
||||||
|
|
||||||
// 计算折扣金额:调整后的商品订单金额 × 优惠比例
|
// 计算折扣金额:调整后的商品订单金额 × 优惠比例
|
||||||
let discountPrice = adjustedGoodsOrderPrice.times(discountAmountRatio)
|
let discountPrice = adjustedGoodsOrderPrice.times(discountAmountRatio)
|
||||||
.decimalPlaces(2, BigNumber.ROUND_FLOOR)
|
.decimalPlaces(2, BigNumber.ROUND_FLOOR)
|
||||||
.toNumber();
|
.toNumber();
|
||||||
|
|
||||||
// 应用最大折扣金额限制
|
// 应用最大折扣金额限制
|
||||||
if (maxDiscountAmount !== 0) {
|
if (maxDiscountAmount !== 0) {
|
||||||
discountPrice = discountPrice >= maxDiscountAmount ? maxDiscountAmount : discountPrice;
|
discountPrice = discountPrice >= maxDiscountAmount ? maxDiscountAmount : discountPrice;
|
||||||
@@ -372,7 +376,7 @@ export function returnCouponZhekouDiscount(
|
|||||||
* @param user 用户信息
|
* @param user 用户信息
|
||||||
* @param shopInfo 店铺信息
|
* @param shopInfo 店铺信息
|
||||||
*/
|
*/
|
||||||
export function returnCouponProductDiscount(canDikouGoodsArr, coupon, user,shopInfo) {
|
export function returnCouponProductDiscount(canDikouGoodsArr, coupon, user, shopInfo) {
|
||||||
const {
|
const {
|
||||||
useFoods,
|
useFoods,
|
||||||
discountNum,
|
discountNum,
|
||||||
@@ -402,7 +406,7 @@ export function returnCouponProductDiscount(canDikouGoodsArr, coupon, user,shopI
|
|||||||
discountGoodsArr = discountSelGoodsArr.slice(0, discountNum);
|
discountGoodsArr = discountSelGoodsArr.slice(0, discountNum);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const result = calcDiscountGoodsArrPrice(discountGoodsArr, discountNum, user,shopInfo);
|
const result = calcDiscountGoodsArrPrice(discountGoodsArr, discountNum, user, shopInfo);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -413,7 +417,7 @@ export function returnCouponProductDiscount(canDikouGoodsArr, coupon, user,shopI
|
|||||||
* @param user 用户信息
|
* @param user 用户信息
|
||||||
* @param shopInfo 店铺信息
|
* @param shopInfo 店铺信息
|
||||||
*/
|
*/
|
||||||
function returnCouponBuyOneGiveOneDiscount(canDikouGoodsArr, coupon, user,shopInfo) {
|
function returnCouponBuyOneGiveOneDiscount(canDikouGoodsArr, coupon, user, shopInfo) {
|
||||||
const {
|
const {
|
||||||
useFoods,
|
useFoods,
|
||||||
useRule
|
useRule
|
||||||
@@ -425,23 +429,28 @@ function returnCouponBuyOneGiveOneDiscount(canDikouGoodsArr, coupon, user,shopIn
|
|||||||
//抵扣全部商品
|
//抵扣全部商品
|
||||||
if (useFoods.length === 0) {
|
if (useFoods.length === 0) {
|
||||||
if (useRule == "price_asc") {
|
if (useRule == "price_asc") {
|
||||||
discountGoods = canUseGoods[canUseGoods.length - 1];
|
discountGoods = canUseGoods[canUseGoods.length - 1]
|
||||||
} else {
|
} else {
|
||||||
discountGoods = canUseGoods.slice(0, 1);
|
discountGoods = canUseGoods[0];
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
//符合抵扣条件的商品
|
//符合抵扣条件的商品
|
||||||
const canUseGoods1 = canUseGoods.filter((v) => useFoods.find((food) => food.id == v.productId));
|
const canUseGoods1 = canUseGoods.filter((v) => useFoods.find((food) => food.id == v.productId));
|
||||||
if (useRule == "price_asc") {
|
if (useRule == "price_asc") {
|
||||||
discountGoods = canUseGoods1[canUseGoods1.length - 1];
|
discountGoods = canUseGoods1[canUseGoods1.length - 1]
|
||||||
} else {
|
} else {
|
||||||
discountGoods = canUseGoods1.slice(0, 1);
|
discountGoods = canUseGoods1[0]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const discountPrice = returnGoodsPrice(discountGoods, user,shopInfo);
|
let discountPrice = 0;
|
||||||
const hasDiscountGoodsArr = [discountGoods];
|
let hasDiscountGoodsArr = []
|
||||||
|
console.log('returnCouponBuyOneGiveOneDiscount:discountGoods',discountGoods);
|
||||||
|
if (discountGoods) {
|
||||||
|
discountPrice = returnGoodsPrice(discountGoods, user, shopInfo);
|
||||||
|
hasDiscountGoodsArr = [discountGoods];
|
||||||
|
}
|
||||||
return {
|
return {
|
||||||
discountPrice,
|
discountPrice:discountPrice<=0?0:discountPrice,
|
||||||
hasDiscountGoodsArr
|
hasDiscountGoodsArr
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -453,38 +462,40 @@ function returnCouponBuyOneGiveOneDiscount(canDikouGoodsArr, coupon, user,shopIn
|
|||||||
* @param user 用户信息
|
* @param user 用户信息
|
||||||
* @param shopInfo 店铺信息
|
* @param shopInfo 店铺信息
|
||||||
*/
|
*/
|
||||||
function returnSecoendDiscount(canDikouGoodsArr, coupon, user,shopInfo) {
|
function returnSecoendDiscount(canDikouGoodsArr, coupon, user, shopInfo) {
|
||||||
const {
|
const {
|
||||||
useFoods,
|
useFoods,
|
||||||
useRule
|
useRule
|
||||||
} = coupon;
|
} = coupon;
|
||||||
//抵扣商品
|
//抵扣商品
|
||||||
let discountGoods = undefined;
|
let discountGoods = undefined;
|
||||||
//符合买一送一条件的商品
|
//符合条件的商品
|
||||||
const canUseGoods = canDikouGoodsArr.filter((v) => v.num >= 2);
|
const canUseGoods = canDikouGoodsArr.filter((v) => v.num >= 2);
|
||||||
//抵扣全部商品
|
//抵扣全部商品
|
||||||
if (useFoods.length === 0) {
|
if (useFoods.length === 0) {
|
||||||
if (useRule == "price_asc") {
|
if (useRule == "price_asc") {
|
||||||
discountGoods = canUseGoods[canUseGoods.length - 1];
|
discountGoods = canUseGoods[canUseGoods.length - 1]
|
||||||
} else {
|
} else {
|
||||||
discountGoods = canUseGoods.slice(0, 1);
|
discountGoods = canUseGoods[0]
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
//符合抵扣条件的商品
|
//符合抵扣条件的商品
|
||||||
const canUseGoods1 = canUseGoods.filter((v) => useFoods.find((food) => food.id == v.productId));
|
const canUseGoods1 = canUseGoods.filter((v) => useFoods.find((food) => food.id == v.productId));
|
||||||
if (useRule == "price_asc") {
|
if (useRule == "price_asc") {
|
||||||
discountGoods = canUseGoods1[canUseGoods1.length - 1];
|
discountGoods = canUseGoods1[canUseGoods1.length - 1]
|
||||||
} else {
|
} else {
|
||||||
discountGoods = canUseGoods1.slice(0, 1);
|
discountGoods = canUseGoods1[0]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
console.log('returnSecoendDiscount:discountGoods',discountGoods);
|
let discountPrice = 0;
|
||||||
const discountPrice = returnGoodsPrice(discountGoods[0], user,shopInfo);
|
let hasDiscountGoodsArr = []
|
||||||
console.log('returnSecoendDiscount:discountPrice',discountPrice);
|
if (discountGoods) {
|
||||||
const hasDiscountGoodsArr = [discountGoods];
|
discountPrice = returnGoodsPrice(discountGoods, user, shopInfo);
|
||||||
|
hasDiscountGoodsArr = [discountGoods];
|
||||||
|
}
|
||||||
//返回半价价格
|
//返回半价价格
|
||||||
return {
|
return {
|
||||||
discountPrice: new BigNumber(discountPrice).dividedBy(2).toNumber(),
|
discountPrice: discountPrice <= 0 ? 0 : new BigNumber(discountPrice).dividedBy(2).toNumber(),
|
||||||
hasDiscountGoodsArr,
|
hasDiscountGoodsArr,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user