From ce06ca62a0dd65d4a8fb57126948449c804ad77e Mon Sep 17 00:00:00 2001
From: MrShi <1878285526@qq.com>
Date: 星期二, 19 五月 2026 19:40:08 +0800
Subject: [PATCH] 提交
---
small-program/shop/pages/coupon-center/coupon-center.vue | 155 ++++++++++++++++++++++++++++++---------------------
1 files changed, 91 insertions(+), 64 deletions(-)
diff --git a/small-program/shop/pages/coupon-center/coupon-center.vue b/small-program/shop/pages/coupon-center/coupon-center.vue
index 154d753..a5ab167 100644
--- a/small-program/shop/pages/coupon-center/coupon-center.vue
+++ b/small-program/shop/pages/coupon-center/coupon-center.vue
@@ -15,43 +15,45 @@
<view class="coupon-list">
<view
- v-for="item in coupons"
- :key="item.id"
- class="coupon-card"
- >
- <view class="coupon-main">
- <view class="coupon-info">
- <view class="coupon-title">{{ item.name }}</view>
- <view class="coupon-time">鏈夋晥鏈焮{ item.startDate }}~{{ item.endDate }}</view>
- </view>
- <view class="coupon-price" :class="item.status">
- <text class="price-value">{{ ((item.price || 0) / 100).toFixed(2) }}</text>
- <text class="price-desc">{{ item.couponType === 0 ? '婊″噺' : '' }}</text>
- </view>
+ v-for="item in coupons"
+ :key="item.id"
+ class="coupon-card"
+ :class="{ 'used': currentTab === 2 || currentTab === 99 }"
+ >
+ <view class="coupon-main">
+ <view class="coupon-info">
+ <view class="coupon-title">{{ item.name }}</view>
+ <view class="coupon-time" v-if="currentTab === 0">鏈夋晥鏈焮{ item.createDate }}~{{ item.validDate }}</view>
+ <view class="coupon-time" v-else>鏈夋晥鏈焮{ item.startDate }}~{{ item.endDate }}</view>
</view>
-
- <view class="coupon-divider"></view>
-
- <view class="coupon-footer">
- <view class="coupon-meta" @tap="toggleRule(item.id)">
- <text class="meta-text">鏈紭鎯犲埜涓嶅彲杞</text>
- <u-icon
- class="meta-arrow"
- :name="item.expanded ? 'arrow-up' : 'arrow-down'"
- size="12"
- color="#9d9d9d"
- ></u-icon>
- </view>
- <view
- class="receive-btn"
- :class="{ 'receive-btn-disabled': [2, 99].includes(currentTab) }"
- @click="handleReceive(item)"
- >
- {{ currentTab === 1 ? '鍘讳娇鐢�' : '绔嬪嵆棰嗗彇' }}
- </view>
+ <view class="coupon-price" :class="item.status">
+ <text class="price-value">{{ ((item.price || 0) / 100).toFixed(2) }}</text>
+ <text class="price-desc" v-if="item.couponType === 0">婊{((item.limitPrice || 0) / 100).toFixed(2)}}鍙敤</text>
</view>
+ </view>
- <view v-if="item.info" class="coupon-rule">
+ <view class="coupon-divider"></view>
+
+ <view class="coupon-footer">
+ <view class="coupon-meta" @tap="toggleRule(item.id)">
+ <text class="meta-text">浣跨敤璇存槑</text>
+ <u-icon
+ class="meta-arrow"
+ :name="item.expanded ? 'arrow-up' : 'arrow-down'"
+ size="12"
+ color="#9d9d9d"
+ ></u-icon>
+ </view>
+ <view
+ class="receive-btn"
+ :class="{ 'receive-btn-disabled': [2, 99].includes(currentTab) }"
+ @click="handleReceive(item)"
+ >
+ {{ currentTab === 2 ? '宸蹭娇鐢�' : (currentTab === 99 ? '宸插け鏁�' : (currentTab === 1 ? '鍘讳娇鐢�' : '绔嬪嵆棰嗗彇')) }}
+ </view>
+ </view>
+
+ <view v-if="item.expanded && item.info" class="coupon-rule">
{{ item.info }}
</view>
</view>
@@ -92,40 +94,54 @@
},
methods: {
async getCouponList() {
- if (!this.isRequest) return
- const res = await this.$u.api.findPage({
- capacity: this.capacity,
- page: this.page,
- model: {
- status: this.currentTab
- }
- })
- if (res.code === 200) {
- const list = res.records || []
- this.coupons = [...this.coupons, ...list]
- this.page++
- if (res.total <= this.coupons.length) {
- this.isRequest = false
- }
+ if (!this.isRequest) return
+ const res = await this.$u.api.findPage({
+ capacity: this.capacity,
+ page: this.page,
+ model: {
+ status: this.currentTab
}
- },
+ })
+ console.log(res)
+ if (res.code === 200) {
+ const list = res.data.records || []
+ // 涓烘瘡涓紭鎯犲埜娣诲姞expanded灞炴�э紝榛樿鍏抽棴
+ const couponsWithExpanded = list.map(item => ({
+ ...item,
+ expanded: false
+ }))
+ this.coupons = [...this.coupons, ...couponsWithExpanded]
+ this.page++
+ if (res.data.total <= this.coupons.length) {
+ this.isRequest = false
+ }
+ }
+ },
async handleReceive(item) {
- uni.showModal({
- title: '鎻愮ず',
- content: '纭畾瑕侀鍙栬浼樻儬鍒稿悧锛�',
- success: async (res) => {
- if (res.confirm) {
- const result = await this.$u.api.claimCoupon({ couponId: item.id })
- if (result.code === 200) {
- uni.showToast({ title: '棰嗗彇鎴愬姛', icon: 'success' })
- this.page = 1
- this.coupons = []
- this.isRequest = true
- this.getCouponList()
+ if (this.currentTab === 1) {
+ // 宸查鍙栨爣绛句笅锛岀偣鍑诲幓浣跨敤璺宠浆鍒拌鏉庡瘎瀛橀〉闈�
+ uni.navigateTo({
+ url: '/pages/luggage-storage/luggage-storage'
+ })
+ } else {
+ // 鍏朵粬鏍囩涓嬶紝鎵ц棰嗗彇鎿嶄綔
+ uni.showModal({
+ title: '鎻愮ず',
+ content: '纭畾瑕侀鍙栬浼樻儬鍒稿悧锛�',
+ success: async (res) => {
+ if (res.confirm) {
+ const result = await this.$u.api.claimCoupon({ couponId: item.id })
+ if (result.code === 200) {
+ uni.showToast({ title: '棰嗗彇鎴愬姛', icon: 'success' })
+ this.page = 1
+ this.coupons = []
+ this.isRequest = true
+ this.getCouponList()
+ }
}
}
- }
- })
+ })
+ }
},
toggleRule(id) {
this.coupons = this.coupons.map((item) => {
@@ -317,6 +333,17 @@
color: #ffffff;
}
+ /* 宸蹭娇鐢ㄤ紭鎯犲埜鏍峰紡 */
+ .coupon-card.used {
+ background: #EFEFEF;
+ }
+
+ .coupon-card.used .coupon-title,
+ .coupon-card.used .coupon-price,
+ .coupon-card.used .price-desc {
+ color: #999999;
+ }
+
.coupon-rule {
margin-top: 16rpx;
font-size: 28rpx;
--
Gitblit v1.9.3