deming/pageD/attention/attention.vue
2020-08-14 10:00:27 +08:00

160 lines
3.3 KiB
Vue

<template>
<view class="attention">
<view class="attention_box" v-for="(item,index) in attention" :key="index" @click="navto(item.friend_tomid)">
<view style="position:relative">
<image :src="item.friend_tomavatar" mode="aspectFill"></image>
<view class="tishi" v-if="item.unread_message"></view>
</view>
<view>{{item.friend_tomname}}</view>
<view>{{item.live_status ? '正在直播' : '未直播'}}</view>
<view class="cur_two" @click="tapClick(index)">已关注</view>
<!-- <view class="cur" @click="tapClick(index)" v-else = "item.about == 2">未关注</view> -->
</view>
<u-loadmore :status="status" icon-type="iconType"/>
</view>
</template>
<script>
export default {
name: "attention",
data() {
return {
rSelect:[],
type : '未关注',
attention: [],
page:1,
status:'loadmore'
};
},
onReachBottom(){
if(this.status == 'loading' || this.status == 'nomore'){
return ;
}else{
this.status = "loading"
this.page++
this.snsfriendList()
}
},
onLoad(){
this.snsfriendList()
},
onShow(){
this.page = 1;
this.snsfriendList();
},
methods: {
// 点击切换颜色
tapClick(index) {
console.log(index)
if (this.rSelect.indexOf(index) == -1) {
console.log(index) //打印下标
this.rSelect.push(index); //选中添加到数组里
} else {
this.rSelect.splice(this.rSelect.indexOf(index), 1); //取消
}
},
snsfriendList(){
this.$u.api.snsfriendList({page:this.page}).then((res)=>{
console.log(res)
if(this.page > 1){
this.attention.push(...res.data.data)
}else{
this.attention = res.data.data;
}
this.status = "loadmore"
if(res.data.data.length < parseInt(res.data.per_page)){
this.status = "nomore"
}
})
},
navto(id){
// /pageB/details/index
this.$u.route({
url:"/pageB/details/index",
params:{
id
}
})
}
},
components: {
}
};
</script>
<style lang="scss" scoped>
.tishi{
position: absolute;
top: 5rpx;
left: 80rpx;
background-color: #ff5d00;
width: 12rpx;
height: 12rpx;
border-radius: 50%;
}
.attention {
display: flex;
flex-wrap: wrap;
justify-content: initial;
padding: 30rpx 30rpx 0 30rpx;
border-top: 1px #ECECEC solid;
.attention_box:nth-child(3n+3){
margin-right: 0;
}
.attention_box {
width: 215rpx;
height: 282rpx;
background: rgba(255, 255, 255, 1);
box-shadow: 0px 3px 7px 0px rgba(153, 153, 153, 0.35);
border-radius: 10rpx;
margin-right: 24rpx;
margin-bottom: 33rpx;
float: left;
view image {
width: 80rpx;
height: 80rpx;
border-radius: 50%;
margin: 24rpx auto 0;
}
view {
text-align: center;
}
view:nth-child(2) {
font-size: 26rpx;
font-weight: 400;
color: rgba(51, 51, 51, 1);
margin: 20rpx 0;
text-align: center;
}
view:nth-child(3) {
font-size: 22rpx;
font-family: PingFang SC;
font-weight: 400;
color: rgba(153, 153, 153, 1);
}
view:nth-child(4) {
width: 130rpx;
height: 50rpx;
line-height: 50rpx;
background: rgba(221, 221, 221, 1);
border-radius: 25rpx;
font-size: 26rpx;
color: rgba(255, 255, 255, 1);
margin: 19rpx auto;
}
}
}
// 选中的样式
.cur {
background-color: #ff5d00!important;
color: #fff!important;
}
</style>