- 从 main 获取 single_uniapp22miao 子项目 - dart-sass: /deep/ -> ::v-deep,calc 运算符加空格 - DEPLOY.md 采用 shccd159 版本(4 子项目架构说明) Made-with: Cursor
173 lines
3.3 KiB
Vue
173 lines
3.3 KiB
Vue
<template>
|
|
<view class="prize-page">
|
|
<scroll-view
|
|
scroll-y
|
|
class="scroll-view"
|
|
@scrolltolower="loadMore"
|
|
>
|
|
<view class="prize-list">
|
|
<view
|
|
v-for="(prize, index) in prizeList"
|
|
:key="index"
|
|
class="prize-item"
|
|
>
|
|
<image :src="prize.image" class="prize-image"></image>
|
|
<view class="prize-info">
|
|
<view class="prize-name">{{ prize.name }}</view>
|
|
<view class="prize-desc">{{ prize.desc }}</view>
|
|
<view class="prize-time">{{ prize.created_at }}</view>
|
|
</view>
|
|
</view>
|
|
|
|
<!-- 加载更多 -->
|
|
<view class="load-more" v-if="prizeList.length > 0">
|
|
<text v-if="loading">加载中...</text>
|
|
<text v-else-if="noMore">没有更多了</text>
|
|
</view>
|
|
|
|
<!-- 空状态 -->
|
|
<view class="empty-state" v-if="prizeList.length === 0 && !loading">
|
|
<text class="icon">🎁</text>
|
|
<text class="text">暂无奖品</text>
|
|
</view>
|
|
</view>
|
|
</scroll-view>
|
|
</view>
|
|
</template>
|
|
|
|
<script>
|
|
export default {
|
|
data() {
|
|
return {
|
|
prizeList: [],
|
|
page: 1,
|
|
limit: 20,
|
|
loading: false,
|
|
noMore: false
|
|
}
|
|
},
|
|
|
|
onLoad() {
|
|
this.loadPrizeList();
|
|
},
|
|
|
|
methods: {
|
|
// 加载奖品列表
|
|
async loadPrizeList() {
|
|
if (this.loading || this.noMore) return;
|
|
|
|
this.loading = true;
|
|
|
|
try {
|
|
const res = await this.$http.get('/api/prize/list', {
|
|
page: this.page,
|
|
limit: this.limit
|
|
});
|
|
|
|
if (res.code === 0) {
|
|
const list = res.data.list || [];
|
|
|
|
if (list.length < this.limit) {
|
|
this.noMore = true;
|
|
}
|
|
|
|
this.prizeList = this.page === 1 ? list : [...this.prizeList, ...list];
|
|
}
|
|
} catch (error) {
|
|
console.error('加载奖品失败:', error);
|
|
} finally {
|
|
this.loading = false;
|
|
}
|
|
},
|
|
|
|
// 加载更多
|
|
loadMore() {
|
|
if (!this.loading && !this.noMore) {
|
|
this.page++;
|
|
this.loadPrizeList();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style lang="scss" scoped>
|
|
.prize-page {
|
|
height: 100vh;
|
|
background-color: #f5f5f5;
|
|
}
|
|
|
|
.scroll-view {
|
|
height: 100%;
|
|
}
|
|
|
|
.prize-list {
|
|
padding: 20rpx 30rpx;
|
|
}
|
|
|
|
.prize-item {
|
|
display: flex;
|
|
padding: 30rpx;
|
|
background-color: #fff;
|
|
border-radius: 20rpx;
|
|
margin-bottom: 20rpx;
|
|
|
|
.prize-image {
|
|
width: 160rpx;
|
|
height: 160rpx;
|
|
border-radius: 8rpx;
|
|
margin-right: 20rpx;
|
|
background-color: #f5f5f5;
|
|
}
|
|
|
|
.prize-info {
|
|
flex: 1;
|
|
|
|
.prize-name {
|
|
font-size: 28rpx;
|
|
font-weight: bold;
|
|
color: #333;
|
|
margin-bottom: 10rpx;
|
|
}
|
|
|
|
.prize-desc {
|
|
font-size: 24rpx;
|
|
color: #666;
|
|
line-height: 1.4;
|
|
margin-bottom: 10rpx;
|
|
}
|
|
|
|
.prize-time {
|
|
font-size: 22rpx;
|
|
color: #999;
|
|
}
|
|
}
|
|
}
|
|
|
|
.load-more {
|
|
padding: 30rpx;
|
|
text-align: center;
|
|
font-size: 26rpx;
|
|
color: #999;
|
|
}
|
|
|
|
.empty-state {
|
|
display: flex;
|
|
flex-direction: column;
|
|
align-items: center;
|
|
justify-content: center;
|
|
padding: 200rpx 0;
|
|
|
|
.icon {
|
|
font-size: 120rpx;
|
|
margin-bottom: 20rpx;
|
|
}
|
|
|
|
.text {
|
|
font-size: 28rpx;
|
|
color: #999;
|
|
}
|
|
}
|
|
</style>
|
|
|