deming/pageE/tool/MineHistory.vue
2020-07-18 17:43:37 +08:00

123 lines
2.8 KiB
Vue
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template>
<view class="mine-history">
<scroll-view scroll-y class="history-box" @scrolltolower="reachBottom">
<view class="item-box">
<!-- 需求只显示最近五十条数据 后台未作限制 -->
<view v-for="(item, index) in historyList.slice(0, 50)" :key="index" class="history-item">
<view class="item-title">
<image :src="item.store_avatar"></image>
<view>{{ item.store_name }}</view>
</view>
<image :src="item.goods_image" class="item-image"></image>
<view class="item-info">
<view class="info-name u-line-1">{{ item.goods_name }}</view>
</view>
</view>
</view>
<u-empty text="暂无足迹" mode="list" color="#000" v-if="!historyList.length"></u-empty>
<u-loadmore :status="loadStatus" bgColor="#ECECEC" margin-bottom="20" v-if="historyList.length > 9"></u-loadmore>
</scroll-view>
</view>
</template>
<script>
export default {
data() {
return {
historyList: [],
page: 1, // 默认1
loadStatus: 'loadmore',
timer: true,
};
},
onLoad() {
this.getBrowseList();
},
methods: {
async getBrowseList () {
const res = await this.$u.api.getBrowseList({ page: this.page });
this.timer = false;
if(res.errCode == 0) {
this.historyList = res.data.storeInfo;
}
return res.data.storeInfo.length;
},
reachBottom() {
if(!this.timer) return false;
this.loadStatus = "loading";
this.page++;
this.getBrowseList({page: this.page}).then(length => {
if(length == 0) {
this.page--;
this.status = 'nomore';
} else {
this.status = 'loading';
}
}).catch(() => {
this.loadStatus = "nomore";
this.page--;
})
}
}
};
</script>
<style lang="scss" scoped>
.mine-history {
min-height: calc(100vh - var(--window-top));
background: #ECECEC;
.history-box {
box-sizing: border-box;
height: calc(100vh - var(--window-top));
padding: 20rpx 30rpx 0;
.item-box {
display: flex;
flex-wrap: wrap;
.history-item {
width: 220rpx;
height: 290rpx;
background: rgba(255,255,255,1);
border-radius: 10rpx;
padding: 20rpx 20rpx 22rpx;
margin: 0 10rpx 20rpx 0;
.item-title {
display: flex;
align-items: center;
> image {
width: 50rpx;
height: 50rpx;
border-radius: 50%;
margin-right: 19rpx;
}
> view {
font-size: 24rpx;
color: rgba(51,51,51,1);
}
}
.item-image {
margin: 20rpx 0 17rpx;
width: 180rpx;
height: 140rpx;
border-radius: 10rpx;
}
.item-info {
display: flex;
justify-content: space-between;
align-items: center;
.info-name {
margin-right: 10rpx;
flex: 1;
font-size: 22rpx;
color: rgba(51,51,51,1);
}
> image {
width: 37rpx;
height: 8rpx;
}
}
}
}
}
}
</style>