fix(uniapp): 移除购物车右滑删除消除红线,优化地址吸底按钮与订单赠品划线展示及阶梯促销

This commit is contained in:
pikachu1995@126.com
2026-11-10 15:22:50 +08:00
parent 869975b3c3
commit 0a4db7b6f4
8 changed files with 238 additions and 85 deletions

View File

@@ -126,7 +126,8 @@
z-index: 99;
padding: 20rpx 30rpx calc(20rpx + constant(safe-area-inset-bottom));
padding: 20rpx 30rpx calc(20rpx + env(safe-area-inset-bottom));
background: $page-color-base;
background: #ffffff;
box-shadow: 0 -2rpx 12rpx rgba(0, 0, 0, 0.04);
box-sizing: border-box;
}

View File

@@ -32,11 +32,12 @@
</view>
</view>
</view>
<view style="height: 100px"></view>
</view>
<view class="btn" @click="addAddress('')">
<u-icon name="plus-circle" color="#ffffff" size="18"></u-icon>
<text class="btn-text">添加新收货人</text>
<view class="btn-bar">
<view class="btn" @click="addAddress('')">
<u-icon name="plus-circle" color="#ffffff" size="18"></u-icon>
<text class="btn-text">添加新收货人</text>
</view>
</view>
</view>
</template>

View File

