| | |
| | | :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-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 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-price" :class="item.status"> |
| | | <text class="price-value">{{ ((item.price || 0) / 100).toFixed(2) }}</text> |
| | |
| | | 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: { |
| | |
| | | }, |
| | | onLoad() { |
| | | this.getCouponList() |
| | | this.getPendingCount() |
| | | }, |
| | | onReachBottom() { |
| | | this.getCouponList() |
| | | }, |
| | | methods: { |
| | | 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({ |
| | |
| | | }, |
| | | async handleReceive(item) { |
| | | 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() |
| | | } |
| | | } |
| | | } |
| | | }) |
| | | 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) { |