You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
360 lines
8.1 KiB
360 lines
8.1 KiB
<template>
|
|
<view class="user">
|
|
<view class="user-navbar" :style="{'height': (statusBarHeight+44)+'px'}">
|
|
<u-navbar :bgColor="bgColor" :fixed="false" :autoBack="true" title="我的关注">
|
|
<view class="u-nav-slot" slot="content">
|
|
<view class="nav"></view>
|
|
</view>
|
|
</u-navbar>
|
|
</view>
|
|
<view class="blank" :style="{'height': (statusBarHeight+44)+'px'}"></view>
|
|
<view class="user-list">
|
|
<view class="users">
|
|
<view class="a">
|
|
<image v-if="guanzhuInfo.avatar" class="avater" :src="baseUrl+guanzhuInfo.avatar"></image>
|
|
<image v-else class="avater" src="https://zhengxin.njrenzhou.cn/static/default.png"></image>
|
|
<view class="name">{{guanzhuInfo.nickname}}</view>
|
|
</view>
|
|
<view class="c" @click="toGuanzhu(guanzhuInfo.user_id)">
|
|
<image src="https://zhengxin.njrenzhou.cn/static/icon-dui.png"></image>已关注
|
|
</view>
|
|
</view>
|
|
</view>
|
|
<view class="list">
|
|
<view class="tab">
|
|
<u-tabs :list="typeList" @click="clickTab"
|
|
lineWidth="0"
|
|
:current="tabIndex"
|
|
:activeStyle="{
|
|
color: '#00C6A9',
|
|
border: '1px solid #00C6A9',
|
|
borderRadius: '5px',
|
|
width: '150rpx',
|
|
textAlign: 'center',
|
|
padding: '10rpx 0',
|
|
display: 'block',
|
|
}"
|
|
:inactiveStyle="{
|
|
color: '#999999',
|
|
border: '1px solid #999999',
|
|
width: '150rpx',
|
|
display: 'block',
|
|
padding: '10rpx 0',
|
|
textAlign: 'center',
|
|
borderRadius: '5px'
|
|
}"
|
|
></u-tabs>
|
|
</view>
|
|
<view class="item" v-for="(a,i) in list" :key="i" @click="openPage(a.id)">
|
|
<view class="name">{{a.title}}</view>
|
|
<view class="desc">{{a.content_tag}}</view>
|
|
<view class="do">
|
|
<view class="fl"><image class="img1" src="https://zhengxin.njrenzhou.cn/static/icon-view.png"></image>{{a.readnum}}</view>
|
|
<view class="fl"><image class="img2" src="https://zhengxin.njrenzhou.cn/static/dianzan.png"></image>{{a.likenum}}</view>
|
|
</view>
|
|
<view class="tag" v-if="a.type_tag == '善'">善</view>
|
|
<view class="tag tag-on" v-else>恶</view>
|
|
</view>
|
|
</view>
|
|
<view class="empty" v-if="total == 0">
|
|
<image src="https://zhengxin.njrenzhou.cn/static/empty.png"></image>
|
|
<view class="txt">暂无数据 ~</view>
|
|
</view>
|
|
</view>
|
|
</template>
|
|
|
|
<script>
|
|
const systemInfoSync = uni.getSystemInfoSync();
|
|
export default {
|
|
data() {
|
|
return {
|
|
baseUrl: "",
|
|
tabIndex: 0,
|
|
statusBarHeight: 0,
|
|
list: [],
|
|
total: 1,
|
|
offset: 1,
|
|
typeList: [],
|
|
bgColor: "transparent",
|
|
guanzhuInfo: {},
|
|
}
|
|
},
|
|
onLoad() {
|
|
this.getTylelist();
|
|
this.baseUrl = this.$baseUrl;
|
|
this.guanzhuInfo = uni.getStorageSync("guanzhuInfo")
|
|
this.statusBarHeight = systemInfoSync.statusBarHeight
|
|
},
|
|
onShow() {
|
|
this.querytContentList(2);
|
|
},
|
|
onReachBottom() {
|
|
const that = this;
|
|
uni.showLoading({
|
|
title: "加载中"
|
|
})
|
|
if(this.list.length <= this.total){
|
|
that.offset ++;
|
|
setTimeout(function() {
|
|
that.querytContentList(1);
|
|
}, 1000);
|
|
}
|
|
},
|
|
methods: {
|
|
//关注
|
|
async toGuanzhu(user_id) {
|
|
const { code, data, msg } = await this.$api.guanzhu({type: 1,token:uni.getStorageSync("token"),user_id})
|
|
if(code == 1){
|
|
uni.showToast({
|
|
title: "取消关注"
|
|
})
|
|
setTimeout(()=>{
|
|
uni.navigateBack({
|
|
delta: 1
|
|
})
|
|
},2000)
|
|
}else {
|
|
uni.showToast({
|
|
icon: "none",
|
|
title: msg
|
|
})
|
|
}
|
|
},
|
|
//数组对象去重
|
|
arrayUnique (arr, name) {
|
|
var hash = {};
|
|
return arr.reduce(function (item, next) {
|
|
hash[next[name]]
|
|
? ""
|
|
: (hash[next[name]] = true && item.push(next));
|
|
return item;
|
|
}, []);
|
|
},
|
|
//事件类型
|
|
async getTylelist() {
|
|
const { code, data } = await this.$api.getTylelist({})
|
|
if(code == 1){
|
|
let arr = []
|
|
if(data && data.length > 0){
|
|
data.map(a=>{
|
|
a.name = a.title
|
|
})
|
|
}
|
|
this.typeList = [{name: "全部事件"},...data]
|
|
}
|
|
},
|
|
//获取事件
|
|
async querytContentList(type) {
|
|
const that = this;
|
|
if(type==2){
|
|
this.offset = 1;
|
|
this.tabIndex= 0;
|
|
}
|
|
const { code, data } = await that.$api.getUserContentList({
|
|
offset: this.offset,
|
|
limit: 20,
|
|
content_type_id: this.tabIndex==0?0:this.typeList[this.tabIndex].id,
|
|
user_id: this.guanzhuInfo.user_id,
|
|
token: uni.getStorageSync("token")
|
|
})
|
|
if(code == 1){
|
|
if(type==1){
|
|
uni.hideLoading();
|
|
}
|
|
that.list = this.arrayUnique([...that.list,...data.rows],'id');
|
|
that.total = data.total;
|
|
}
|
|
},
|
|
clickTab(e) {
|
|
this.tabIndex = e.index;
|
|
this.list = [];
|
|
this.offset = 1;
|
|
this.querytContentList();
|
|
},
|
|
openPage(id){
|
|
uni.navigateTo({
|
|
url: "/pages/release/detail?id="+id
|
|
})
|
|
},
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style lang="scss" scoped>
|
|
.user {
|
|
min-height: 100vh;
|
|
background: url(https://zhengxin.njrenzhou.cn/static/bg.png) center top no-repeat;
|
|
background-size: 100% auto;
|
|
overflow: hidden;
|
|
box-sizing: border-box;
|
|
.empty{
|
|
padding: 150rpx 0;
|
|
text-align: center;
|
|
font-size: 26rpx;
|
|
color: #666;
|
|
image{
|
|
width: 460rpx;
|
|
height: 400rpx;
|
|
margin-bottom: 30rpx;
|
|
}
|
|
}
|
|
.list{
|
|
padding: 0 0 25rpx 0;
|
|
background-color: #f3f7f8;
|
|
overflow: hidden;
|
|
border-radius: 20rpx 20rpx 0 0 ;
|
|
margin-top: 50rpx;
|
|
.tab{
|
|
margin-top: 20rpx;
|
|
}
|
|
.item{
|
|
width: 700rpx;
|
|
height: 180rpx;
|
|
background: #FFFFFF;
|
|
box-shadow: 0px 3rpx 10rpx 0px rgba(9,44,39,0.05);
|
|
border-radius: 20rpx;
|
|
padding: 30rpx;
|
|
box-sizing: border-box;
|
|
position: relative;
|
|
margin: 0 auto;
|
|
margin-top: 20rpx;
|
|
.tag{
|
|
width: 80rpx;
|
|
height: 56rpx;
|
|
text-align: center;
|
|
line-height: 56rpx;
|
|
background: #00C6A9;
|
|
border-radius: 0px 20rpx 0px 20rpx;
|
|
font-size: 32rpx;
|
|
color: #FFFFFF;
|
|
position: absolute;
|
|
right: 0;
|
|
top: 0;
|
|
z-index: 2;
|
|
&-on{
|
|
background: #333333;
|
|
}
|
|
}
|
|
.name{
|
|
font-weight: 500;
|
|
font-size: 30rpx;
|
|
white-space: nowrap;
|
|
text-overflow: ellipsis;
|
|
overflow: hidden;
|
|
color: #333333;
|
|
}
|
|
.desc{
|
|
font-weight: 500;
|
|
font-size: 24rpx;
|
|
color: #999999;
|
|
margin-top: 10rpx;
|
|
white-space: nowrap;
|
|
text-overflow: ellipsis;
|
|
overflow: hidden;
|
|
}
|
|
.do{
|
|
display: flex;
|
|
align-items: center;
|
|
margin-top: 10rpx;
|
|
.fl{
|
|
width: 130rpx;
|
|
display: flex;
|
|
align-items: center;
|
|
font-weight: 500;
|
|
font-size: 24rpx;
|
|
color: #999999;
|
|
.img1{
|
|
width: 30rpx;
|
|
height: 20rpx;
|
|
margin-right: 10rpx;
|
|
margin-top: 5rpx;
|
|
}
|
|
.img2{
|
|
width: 24rpx;
|
|
height: 24rpx;
|
|
margin-right: 10rpx;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
&-navbar{
|
|
position: fixed;
|
|
left: 0;
|
|
right: 0;
|
|
top: 0;
|
|
z-index: 12;
|
|
width: 100%;
|
|
background: url(https://zhengxin.njrenzhou.cn/static/bg.png) center top no-repeat;
|
|
background-size: 100% auto;
|
|
}
|
|
&-list{
|
|
overflow: hidden;
|
|
margin-top: 45rpx;
|
|
.info{
|
|
display: flex;
|
|
align-items: center;
|
|
overflow: hidden;
|
|
margin-top: 40rpx;
|
|
.item{
|
|
flex: 1;
|
|
font-weight: 500;
|
|
font-size: 24rpx;
|
|
color: #333333;
|
|
text-align: center;
|
|
text{
|
|
display: block;
|
|
font-weight: bold;
|
|
font-size: 36rpx;
|
|
color: #333333;
|
|
margin-bottom: 20rpx;
|
|
}
|
|
}
|
|
}
|
|
.users{
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: space-between;
|
|
padding: 0 25rpx;
|
|
.a{
|
|
font-weight: 400;
|
|
font-size: 34rpx;
|
|
color: #333333;
|
|
line-height: 36rpx;
|
|
display: flex;
|
|
align-items: center;
|
|
.avater{
|
|
width: 110rpx;
|
|
height: 110rpx;
|
|
border-radius: 50%;
|
|
margin-right: 25rpx;
|
|
}
|
|
.edit{
|
|
width: 45rpx;
|
|
height: 45rpx;
|
|
margin-left: 10rpx;
|
|
margin-top: 10rpx;
|
|
}
|
|
}
|
|
.c{
|
|
width: 130rpx;
|
|
height: 50rpx;
|
|
line-height: 50rpx;
|
|
background: #00C6A9;
|
|
border-radius: 4rpx;
|
|
font-weight: 500;
|
|
font-size: 22rpx;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
color: #FFFFFF;
|
|
image{
|
|
width: 20rpx;
|
|
height: 14rpx;
|
|
margin-right: 10rpx;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
</style>
|
|
|