baodeng_xcx/page_user/chongzhi/kajuanindex.vue
2025-08-19 17:02:49 +08:00

266 lines
5.3 KiB
Vue

<template>
<view class="page">
<u-navbar title="礼物兑换" :border-bottom="false" :background="bgc" back-icon-color="#fff" title-color='#fff'
title-size='36' height='36' id="navbar">
</u-navbar>
<!-- 顶部Tabs -->
<view class="tabs">
<view v-for="(tab, idx) in tabs" :key="tab" :class="['tab', { active: currentTab === idx }]"
@click="btntab(idx)">
{{ tab }}
</view>
</view>
<!-- 卡券列表 -->
<scroll-view @scrolltolower="handqixing" scroll-y class="card-list">
<view class="card-item" v-for="(item, idx) in cardList" :key="idx">
<view class="card-img">
<image :src="item.skuList[0].image" mode="aspectFill" />
</view>
<view class="card-content">
<view class="card-title-row">
<view class="card-title">{{ item.name }}</view>
<view class="card-count">x{{ item.surplusTotal }}</view>
</view>
<view class="card-date">获取时间{{ item.createTime }}</view>
<view class="card-bottom-row">
<view class="card-money">
<text class="icon">🍬</text>
<text class="money">立省{{ item.skuList[0].price }}</text>
</view>
<view class="card-btn" v-if="currentTab == 0" @click="btndh(item.id)">立即兑换</view>
<view class="card-btn" v-else style="background-color: #ccc;">已兑换</view>
</view>
</view>
</view>
<view class="" style="width: 100%;margin-top: 30rpx;text-align: center;color: #ccc;">
暂时没有更多礼物兑换劵了...
</view>
</scroll-view>
</view>
</template>
<script>
export default {
data() {
return {
tabs: ['待兑换', '已兑换'],
currentTab: 0,
cardList: [],
bgc: {
backgroundColor: '#010000',
},
pageNum:1,
total:0,
hasCount:true
};
},
onLoad() {
},
onShow() {
this.pageNum = 1
this.cardList = []
this.hasCount = true
this.getlist()
},
methods: {
// 点击跳转到立即兑换
btndh(id){
uni.navigateTo({
url:'/page_user/chongzhi/duihuan?id=' + id
})
},
// 上拉加载更多
handqixing(){
if(this.total > this.cardList.length){
this.getlist()
}else{
console.log(11);
}
},
// 点击tab
btntab(idx){
this.currentTab = idx
if(idx == 0){
this.hasCount = true
}else{
this.hasCount = false
}
this.pageNum = 1
this.getlist()
},
// 获取礼物列表
getlist() {
this.$u.get(`/app/vipUser/list?pageNum=${this.pageNum}&pageSize=20&storeId=${this.$store.state.storeId}&source=2&hasCount=${this.hasCount}`).then(res => {
if (res.code == 200) {
this.total = res.total
if (this.pageNum == 1) {
this.cardList = res.rows
this.pageNum++
} else {
this.cardList = this.cardList.concat(res.rows)
this.pageNum++
}
}
})
}
}
};
</script>
<style lang="scss">
.page {
min-height: 100vh;
background: #010000;
padding: 0;
}
.tabs {
display: flex;
justify-content: flex-start;
padding: 32rpx 30rpx 36rpx 30rpx;
box-sizing: border-box;
background: #010000;
.tab {
background: #232223;
color: #fff;
border-radius: 40rpx;
padding: 12rpx 44rpx;
margin-left: 20rpx;
font-size: 28rpx;
font-weight: 500;
transition: background 0.2s, color 0.2s;
&.active {
background: #ff7e9e;
color: #fff;
font-weight: bold;
}
}
.tab:first-child {
margin-left: 0;
}
}
.card-list {
padding: 0 20rpx;
height: 82vh;
overflow: scroll;
padding-bottom: 70rpx;
box-sizing: border-box;
}
.card-item {
display: flex;
flex-direction: row;
align-items: center;
background: #181718;
border-radius: 28rpx;
margin-bottom: 32rpx;
padding: 24rpx 20rpx 24rpx 24rpx;
position: relative;
min-height: 140rpx;
box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.08);
}
.card-img {
width: 178rpx;
height: 178rpx;
border-radius: 18rpx;
overflow: hidden;
background: #232223;
display: flex;
align-items: center;
justify-content: center;
margin-right: 24rpx;
image {
width: 178rpx;
height: 178rpx;
border-radius: 12rpx;
}
}
.card-content {
flex: 1;
display: flex;
flex-direction: column;
justify-content: space-between;
min-height: 90rpx;
}
.card-title-row {
display: flex;
align-items: center;
justify-content: space-between;
}
.card-title {
color: #fff;
font-size: 32rpx;
font-weight: bold;
margin-bottom: 4rpx;
}
.card-count {
color: #fff;
font-size: 26rpx;
font-weight: bold;
margin-left: 16rpx;
}
.card-date {
color: #bdbdbd;
font-size: 22rpx;
margin-bottom: 46rpx;
margin-top: 16rpx;
}
.card-bottom-row {
display: flex;
align-items: center;
justify-content: space-between;
margin-top: 8rpx;
}
.card-money {
display: flex;
align-items: center;
background: #232223;
border-radius: 20rpx;
padding: 0 18rpx;
height: 36rpx;
margin-right: 18rpx;
.icon {
font-size: 22rpx;
margin-right: 4rpx;
}
.money {
color: #ff7e9e;
font-size: 22rpx;
font-weight: 500;
}
}
.card-btn {
background: #ff7e9e;
color: #fff;
border: none;
border-radius: 30rpx;
font-size: 26rpx;
padding: 0 36rpx;
height: 48rpx;
line-height: 48rpx;
margin-left: 0;
font-weight: bold;
box-shadow: none;
display: flex;
align-items: center;
justify-content: center;
}
</style>