修改订单支付优惠券积分

This commit is contained in:
2024-11-11 16:09:09 +08:00
parent 2691cf9b53
commit 7d39bc2bee
5 changed files with 126 additions and 80 deletions

View File

@@ -45,9 +45,8 @@
<template v-if="myQuan.types.sel==1">
<view class="" @click="changeProductCoupon(item)" v-for="(item,index) in myQuan.res.productCoupon"
:class="{filtergray:!item.use}" :key="index"
>
<view class="quan goods u-row-between u-flex u-col-center u-m-b-32 border-r-10 u-relative" >
:class="{filtergray:!item.use}" :key="index">
<view class="quan goods u-row-between u-flex u-col-center u-m-b-32 border-r-10 u-relative">
<view class="no-use" v-if="!item.use">
<image class="img" src="/pagesOrder/static/image/no-use.svg" mode=""></image>
</view>
@@ -90,13 +89,21 @@
</view>
<view :style="{height:safebottomHeight+'px'}"></view>
<view class="fixed-b u-flex gap-20 bottom safe-bottom border-top">
<up-button shape="circle" plain @click="back">
<view class="font-bold">取消</view>
</up-button>
<up-button shape="circle" type="primary" @click="toEmitChooseQuan()">
<view class="font-bold" >确定</view>
</up-button>
<view class="fixed-b bottom safe-bottom border-top">
<view class="u-m-b-32">
<text>抵扣金额</text>
<text class="color-red"></text>
<text class="color-red">{{discountAmount}}</text>
</view>
<view class="u-flex gap-20">
<up-button shape="circle" plain @click="back">
<view class="font-bold">取消</view>
</up-button>
<up-button shape="circle" type="primary" @click="toEmitChooseQuan()">
<view class="font-bold">确定</view>
</up-button>
</view>
</view>
</view>
</template>
@@ -125,14 +132,20 @@
import {
queryAllShopUser
} from '@/http/yskApi/shop-user.js'
import {returnNewGoodsList,returnCoupCanUse,returnProductCoupon} from '../quan_util.js'
function back(){
import {
returnNewGoodsList,
returnCoupCanUse,
returnCouponAllPrice,
returnProductCoupon
} from '../quan_util.js'
function back() {
uni.navigateBack()
}
let order=ref({
let order = ref({
})
let canDikouGoodsArr=[]
let canDikouGoodsArr = []
const myQuan = reactive({
fullReductionCouponSel: {
id: ''
@@ -151,15 +164,15 @@
})
function changeProductCoupon(item) {
if(!item.use){
return
if (!item.use) {
return
}
item.checked = !item.checked
const CheckedArr=myQuan.res.productCoupon.filter(v=>v.checked)
const noCheckedArr=myQuan.res.productCoupon.filter(v=>!v.checked)
noCheckedArr.map(v=>{
console.log(returnCoupCanUse(canDikouGoodsArr,v,CheckedArr));
v.use=returnCoupCanUse(canDikouGoodsArr,v,CheckedArr)
const CheckedArr = myQuan.res.productCoupon.filter(v => v.checked)
const noCheckedArr = myQuan.res.productCoupon.filter(v => !v.checked)
noCheckedArr.map(v => {
console.log(returnCoupCanUse(canDikouGoodsArr, v, CheckedArr));
v.use = returnCoupCanUse(canDikouGoodsArr, v, CheckedArr)
})
}
@@ -174,26 +187,26 @@
function toUse(item) {
}
let user=reactive({
isVip:false
let user = reactive({
isVip: false
})
async function getQuan() {
order.value=await orderApi.tbOrderInfoDetail(option.orderId)
if(order.value.memberId){
const userRes= await queryAllShopUser({
order.value = await orderApi.tbOrderInfoDetail(option.orderId)
if (order.value.memberId) {
const userRes = await queryAllShopUser({
id: order.value.memberId
})
if (userRes.content[0]) {
user.value = userRes.content[0]
}
}
console.log(order.value);
const res = await $activateByOrderId(option)
canDikouGoodsArr=returnNewGoodsList(order.value.detailList||[])
canDikouGoodsArr = returnNewGoodsList(order.value.detailList || [])
res.fullReductionCoupon = res.fullReductionCoupon.filter((v) => !v.use)
res.productCoupon = res.productCoupon.map(v => {
const calcCoup=returnProductCoupon(v,canDikouGoodsArr,user.value)
const calcCoup = returnProductCoupon(v, canDikouGoodsArr, user.value)
return {
...calcCoup,
checked: false
@@ -204,32 +217,36 @@
}
const option = reactive({
orderId: '',
memberId: '',
payPrice:''
memberId: ''
})
function toEmitChooseQuan(item){
let arr=[]
if(item){
arr=[item]
}else{
if(myQuan.fullReductionCouponSel.id){
function toEmitChooseQuan(item) {
let arr = []
if (item) {
arr = [item]
} else {
if (myQuan.fullReductionCouponSel.id) {
arr.push(myQuan.fullReductionCouponSel)
}
const goodsQuan=myQuan.res.productCoupon.filter(v=>v.checked)
const goodsQuan = myQuan.res.productCoupon.filter(v => v.checked)
arr.push(...goodsQuan)
}
uni.$emit('choose-quan',arr)
uni.$emit('choose-quan', arr)
back()
}
const discountAmount = computed(() => {
const goodsQuan = myQuan.res.productCoupon.filter(v => v.checked)
const fullReductionCoupon = myQuan.fullReductionCouponSel.id ? [myQuan.fullReductionCouponSel] : []
let coupArr = [...fullReductionCoupon, ...goodsQuan]
return returnCouponAllPrice(coupArr, canDikouGoodsArr, user.value)
})
onLoad((opt) => {
Object.assign(option, opt)
getQuan()
})
let safebottomHeight = ref(0)
onReady(() => {
getSafeBottomHeight('bottom',0).then(height => {
getSafeBottomHeight('bottom', 0).then(height => {
safebottomHeight.value = height
})
})
@@ -238,7 +255,8 @@
<style lang="scss" scoped>
// $quan-color:rgb(233, 77, 60);
$quan-color: #318AFE;
.no-use{
.no-use {
position: absolute;
left: 0;
right: 0;
@@ -247,12 +265,14 @@
display: flex;
justify-content: center;
align-items: center;
.img{
.img {
width: 200rpx;
height: 200rpx;
z-index: 10;
}
}
.fixed-b {
position: fixed;
bottom: 0;
@@ -357,7 +377,7 @@
.hui {
// background-color: $quan-color;
background-image: linear-gradient(to right bottom,rgb(254,103,4),rgb(241,50,42));
background-image: linear-gradient(to right bottom, rgb(254, 103, 4), rgb(241, 50, 42));
padding: 4rpx 10rpx;
border-radius: 10rpx;
font-size: 24rpx;