deming/pageE/tool/MineHistory.vue
2020-08-12 18:38:14 +08:00

144 lines
3.3 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" @click="viewStoreDetails(item.store_id)">
<image :src="item.store_avatar"></image>
<view class="u-line-1">{{ item.store_name }}</view>
</view>
<image :src="item.goods_image" class="item-image" @click="viewGoodsDetails(item.goods_id)"></image>
<view class="item-info" @click="viewGoodsDetails(item.goods_id)">
<view class="info-name u-line-1">{{ item.goods_name }}</view>
<u-icon name="trash" color="#666" size="32"></u-icon>
</view>
<!-- <view @click.stop="delArticle(item.article_id)">
</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: {
viewStoreDetails(sid) {
this.$u.route({
url: 'pageC/merchant/index',
params: {
id: sid,
}
})
},
viewGoodsDetails(id) {
this.$u.route({
url: 'pageB/sdetails/index',
params: {
id: id,
}
})
},
async getBrowseList () {
const res = await this.$u.api.getBrowseList({ page: this.page });
this.timer = true;
if(res.errCode == 0) {
this.historyList.push(...res.data.storeInfo);
}
return res.data.storeInfo.length;
},
reachBottom() {
if(!this.timer) return false;
this.timer = false;
this.loadStatus = "loading";
this.page++;
this.getBrowseList().then(length => {
if(length == 0) {
this.page--;
this.loadStatus = 'nomore';
} else {
this.loadStatus = '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>