Files
dvcp_v2_wxcp_app/src/apps/AppVillageDiscuss/Detail.vue

666 lines
16 KiB
Vue
Raw Normal View History

2021-12-30 21:05:45 +08:00
<template>
2022-01-07 18:00:10 +08:00
<div class="Detail" v-if="pageShow" :class="[isAnnouncer && data.status === '0' && data.type === '0' ? 'detail-active' : '']">
<div class="detail-top">
<div flex class="w-100">
<div class="avatar" v-text="data.avatar" />
<div flex class="column start fill">
<b class="color-333" v-text="data.createUserName" />
<span class="color-999" v-text="data.createTime" />
</div>
<div class="statusTag" :class="{ over: data.status > 0 }" v-text="data.status == 0 ? (data.type == 0 ? '征集中' : '投票中') : $dict.getLabel('discussStatus', data.status)" />
2021-12-30 21:05:45 +08:00
</div>
2022-01-07 18:00:10 +08:00
<div class="header-middle">
<div class="contsnts">
2022-01-07 18:32:51 +08:00
<u-parse :html="data.content"></u-parse>
2022-01-07 18:00:10 +08:00
</div>
2021-12-30 21:05:45 +08:00
</div>
2022-01-07 18:00:10 +08:00
<div class="img-list" v-if="data.images && data.images.length">
<img :src="item.url" alt="" v-for="(item, index) in data.images" :key="index" @click="previewImage(data.images, item.url)" />
2022-01-07 17:56:09 +08:00
</div>
2022-01-07 18:00:10 +08:00
</div>
<div v-if="data.type == 0" class="comments">
<span class="totalCount">
<span class="total" v-text="`全部评论(${commentCount})`" />
<span class="rightCount">
<u-icon name="clock" v-if="data.status === '0'"></u-icon>
<u-count-down v-if="data.status === '0'" :timestamp="timestamp" separator="zh" show-days show-hours show-minutes show-seconds></u-count-down>
<span style="color: #999" v-else>已截止</span>
</span>
</span>
<div v-for="op in data.messages" :key="op.id">
<div flex class="header">
<u-avatar :src="op.avatar" size="48" />
<div flex class="fill">
<b v-text="op.createUserName" />
<span class="tags">{{ data.createUserId === op.createUserId ? '话事人' : '居民' }}</span>
2022-01-07 15:54:49 +08:00
</div>
2022-01-07 18:00:10 +08:00
<u-icon name="thumb-up" :label="op.suport" :color="op.isSuport ? 'red' : '#ccc'" @click="like(op.id)" />
2021-12-30 21:05:45 +08:00
</div>
2022-01-07 18:00:10 +08:00
<div class="content" v-text="op.content" @click="adddeleShow(op.id)" />
<div class="content color-999" v-text="op.createTime" />
2021-12-30 21:05:45 +08:00
</div>
2022-01-07 18:00:10 +08:00
<AiEmpty v-if="!data.messages.length"></AiEmpty>
</div>
<div v-else-if="data.type == 1" class="comments">
<span class="totalCount">
<span class="total">{{ data.voteType === '1' ? '投票清单(可多选)' : '投票清单' }}</span>
<span class="rightCount">
<u-icon name="clock" v-if="data.status === '0'"></u-icon>
<u-count-down v-if="data.status === '0'" :timestamp="timestamp" separator="zh" show-days show-hours show-minutes show-seconds></u-count-down>
<span style="color: #999" v-else>已截止</span>
</span>
</span>
<div class="comments-vote">
<div class="vote-item" v-for="(item, index) in data.voteList" :key="index">
2022-01-07 17:56:09 +08:00
<div class="left">
2022-01-07 18:00:10 +08:00
<span>{{ item.item }}</span>
<span>{{ item.content }}</span>
2022-01-07 17:49:05 +08:00
</div>
2022-01-07 18:00:10 +08:00
<i>{{ item.count }}</i>
<em :style="{ width: item.percentage }"></em>
2022-01-07 15:41:59 +08:00
</div>
</div>
2022-01-07 14:52:57 +08:00
</div>
2022-01-07 11:47:56 +08:00
2022-01-07 18:28:43 +08:00
<div class="votePeople" v-if="data.type === '1'">
<div class="leftPeople">{{ data.voteCount }}人参与投票</div>
2022-01-07 11:47:56 +08:00
2022-01-07 18:05:48 +08:00
<div class="right">
2022-01-07 18:28:43 +08:00
<span @click="toUserList">查看详情</span>
<u-icon name="arrow-right" color="#999"></u-icon>
2022-01-07 18:05:48 +08:00
</div>
2022-01-07 18:00:10 +08:00
</div>
2022-01-07 11:47:56 +08:00
2022-01-07 18:00:10 +08:00
<div class="bottomInput" v-if="isAnnouncer && data.status === '0' && data.type === '0'">
<div class="leftInput" @click="showBottomInput = true">我来说两句...</div>
</div>
2022-01-07 17:27:06 +08:00
2022-01-07 18:00:10 +08:00
<u-popup v-model="showBottomInput" height="auto" mode="bottom">
<div class="comments-wrapper">
<u-input v-model="content" placeholder="写下你的想法" type="textarea" auto-height height="180" maxlength="140"> </u-input>
<div class="words">字数{{ content.length }}/140</div>
2022-01-07 17:27:06 +08:00
2022-01-07 18:00:10 +08:00
<div class="bottombtn">
<div class="emptys" @click="content = ''">清空内容</div>
2021-12-30 21:05:45 +08:00
2022-01-07 18:00:10 +08:00
<div class="publishs" @click="publish">发表</div>
</div>
</div>
</u-popup>
2022-01-07 13:54:22 +08:00
2022-01-07 18:00:10 +08:00
<u-popup v-model="deleShow" mode="bottom" class="popupdele">
2022-01-07 19:05:11 +08:00
<div class="hint">删除我的评论</div>
2022-01-07 18:00:10 +08:00
<div class="dele" @click="modalShow = true">删除</div>
2022-01-10 09:33:11 +08:00
<div class="liness"></div>
<div class="cancel" @click="deleShow = false">取消</div>
2022-01-07 18:00:10 +08:00
</u-popup>
2022-01-07 11:47:56 +08:00
2022-01-07 18:52:08 +08:00
<u-modal v-model="modalShow" content="确定删除该留言" :mask-close-able="true" @confirm="confirmDelete"></u-modal>
2022-01-07 15:41:59 +08:00
2022-01-07 18:00:10 +08:00
<div class="end-btn" hover-class="text-hover" v-if="data.status === '1'" @click="handleComplete">结束公示</div>
</div>
</template>
2022-01-07 17:56:09 +08:00
2022-01-07 18:00:10 +08:00
<script>
import { mapState } from 'vuex'
export default {
name: 'Detail',
props: {},
data() {
return {
data: {},
id: '',
timestamp: '',
showBottomInput: false,
content: '',
flag: false,
pageShow: false,
isAnnouncer: false,
deleShow: false,
modalShow: false,
deleId: '',
isAnnouncer: false,
}
},
computed: {
...mapState(['user']),
2022-01-07 15:48:15 +08:00
2022-01-07 18:00:10 +08:00
commentCount() {
return this.data.messages?.length || 0
},
},
onLoad(o) {
this.id = o.id
this.getDetail()
this.$dict.load('discussStatus')
},
onShow() {
document.title = '议事详情'
},
methods: {
getDetail() {
this.$loading()
this.$http
.post(`/app/appvillagediscuss/queryDetailById?id=${this.id}`)
.then((res) => {
if (res?.data) {
this.data = {
...res.data,
2022-01-07 18:32:51 +08:00
avatar: res.data.createUserName.substring(res.data.createUserName.length, res.data.createUserName.length - 2),
2022-01-07 18:00:10 +08:00
messages: res.data.messages
? res.data.messages.map((v) => {
return {
...v,
isSuport: v.suportUser ? v.suportUser.indexOf(this.user.id) > -1 : false,
}
})
: [],
2022-01-07 17:56:09 +08:00
}
2022-01-07 18:00:10 +08:00
this.data.images = res.data.images ? JSON.parse(res.data.images) : []
this.isAnnouncer = this.user.id === res.data.createUserId
2022-01-07 17:56:09 +08:00
2022-01-07 18:00:10 +08:00
var discussTime = (new Date(res.data.discussDeadline).getTime() * 1) / 1000
var nowTime = (new Date().getTime() * 1) / 1000
if (discussTime >= nowTime) {
this.timestamp = discussTime - nowTime
}
2022-01-07 17:27:06 +08:00
2022-01-07 18:00:10 +08:00
if (res.data.type === '1' && res.data.statistic) {
const total = Object.values(res.data.statistic).reduce((x, y) => {
return x + y
2022-01-07 17:56:09 +08:00
})
2022-01-07 18:00:10 +08:00
this.data.voteList = res.data.voteItems.map((v) => {
2022-01-07 17:56:09 +08:00
return {
...v,
2022-01-07 18:00:10 +08:00
count: res.data.statistic[v.item],
percentage: (res.data.statistic[v.item] / total) * 100 + '%',
2022-01-07 17:56:09 +08:00
}
})
}
this.pageShow = true
2022-01-07 17:06:23 +08:00
2022-01-07 18:00:10 +08:00
this.$hideLoading()
2022-01-07 17:56:09 +08:00
} else {
2022-01-07 18:00:10 +08:00
this.$hideLoading()
this.pageShow = true
2022-01-07 13:54:22 +08:00
}
})
2022-01-07 18:00:10 +08:00
.catch(() => {
this.$hideLoading()
})
},
2022-01-07 13:54:22 +08:00
2022-01-07 18:00:10 +08:00
like(id) {
this.$loading()
this.$http.post(`/app/appvillagediscussmessage/suport?id=${id}&userId=${this.user.id}`).then((res) => {
this.$hideLoading()
if (res.code === 0) {
this.$u.toast('点赞成功')
this.$nextTick(() => {
this.getDetail()
})
} else {
this.$u.toast(res.msg)
2022-01-07 13:54:22 +08:00
}
2022-01-07 18:00:10 +08:00
})
},
2022-01-07 13:54:22 +08:00
2022-01-07 18:00:10 +08:00
adddeleShow(id) {
if (this.user.id == this.data.createUserId) {
this.deleId = id
this.deleShow = true
}
},
2022-01-07 11:47:56 +08:00
2022-01-07 18:00:10 +08:00
confirmDelete() {
this.$http
.post(`/app/appvillagediscussmessage/delete?ids=${this.deleId}`)
.then((res) => {
if (res?.data) {
this.deleShow = false
this.modalShow = false
this.deleId = ''
this.getDetail()
}
})
.catch((e) => {
2022-01-07 17:56:09 +08:00
this.$hideLoading()
2022-01-07 18:00:10 +08:00
this.$u.toast(e)
2021-12-30 21:05:45 +08:00
})
2022-01-07 18:00:10 +08:00
},
2022-01-07 17:56:09 +08:00
2022-01-07 18:00:10 +08:00
publish() {
if (this.flag) return
if (!this.content) {
return this.$u.toast('请输入你的想法')
}
2022-01-07 17:56:09 +08:00
2022-01-07 18:00:10 +08:00
this.$http
.post(`/app/appvillagediscussmessage/addOrUpdate`, {
content: this.content,
avatar: this.user.avatar,
createUserId: this.user.id,
createUserName: this.user.name,
discussId: this.id,
})
.then((res) => {
if (res?.code == 0) {
this.$u.toast('留言成功')
this.flag = false
this.content = ''
this.showBottomInput = false
this.getDetail()
}
2022-01-07 17:56:09 +08:00
})
2022-01-05 17:53:36 +08:00
},
2021-12-30 21:05:45 +08:00
2022-01-07 18:00:10 +08:00
praise() {
console.log('点赞')
this.$http.post(`/app/appvillagediscussmessage/suport?id=${this.id}&userId=${this.user.id}`).then((res) => {
if (res?.code == 0) {
this.$u.toast('点赞成功!')
this.getDetail()
2022-01-07 17:56:09 +08:00
}
2022-01-07 18:00:10 +08:00
})
},
2021-12-30 21:05:45 +08:00
2022-01-07 18:00:10 +08:00
previewImage(images, img) {
uni.previewImage({
urls: images.map((v) => v.url),
current: img,
})
},
handleSubmitComment(content) {
if (!!content) {
let { id } = this
this.$http
.post('/app/appvillagediscussmessage/addOrUpdate', {
id,
content,
})
.then((res) => {
if (res?.code == 0) {
this.$u.toast('提交成功!')
this.getDetail()
}
})
} else {
this.$u.toast('不能提交空评论!')
2022-01-07 17:56:09 +08:00
}
2022-01-07 18:00:10 +08:00
},
2022-01-07 18:16:28 +08:00
2022-01-07 18:00:10 +08:00
handleComplete() {
this.$confirm('是否要结束公示')
.then(() => {
this.$http
.post('/app/appvillagediscuss/finishPublic', {
status: '2',
id: this.id,
})
.then((res) => {
if (res?.code == 0) {
this.$u.toast('结束公示成功!')
2022-01-07 18:30:02 +08:00
setTimeout(() => {
this.getDetail()
}, 600)
2022-01-07 18:00:10 +08:00
}
})
})
.catch(() => 0)
},
2022-01-07 18:16:28 +08:00
toUserList() {
2022-01-07 18:49:50 +08:00
uni.navigateTo({ url: `./userList?id=${this.id}&anonymous=${this.data.anonymous}` })
2022-01-07 18:16:28 +08:00
},
2022-01-07 18:00:10 +08:00
},
}
</script>
2021-12-30 21:05:45 +08:00
2022-01-07 18:00:10 +08:00
<style scoped lang="scss">
.Detail {
padding-bottom: 40px;
2022-01-07 18:49:50 +08:00
background: #f6f7f9;
2022-01-07 18:00:10 +08:00
.end-btn {
position: fixed;
bottom: 0;
left: 0;
z-index: 11;
width: 100%;
height: 112px;
line-height: 112px;
text-align: center;
color: #fff;
font-size: 32px;
background: #1365dd;
}
2022-01-07 17:56:09 +08:00
2022-01-07 18:00:10 +08:00
&.detail-active {
padding-bottom: 132px;
}
2021-12-30 21:05:45 +08:00
2022-01-07 18:00:10 +08:00
.detail-top {
padding: 30px;
background: #fff;
border-bottom: 16px solid #f6f7f9;
.avatar {
height: 64px;
width: 64px;
color: #fff;
background: $uni-color-primary;
border-radius: 50%;
font-size: 24px;
text-align: center;
line-height: 64px;
margin-right: 16px;
}
2021-12-30 21:05:45 +08:00
2022-01-07 18:00:10 +08:00
.color-999 {
color: #999999;
2021-12-30 21:05:45 +08:00
}
2022-01-07 18:00:10 +08:00
.color-333 {
color: #333;
}
2021-12-30 21:05:45 +08:00
2022-01-07 18:00:10 +08:00
.w-100 {
width: 100%;
2022-01-07 17:56:09 +08:00
}
2022-01-07 18:00:10 +08:00
.statusTag {
padding: 0 12px;
line-height: 30px;
border: 1px solid #2573ff;
color: #2573ff;
font-size: 22px;
2021-12-30 21:05:45 +08:00
2022-01-07 18:00:10 +08:00
&.over {
border-color: #666;
color: #666;
}
}
2021-12-30 21:05:45 +08:00
2022-01-07 18:00:10 +08:00
.header-middle {
padding: 32px 0 48px 0;
2021-12-30 21:05:45 +08:00
2022-01-07 18:00:10 +08:00
.contsnts {
font-size: 26px;
line-height: 1.5;
word-break: break-all;
2021-12-30 21:05:45 +08:00
}
2022-01-07 18:00:10 +08:00
img {
margin-top: 30px;
width: 686px;
height: 486px;
2021-12-30 21:05:45 +08:00
}
2022-01-07 18:00:10 +08:00
}
2021-12-30 21:05:45 +08:00
2022-01-07 18:00:10 +08:00
.img-list {
img {
width: calc(33vw - 6px - 24px);
height: calc(33vw - 6px - 24px);
margin: 0 12px 12px 0;
2022-01-07 15:54:49 +08:00
2022-01-07 18:00:10 +08:00
&:nth-of-type(3n) {
margin-right: 0;
2022-01-07 17:56:09 +08:00
}
2022-01-07 18:00:10 +08:00
}
2021-12-30 21:05:45 +08:00
2022-01-07 18:00:10 +08:00
.title {
width: 100%;
line-height: 112px;
background: #fff;
font-size: 32px;
font-family: PingFangSC-Regular, PingFang SC;
color: #999;
2022-01-07 17:56:09 +08:00
}
}
2022-01-07 18:00:10 +08:00
}
.tags {
width: 80px;
height: 34px;
line-height: 34px;
margin-left: 16px;
text-align: center;
color: #fff;
font-size: 24px;
background: #1aaaff;
border-radius: 8px;
}
2022-01-07 15:41:59 +08:00
2022-01-07 18:00:10 +08:00
::v-deep uni-video {
width: 100%;
}
.comments {
padding: 0 32px 20px;
font-size: 28px;
background: #fff;
2022-01-07 17:56:09 +08:00
2022-01-07 18:00:10 +08:00
.vote-item {
display: flex;
position: relative;
align-items: center;
justify-content: space-between;
padding: 24px 32px;
margin-bottom: 16px;
background: #ffffff;
border-radius: 8px;
overflow: hidden;
border: 1px solid #95cbff;
.left {
2022-01-07 17:49:05 +08:00
display: flex;
2022-01-07 18:00:10 +08:00
flex: 1;
line-height: 1.2;
margin-right: 20px;
2022-01-07 17:49:05 +08:00
span {
2022-01-07 18:00:10 +08:00
word-break: break-word;
2022-01-07 17:49:05 +08:00
2022-01-07 18:00:10 +08:00
&:first-child {
flex-shrink: 1;
}
2022-01-07 15:41:59 +08:00
2022-01-07 18:00:10 +08:00
&:last-child {
flex: 1;
}
2022-01-07 17:56:09 +08:00
}
2022-01-07 18:00:10 +08:00
}
2022-01-07 15:41:59 +08:00
2022-01-07 18:00:10 +08:00
em {
position: absolute;
left: 0;
top: 0;
z-index: 0;
height: 100%;
background: #dce8f4;
}
2022-01-07 15:41:59 +08:00
2022-01-07 18:00:10 +08:00
span {
flex-shrink: 1;
position: relative;
z-index: 1;
color: #5b84b3;
font-size: 28px;
}
2022-01-05 18:26:02 +08:00
2022-01-07 18:00:10 +08:00
i {
position: relative;
z-index: 1;
font-style: normal;
color: #5b84b3;
font-size: 28px;
}
}
2021-12-30 21:05:45 +08:00
2022-01-07 18:00:10 +08:00
.totalCount {
display: flex;
justify-content: space-between;
2021-12-30 21:05:45 +08:00
2022-01-07 18:00:10 +08:00
.total {
display: block;
font-size: 30px;
height: 120px;
box-sizing: border-box;
padding-top: 44px;
}
.rightCount {
padding-top: 44px;
}
}
2021-12-30 21:05:45 +08:00
2022-01-07 18:00:10 +08:00
.u-avatar {
margin-right: 24px;
}
2022-01-07 11:47:56 +08:00
2022-01-07 18:00:10 +08:00
.content {
color: #333;
margin-left: 72px;
margin-top: 10px;
2022-01-07 17:55:06 +08:00
2022-01-07 18:00:10 +08:00
&.color-999 {
color: #999999;
font-size: 24px;
margin-bottom: 48px;
}
}
}
2022-01-07 11:47:56 +08:00
2022-01-07 18:00:10 +08:00
.votePeople {
display: flex;
2022-01-07 18:05:48 +08:00
align-items: center;
2022-01-07 18:00:10 +08:00
justify-content: space-between;
2022-01-07 18:20:44 +08:00
margin-top: 16px;
2022-01-07 18:05:48 +08:00
height: 112px;
padding: 0 32px 0 52px;
background: #fff;
2022-01-07 18:00:10 +08:00
.leftPeople {
font-size: 28px;
2022-01-07 18:05:48 +08:00
color: #333;
}
.right {
span {
2022-01-07 18:16:28 +08:00
color: #2573ff;
2022-01-07 18:05:48 +08:00
font-size: 28px;
}
2022-01-07 18:00:10 +08:00
}
}
2022-01-07 15:02:32 +08:00
2022-01-07 18:00:10 +08:00
.bottomInput {
position: fixed;
bottom: 0;
z-index: 11;
width: 100%;
background: #fff;
display: flex;
justify-content: space-between;
align-items: center;
padding: 24px 30px;
box-sizing: border-box;
border-top: 1px solid #eee;
.leftInput {
flex: 1;
height: 58px;
line-height: 58px;
text-align: center;
background: #f0f0f0;
border-radius: 30px;
}
// .righticon {
// .icontext {
// margin-left: 10px;
// }
// }
}
2022-01-07 17:56:09 +08:00
2022-01-07 18:00:10 +08:00
.comments-wrapper {
padding: 20px 0;
.u-input {
background: #f7f7f7;
border-radius: 8px 8px 0 0;
padding: 10px !important;
margin: 0 30px 0 30px;
.uni-textarea-placeholder {
padding: 16px 0 0 16px;
}
.uni-textarea-textarea {
padding: 16px 0 0 16px;
}
}
.words {
background: #f7f7f7;
border-radius: 0 0 8px 8px;
margin: 0 30px;
padding: 10px;
text-align: right;
font-size: 26px;
color: #999999;
}
.bottombtn {
display: flex;
justify-content: space-between;
align-items: center;
margin: 0 30px;
padding: 20px 0 0;
.emptys {
font-size: 26px;
color: #666666;
}
.publishs {
width: 144px;
height: 64px;
line-height: 64px;
text-align: center;
background: #1365dd;
border-radius: 32px;
color: #fff;
}
}
}
.popupdele {
::v-deep .u-drawer-content {
2022-01-07 19:05:11 +08:00
border-radius: 24px 24px 0px 0px;
2022-01-07 18:00:10 +08:00
text-align: center;
2022-01-07 19:05:11 +08:00
.hint {
2022-01-10 09:33:11 +08:00
padding: 40px 0 44px 0;
border-bottom: 1px solid #e7e8e9;
2022-01-07 19:05:11 +08:00
font-size: 24px;
color: #666666;
2022-01-10 09:33:11 +08:00
font-size: 24px;
2022-01-07 19:07:05 +08:00
color: #666666;
2022-01-07 17:27:06 +08:00
}
2022-01-10 09:33:11 +08:00
.dele {
padding: 24px 0 28px 0;
font-size: 32px;
color: #c25450;
}
.liness {
height: 12px;
background: #f6f7f8;
}
.cancel {
padding: 24px 0 62px 0;
font-size: 32px;
color: #333333;
}
2022-01-07 17:27:06 +08:00
}
}
2022-01-07 18:00:10 +08:00
}
2021-12-30 21:05:45 +08:00
</style>