@@ -68,9 +68,11 @@
:key="goodsIndex">
<u-image border-radius="6" width="131rpx" height="131rpx" mode="aspectFill"
:src="getOrderItemImage(goods, order, goodsIndex)"></u-image>
<text v-if="isGiftItem(goods)" class="gift-corner-badge">赠</text>
</view>
<view class="goods-info">
<view v-if="order.orderItems.length <= 1" class="goods-title u-line-2">
<text v-if="isGiftItem(order.orderItems[0])" class="gift-badge">赠品</text>
{{ order.groupName }}</view>
<view v-if="order.orderItems.length <= 1" class="goods-price">
¥{{unitPrice(order.flowPrice) }}
@@ -444,6 +446,11 @@ async function confirmCancelAfterSale() {
}
}
function isGiftItem(goods: any) {
if (!goods) return false
return goods.promotionType === 'GIFT' || (Number(goods.flowPrice) === 0 && goods.promotionType === 'GIFT')
}
function onAfterSaleExpress(order: any) {
const sku = (order?.orderItems && order.orderItems[0]) || {}
storage.setAfterSaleData({ ...order, ...sku, storeName: order.storeName })
@@ -692,6 +699,7 @@ function reBuy(order: any) {
height: 131rpx;
margin-right: 10rpx;
margin-bottom: 10rpx;
position: relative;
}
.goods-info {
@@ -803,4 +811,30 @@ function reBuy(order: any) {
border-color: $light-color !important;
background-color: #ffffff !important;
}
.gift-corner-badge {
position: absolute;
top: 0;
left: 0;
background: #ff4d4f;
color: #fff;
font-size: 18rpx;
padding: 2rpx 8rpx;
border-top-left-radius: 6rpx;
border-bottom-right-radius: 6rpx;
z-index: 2;
line-height: 1.2;
}
.gift-badge {
display: inline-block;
background: #ff4d4f;
color: #fff;
font-size: 20rpx;
line-height: 28rpx;
padding: 0 10rpx;
border-radius: 6rpx;
margin-right: 8rpx;
vertical-align: middle;
}
</style>

View File

@@ -108,8 +108,14 @@
</view>
<view class="goods-body">
<view class="goods-info" @click="gotoGoodsDetail(sku)">
<view class="goods-title u-line-2">{{ sku.goodsName }}</view>
<view class="goods-price">
<view class="goods-title u-line-2">
<text v-if="isGiftItem(sku)" class="gift-badge">赠品</text>
{{ sku.goodsName }}
</view>
<view class="goods-price" v-if="isGiftItem(sku)">
<text class="gift-original-price">¥{{ unitPrice(sku.goodsPrice) }}</text>
</view>
<view class="goods-price" v-else>
¥{{unitPrice(sku.goodsPrice) }}
<!-- <span v-if="sku.point">+{{ sku.point }}积分</span> -->
<span style="font-size: 24rpx;margin-left: 14rpx;color: #ff9900;" v-if="!isECouponOrder && !isAppointmentOrderFlag && sku.isRefund && sku.isRefund !== 'NO_REFUND'">
@@ -122,6 +128,7 @@
<view>x{{ sku.num }}</view>
</view>
<view class="after-sale-btn" v-if="canShowSkuAfterSale(sku)" @click.stop="onSkuAfterSale(sku)">退款/售后</view>
<view class="gift-tip" v-else-if="isGiftItem(sku)">随单赠送</view>
</view>
</view>
</view>
@@ -631,7 +638,13 @@ function canApplySkuAfterSale(sku: any) {
return false
}
function isGiftItem(sku: any) {
if (!sku) return false
return sku.promotionType === 'GIFT' || (Number(sku.flowPrice) === 0 && sku.promotionType === 'GIFT')
}
function canShowSkuAfterSale(sku: any) {
if (isGiftItem(sku)) return false
if (isECouponOrder.value) return false
if (!order.value?.sn || Number(order.value.flowPrice) === 0) return false
if (isAppointmentOrderFlag.value && !appointmentAllow.value.afterSale) return false
@@ -1178,4 +1191,28 @@ page,
flex:2;
}
}
.gift-badge {
display: inline-block;
background: #ff4d4f;
color: #fff;
font-size: 20rpx;
line-height: 28rpx;
padding: 0 10rpx;
border-radius: 6rpx;
margin-right: 8rpx;
vertical-align: middle;
}
.gift-original-price {
color: #999;
font-size: 26rpx;
text-decoration: line-through;
font-weight: normal;
}
.gift-tip {
font-size: 22rpx;
color: #999;
margin-top: 8rpx;
text-align: right;
}
</style>

View File

@@ -1,25 +1,23 @@
<!--
移动端商品详情页-促销详情弹窗内容(支持满减、满折、满赠及三级阶梯与赠品明细展示)
@author Bulbasaur
@since 2026-11-09
-->
<template>
<view class="wrapper" v-if="res">
<view v-for="prom in promotionKeys" :key="prom">
<view v-if="getPromType(prom) == 'FULL_DISCOUNT'">
<view class="res_prom_item" v-if="res[prom].fullMinus">
<view class="deg_tag">满减</view>
<text class="pro-text">
满{{ res[prom].fullMoney }}元 立减现金
<text class="price">{{ res[prom].fullMinus }}元</text>
<text v-if="res[prom].couponFlag"> 赠送优惠券</text>
<text v-if="res[prom].pointFlag"> 赠送{{ res[prom].point }}积分</text>
<text v-if="res[prom].giftFlag"> 赠送商品</text>
<text v-if="res[prom].freeFreightFlag"> 赠送包邮服务</text>
</text>
</view>
<view class="res_prom_item" v-if="res[prom].fullRate && res[prom].fullRateFlag">
<view class="deg_tag">打折</view>
<text class="pro-text">
满{{ res[prom].fullMoney }}元,立享
<text class="price">{{ res[prom].fullRate }}折</text>
优惠
</text>
<view class="res_prom_item">
<view class="deg_tag">{{ resolveFullDiscountTag(res[prom]) }}</view>
<view class="pro-text">
<view
v-for="(tierText, idx) in formatFullDiscountTiers(res[prom])"
:key="idx"
class="tier-line"
>
{{ tierText }}
</view>
</view>
</view>
</view>
@@ -82,6 +80,50 @@ function getPromType(key: string) {
return key.split('-')[0]
}
function resolveFullDiscountTag(act: any): string {
if (!act) return '满减'
if (act.activityType === 'FULL_RATE' || act.fullRateFlag) return '满折'
if (act.activityType === 'FULL_GIFT' || (!act.fullMinusFlag && act.giftFlag)) return '满赠'
return '满减'
}
function formatFullDiscountTiers(act: any): string[] {
if (!act) return []
let rules: any[] = Array.isArray(act.ruleList) ? act.ruleList : []
if (!rules.length && act.rulesJson) {
try {
rules = JSON.parse(act.rulesJson) || []
} catch (e) {
rules = []
}
}
const tag = resolveFullDiscountTag(act)
if (rules.length) {
return rules.map((r: any, i: number) => {
const prefix = rules.length > 1 ? `阶梯${i + 1}:` : ''
if (tag === '满折') {
return `${prefix}满${r.fullMoney}元,立享${r.fullRate}折优惠`
}
if (tag === '满赠') {
const gifts = Array.isArray(r.giftItems)
? r.giftItems
.map((g: any) => `${g.goodsName || '赠品'}×${g.num || 1}`)
.join('、')
: '赠品'
return `${prefix}满${r.fullMoney}元,赠送[${gifts}]`
}
return `${prefix}满${r.fullMoney}元,立减现金${r.fullMinus}元`
})
}
if (act.fullRateFlag && act.fullRate) {
return [`满${act.fullMoney}元,立享${act.fullRate}折优惠`]
}
if (act.giftFlag) {
return [`满${act.fullMoney}元,赠送商品`]
}
return [`满${act.fullMoney}元,立减现金${act.fullMinus || 0}元`]
}
function handClickToJoinPromotion(val: string) {
const type = getPromType(val)
const promotionMap: Record<string, string> = {
@@ -115,6 +157,10 @@ function handClickToJoinPromotion(val: string) {
color: #333333;
}
.tier-line {
margin-bottom: 6rpx;
}
.wrapper {
display: block;
}

View File

@@ -1,12 +1,17 @@
<!--
移动端商品详情页-促销信息摘要栏(支持满减、满折、满赠及三级阶梯文案)
@author Bulbasaur
@since 2026-11-09
-->
<template>
<view>
<view v-for="(promotionItem, promotionIndex) in promotion" :key="promotionIndex" class="promotion_row" @click="shutMask(1)">
<view v-if="res != null" v-for="(item, index) in Object.keys(res)" :key="index">
<div class="promotion_col" v-if="item.split('-')[0] == promotionItem.value && item.split('-')[0] == 'FULL_DISCOUNT'">
<!-- 满减,折扣 -->
<!-- 满减 / 满折 / 满赠 -->
<div class="flex">
<view class="deg_tag">{{ promotionItem.title }}</view>
<div class="text proText">满{{ res[item].fullMoney }}元,立享优惠</div>
<view class="deg_tag">{{ resolveFullDiscountTag(res[item]) }}</view>
<div class="text proText">{{ formatFullDiscountSummary(res[item]) }}</div>
</div>
</div>
<div class="promotion_col" v-if="item.split('-')[0] == promotionItem.value && item.split('-')[0] == 'PINTUAN'">
@@ -43,7 +48,6 @@
<view>
<div class="promotion_col coupon" v-if="couponList && promotionIndex == 1">
<!-- 优惠券 -->
<div><view class="deg_tag">优惠券</view></div>
</div>
</view>
@@ -86,6 +90,39 @@ watch(
{ immediate: true }
)
function resolveFullDiscountTag(act: any): string {
if (!act) return '满减'
if (act.activityType === 'FULL_RATE' || act.fullRateFlag) return '满折'
if (act.activityType === 'FULL_GIFT' || (!act.fullMinusFlag && act.giftFlag)) return '满赠'
return '满减'
}
function formatFullDiscountSummary(act: any): string {
if (!act) return ''
if (act.title) return act.title
if (act.rulesJson) {
try {
const rules = JSON.parse(act.rulesJson)
if (Array.isArray(rules) && rules.length) {
return rules
.map((r: any) => {
if (act.activityType === 'FULL_RATE' || act.fullRateFlag) {
return `满${r.fullMoney}元打${r.fullRate}折`
}
if (act.activityType === 'FULL_GIFT' || act.giftFlag) {
return `满${r.fullMoney}元享好礼`
}
return `满${r.fullMoney}元减${r.fullMinus}元`
})
.join(';')
}
} catch (e) {
// ignore
}
}
return `满${act.fullMoney}元,立享优惠`
}
function shutMask(val: number) {
emit('shutMasks', val)
}
@@ -100,11 +137,7 @@ function shutMask(val: number) {
}
.promotion_col {
/**/
// margin: 0 0 17rpx 0;
padding: 0 !important;
margin: 10rpx 0;
}
.promotion_row {

View File

@@ -37,16 +37,14 @@
<span>领劵</span>
</view>
</view>
<u-swipe-action ref="swiperAction" class="cart-item" v-for="(skuItem, i) in item.skuList" :key="skuItem.goodsSku.id">
<u-swipe-action-item :show="skuItem.selected" @open="openAction(skuItem)" :options="options"
:name="i"
@click="changeActionTab(skuItem)" @longpress="changeActionTab(skuItem)">
<!-- 满减活动 -->
<div v-if="Object.keys(skuItem.promotionMap).length != 0">
<view class="cart-item" v-for="(skuItem) in item.skuList" :key="skuItem.goodsSku.id"
@longpress="changeActionTab(skuItem)">
<!-- 满优惠活动 -->
<div v-if="Object.keys(skuItem.promotionMap).length != 0" class="promotion-box">
<div v-if="getPromotion(skuItem).includes('FULL_DISCOUNT')">
<div class="promotion-notice" v-if="item.promotionNotice">
<span class="tips">满减</span>
<span style="flex:10;">{{item.promotionNotice}}</span>
<span class="tips">{{ getFullDiscountTag(skuItem) }}</span>
<span class="notice-desc">{{item.promotionNotice}}</span>
</div>
</div>
</div>
@@ -93,8 +91,7 @@
</view>
</view>
</u-swipe-action-item>
</u-swipe-action>
</view>
</div>
</div>
<u-modal v-if="deleteShow" v-model:show="deleteShow" :confirm-style="modalConfirmStyle" @confirm="deleteConfirm" show-cancel-button
@@ -168,20 +165,10 @@ import { useStore } from '@/store'
import { unitPrice, goodsFormatPrice, isLogin, forceLogin } from '@/utils/filters.js'
const store = useStore()
const swiperAction = ref()
const lightColor = computed(() => store.getters.lightColor)
const loading = ref(false)
const discountDetailsFlag = ref(false)
// 商品栏右侧滑动按钮
const options = [
{
text: "删除",
style: {
backgroundColor: store.getters.lightColor,
},
},
]
const isInvalid = (val: any): boolean => {
if (!val) return false
if (val.invalid == 1 || (!val.checked && val.errorMessage)) {
@@ -226,14 +213,7 @@ onPullDownRefresh(() => {
onShow(() => {
deleteShow.value ? (deleteShow.value = false) : true
if (swiperAction.value) {
(swiperAction.value as any[]).forEach((item: any) => {
item.show = false
})
getCardData()
} else {
getCardData()
}
getCardData()
})
function setCapsuleInset() {
@@ -277,22 +257,9 @@ function getCountDownTime(val: any) {
function discountDetails() {
discountDetailsFlag.value = true
}
/**
* 左滑打开删除
*/
function openAction(skuItem: any) {
cartDetail.value.cartList.forEach((cartItem: any) => {
if (cartItem.skuList) {
cartItem.skuList.forEach((sku: any) => {
sku["selected"] = false
})
}
})
skuItem["selected"] = true
}
/**
* 滑动删除
* 长按或点击删除
*/
function changeActionTab(val: any) {
deleteShow.value = true
@@ -496,6 +463,22 @@ function getPromotion(item: any) {
})
}
/**
* 获取购物车商品绑定的满额活动类型标签(满减/满折/满赠)
*/
function getFullDiscountTag(item: any) {
if (!item || !item.promotionMap) return "满优惠"
const fdKey = Object.keys(item.promotionMap).find((child: string) => child.split("-")[0] === "FULL_DISCOUNT")
if (!fdKey) return "满优惠"
const fdObj = item.promotionMap[fdKey]
if (fdObj && fdObj.activityType === "FULL_RATE") return "满折"
if (fdObj && fdObj.activityType === "FULL_GIFT") return "满赠"
if (fdObj && fdObj.activityType === "FULL_MINUS") return "满减"
if (fdObj && fdObj.fullRateFlag) return "满折"
if (fdObj && fdObj.giftFlag) return "满赠"
return "满减"
}
/**
* 获取购物车数据
*/
@@ -569,22 +552,38 @@ page {
font-size: 28rpx;
}
}
.promotion-box {
background: #fff;
padding-top: 16rpx;
}
.promotion-notice {
margin-top: 10px;
margin-left: 68rpx;
margin: 0 0 0 68rpx;
padding-right: 20rpx;
font-size: 24rpx;
color: #333;
font-weight: bold;
display: flex;
align-items: center;
::v-deep .tips {
margin: 0 8rpx 0 0;
background: #fff;
.tips {
margin: 0 12rpx 0 0;
background: $main-color;
border-radius: 100px;
display: block;
flex: 1;
padding: 2rpx 12rpx;
display: inline-block;
flex-shrink: 0;
padding: 2rpx 14rpx;
color: #fff;
font-size: 20rpx;
line-height: 32rpx;
}
.notice-desc {
flex: 1;
min-width: 0;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
}
.default-color {
@@ -616,8 +615,7 @@ page {
.cart-item {
width: 100%;
border-radius: 0.4em;
transition: 0.35s;
overflow: hidden;
background: #fff;
}
/* 空白页 */

View File

@@ -51,8 +51,11 @@ export function modelNavigateTo(item) {
url: "/pages/product/goods?id=" + val.skuId + "&goodsId=" + val.goodsId,
});
break;
// 满减商品
// 满减/满折/满赠商品
case "FULL_DISCOUNT":
case "FULL_MINUS":
case "FULL_RATE":
case "FULL_GIFT":
uni.navigateTo({
url: "/pages/product/goods?id=" + val.skuId + "&goodsId=" + val.goodsId,
});