<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 class="send" @click="navigateTo('/pages/square/release')">
|
<image src="/static/remote/4753eb9da70ba6656f269dc25ae9bb54.png"></image>
|
<text>发布</text>
|
</view>
|
</view>
|
<view class="cate_nav">
|
<view class="left_tab_bar">
|
<u-tabs name="name" ref="uTabs" height="60" active-color="#FF960C" inactive-color="#666666"
|
duration="0.2" :list="treeData" :current="current" @change="currentChange" :is-scroll="true"
|
font-size="28">
|
</u-tabs>
|
</view>
|
<view class="flex-col group_1">
|
<view class="flex-row section_2" @tap="show = true">
|
<image src="/static/remote/583cec43cd3b95db50eda7f0b7ba6adf.png" class="image_1" />
|
<text>筛选</text>
|
</view>
|
</view>
|
<u-popup v-model="show" mode="bottom" height="70%" :closeable="true">
|
<view class="pop_bg">
|
<view class="title">分类筛选</view>
|
<scroll-view scroll-y scroll-with-animation class="scroll_main">
|
<text class="main_item" v-for="(item,index) in treeData" :key="item._id"
|
:class="{selected:index == current}" @click="select(index)">
|
{{item.name}}
|
</text>
|
</scroll-view>
|
</view>
|
</u-popup>
|
</view>
|
<z-paging ref="paging" class="z_pag" v-model="squareList" @query="getList" v-if="treeData.length > 0"
|
: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.user.avatar || '../../static/member/avatra.png'" :lazy-load="true"
|
shape="circle" class="image_5" mode="aspectFill"></u-image>
|
<view class="flex-col group_9">
|
<text class="text_8">{{item.user.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.content}}</text>
|
<view class="justify-evenly section_4" v-show="item._id == popIndex"
|
@tap.stop="changeCollection(item,index)">
|
<block v-if="vk.pubfn.isNotNull(item.star)">
|
<image src="/static/remote/397bef721f64f4244af8b14f31ffefc5.png" class="image_9" />
|
<text class="text_11">取消收藏</text>
|
</block>
|
<block v-else>
|
<image src="/static/remote/09863c457015db66cde42fb3ed7529ce.png" class="image_9" />
|
<text class="text_11">收藏</text>
|
</block>
|
</view>
|
</view>
|
<view class="images">
|
<view class="image_item" v-for="(img,index) in item.images"
|
@click.stop="preview(item.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 || '../../static/member/avatra.png'" :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 {
|
// 分类列表 选中
|
treeData: [],
|
current: 0,
|
// 数据列表
|
squareList: [],
|
|
popIndex: '',
|
show: false,
|
}
|
},
|
// 监听 - 页面每次【加载时】执行(如:前进)
|
onLoad(options = {}) {
|
that = this;
|
vk = that.vk;
|
that.init(options)
|
uni.$on('pageFresh', () => {
|
this.getList(1, 10, true)
|
})
|
uni.$on('tumpChange', (res) => {
|
for (let k in this.squareList) {
|
if (this.squareList[k]._id == res.id) {
|
this.squareList[k].tumbup = res.status
|
if (res.add) {
|
this.squareList[k].tumbups.push({ id: 'myid' })
|
} else {
|
this.squareList[k].tumbups.shift()
|
}
|
return
|
}
|
}
|
})
|
},
|
// 监听 - 页面【首次渲染完成时】执行。注意如果渲染速度快,会在页面进入动画完成前触发
|
onReady() {},
|
// 监听 - 页面每次【显示时】执行(如:前进和返回) (页面每次出现在屏幕上都触发,包括从下级页面点返回露出当前页面)
|
onShow() {},
|
// 监听 - 页面每次【隐藏时】执行(如:返回)
|
onHide() {},
|
// 函数
|
methods: {
|
// 页面数据初始化函数
|
init(options) {
|
vk.callFunction({
|
url: 'client/bbs/pub/categories',
|
title: '获取分类中...',
|
success(data) {
|
data.rows.unshift({ name: '全部', _id: '' })
|
that.treeData = data.rows
|
}
|
})
|
},
|
pageBack() {
|
uni.navigateBack({ delta: 1 })
|
},
|
currentChange(index) {
|
this.current = index;
|
this.getList(1, 10)
|
},
|
// 筛选完成
|
select(index) {
|
this.show = false
|
this.$nextTick(() => {
|
this.currentChange(index)
|
})
|
},
|
// 获取列表
|
getList(pageNo, pageSize, flag) {
|
if (pageNo == 1) {
|
this.hiddenPop()
|
this.squareList = []
|
}
|
let cid = this.treeData[this.current]._id
|
vk.callFunction({
|
url: 'client/bbs/pub/getSquareList',
|
title: flag ? '' : '获取帖子中...',
|
data: {
|
pageNo,
|
pageSize,
|
cid,
|
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, index) {
|
uni.vk.callFunction({
|
url: 'client/bbs/kh/change_bbs_star',
|
title: "加载中...",
|
data: {
|
posts_id: item._id,
|
poster_id: item.user._id,
|
status: vk.pubfn.isNotNull(item.star) ? 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()
|
that.squareList[index].star = res.noStatus ? { id: 'myid' } : {}
|
}
|
}
|
})
|
},
|
// 修改点赞状态
|
giveTumbUp(item, index) {
|
uni.vk.callFunction({
|
url: 'client/bbs/kh/change_bbs_tumbup',
|
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.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' })
|
}
|
}
|
})
|
},
|
// 查看发布详情
|
checkDetail(item) {
|
uni.vk.navigateTo('/pages/square/detail?id=' + item._id);
|
},
|
// 预览图片
|
preview(imgs, index) {
|
uni.previewImage({
|
current: index,
|
urls: imgs,
|
indicator: 'number',
|
loop: true
|
})
|
},
|
// 隐藏弹框
|
hiddenPop() {
|
this.popIndex = '';
|
}
|
},
|
onUnload() {
|
uni.$off(['tumpChange', 'pageFresh'])
|
}
|
}
|
</script>
|
|
<style lang="scss" scoped>
|
.page_bg {
|
background-color: #ffffff;
|
width: 100%;
|
height: 100vh;
|
overflow-y: auto;
|
display: flex;
|
flex-direction: column;
|
}
|
|
.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;
|
|
.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;
|
}
|
|
.send {
|
position: absolute;
|
right: 20rpx;
|
top: 22rpx;
|
font-size: 28rpx;
|
display: flex;
|
align-items: center;
|
|
image {
|
width: 36rpx;
|
height: 36rpx;
|
margin-right: 12rpx;
|
}
|
}
|
}
|
|
.cate_nav {
|
position: relative;
|
box-shadow: 0px 6px 12px rgba(0, 0, 0, 0.1);
|
|
.left_tab_bar {
|
width: 90%;
|
}
|
|
.group_1 {
|
margin-left: 50rpx;
|
padding: 7rpx 0 6rpx;
|
position: absolute;
|
right: 20rpx;
|
top: 54%;
|
text-align: right;
|
transform: translate(0, -50%);
|
z-index: 999;
|
height: 60rpx;
|
background: linear-gradient(90deg, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 0.98) 12%, #FFFFFF 100%);
|
|
.image_1 {
|
margin-left: 20rpx;
|
width: 36rpx;
|
height: 36rpx;
|
}
|
}
|
|
.pop_bg {
|
padding: 18rpx;
|
height: 100%;
|
|
.title {
|
text-align: center;
|
font-size: 30rpx;
|
font-weight: bold;
|
padding: 12rpx;
|
}
|
|
.scroll_main {
|
height: calc(100% - 60rpx);
|
margin-top: 20rpx;
|
|
.main_item {
|
display: inline-block;
|
width: 31%;
|
margin: 0 1% 26rpx;
|
height: 80rpx;
|
background: #F5F5F5;
|
border-radius: 6rpx;
|
line-height: 80rpx;
|
text-align: center;
|
overflow: hidden;
|
font-size: 26rpx;
|
}
|
|
.selected {
|
background-color: #FF960C;
|
color: #FFFFFF;
|
}
|
}
|
}
|
}
|
|
.z_pag {
|
flex: 1;
|
}
|
|
.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;
|
flex: 1;
|
overflow: hidden;
|
|
.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;
|
overflow: hidden;
|
text-overflow: ellipsis;
|
white-space: nowrap;
|
}
|
}
|
}
|
|
.watch_more {
|
text-align: right;
|
font-size: 20rpx;
|
padding-right: 20rpx;
|
color: #FF960C;
|
}
|
}
|
}
|
}
|
</style>
|