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.
327 lines
7.0 KiB
327 lines
7.0 KiB
<template>
|
|
<view class="dongtai">
|
|
<view class="dongtai-tab">
|
|
<view class="tab">
|
|
<u-tabs :list="list" bg-color="transparent" :is-scroll="false" active-color="#222222" inactive-color="#666666" font-size="30" :active-item-style="activeStyle" bar-height="10" bar-width="60" v-model="current" @change="changeTabs"></u-tabs>
|
|
</view>
|
|
</view>
|
|
<view class="dongtai-list">
|
|
<view class="item" v-for="(a,i) in dongtaiList" :key="i" @click="openPage(1,a.id)">
|
|
<view class="a">
|
|
<view class="fl">
|
|
<image :src="a.faceImage?a.faceImage:a.img"></image>
|
|
<view class="info">
|
|
<view class="name">{{a.nickname}}</view>
|
|
<view class="desc">{{a.createTime}}</view>
|
|
</view>
|
|
</view>
|
|
<view class="fr">
|
|
<image src="@/static/shenglue.png"></image>
|
|
</view>
|
|
</view>
|
|
<view class="b">{{a.content}}</view>
|
|
<view class="c">
|
|
<image mode="aspectFill" v-for="(b,idx) in a.imgurl" :key="idx" @click.stop="previewImage(i,idx)" :src="b"></image>
|
|
</view>
|
|
<view class="d">
|
|
<view class="fl">
|
|
<view class="li">
|
|
<image src="@/static/xiaoxi.png"></image>{{a.pinglun}}
|
|
</view>
|
|
<view class="li">
|
|
<image v-if="a.isUserZan == 0 " src="@/static/dianzan.png"></image>
|
|
<image v-else src="@/static/zandin2.png"></image>{{a.zan}}
|
|
</view>
|
|
<view class="li">
|
|
<image src="@/static/fenxiang.png"></image>分享
|
|
</view>
|
|
</view>
|
|
<view class="fr">搭讪</view>
|
|
</view>
|
|
</view>
|
|
<view style="margin-top: 25rpx;">
|
|
<u-divider v-if="total>=1 && total==dongtaiList.length" bg-color="transparent">到底啦~</u-divider>
|
|
</view>
|
|
<view class="empty" v-if="total == 0">
|
|
<image src="@/static/empty.png"></image>
|
|
<view class="txt">暂无数据</view>
|
|
</view>
|
|
</view>
|
|
<view class="dongtai-fd" @click.stop="openPage(2)">
|
|
<image src="@/static/icon-fabu.png"></image>
|
|
</view>
|
|
<unverified :isPopup="isPopup" />
|
|
</view>
|
|
</template>
|
|
|
|
<script>
|
|
export default {
|
|
data() {
|
|
return {
|
|
isPopup: false,
|
|
current: 0,
|
|
pageNum: 1,
|
|
total: 1,
|
|
list:[{'name': '广场'},{'name': '关注'}],
|
|
activeStyle:{'fontSize': '35rpx'},
|
|
dongtaiList: [],
|
|
userInfo: {}
|
|
}
|
|
},
|
|
onReady() {
|
|
const that = this;
|
|
that.getList();
|
|
uni.$on("toAddDongtai",res=>{
|
|
that.pageNum = 1;
|
|
that.current = 0;
|
|
that.dongtaiList = [];
|
|
that.getList();
|
|
})
|
|
uni.$on("closeSharePopup",res=>{
|
|
that.isPopup = false;
|
|
})
|
|
},
|
|
onShow() {
|
|
this.getUserInfo();
|
|
},
|
|
onReachBottom() {
|
|
const that = this;
|
|
uni.showLoading({
|
|
title: "加载中"
|
|
})
|
|
if(this.dongtaiList.length <= this.total){
|
|
that.pageNum ++;
|
|
setTimeout(function() {
|
|
that.getList(1);
|
|
}, 1000);
|
|
}
|
|
},
|
|
methods: {
|
|
previewImage(index,i){
|
|
uni.previewImage({
|
|
urls: this.dongtaiList[index].imgurl,
|
|
count: i
|
|
})
|
|
},
|
|
//数组对象去重
|
|
arrayUnique (arr, name) {
|
|
var hash = {};
|
|
return arr.reduce(function (item, next) {
|
|
hash[next[name]]
|
|
? ""
|
|
: (hash[next[name]] = true && item.push(next));
|
|
return item;
|
|
}, []);
|
|
},
|
|
//查询列表
|
|
async getList(type) {
|
|
const { code, data } = await this.$api.articleList({
|
|
userId: uni.getStorageSync("userInfo").id,
|
|
type: Number(this.current)+1,
|
|
limit: 20,
|
|
page: this.pageNum,
|
|
})
|
|
if(code == 200){
|
|
if(type == 1){
|
|
uni.hideLoading();
|
|
}
|
|
console.log(data.total)
|
|
if(data.totalCount > 0){
|
|
data.list.map(a=>{
|
|
if(a.imgurl){
|
|
a.imgurl = a.imgurl.split(",")
|
|
}
|
|
})
|
|
}
|
|
this.total = data.totalCount;
|
|
this.dongtaiList = this.arrayUnique([...this.dongtaiList,...data.list],"id")
|
|
}
|
|
},
|
|
openPage(index,id){
|
|
if(index == 1){
|
|
uni.navigateTo({
|
|
url: "/pages/dongtai/detail?id="+id
|
|
})
|
|
}else if(index == 2){
|
|
if(this.userInfo.realnameFlag == 0){
|
|
this.isPopup = true
|
|
return ;
|
|
}
|
|
uni.navigateTo({
|
|
url: "/pages/dongtai/add"
|
|
})
|
|
}
|
|
},
|
|
async getUserInfo() {
|
|
const { code, data , msg } = await this.$api.findUserInfo({userId: uni.getStorageSync("userInfo").id});
|
|
if(code == 200){
|
|
this.userInfo = data;
|
|
uni.setStorageSync("userInfo",data)
|
|
}else{
|
|
uni.showToast({
|
|
title: mgs,
|
|
position: "bottom",
|
|
icon: "none",
|
|
})
|
|
}
|
|
},
|
|
changeTabs(index){
|
|
this.current = index
|
|
this.pageNum = 1;
|
|
this.total = 1;
|
|
this.dongtaiList = []
|
|
this.getList();
|
|
},
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style scoped lang="scss">
|
|
.dongtai{
|
|
overflow: hidden;
|
|
.empty{
|
|
padding: 150rpx 0;
|
|
text-align: center;
|
|
font-weight: 500;
|
|
font-size: 28rpx;
|
|
color: #222222;
|
|
image{
|
|
display: block;
|
|
width: 460rpx;
|
|
height: 400rpx;
|
|
margin: 0 auto;
|
|
}
|
|
}
|
|
&-fd{
|
|
width: 135rpx;
|
|
height: 135rpx;
|
|
position: fixed;
|
|
right: 10rpx;
|
|
bottom: 100rpx;
|
|
z-index: 22;
|
|
image{
|
|
width: 100%;
|
|
height: 100%;
|
|
}
|
|
}
|
|
&-tab{
|
|
display: flex;
|
|
margin-top: 10rpx;
|
|
overflow: hidden;
|
|
.tab{
|
|
width: 250rpx;
|
|
}
|
|
}
|
|
&-list{
|
|
padding: 0 25rpx 25rpx;
|
|
overflow: hidden;
|
|
.item{
|
|
width: 100%;
|
|
background: #FFFFFF;
|
|
border-radius: 20rpx;
|
|
padding: 30rpx;
|
|
box-sizing: border-box;
|
|
margin-top: 20rpx;
|
|
.d{
|
|
font-weight: 400;
|
|
font-size: 24rpx;
|
|
color: #333333;
|
|
line-height: 42rpx;
|
|
margin-top: 20rpx;
|
|
text-align: left;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: space-between;
|
|
.fl{
|
|
flex: 1;
|
|
display: flex;
|
|
align-items: center;
|
|
.li{
|
|
display: flex;
|
|
align-items: center;
|
|
width: 120rpx;
|
|
image{
|
|
width: 32rpx;
|
|
height: 32rpx;
|
|
margin-right: 10rpx;
|
|
}
|
|
}
|
|
}
|
|
.fr{
|
|
width: 90rpx;
|
|
line-height: 44rpx;
|
|
background: #000000;
|
|
border-radius: 44rpx;
|
|
text-align: center;
|
|
font-weight: 500;
|
|
font-size: 24rpx;
|
|
color: #FFFFFF;
|
|
}
|
|
}
|
|
.c{
|
|
width: 110%;
|
|
margin-top: 20rpx;
|
|
overflow: hidden;
|
|
image{
|
|
width: 210rpx;
|
|
height: 210rpx;
|
|
border-radius: 10rpx;
|
|
margin-right: 10rpx;
|
|
}
|
|
}
|
|
.b{
|
|
font-weight: 400;
|
|
font-size: 28rpx;
|
|
color: #222222;
|
|
line-height: 42rpx;
|
|
margin-top: 20rpx;
|
|
text-align: left;
|
|
display: -webkit-box;
|
|
-webkit-box-orient: vertical;
|
|
-webkit-line-clamp: 2; /* 定义文本的行数 */
|
|
overflow: hidden;
|
|
text-overflow: ellipsis;
|
|
}
|
|
.a{
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: space-between;
|
|
.fl{
|
|
flex: 1;
|
|
display: flex;
|
|
align-items: center;
|
|
margin-right: 20rpx;
|
|
image{
|
|
width: 80rpx;
|
|
height: 80rpx;
|
|
background: #E6E9ED;
|
|
border-radius: 50%;
|
|
margin-right: 20rpx;
|
|
}
|
|
.info{
|
|
flex: 1;
|
|
}
|
|
.name{
|
|
font-weight: 400;
|
|
font-size: 30rpx;
|
|
color: #222222;
|
|
}
|
|
.desc{
|
|
font-weight: 400;
|
|
font-size: 22rpx;
|
|
color: #B6BCC2;
|
|
margin-top: 10rpx;
|
|
}
|
|
}
|
|
.fr{
|
|
width: 32rpx;
|
|
image{
|
|
width: 32rpx;
|
|
height: 32rpx;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
</style>
|
|
|