youdas/pages/other/coupon.vue
2025-06-22 12:31:15 +08:00

238 lines
5.9 KiB
Vue

<template>
<page-container ref="pageContainer" title="优惠卷" show-back :show-not-data="showNotData" :refresh="onRefresh"
:showLoading="showLoading">
<view class="tab-list">
<view @click="tabChange(i)" v-for="(item, i) in tabList" :key="i" class="tab-list-item"
:class="{ active: tabCur == i }">
{{ item.title }}
<view v-if="tabCur == i" class="arrow"></view>
</view>
</view>
<view v-if="listData.length > 0">
<view class="list-item" v-for="(item, i) in listData" :key="i" :class="{ dis: tabList[tabCur].type == 2 }">
<view class="money">
¥
<text>{{ Number(item.price) }}</text>
</view>
<view class="info">
<view class="title">满{{ item.man_price }}减{{ item.price }}</view>
<view class="time">{{ item.end_time }}到期</view>
</view>
<view class="btn">
{{ item.mark }}
</view>
</view>
</view>
<view v-else class="not-data">
<NoData></NoData>
</view>
</page-container>
</template>
<script setup>
import { getUserCoupon } from '@/common/server/user';
//# 必须要引入
import PageContainer from '@/components/youdas-container/page-container.vue'
let showLoading = ref(false);
let pageContainer = ref(null);
let showNotData = ref(false);
let tabList = ref([
{ title: '未使用', type: 0 },
{ title: '已使用', type: 1 },
{ title: '已过期', type: 2 }
]);
let tabCur = ref(0);
let listData = ref([]);
const tabChange = (index) => {
tabCur.value = index;
getList();
};
const getList = async () => {
showLoading.value = true;
let res = await getUserCoupon(tabCur.value, 1, 50);
listData.value = res.data.list;
showLoading.value = false;
};
// 下拉刷新方法
const onRefresh = async (paging) => {
await getList();
paging.complete();
};
</script>
<style lang="scss" scoped>
.tab-list {
display: flex;
padding: 30rpx;
background: #fff;
box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.05);
border-radius: 16rpx;
margin: 20rpx 20rpx 30rpx;
.tab-list-item {
flex: 1;
text-align: center;
position: relative;
padding: 20rpx 18rpx;
font-size: 24rpx;
font-weight: 500;
border-radius: 8rpx;
color: #999999;
transition: all 0.3s;
&.active {
font-size: 24rpx;
color: #333333;
background-color: #E6F791;
box-shadow: 0 2rpx 8rpx rgba(230, 247, 145, 0.6);
.arrow {
position: absolute;
bottom: -10rpx;
left: 50%;
transform: translateX(-50%);
width: 0;
height: 0;
border-left: 10rpx solid transparent;
border-right: 10rpx solid transparent;
border-top: 10rpx solid #E6F791;
}
}
}
}
.list-item {
width: 710rpx;
box-sizing: border-box;
padding: 0;
display: flex;
align-items: center;
margin: 0 auto 30rpx;
background: #fff;
border-radius: 16rpx;
box-shadow: 0 6rpx 16rpx rgba(0, 0, 0, 0.08);
overflow: hidden;
position: relative;
&::before {
content: '';
position: absolute;
left: 0;
top: 0;
height: 100%;
width: 8rpx;
background: linear-gradient(to bottom, #F39205, #FFBB5C);
}
.money {
width: 180rpx;
text-align: center;
position: relative;
font-size: 28rpx;
font-weight: 500;
color: #F39205;
padding: 30rpx 0;
background: rgba(243, 146, 5, 0.05);
text {
font-weight: 600;
font-size: 70rpx;
color: #F39205;
}
&::after {
content: '';
position: absolute;
right: 0;
top: 50%;
transform: translateY(-50%);
width: 1rpx;
height: 116rpx;
background: #EEEEEE;
}
}
.info {
flex: 1;
padding: 30rpx 20rpx;
.title {
font-size: 28rpx;
font-weight: 500;
color: #333333;
}
.time {
margin-top: 20rpx;
font-size: 20rpx;
font-weight: 400;
color: #8A8A8A;
display: flex;
align-items: center;
&::before {
content: '';
display: inline-block;
width: 20rpx;
height: 20rpx;
background: #E6F791;
border-radius: 50%;
margin-right: 8rpx;
}
}
}
.btn {
width: 120rpx;
height: 60rpx;
background: linear-gradient(to right, #E6F791, #D7E87D);
border-radius: 30rpx;
display: flex;
justify-content: center;
align-items: center;
font-size: 22rpx;
font-weight: 500;
color: #333333;
margin-right: 20rpx;
box-shadow: 0 4rpx 8rpx rgba(230, 247, 145, 0.4);
transition: all 0.3s;
&:active {
transform: scale(0.95);
}
}
&.dis {
position: relative;
opacity: 0.8;
&::after {
content: '';
position: absolute;
width: 100%;
height: 100%;
top: 0;
left: 0;
background: rgba(0, 0, 0, 0.2);
backdrop-filter: grayscale(100%);
}
.btn {
background: #CCCCCC;
box-shadow: none;
}
}
}
.not-data {
margin-top: 200rpx;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
</style>