耀实惠小程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

116 lines
2.3 KiB

<template>
<view>
<!-- 展示数据 -->
<view class="over_y">
<view class="item_goods" v-for="(item,index) in list" :key="index">
<goods-item :goods="item.goodList[0]" :thereTo='item.thereTo'></goods-item>
</view>
<view class="empty_box" v-if="list.length == 0">
<image :src="IMG_URL+'empty.png'" alt=""></image>
<text class="text_">暂无收藏记录</text>
</view>
</view>
</view>
</template>
<script>
import { IMG_URL } from '@/env.js'
export default {
data() {
return {
IMG_URL,
list: [],
pageNo: 1,
pageSize: 10,
total: null,
isLock: true, // 锁
}
},
onPullDownRefresh() {
this.pageNo= 1;
this.total = null;
this.list = [];
this.getCollectionPages();
},
onReachBottom() {
if(this.isLock) {
if(this.total !== null && this.pageNo * this.pageSize >= this.total){
this.isLock = false;
this.$Toast('没有更多数据了哦!');
setTimeout(()=>{
this.isLock = true;
},3000)
return
}
this.pageNo+=1;
this.getCollectionPages();
}
},
onLoad(){
},
onShow() {
this.pageNo= 1;
this.total = null;
this.list = [];
this.getCollectionPages();
},
methods: {
getCollectionPages() {
uni.showLoading();
const params = {
pageNo: this.pageNo,
pageSize: this.pageSize,
}
this.$api('getCollectionPages',params).then(res => {
let { code, result, message} = res;
uni.hideLoading();
if(code == 200){
if(this.total == null) {
this.total = result.total;
}
result.records.forEach(item => {
if(item && item.goodList.length>0 && item.goodList[0].pic){
item.goodList[0].pic = item.goodList[0].pic.split(',')[0]
}
})
this.list = this.list.concat(result.records);
}else{
this.$Toast(message);
}
}).catch( err => {
uni.hideLoading();
this.$Toast(err.message);
})
}
}
}
</script>
<style lang="scss" scoped>
.over_y {
width: 100%;
padding: 0 20rpx;
overflow-y: auto;
}
.empty_box{
width: 100%;
height: 80vh;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
image{
width: 371rpx;
height: 371rpx;
}
.text_{
margin-top: 10rpx;
font-size: 36rpx;
font-weight: bold;
color: #01AEEA;
}
}
</style>