套餐问题修复

This commit is contained in:
2025-12-20 14:41:46 +08:00
parent e29ccfeab4
commit 5b2c925fad
19 changed files with 1474 additions and 294 deletions

View File

@@ -18,7 +18,7 @@
</view>
<view class="u-flex u-col-center" v-if="tabs.sel==0">
<up-search v-model="query.wareName" @search="refresh" @clear="refresh"
<up-search v-model="query.packageName" @search="refresh" @clear="refresh"
@custom="refresh"></up-search>
<!-- <perpoleNumber v-model="query.groupPeopleNum"></perpoleNumber> -->
</view>
@@ -39,7 +39,7 @@
<view class="item" v-for="(item,index) in list" :key="index" @click="toDetail(item)">
<view class="relative img-box">
<up-image width="218rpx" radius="16rpx" height="218rpx" :src="returnCoverImg(item)"></up-image>
<view class="tag" v-if="item.tieredDiscount&&item.tieredDiscount.length">阶梯优惠</view>
<view class="tag" v-if="isHasDiscount(item)">阶梯优惠</view>
</view>
<view class="u-flex-1 u-p-l-16" style="max-width: 416rpx;">
<view class="u-line-1 name">{{item.packageName}}</view>
@@ -48,9 +48,9 @@
</view>
<view class="sale-number">已售{{item.saleNum||0}}</view>
<view class="info ">
<view class="left u-flex u-col-center">
<text class="u-font-24">最低到手</text>
<text class="u-font-32 font-bold"> ¥{{item.price}}</text>
<view class="left u-flex u-col-baseline">
<text class="u-font-24" v-if="isHasDiscount(item)">最低到手</text>
<text class="u-font-40 font-bold"> ¥{{minPrice(item)}}</text>
<text class="color-999 old-price"> ¥{{item.originPrice}}</text>
</view>
@@ -65,17 +65,57 @@
<view class="orders" v-else-if="tabs.sel==1">
<view class="item" v-for="(item,index) in list" :key="index" @click="toOrderDetail(item)">
<view class="u-flex u-col-center u-row-between">
<text class="numbers">{{item.groupPeopleNum}}人团</text>
<statusVue :status="item.status"></statusVue>
</view>
<view class="u-m-t-32 u-flex">
<up-image width="154rpx" height="154rpx" :src="item.goodsImg"></up-image>
<view class="img-box">
<up-image width="174rpx" height="174rpx" radius="12rpx" :src="item.goodsImg"></up-image>
<view class="tag" v-if="isHasDiscount(item)">阶梯优惠</view>
</view>
<view class="u-flex-1 u-flex u-p-l-30 u-col-center u-row-between">
<view>
<view class="">{{item.wareJson.wareName}}</view>
<view class="u-m-t-34 price">¥{{item.payAmount}}</view>
<view style="max-width: 336rpx;">
<view class="u-line-2 font-bold u-font-32">{{item.packageName}}</view>
<view class="u-line-1 u-m-t-10 color-666" >{{item.packageName}}
</view>
</view>
<view>
<statusVue :status="item.status"></statusVue>
<view class="u-m-t-16">
<template v-if="item.status=='ing'||item.status=='timeout'">
<view class=" main-color main-color">
当前到手
</view>
<view class=" font-bold price main-color u-m-t-4">
<text class="u-font-26"> ¥</text>
<text class="u-font-40">{{nowPrice(item)}}</text>
</view>
<view class=" main-color old-price" v-if="item">
¥{{item.originPrice}}
</view>
</template>
<template v-else>
<template v-if="item&&item.finalPrice">
<view class=" font-bold price main-color" >
<text class="u-font-26"> ¥</text>
<text class="u-font-40">{{item.finalPrice}}</text>
</view>
<view class=" main-color old-price" >
¥{{item.originPrice}}
</view>
</template>
<template v-else>
<view class=" font-bold price main-color" >
<text class="u-font-26"> ¥</text>
<text class="u-font-40">{{item.price}}</text>
</view>
<view class=" main-color old-price" >
¥{{item.originPrice}}
</view>
</template>
</template>
</view>
</view>
<text class="u-font-40 font-bold">x{{item.num}}</text>
</view>
@@ -94,19 +134,24 @@
<text class="stitle price">{{returnTime(item)}}</text>
</view>
</view>
<view class="btns" v-if="showBtns(item)">
<template v-if="item.status=='待核销'">
<view class="btn " @click.stop="lookCode(item)">查看券码</view>
<button class="btn black" @click.stop="refund(item)">申请退款</button>
<view class="btns" v-if="item&&item.status">
<template v-if="item.status=='ing'">
<view class="btn " @click.stop="cancelOrder(item)">取消活动</view>
<view class="btn " @click.stop="nowBuy(item)">立即购买</view>
<button class="btn black" open-type="share" @click.stop="share(item)">分享</button>
</template>
<template v-else-if="item.status=='退款中'">
<view class="btn " @click.stop="lookCode(item)">查看券码</view>
<view class="btn black" @click.stop="cancelRefund(item)">取消退款</view>
<template v-if="item.status=='timeout'">
<view class="btn " @click.stop="cancelOrder(item)">取消活动</view>
<view class="btn " @click.stop="nowBuy(item)">立即购买</view>
</template>
<template v-else>
<view class="btn " @click.stop="refund(item)" v-if="canRefund(item)">申请退款</view>
<button open-type="share" class="btn black" @click.stop="share(item)"
v-if="showShare(item)">邀请好友</button>
<template v-if="item.status=='wait_verify'">
<view class="btn " @click.stop="refund(item)">申请退款</view>
<button class="btn black" @click.stop="lookCode(item)">查看券码</button>
</template>
<template v-if="item.status=='refunding'">
<view class="btn " @click.stop="lookCode(item)">查看券码</view>
<button class="btn black" @click.stop="cancelRefund(item)">取消退款</button>
</template>
</view>
@@ -136,7 +181,7 @@
} from '@dcloudio/uni-app'
import * as Api from '@/common/api/market/package.js'
import perpoleNumber from './components/perpole-number.vue'
import statusVue from '@/groupBuying/components/status.vue'
import statusVue from '@/userPackage/components/status.vue'
import {
computed,
reactive,
@@ -147,6 +192,11 @@
APIusershopInfodetail
} from '@/common/api/member.js'
// 判断是否有阶梯优惠
function isHasDiscount(item) {
return item.tieredDiscount && item.tieredDiscount.length
}
const canRefundStatus = ['待成团', '待核销']
function canRefund(item) {
@@ -155,6 +205,7 @@
}
return false
}
const modalData = reactive({
show: false,
});
@@ -189,20 +240,20 @@
value: ''
},
{
name: '待成团',
value: '待成团'
name: '进行中',
value: 'ing'
},
{
name: '待核销',
value: '待核销'
value: 'wait_verify'
},
{
name: '已核销',
value: '已核销'
value: 'finish'
},
{
name: '退款',
value: '退款'
value: 'ref'
},
],
sel: 0
@@ -211,7 +262,7 @@
const query = reactive({
page: 1,
size: 10,
wareName: '',
packageName: '',
groupPeopleNum: '',
shopId: uni.cache.get('shopId'),
})
@@ -227,6 +278,19 @@
refresh()
})
async function nowBuy(item) {
uni.setStorageSync('group_buying_order', {
...item,
number: 1,
price: nowPrice(item),
paramId: item.id
})
uni.navigateTo({
url: '/userPackage/confirm-order/confirm-order'
})
}
function getData() {
if (tabs.sel == 0) {
Api.getPackage(query).then(res => {
@@ -253,12 +317,9 @@
status: status.value,
}).then(res => {
const newArr = (res.records || []).map(v => {
const wareJson = JSON.parse(v.wareJson)
wareJson.wareImgs = wareJson.wareImgs.split(',').filter(v => v)
return {
...v,
goodsImg: wareJson.wareImgs[0],
wareJson,
goodsImg: v.images[0],
}
})
@@ -282,7 +343,7 @@
function toOrderDetail(item) {
uni.navigateTo({
url: '/userPackage/detail/index?detailId=' + item.id + '&shopId=' + item.shopId
url: '/userPackage/order/detail?orderId=' + item.id + '&shopId=' + item.shopId
})
}
@@ -294,12 +355,64 @@
return item.images[0]
}
function nowPrice(item) {
if (!item.tieredDiscount.length) {
return 0
}
let nowStep = null
for (let i in item.tieredDiscount) {
const nowItem = item.tieredDiscount[i]
const nextItem = item.tieredDiscount[i + 1]
if (!nextItem) {
if (item.shareNum >= nowItem.peopleNum) {
nowStep = nowItem
}
} else {
if (item.shareNum >= nowItem.peopleNum && item.shareNum < nextItem.peopleNum) {
nowStep = nowItem
}
}
}
console.log('nowStep', nowStep);
return nowStep ? nowStep.price : item.price
}
function refresh() {
query.page = 1
isEnd.value = false
getData()
}
function cancelOrder(item) {
uni.showModal({
title: '提示',
content: '是否取消该活动?',
showCancel: true,
success(res) {
if (res.confirm) {
Api.cancel({
orderId: item.id,
}).then(res => {
if (res) {
uni.showToast({
title: '取消成功'
})
setTimeout(() => {
refresh()
}, 1000)
}
})
}
}
})
}
function refund(item) {
uni.showModal({
title: '提示',
@@ -385,11 +498,11 @@
onShareAppMessage(() => {
console.log('onShareAppMessage')
console.log(shareItem)
const query = `groupOrderNo=${shareItem.groupOrderNo}&shopId=${shareItem.shopId}`
const query = `orderId=${shareItem.id}&shopId=${shareItem.shopId}`
return wxShare({
title: shareItem.wareJson.wareName,
title: shareItem.packageName,
imageUrl: shareItem.goodsImg,
path: '/groupBuying/detail/index' + '?' + query,
path: '/userPackage/order/detail' + '?' + query,
query,
})
})
@@ -417,6 +530,13 @@
nowTime.value
return getRemainingHMS(item)
}
function minPrice(item) {
if (!item || item.tieredDiscount <= 0) {
return item.price
}
return item.tieredDiscount[item.tieredDiscount.length - 1].price
}
</script>
<style lang="scss" scoped>
@@ -548,18 +668,28 @@
background-size: cover;
transform: translateY(-10rpx);
display: flex;
justify-content: space-between;
.left {
width: 306rpx;
padding: 16rpx 22rpx;
color: #eb532a;
flex: 1;
}
.old-price{
.old-price {
text-decoration: line-through;
font-size: 24rpx;
}
.right {
background-color: #ED5A2E;
border-radius: 0 16rpx 16rpx 0;
padding-right: 10rpx;
padding-left: 16rpx;
margin-top: 30rpx;
display: flex;
justify-content: center;
align-items: center;
.pin {
width: 76rpx;
@@ -618,13 +748,38 @@
.orders {
padding: 0 26rpx 36rpx;
margin-top: 32rpx;
.item {
padding: 32rpx 24rpx;
border-radius: 16rpx;
background: #FFF;
margin-bottom: 32rpx;
.main-color {
color: #eb532a;
}
.img-box {
position: relative;
.tag {
position: absolute;
left: 0;
top: 0;
padding: 8rpx 18rpx;
border-radius: 16rpx 0;
background: #4C2828;
color: #faeac6;
font-size: 700;
}
}
.old-price {
font-size: 24rpx;
color: #999;
text-decoration: line-through;
}
.numbers {
background-color: #ED5A2E;
padding: 16rpx 30rpx;