增加推销模式
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
<!-- 消费者端 - 商品详情页 -->
|
||||
<!-- 消费者端 - 商品详情页 -->
|
||||
<template>
|
||||
<view class="product-detail-page">
|
||||
<scroll-view class="page-scroll" scroll-y="true">
|
||||
@@ -16,8 +16,12 @@
|
||||
<view class="product-info">
|
||||
<view class="price-section">
|
||||
<text class="current-price">¥{{ product.price }}</text>
|
||||
<text v-if="memberPrice > 0 && memberPrice < product.price" class="member-price-tag">会员价 ¥{{ memberPrice }}</text>
|
||||
<text v-if="product.original_price" class="original-price">¥{{ product.original_price }}</text>
|
||||
</view>
|
||||
<view v-if="memberDiscount > 0" class="member-discount-row">
|
||||
<text class="member-discount-text">会员专享 {{ memberDiscount }}折优惠</text>
|
||||
</view>
|
||||
<text class="product-name">{{ product.name }}</text>
|
||||
<text class="sales-info">已售{{ product.sales }}件 · 库存{{ product.stock }}件</text>
|
||||
</view>
|
||||
@@ -270,7 +274,11 @@ export default {
|
||||
showParams: false,
|
||||
// 新增: 优惠券相关
|
||||
coupons: [] as Array<CouponTemplateType>,
|
||||
showCoupons: false
|
||||
showCoupons: false,
|
||||
// 会员价相关
|
||||
memberPrice: 0 as number,
|
||||
memberDiscount: 0 as number,
|
||||
memberLevelName: '' as string
|
||||
}
|
||||
},
|
||||
onLoad(options: any) {
|
||||
@@ -461,6 +469,9 @@ export default {
|
||||
if (this.product.id != null && this.product.id !== '') {
|
||||
this.loadProductSkus(this.product.id)
|
||||
}
|
||||
|
||||
// 加载会员价
|
||||
this.loadMemberPrice()
|
||||
|
||||
uni.hideLoading()
|
||||
},
|
||||
@@ -559,6 +570,28 @@ export default {
|
||||
}
|
||||
},
|
||||
|
||||
async loadMemberPrice() {
|
||||
try {
|
||||
const memberInfo = await supabaseService.getUserMemberInfo()
|
||||
const levelNameRaw = memberInfo.get('level_name')
|
||||
const discountRaw = memberInfo.get('discount')
|
||||
|
||||
if (levelNameRaw != null) {
|
||||
this.memberLevelName = levelNameRaw as string
|
||||
}
|
||||
|
||||
if (discountRaw != null) {
|
||||
const discount = discountRaw as number
|
||||
if (discount > 0 && discount < 10) {
|
||||
this.memberDiscount = discount
|
||||
this.memberPrice = Math.round(this.product.price * discount) / 10
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
console.log('获取会员信息失败,可能未登录或非会员:', e)
|
||||
}
|
||||
},
|
||||
|
||||
// 新增:加载优惠券
|
||||
async loadCoupons() {
|
||||
if (this.product.merchant_id == '') return
|
||||
@@ -958,6 +991,25 @@ export default {
|
||||
margin-right: 20rpx;
|
||||
}
|
||||
|
||||
.member-price-tag {
|
||||
font-size: 28rpx;
|
||||
font-weight: bold;
|
||||
color: #52c41a;
|
||||
background-color: #f6ffed;
|
||||
padding: 4rpx 12rpx;
|
||||
border-radius: 8rpx;
|
||||
margin-right: 20rpx;
|
||||
}
|
||||
|
||||
.member-discount-row {
|
||||
margin-bottom: 15rpx;
|
||||
}
|
||||
|
||||
.member-discount-text {
|
||||
font-size: 24rpx;
|
||||
color: #52c41a;
|
||||
}
|
||||
|
||||
.original-price {
|
||||
font-size: 28rpx;
|
||||
color: #999;
|
||||
|
||||
Reference in New Issue
Block a user