deming/pageB/follow/index.vue

117 lines
2.8 KiB
Vue
Raw Normal View History

2020-06-02 17:24:13 +08:00
<template>
<view class="follow">
2020-08-15 18:32:46 +08:00
<scroll-view scroll-y :style="{ height: viewHeight }" @scrolltolower="loadmore" class="container">
<view class="sosuo" @click="searchValue">
<image src="/static/image/common/10.png"></image>
<text>输入达人名称</text>
</view>
<view class="list" style="margin-left:-20rpx">
<darenItem style="margin-top:20rpx;margin-left:20rpx;" v-for="item in recommendList" :key="item.id" :info="item" v-on:pChangeType="changeType"></darenItem>
</view>
<u-loadmore :status="loadStatus" bgColor="#ECECEC" font-size="14" margin-top="40" margin-bottom="20" v-if="recommendList.length > pageSize" @loadmore="loadmore"></u-loadmore>
</scroll-view>
2020-06-02 17:24:13 +08:00
</view>
</template>
<style lang="scss" scoped>
.follow{
background-color: #ECECEC;
min-height: calc(100vh - var(--window-top));
2020-08-15 18:32:46 +08:00
.container {
box-sizing: border-box;
padding: 20rpx 30rpx;
.sosuo{
width: 100%;
height: 60rpx;
border-radius: 30rpx;
background-color: #fff;
display: flex;
align-items: center;
justify-content: center;
>image{
width: 29rpx;
height: 29rpx;
}
>text{
font-size: 24rpx;
color: #999;
margin-left: 15rpx;
}
}
.list{
display: flex;
flex-wrap: wrap;
width: calc(100% + 23rpx);
margin-right: -23rpx;
}
}
2020-06-02 17:24:13 +08:00
}
</style>
<script>
import darenItem from "@/components/index/daren-item/index"
export default {
name:"follow",
components:{
darenItem
},
data(){
return{
2020-08-15 18:32:46 +08:00
pageSize: 2,
2020-07-01 17:32:36 +08:00
recommendList: [], // 推荐达人
2020-08-15 18:32:46 +08:00
page: 1,
loadStatus: 'loadmore',
timer: true,
viewHeight: '',
2020-06-02 17:24:13 +08:00
}
2020-07-01 17:32:36 +08:00
},
2020-08-15 18:32:46 +08:00
onLoad() {
this.setViewHeight();
},
2020-07-01 17:32:36 +08:00
onShow() {
this.getRecommendList();
},
methods: {
2020-08-15 18:32:46 +08:00
async getRecommendList({ load = 'reload' } = {}) {
const res = await this.$u.api.getAllRecommendList({ page: this.page });
this.timer = true;
if(res.errCode == 0) {
if(load == 'reload') this.recommendList = res.data.list;
if(load == 'loadmore') this.recommendList.push(...res.data.list);
}
return res.data.list.length;
},
loadmore() {
if(!this.timer) return false;
this.timer = false;
this.loadStatus = "loading";
this.page++;
this.getRecommendList({ load: "loadmore" }).then(length => {
this.loadStatus = "nomore";
if(length == 0) this.page--;
}).catch(() => {
this.loadStatus = "nomore";
this.page--;
2020-07-01 17:32:36 +08:00
})
},
2020-07-20 17:14:18 +08:00
changeType(member_id){
2020-08-15 18:32:46 +08:00
// console.log(member_id);
2020-07-20 17:14:18 +08:00
this.$emit("pChangeType")
this.$u.api.attentionMember({
member_id: member_id
}).then((res)=>{
console.log(res)
this.getRecommendList();
})
},
2020-07-01 17:32:36 +08:00
searchValue() {
uni.navigateTo({
2020-08-11 18:27:19 +08:00
url: '/pageB/search/index?type=2&curent=1'
2020-07-01 17:32:36 +08:00
})
},
2020-08-15 18:32:46 +08:00
setViewHeight() {
const res = uni.getSystemInfoSync();
this.viewHeight = res.windowHeight + 'px';
}
2020-07-01 17:32:36 +08:00
},
2020-06-02 17:24:13 +08:00
}
</script>