修复奖品列表触底加载

This commit is contained in:
YeMingfei666 2025-01-03 21:27:06 +08:00
parent 95be7e966f
commit 688f814c2e
1 changed files with 51 additions and 30 deletions

View File

@ -5,17 +5,15 @@
</view> </view>
<view class="list"> <view class="list">
<view class="tab"> <view class="tab">
<view class="tab_item" <view class="tab_item" :class="{active: item.type == tabIndex}" @click="tabClick(item)"
:class="{active: item.type == tabIndex}" v-for="(item,index) in tab" :key="index">{{item.label}}</view>
@click="tabClick(item)"
v-for="(item,index) in tab" :key="index"
>{{item.label}}</view>
</view> </view>
<view class="item" v-for="(item,index) in list" :key="index"> <view class="item" v-for="(item,index) in list" :key="index">
<view class="color-666 u-font-24">{{tabIndex==1?'中奖时间':'兑换时间'}} {{item.createTime}}</view> <view class="color-666 u-font-24">{{tabIndex==1?'中奖时间':'兑换时间'}} {{item.createTime}}</view>
<view class="u-m-t-24 u-flex u-row-between"> <view class="u-m-t-24 u-flex u-row-between">
<view class="u-flex-1 u-flex u-col-top"> <view class="u-flex-1 u-flex u-col-top">
<u-image width="128rpx" height="128rpx" v-if="item.type == 2 " src="/static/red-pack.png"></u-image> <u-image width="128rpx" height="128rpx" v-if="item.type == 2 "
src="/static/red-pack.png"></u-image>
<u-image width="128rpx" height="128rpx" v-else :src="item.imgUrl"></u-image> <u-image width="128rpx" height="128rpx" v-else :src="item.imgUrl"></u-image>
<view class="u-m-l-16"> <view class="u-m-l-16">
<view v-if="tabIndex == 1">{{item.name}}</view> <view v-if="tabIndex == 1">{{item.name}}</view>
@ -30,7 +28,7 @@
</view> </view>
</view> </view>
<view class="u-p-t-30 u-p-b-30 empty" v-if="hasAjax&&!list.length"> <view class="u-p-t-30 u-p-b-30 empty" v-if="hasAjax&&!list.length">
<u-empty text="暂无记录" src="/static/icon-empty.svg"></u-empty> <u-empty text="暂无记录" src="/static/icon-empty.svg"></u-empty>
</view> </view>
</view> </view>
<!-- <view class="u-p-30"> <!-- <view class="u-p-30">
@ -46,7 +44,13 @@
background: { background: {
backgroundColor: 'transparent' backgroundColor: 'transparent'
}, },
tab: [{label: '抽奖记录', type: 1},{label: '兑换记录', type: 2}], tab: [{
label: '抽奖记录',
type: 1
}, {
label: '兑换记录',
type: 2
}],
tabIndex: 1, tabIndex: 1,
query: { query: {
page: 1, page: 1,
@ -54,61 +58,73 @@
}, },
total: 0, total: 0,
status: 'nomore', status: 'nomore',
hasAjax:true, hasAjax: true,
list:[] list: [],
isLoading:false,
isEnd:false
} }
}, },
onLoad(options) { onLoad(options) {
}, },
onShow() { onShow() {
this.list = []; this.list = [];
this.getList() this.getList()
}, },
// onReachBottom() {
// console.log('onReachBottom');
// if (this.isEnd || this.isLoading) {
// return
// }
// this.query.page+=1;
// this.getList()
// },
methods: { methods: {
toDuiHuan(item){ toDuiHuan(item) {
uni.navigateTo({ uni.navigateTo({
url:`/me/gift/duihuan?id=${item.id}` url: `/me/gift/duihuan?id=${item.id}`
}) })
}, },
tabClick(item){ tabClick(item) {
this.list = []; this.list = [];
this.tabIndex = item.type; this.tabIndex = item.type;
this.getList() this.getList()
}, },
getList(){ getList() {
let url = "" let url = ""
if ( this.tabIndex == 1) { if (this.tabIndex == 1) {
url = "app/discSpinningRecord/selectDiscSpinningRecord" url = "app/discSpinningRecord/selectDiscSpinningRecord"
} else { } else {
url = "/app/userPrizeExchange/page" url = "/app/userPrizeExchange/page"
} }
this.isLoading=true
this.$Request.getT(url, this.query).then(res => { this.$Request.getT(url, this.query).then(res => {
if (res.code == 0 ) { this.isLoading=false
if ( this.tabIndex == 1) { this.isEnd=this.query.page>=res.data.totalPage
this.list = [...this.list,...res.data.records] if (res.code == 0) {
if (this.tabIndex == 1) {
this.list = [...this.list, ...res.data.records]
this.total = res.data.total this.total = res.data.total
} else { } else {
this.list = [...this.list,...res.page.list] this.list = [...this.list, ...res.page.list]
this.total = res.page.totalCount this.total = res.page.totalCount
} }
} }
}) })
}, },
onReachBottom: function () { onReachBottom: function() {
console.log(this.query.page) console.log(this.query.page)
console.log(this.query.limit) console.log(this.query.limit)
if (this.query.page * this.query.limit < this.total) { if (!this.isEnd&&!this.isLoading) {
this.query.page = this.query.page + 1; this.query.page = this.query.page + 1;
this.getList(); this.getList();
} }
}, },
} }
} }
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.duihuan { .duihuan {
background: linear-gradient(87deg, #ED8087 0%, #ECA2AA 100%); background: linear-gradient(87deg, #ED8087 0%, #ECA2AA 100%);
font-size: 24rpx; font-size: 24rpx;
@ -139,7 +155,8 @@
} }
} }
.empty{
.empty {
// min-height: 50vh; // min-height: 50vh;
} }
@ -155,9 +172,11 @@
border-radius: 18rpx 18rpx 18rpx 18rpx; border-radius: 18rpx 18rpx 18rpx 18rpx;
overflow: hidden; overflow: hidden;
background-color: #fff; background-color: #fff;
.tab{
.tab {
display: flex; display: flex;
.tab_item{
.tab_item {
height: 80rpx; height: 80rpx;
line-height: 80rpx; line-height: 80rpx;
width: 50%; width: 50%;
@ -165,11 +184,13 @@
font-size: 32rpx; font-size: 32rpx;
color: #333; color: #333;
} }
.tab_item.active{
.tab_item.active {
background-color: #ECA2AA; background-color: #ECA2AA;
color: #fff; color: #fff;
} }
} }
.item { .item {
padding: 32rpx 24rpx; padding: 32rpx 24rpx;
border-bottom: 1rpx solid #E5E5E5; border-bottom: 1rpx solid #E5E5E5;