From 777bcb6c5660c0ed14d85207377b62b779d81dde Mon Sep 17 00:00:00 2001
From: MrShi <1878285526@qq.com>
Date: 星期三, 20 五月 2026 23:08:55 +0800
Subject: [PATCH] Merge branch 'master' of http://139.186.142.91:10010/r/productDev/gtzxinglijicun

---
 small-program/shop/pages/coupon-center/coupon-center.vue |  175 +++++++++++++++++++++++++++++++++++----------------------
 1 files changed, 107 insertions(+), 68 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..ae95eef 100644
--- a/small-program/shop/pages/coupon-center/coupon-center.vue
+++ b/small-program/shop/pages/coupon-center/coupon-center.vue
@@ -8,50 +8,52 @@
 				:class="{ active: currentTab === tab.value }"
 				@tap="currentTab = tab.value"
 			>
-				<text>{{ tab.label }}</text>
+				<text>{{ tab.label }}<text v-if="tab.value === 0 && waitClaim > 0">({{ waitClaim }})</text><text v-if="tab.value === 1 && waitUse > 0">({{ waitUse }})</text></text>
 				<view class="tab-line"></view>
 			</view>
 		</view>
 
 		<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" v-if="item.couponType === 0">骞冲彴婊″噺鍒�</view>
+					<view class="coupon-time" v-if="currentTab === 0">鏈夋晥鏈焮{ formatDate(item.createDate) }}~{{ formatDate(item.validDate) }}</view>
+					<view class="coupon-time" v-else>鏈夋晥鏈焮{ formatDate(item.startDate) }}~{{ formatDate(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>
@@ -66,14 +68,16 @@
 				currentTab: 0,
 				tabs: [
 					{ label: '寰呴鍙�', value: 0 },
-					{ label: '宸查鍙�', value: 1 },
+					{ label: '寰呬娇鐢�', value: 1 },
 					{ label: '宸蹭娇鐢�', value: 2 },
 					{ label: '宸插け鏁�', value: 99 }
 				],
 				coupons: [],
 				page: 1,
 				capacity: 10,
-				isRequest: true
+				isRequest: true,
+				waitClaim: 0,
+				waitUse: 0
 			}
 		},
 		watch: {
@@ -86,46 +90,70 @@
 		},
 		onLoad() {
 			this.getCouponList()
+			this.getPendingCount()
 		},
 		onReachBottom() {
 			this.getCouponList()
 		},
 		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
-					}
+			async getPendingCount() {
+				const res = await this.$u.api.pendingCount({})
+				console.log(res)
+				if (res.code === 200 && res.data) {
+					this.waitClaim = res.data.waitClaim || 0
+					this.waitUse = res.data.waitUse || 0
 				}
 			},
+			formatDate(dateStr) {
+				if (!dateStr) return ''
+				const date = new Date(dateStr)
+				const year = String(date.getFullYear()).slice(2)
+				const month = String(date.getMonth() + 1).padStart(2, '0')
+				const day = String(date.getDate()).padStart(2, '0')
+				const hours = String(date.getHours()).padStart(2, '0')
+				const minutes = String(date.getMinutes()).padStart(2, '0')
+				return `${year}.${month}.${day} ${hours}:${minutes}`
+			},
+			async getCouponList() {
+			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 {
+					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()
+						this.getPendingCount()
 					}
-				})
+				}
 			},
 			toggleRule(id) {
 				this.coupons = this.coupons.map((item) => {
@@ -317,6 +345,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