|
@@ -1,32 +1,72 @@
|
|
|
<template>
|
|
<template>
|
|
|
- <u-popup v-model="show" mode="bottom" border-radius="24">
|
|
|
|
|
|
|
+ <u-popup v-model="show" mode="bottom" border-radius="24" :safe-area-inset-bottom="true">
|
|
|
<view class="red-packet-popup">
|
|
<view class="red-packet-popup">
|
|
|
<view class="popup-header">
|
|
<view class="popup-header">
|
|
|
- <text>选择红包</text>
|
|
|
|
|
- <u-icon name="close" size="28" color="#999" class="close-icon" @click="close"></u-icon>
|
|
|
|
|
|
|
+ <text>优惠详情</text>
|
|
|
|
|
+ <view class="close-btn" @click="close">
|
|
|
|
|
+ <u-icon name="close" size="24" color="#666"></u-icon>
|
|
|
|
|
+ </view>
|
|
|
|
|
+ </view>
|
|
|
|
|
+
|
|
|
|
|
+ <view class="filter-tabs" v-if="list && list.length > 0">
|
|
|
|
|
+ <view class="tab" :class="{ active: currentTab === 'all' }" @click="currentTab = 'all'">全部</view>
|
|
|
|
|
+ <view class="tab" :class="{ active: currentTab === 'unavailable' }" @click="currentTab = 'unavailable'">不可用</view>
|
|
|
</view>
|
|
</view>
|
|
|
|
|
|
|
|
<scroll-view scroll-y class="packet-list" v-if="list && list.length > 0">
|
|
<scroll-view scroll-y class="packet-list" v-if="list && list.length > 0">
|
|
|
- <view class="packet-item" v-for="(item, index) in list" :key="index" @click="selectPacket(index)">
|
|
|
|
|
- <view class="packet-info">
|
|
|
|
|
- <view class="packet-name">{{ item.couponName }} ¥{{ item.faceMoney }}</view>
|
|
|
|
|
- <view class="packet-desc">满{{ item.thresholdMoney }}元可用</view>
|
|
|
|
|
|
|
+ <!-- 可用红包 -->
|
|
|
|
|
+ <template v-if="currentTab === 'all'">
|
|
|
|
|
+ <view class="packet-item available" v-for="(item, index) in availableList" :key="index" @click="selectPacket(item)">
|
|
|
|
|
+ <view class="packet-main">
|
|
|
|
|
+ <view class="packet-left">
|
|
|
|
|
+ <text class="currency">¥</text>
|
|
|
|
|
+ <text class="amount">{{ item.faceMoney }}</text>
|
|
|
|
|
+ </view>
|
|
|
|
|
+ <view class="packet-right">
|
|
|
|
|
+ <view class="packet-name">{{ item.couponName }}</view>
|
|
|
|
|
+ <view class="packet-rule">{{ item.thresholdMoney == 0 ? '无门槛' : '满' + item.thresholdMoney + '元可用' }}</view>
|
|
|
|
|
+ </view>
|
|
|
|
|
+ <view class="packet-check">
|
|
|
|
|
+ <u-icon name="checkmark-circle-fill" size="40"
|
|
|
|
|
+ :color="selectedItem && selectedItem.userCouponId === item.userCouponId ? '#ff4500' : '#e0e0e0'"></u-icon>
|
|
|
|
|
+ </view>
|
|
|
|
|
+ </view>
|
|
|
<view class="packet-time">{{ item.effectStartTime }}至{{ item.effectEndTime }}</view>
|
|
<view class="packet-time">{{ item.effectStartTime }}至{{ item.effectEndTime }}</view>
|
|
|
</view>
|
|
</view>
|
|
|
- <view class="packet-check">
|
|
|
|
|
- <u-icon name="checkmark-circle-fill" size="40"
|
|
|
|
|
- :color="selectedIndex === index ? '#ff4500' : '#ccc'"></u-icon>
|
|
|
|
|
|
|
+ </template>
|
|
|
|
|
+
|
|
|
|
|
+ <!-- 不可用红包 -->
|
|
|
|
|
+ <template v-if="unavailableList.length > 0 && (currentTab === 'all' || currentTab === 'unavailable')">
|
|
|
|
|
+ <view class="section-title" v-if="currentTab === 'all'">本单不可用红包</view>
|
|
|
|
|
+ <view class="packet-item unavailable" v-for="(item, index) in unavailableList" :key="index">
|
|
|
|
|
+ <view class="packet-main">
|
|
|
|
|
+ <view class="packet-left">
|
|
|
|
|
+ <text class="currency">¥</text>
|
|
|
|
|
+ <text class="amount">{{ item.faceMoney }}</text>
|
|
|
|
|
+ </view>
|
|
|
|
|
+ <view class="packet-right">
|
|
|
|
|
+ <view class="packet-name">{{ item.couponName }}</view>
|
|
|
|
|
+ <view class="packet-rule">{{ item.thresholdMoney == 0 ? '无门槛' : '满' + item.thresholdMoney + '元可用' }}</view>
|
|
|
|
|
+ </view>
|
|
|
|
|
+ <view class="packet-check">
|
|
|
|
|
+ <view class="disabled-radio"></view>
|
|
|
|
|
+ </view>
|
|
|
|
|
+ </view>
|
|
|
|
|
+ <view class="packet-reason">
|
|
|
|
|
+ 本单不可用原因:{{ item.unavailableReason || '不满足使用条件' }}
|
|
|
|
|
+ </view>
|
|
|
</view>
|
|
</view>
|
|
|
- </view>
|
|
|
|
|
|
|
+ </template>
|
|
|
</scroll-view>
|
|
</scroll-view>
|
|
|
|
|
+
|
|
|
<view class="empty-state" v-else>
|
|
<view class="empty-state" v-else>
|
|
|
<image src="https://shuhi.oss-cn-qingdao.aliyuncs.com/mini/no-data.png"
|
|
<image src="https://shuhi.oss-cn-qingdao.aliyuncs.com/mini/no-data.png"
|
|
|
style="width: 260rpx; height: 260rpx" mode="aspectFit"></image>
|
|
style="width: 260rpx; height: 260rpx" mode="aspectFit"></image>
|
|
|
- <view class="empty-text">暂无可用红包</view>
|
|
|
|
|
|
|
+ <view class="empty-text">暂无红包</view>
|
|
|
</view>
|
|
</view>
|
|
|
|
|
|
|
|
<view class="popup-footer" v-if="list && list.length > 0">
|
|
<view class="popup-footer" v-if="list && list.length > 0">
|
|
|
- <u-button type="primary" shape="circle" @click="confirm">确认</u-button>
|
|
|
|
|
|
|
+ <u-button type="primary" shape="circle" @click="confirm" :custom-style="btnStyle">确定</u-button>
|
|
|
</view>
|
|
</view>
|
|
|
</view>
|
|
</view>
|
|
|
</u-popup>
|
|
</u-popup>
|
|
@@ -47,12 +87,30 @@
|
|
|
data() {
|
|
data() {
|
|
|
return {
|
|
return {
|
|
|
show: false,
|
|
show: false,
|
|
|
- selectedIndex: -1,
|
|
|
|
|
|
|
+ currentTab: 'all',
|
|
|
|
|
+ selectedItem: null,
|
|
|
|
|
+ btnStyle: {
|
|
|
|
|
+ background: 'linear-gradient(90deg, #ff6b00, #ff4500)',
|
|
|
|
|
+ color: '#fff',
|
|
|
|
|
+ border: 'none'
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ computed: {
|
|
|
|
|
+ availableList() {
|
|
|
|
|
+ return this.list.filter(item => item.status === 1);
|
|
|
|
|
+ },
|
|
|
|
|
+ unavailableList() {
|
|
|
|
|
+ return this.list.filter(item => item.status === 0);
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
watch: {
|
|
watch: {
|
|
|
value(val) {
|
|
value(val) {
|
|
|
this.show = val;
|
|
this.show = val;
|
|
|
|
|
+ if (val) {
|
|
|
|
|
+ // 重置 tab
|
|
|
|
|
+ this.currentTab = 'all';
|
|
|
|
|
+ }
|
|
|
},
|
|
},
|
|
|
show(val) {
|
|
show(val) {
|
|
|
this.$emit('input', val);
|
|
this.$emit('input', val);
|
|
@@ -62,20 +120,16 @@
|
|
|
close() {
|
|
close() {
|
|
|
this.show = false;
|
|
this.show = false;
|
|
|
},
|
|
},
|
|
|
- selectPacket(index) {
|
|
|
|
|
- if (this.selectedIndex === index) {
|
|
|
|
|
|
|
+ selectPacket(item) {
|
|
|
|
|
+ if (this.selectedItem && this.selectedItem.userCouponId === item.userCouponId) {
|
|
|
// 如果点击的是已选中的项,则取消选中
|
|
// 如果点击的是已选中的项,则取消选中
|
|
|
- this.selectedIndex = -1;
|
|
|
|
|
|
|
+ this.selectedItem = null;
|
|
|
} else {
|
|
} else {
|
|
|
- this.selectedIndex = index;
|
|
|
|
|
|
|
+ this.selectedItem = item;
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
confirm() {
|
|
confirm() {
|
|
|
- if (this.list && this.list.length > 0 && this.selectedIndex !== -1) {
|
|
|
|
|
- this.$emit('confirm', this.list[this.selectedIndex]);
|
|
|
|
|
- } else {
|
|
|
|
|
- this.$emit('confirm', null);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ this.$emit('confirm', this.selectedItem);
|
|
|
this.close();
|
|
this.close();
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -91,54 +145,163 @@
|
|
|
overflow: hidden;
|
|
overflow: hidden;
|
|
|
|
|
|
|
|
.popup-header {
|
|
.popup-header {
|
|
|
|
|
+ display: flex;
|
|
|
|
|
+ justify-content: center;
|
|
|
|
|
+ align-items: center;
|
|
|
padding: 30rpx;
|
|
padding: 30rpx;
|
|
|
- text-align: center;
|
|
|
|
|
|
|
+ position: relative;
|
|
|
font-size: 32rpx;
|
|
font-size: 32rpx;
|
|
|
font-weight: bold;
|
|
font-weight: bold;
|
|
|
- position: sticky;
|
|
|
|
|
- top: 0;
|
|
|
|
|
|
|
+ color: #333;
|
|
|
background-color: #fff;
|
|
background-color: #fff;
|
|
|
- border-bottom: 1rpx solid #eee;
|
|
|
|
|
|
|
|
|
|
- .close-icon {
|
|
|
|
|
|
|
+ .close-btn {
|
|
|
position: absolute;
|
|
position: absolute;
|
|
|
right: 30rpx;
|
|
right: 30rpx;
|
|
|
- top: 40rpx;
|
|
|
|
|
|
|
+ top: 50%;
|
|
|
|
|
+ transform: translateY(-50%);
|
|
|
|
|
+ width: 50rpx;
|
|
|
|
|
+ height: 50rpx;
|
|
|
|
|
+ background-color: #f5f5f5;
|
|
|
|
|
+ border-radius: 50%;
|
|
|
|
|
+ display: flex;
|
|
|
|
|
+ align-items: center;
|
|
|
|
|
+ justify-content: center;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ .filter-tabs {
|
|
|
|
|
+ display: flex;
|
|
|
|
|
+ padding: 0 30rpx;
|
|
|
|
|
+ margin-bottom: 20rpx;
|
|
|
|
|
+ background-color: #fff;
|
|
|
|
|
+ padding-bottom: 10rpx;
|
|
|
|
|
+
|
|
|
|
|
+ .tab {
|
|
|
|
|
+ padding: 12rpx 30rpx;
|
|
|
|
|
+ border-radius: 8rpx;
|
|
|
|
|
+ font-size: 26rpx;
|
|
|
|
|
+ margin-right: 20rpx;
|
|
|
|
|
+ background-color: #f5f5f5;
|
|
|
|
|
+ color: #333;
|
|
|
|
|
+ transition: all 0.3s;
|
|
|
|
|
+
|
|
|
|
|
+ &.active {
|
|
|
|
|
+ background-color: #fff0e6;
|
|
|
|
|
+ color: #ff4500;
|
|
|
|
|
+ font-weight: bold;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
.packet-list {
|
|
.packet-list {
|
|
|
flex: 1;
|
|
flex: 1;
|
|
|
- padding: 20rpx;
|
|
|
|
|
box-sizing: border-box;
|
|
box-sizing: border-box;
|
|
|
- height: 600rpx; // Give it a fixed height for scroll
|
|
|
|
|
|
|
+ height: 600rpx;
|
|
|
overflow-y: auto;
|
|
overflow-y: auto;
|
|
|
|
|
+ padding-top: 20rpx;
|
|
|
|
|
+ padding-bottom: 40rpx;
|
|
|
|
|
+
|
|
|
|
|
+ .section-title {
|
|
|
|
|
+ font-size: 30rpx;
|
|
|
|
|
+ color: #333;
|
|
|
|
|
+ font-weight: bold;
|
|
|
|
|
+ margin: 10rpx 30rpx 20rpx;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
.packet-item {
|
|
.packet-item {
|
|
|
- display: flex;
|
|
|
|
|
- align-items: center;
|
|
|
|
|
- padding: 20rpx 30rpx;
|
|
|
|
|
- border-bottom: 1rpx solid #f5f5f5;
|
|
|
|
|
|
|
+ margin: 0 30rpx 20rpx;
|
|
|
|
|
+ border-radius: 16rpx;
|
|
|
|
|
+ overflow: hidden;
|
|
|
|
|
+ background-color: #fffaf7;
|
|
|
|
|
|
|
|
- .packet-info {
|
|
|
|
|
- flex: 1;
|
|
|
|
|
|
|
+ &.available {
|
|
|
|
|
+ box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.04);
|
|
|
|
|
+ border: 1rpx solid #f9f9f9;
|
|
|
|
|
|
|
|
- .packet-name {
|
|
|
|
|
- font-size: 30rpx;
|
|
|
|
|
|
|
+ .packet-left {
|
|
|
color: #ff4500;
|
|
color: #ff4500;
|
|
|
- font-weight: bold;
|
|
|
|
|
- margin-bottom: 10rpx;
|
|
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- .packet-desc {
|
|
|
|
|
- font-size: 26rpx;
|
|
|
|
|
|
|
+ .packet-name {
|
|
|
color: #333;
|
|
color: #333;
|
|
|
- margin-bottom: 6rpx;
|
|
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+ .packet-rule {
|
|
|
|
|
+ color: #666;
|
|
|
|
|
+ }
|
|
|
.packet-time {
|
|
.packet-time {
|
|
|
|
|
+ padding: 16rpx 24rpx;
|
|
|
font-size: 22rpx;
|
|
font-size: 22rpx;
|
|
|
color: #999;
|
|
color: #999;
|
|
|
|
|
+ background-color: #fffaf7;
|
|
|
|
|
+ border-top: 1rpx dashed #ffe6e6;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ &.unavailable {
|
|
|
|
|
+ background-color: #fefefe;
|
|
|
|
|
+ .packet-left {
|
|
|
|
|
+ color: #999;
|
|
|
|
|
+ }
|
|
|
|
|
+ .packet-name {
|
|
|
|
|
+ color: #666;
|
|
|
|
|
+ }
|
|
|
|
|
+ .packet-rule {
|
|
|
|
|
+ color: #999;
|
|
|
|
|
+ }
|
|
|
|
|
+ .packet-reason {
|
|
|
|
|
+ padding: 20rpx 24rpx;
|
|
|
|
|
+ font-size: 24rpx;
|
|
|
|
|
+ color: #999;
|
|
|
|
|
+ border-top: 1rpx dashed #eee;
|
|
|
|
|
+ background-color: #fafafa;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ .packet-main {
|
|
|
|
|
+ display: flex;
|
|
|
|
|
+ align-items: center;
|
|
|
|
|
+ padding: 30rpx 24rpx;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ .packet-left {
|
|
|
|
|
+ width: 150rpx;
|
|
|
|
|
+ display: flex;
|
|
|
|
|
+ align-items: baseline;
|
|
|
|
|
+
|
|
|
|
|
+ .currency {
|
|
|
|
|
+ font-size: 28rpx;
|
|
|
|
|
+ margin-right: 4rpx;
|
|
|
|
|
+ }
|
|
|
|
|
+ .amount {
|
|
|
|
|
+ font-size: 48rpx;
|
|
|
|
|
+ font-weight: bold;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ .packet-right {
|
|
|
|
|
+ flex: 1;
|
|
|
|
|
+ margin-left: 10rpx;
|
|
|
|
|
+
|
|
|
|
|
+ .packet-name {
|
|
|
|
|
+ font-size: 30rpx;
|
|
|
|
|
+ font-weight: bold;
|
|
|
|
|
+ margin-bottom: 8rpx;
|
|
|
|
|
+ }
|
|
|
|
|
+ .packet-rule {
|
|
|
|
|
+ font-size: 24rpx;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ .packet-check {
|
|
|
|
|
+ margin-left: 20rpx;
|
|
|
|
|
+
|
|
|
|
|
+ .disabled-radio {
|
|
|
|
|
+ width: 40rpx;
|
|
|
|
|
+ height: 40rpx;
|
|
|
|
|
+ border-radius: 50%;
|
|
|
|
|
+ border: 2rpx solid #ddd;
|
|
|
|
|
+ background-color: #eee;
|
|
|
|
|
+ box-sizing: border-box;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -160,7 +323,8 @@
|
|
|
|
|
|
|
|
.popup-footer {
|
|
.popup-footer {
|
|
|
padding: 20rpx 40rpx;
|
|
padding: 20rpx 40rpx;
|
|
|
- padding-bottom: env(safe-area-inset-bottom);
|
|
|
|
|
|
|
+ background-color: #fff;
|
|
|
|
|
+ box-shadow: 0 -4rpx 10rpx rgba(0, 0, 0, 0.02);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
</style>
|
|
</style>
|