deming/pageE/tool/MineHistory.vue

140 lines
3.2 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">
2020-08-09 18:39:35 +08:00
<view class="item-title" @click="viewStoreDetails(item.store_id)">
2020-07-06 17:32:29 +08:00
<image :src="item.store_avatar"></image>
2020-08-09 18:39:35 +08:00
<view class="u-line-2">{{ item.store_name }}</view>
2020-07-06 17:32:29 +08:00
</view>
2020-08-09 18:39:35 +08:00
<image :src="item.goods_image" class="item-image" @click="viewGoodsDetails(item.goods_id)"></image>
<view class="item-info" @click="viewGoodsDetails(item.goods_id)">
2020-07-06 17:32:29 +08:00
<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-08-09 18:39:35 +08:00
viewStoreDetails(sid) {
this.$u.route({
url: 'pageC/merchant/index',
params: {
id: sid,
}
})
},
viewGoodsDetails(id) {
this.$u.route({
url: 'pageB/sdetails/index',
params: {
id: id,
}
})
},
2020-07-06 17:32:29 +08:00
async getBrowseList () {
const res = await this.$u.api.getBrowseList({ page: this.page });
2020-08-12 11:45:12 +08:00
this.timer = true;
2020-07-06 17:32:29 +08:00
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;
2020-08-12 11:45:12 +08:00
this.timer = false;
2020-07-06 17:32:29 +08:00
this.loadStatus = "loading";
this.page++;
2020-08-12 11:45:12 +08:00
this.getBrowseList().then(length => {
2020-07-06 17:32:29 +08:00
if(length == 0) {
this.page--;
2020-08-12 11:45:12 +08:00
this.loadStatus = 'nomore';
2020-07-06 17:32:29 +08:00
} else {
2020-08-12 11:45:12 +08:00
this.loadStatus = '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>