deming/pageE/tool/MineHistory.vue

123 lines
2.8 KiB
Vue
Raw Normal View History

2020-06-01 16:51:11 +08:00
<template>
<view class="mine-history">
2020-07-06 17:32:29 +08:00
<scroll-view scroll-y class="history-box" @scrolltolower="reachBottom">
<view class="item-box">
2020-07-18 17:43:37 +08:00
<!-- 需求只显示最近五十条数据 后台未作限制 -->
2020-07-06 17:32:29 +08:00
<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>
2020-06-02 11:42:13 +08:00
</view>
2020-06-01 16:51:11 +08:00
</view>
2020-07-18 17:43:37 +08:00
<u-empty text="暂无足迹" mode="list" color="#000" v-if="!historyList.length"></u-empty>
2020-07-06 17:32:29 +08:00
<u-loadmore :status="loadStatus" bgColor="#ECECEC" margin-bottom="20" v-if="historyList.length > 9"></u-loadmore>
</scroll-view>
2020-06-01 16:51:11 +08:00
</view>
</template>
<script>
export default {
data() {
return {
2020-07-18 17:43:37 +08:00
historyList: [],
2020-07-06 17:32:29 +08:00
page: 1, // 默认1
loadStatus: 'loadmore',
timer: true,
2020-06-01 16:51:11 +08:00
};
},
2020-06-29 17:24:57 +08:00
onLoad() {
this.getBrowseList();
},
methods: {
2020-07-06 17:32:29 +08:00
async getBrowseList () {
const res = await this.$u.api.getBrowseList({ page: this.page });
this.timer = false;
if(res.errCode == 0) {
2020-07-28 20:47:31 +08:00
this.historyList.push(...res.data.storeInfo);
2020-07-06 17:32:29 +08:00
}
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';
2020-06-29 17:24:57 +08:00
}
2020-07-06 17:32:29 +08:00
}).catch(() => {
this.loadStatus = "nomore";
this.page--;
2020-06-29 17:24:57 +08:00
})
}
}
2020-06-01 16:51:11 +08:00
};
</script>
<style lang="scss" scoped>
2020-06-02 11:42:13 +08:00
.mine-history {
2020-06-04 08:21:34 +08:00
min-height: calc(100vh - var(--window-top));
2020-06-01 16:51:11 +08:00
background: #ECECEC;
2020-06-02 11:42:13 +08:00
.history-box {
2020-07-18 17:43:37 +08:00
box-sizing: border-box;
2020-07-06 17:32:29 +08:00
height: calc(100vh - var(--window-top));
2020-06-02 11:42:13 +08:00
padding: 20rpx 30rpx 0;
2020-07-06 17:32:29 +08:00
.item-box {
display: flex;
flex-wrap: wrap;
.history-item {
width: 220rpx;
height: 290rpx;
background: rgba(255,255,255,1);
2020-06-02 11:42:13 +08:00
border-radius: 10rpx;
2020-07-06 17:32:29 +08:00
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;
2020-06-02 11:42:13 +08:00
}
2020-07-06 17:32:29 +08:00
.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;
}
2020-06-02 11:42:13 +08:00
}
2020-06-01 16:51:11 +08:00
}
}
2020-07-06 17:32:29 +08:00
2020-06-01 16:51:11 +08:00
}
}
</style>