<template>
|
<view class="page_bg" @tap="hiddenPop">
|
<!-- #ifdef APP-PLUS -->
|
<view class="status_bar">
|
<view class="top_view"></view>
|
</view>
|
<!-- #endif -->
|
<view class="top_nav">
|
<image src="/static/local/3546451940011a031009b939a8b26314.png" class="image_1" @click="pageBack" />
|
<view class="cate">我的收藏</view>
|
</view>
|
<z-paging ref="paging" class="z_pag" v-model="squareList" @query="getList" :empty-view-fixed="true"
|
:fixed="false" @scroll="hiddenPop" :hide-loading-more-when-no-more-by-limit="5">
|
<view class="posts_item" v-for="(item,index) in squareList" :key="item._id" @click="checkDetail(item)">
|
<view class="flex-col group_6">
|
<view class="justify-between">
|
<view class="flex-row" style="align-items: center;">
|
<u-image :src="item.poster.avatar" shape="circle" :lazy-load="true" class="image_5"
|
mode="aspectFill"></u-image>
|
<view class="flex-col group_9">
|
<text class="text_8">{{item.poster.nickname}}</text>
|
<text class="text_9">
|
{{vk.pubfn.timeFormat(new Date(item._add_time),"yyyy-MM-dd hh:mm:ss")}}
|
</text>
|
</view>
|
</view>
|
<image src="/static/local/16403089381554525532.png" class="image_7"
|
@click.stop="openPop(item)" />
|
</view>
|
<view class="flex-col group_10">
|
<text class="text_10">{{item.posts.content}}</text>
|
<view class="justify-evenly section_4" v-show="item._id == popIndex"
|
@tap.stop="changeCollection(item)">
|
<image src="/static/remote/397bef721f64f4244af8b14f31ffefc5.png" class="image_9" />
|
<text class="text_11">取消收藏</text>
|
</view>
|
</view>
|
<view class="images">
|
<view class="image_item" v-for="(img,index) in item.posts.images"
|
@click.stop="preview(item.posts.images,index)">
|
<u-image :src="img" :lazy-load="true" class="img" mode="aspectFill">
|
</u-image>
|
</view>
|
</view>
|
</view>
|
<view class="flex-col group_11">
|
<view class="top-group justify-end">
|
<view v-if="vk.pubfn.isNotNull(item.tumbup)" @click.stop="giveTumbUp(item,index)">
|
<u-icon name="thumb-up-fill" size="34" class="image_10"></u-icon>
|
</view>
|
<view v-else @click.stop="giveTumbUp(item,index)">
|
<u-icon name="thumb-up" size="34" class="image_10"></u-icon>
|
</view>
|
<text class="text_13">{{item.tumbups.length}}</text>
|
<u-icon name="chat" size="34" class="image_10"></u-icon>
|
<text class="text_13">{{item.comments.length}}</text>
|
</view>
|
<view class="flex-col section_5">
|
<view class="no_com" v-if="item.comments.length < 1">- 暂无最新评论 -</view>
|
<view class="comments_item" v-for="com in item.comments.slice(0,5)">
|
<u-image :src="com.user.avatar" shape="circle" :lazy-load="true" class="left_avatar"
|
mode="aspectFill"></u-image>
|
<view class="right_area">
|
<view class="name">
|
{{com.user.nickname}}
|
<u-icon name="play-right-fill" color="#707070" size="10" class="to"
|
v-if="com.talkToId != ''"></u-icon>
|
{{com.talkToName}}
|
</view>
|
<view class="time">{{com._add_time_str}}</view>
|
<view class="content">{{com.content}}</view>
|
</view>
|
</view>
|
<view class="watch_more" v-if="item.comments.length > 5">点击查看更多...</view>
|
</view>
|
</view>
|
</view>
|
</z-paging>
|
<u-toast ref="uToast" />
|
</view>
|
</template>
|
|
<script>
|
var that; // 当前页面对象
|
var vk; // vk依赖
|
export default {
|
data() {
|
// 页面数据变量
|
return {
|
// 数据列表
|
squareList: [],
|
|
popIndex: '',
|
show: false,
|
}
|
},
|
// 监听 - 页面每次【加载时】执行(如:前进)
|
onLoad(options = {}) {
|
that = this;
|
vk = that.vk;
|
that.init(options)
|
},
|
// 监听 - 页面【首次渲染完成时】执行。注意如果渲染速度快,会在页面进入动画完成前触发
|
onReady() {},
|
// 监听 - 页面每次【显示时】执行(如:前进和返回) (页面每次出现在屏幕上都触发,包括从下级页面点返回露出当前页面)
|
onShow() {},
|
// 监听 - 页面每次【隐藏时】执行(如:返回)
|
onHide() {},
|
// 函数
|
methods: {
|
// 页面数据初始化函数
|
init(options) {
|
uni.$on('squareRefresh', function() {
|
that.$refs.paging.reload()
|
})
|
},
|
pageBack() {
|
uni.navigateBack({
|
delta: 1
|
})
|
},
|
// 获取列表
|
getList(pageNo, pageSize) {
|
if (pageNo == 1) {
|
this.hiddenPop()
|
}
|
vk.callFunction({
|
url: 'client/bbs/pub/getMySquareCollection',
|
title:'获取中...',
|
data: {
|
pageNo,
|
pageSize,
|
need_user_info: true
|
},
|
success(data) {
|
that.$refs.paging.complete(data.rows);
|
}
|
});
|
},
|
// 打开弹框
|
openPop(item) {
|
if (this.popIndex == item._id) {
|
this.popIndex = ''
|
return
|
}
|
this.popIndex = item._id
|
},
|
// 修改收藏状态
|
changeCollection(item) {
|
uni.vk.callFunction({
|
url: 'client/bbs/kh/change_bbs_star',
|
title: "加载中...",
|
data: {
|
posts_id: item.posts._id,
|
status: 1,
|
need_user_info: true
|
},
|
success(res) {
|
if (res.code == 0) {
|
that.$refs.uToast.show({
|
title: '已取消收藏',
|
type: 'success',
|
duration: 1000,
|
})
|
that.hiddenPop()
|
that.$refs.paging.reload()
|
}
|
}
|
})
|
},
|
// 修改点赞状态
|
giveTumbUp(item, index) {
|
uni.vk.callFunction({
|
url: 'client/bbs/kh/change_bbs_tumbup',
|
title: "加载中...",
|
data: {
|
posts_id: item._id,
|
posterId: item.user._id,
|
status: vk.pubfn.isNotNull(item.tumbup) ? 1 : 0,
|
need_user_info: true
|
},
|
success(res) {
|
if (res.code == 0) {
|
that.$refs.uToast.show({
|
title: res.msg,
|
type: 'success',
|
duration: 1000,
|
})
|
that.hiddenPop()
|
// 暂时性增删
|
if (res.noStatus == 0) {
|
that.squareList[index].tumbup = {}
|
that.squareList[index].tumbups.shift()
|
return
|
}
|
that.squareList[index].tumbup = { id: 'myid' }
|
that.squareList[index].tumbups.push({ id: 'myid' })
|
}
|
}
|
})
|
},
|
// 预览图片
|
preview(imgs, index) {
|
uni.previewImage({
|
current: index,
|
urls: imgs,
|
indicator: 'number',
|
loop: true
|
})
|
},
|
// 查看发布详情
|
checkDetail(item) {
|
uni.vk.navigateTo('/pages/square/detail?id=' + item.posts_id);
|
},
|
// 隐藏弹框
|
hiddenPop() {
|
this.popIndex = '';
|
this.show = false
|
}
|
},
|
onUnload() {
|
uni.$off('squareRefresh')
|
}
|
}
|
</script>
|
|
<style lang="scss" scoped>
|
.page_bg {
|
background-color: #ffffff;
|
width: 100%;
|
height: 100vh;
|
overflow-y: auto;
|
}
|
|
.top_nav {
|
padding-bottom: 24rpx;
|
color: rgb(51, 51, 51);
|
font-size: 34rpx;
|
line-height: 41rpx;
|
white-space: nowrap;
|
background-color: rgb(255, 255, 255);
|
height: 88rpx;
|
position: relative;
|
box-shadow: 0px 6px 12px rgba(0, 0, 0, 0.1);
|
|
.image_1 {
|
left: 21rpx;
|
top: 27rpx;
|
width: 19rpx;
|
height: 35rpx;
|
position: absolute;
|
}
|
|
.cate {
|
width: 100%;
|
padding: 20rpx 0;
|
color: rgb(51, 51, 51);
|
font-size: 34rpx;
|
font-weight: 500;
|
line-height: 41rpx;
|
white-space: nowrap;
|
text-align: center;
|
}
|
}
|
|
.z_pag {
|
height: calc(100vh - 88rpx);
|
}
|
|
.posts_item {
|
padding: 40rpx 10rpx;
|
border-bottom: 1px solid #F0F0F0;
|
|
.group_6 {
|
padding: 0 20rpx;
|
|
.group_10 {
|
padding-top: 32rpx;
|
position: relative;
|
|
.text_10 {
|
margin-left: 4rpx;
|
color: rgb(51, 51, 51);
|
font-size: 28rpx;
|
line-height: 33rpx;
|
text-align: left;
|
}
|
|
.section_4 {
|
padding: 17rpx 30rpx 17rpx 36rpx;
|
color: rgb(255, 255, 255);
|
font-size: 24rpx;
|
display: flex;
|
align-items: center;
|
white-space: nowrap;
|
background-color: rgb(81, 81, 81);
|
box-shadow: 0px 0px 16rpx 0px rgba(0, 0, 0, 0.12);
|
border-radius: 12rpx;
|
position: absolute;
|
right: 4rpx;
|
top: -20rpx;
|
|
.image_9 {
|
width: 32rpx;
|
height: 34rpx;
|
}
|
|
.text_11 {
|
margin-left: 8rpx;
|
}
|
}
|
}
|
|
.images {
|
display: flex;
|
flex-wrap: wrap;
|
margin-top: 20rpx;
|
|
.image_item {
|
width: 31.1%;
|
margin: 1.1%;
|
padding-bottom: 31.1%;
|
height: 0;
|
position: relative;
|
border-radius: 8rpx;
|
overflow: hidden;
|
|
.img {
|
width: 100% !important;
|
height: 100% !important;
|
position: absolute;
|
top: 0;
|
left: 0;
|
}
|
}
|
}
|
|
.image_7 {
|
margin-right: 4rpx;
|
align-self: center;
|
width: 40rpx;
|
height: 28rpx;
|
}
|
|
.image_5 {
|
width: 88rpx !important;
|
height: 88rpx !important;
|
}
|
|
.group_9 {
|
margin-left: 20rpx;
|
|
.text_8 {
|
color: rgb(51, 51, 51);
|
font-size: 32rpx;
|
line-height: 38rpx;
|
white-space: nowrap;
|
font-weight: bold;
|
font-size: 30rpx;
|
}
|
|
.text_9 {
|
margin-top: 14rpx;
|
color: rgb(153, 153, 153);
|
font-size: 24rpx;
|
line-height: 29rpx;
|
white-space: nowrap;
|
}
|
}
|
}
|
|
.group_11 {
|
margin: 20rpx 24rpx 0;
|
|
.top-group {
|
color: rgb(51, 51, 51);
|
font-size: 24rpx;
|
white-space: nowrap;
|
padding: 0 10rpx 16rpx 0;
|
display: flex;
|
align-items: center;
|
|
.image_10 {
|
margin: 0 10rpx 0 80rpx;
|
}
|
}
|
|
.section_5 {
|
background-color: rgb(248, 248, 248);
|
border-radius: 10rpx;
|
padding: 10rpx 0;
|
|
.no_com {
|
text-align: center;
|
color: #999;
|
}
|
|
.comments_item {
|
display: flex;
|
padding: 14rpx 20rpx;
|
|
.left_avatar {
|
width: 56rpx !important;
|
height: 56rpx !important;
|
margin-top: 10rpx;
|
}
|
|
.right_area {
|
margin-left: 20rpx;
|
font-size: 20rpx;
|
|
.name {
|
margin-bottom: 5rpx;
|
font-weight: bold;
|
|
.to {
|
transform: scale(0.5);
|
}
|
}
|
|
.time {
|
font-size: 20rpx;
|
font-weight: 400;
|
color: #999999;
|
margin-bottom: 8rpx;
|
}
|
|
.content {
|
font-weight: 500;
|
color: #666666;
|
}
|
}
|
}
|
|
.watch_more {
|
text-align: right;
|
font-size: 20rpx;
|
padding-right: 20rpx;
|
color: #FF960C;
|
}
|
}
|
}
|
}
|
</style>
|