2020-09-16 09:25:13 +08:00
|
|
|
|
<template>
|
|
|
|
|
<view class="page">
|
2020-09-18 21:13:55 +08:00
|
|
|
|
<view class="top">
|
|
|
|
|
<view class="title">
|
|
|
|
|
{{noticeInfo.title}}
|
2020-09-16 09:25:13 +08:00
|
|
|
|
</view>
|
2020-09-18 21:13:55 +08:00
|
|
|
|
<view class="label">
|
|
|
|
|
{{noticeInfo.label}}
|
|
|
|
|
</view>
|
|
|
|
|
<view class="author-and-time">
|
2020-09-23 18:53:25 +08:00
|
|
|
|
<view class="author" @tap="goToUserInfo(noticeInfo)" style="padding: 0;">
|
2020-09-27 15:39:35 +08:00
|
|
|
|
{{noticeInfo.author_name}}
|
2020-09-18 21:13:55 +08:00
|
|
|
|
</view>
|
|
|
|
|
<view class="time">
|
2020-09-27 15:39:35 +08:00
|
|
|
|
{{noticeInfo.create_time}}
|
2020-09-18 21:13:55 +08:00
|
|
|
|
</view>
|
|
|
|
|
</view>
|
|
|
|
|
<view class="content">
|
|
|
|
|
<textarea placeholder="请输入文章内容"
|
|
|
|
|
v-model="noticeInfo.content"
|
|
|
|
|
auto-height="true"
|
|
|
|
|
disabled="true"
|
|
|
|
|
></textarea>
|
2020-09-16 09:25:13 +08:00
|
|
|
|
</view>
|
|
|
|
|
</view>
|
|
|
|
|
<view class="feedback">
|
|
|
|
|
<view class="reading-volume">
|
2020-09-27 15:39:35 +08:00
|
|
|
|
阅读 {{noticeInfo.read_number}}
|
2020-09-16 09:25:13 +08:00
|
|
|
|
</view>
|
|
|
|
|
<view class="fabulous">
|
2020-09-27 15:39:35 +08:00
|
|
|
|
<uni-fav :checked="noticeInfo.isCollection === 0 ? false : true"
|
|
|
|
|
:class="noticeInfo.isCollection === 0 ? 'grey' : 'blue'"
|
2020-09-23 18:53:25 +08:00
|
|
|
|
class="favBtn"
|
|
|
|
|
circle="true"
|
|
|
|
|
bg-color="#FFFFFF"
|
|
|
|
|
bg-color-checked="#1296DB"
|
2020-09-27 15:39:35 +08:00
|
|
|
|
@tap="collection(noticeInfo.isCollection)"></uni-fav>
|
2020-09-16 09:25:13 +08:00
|
|
|
|
</view>
|
|
|
|
|
</view>
|
2020-12-19 12:13:27 +08:00
|
|
|
|
<view class="no-message" v-if="isMessage === true && noMessage === true" @tap="addMessage">
|
2020-09-16 09:25:13 +08:00
|
|
|
|
写留言
|
|
|
|
|
</view>
|
|
|
|
|
<view class="leave-message" v-if="noMessage === false">
|
|
|
|
|
<view class="message-title">
|
|
|
|
|
<view class="left">
|
|
|
|
|
精选留言
|
|
|
|
|
</view>
|
|
|
|
|
<view class="right" @tap="addMessage">
|
|
|
|
|
写留言
|
|
|
|
|
</view>
|
|
|
|
|
</view>
|
2020-09-17 20:01:50 +08:00
|
|
|
|
<view class="one-message" v-for="(item,index) in messageList" :key="index">
|
2020-09-16 09:25:13 +08:00
|
|
|
|
<view class="left">
|
|
|
|
|
<view class="header-photo">
|
2020-10-10 10:44:32 +08:00
|
|
|
|
<avatar :userName="item.real_name" size="50"></avatar>
|
2020-09-16 09:25:13 +08:00
|
|
|
|
</view>
|
|
|
|
|
<view class="message">
|
|
|
|
|
<view class="name">
|
|
|
|
|
{{item.real_name}}
|
|
|
|
|
</view>
|
|
|
|
|
<view class="message-content">
|
|
|
|
|
{{item.content}}
|
|
|
|
|
</view>
|
|
|
|
|
</view>
|
|
|
|
|
</view>
|
2020-09-23 18:53:25 +08:00
|
|
|
|
</view>
|
|
|
|
|
</view>
|
2020-09-27 15:39:35 +08:00
|
|
|
|
<view class="cu-modal" :class="messageDialog ? 'show' : ''" :style="[{'margin-top': -InputBottom/2+'px'}]">
|
2020-09-23 18:53:25 +08:00
|
|
|
|
<view class="cu-dialog">
|
|
|
|
|
<view class="cu-bar bg-white justify-end">
|
2020-10-10 10:44:32 +08:00
|
|
|
|
<view class="title-content bg-white">留言</view>
|
2020-09-23 18:53:25 +08:00
|
|
|
|
<view class="action" @tap="hideModal">
|
|
|
|
|
<text class="cuIcon-close text-red"></text>
|
|
|
|
|
</view>
|
|
|
|
|
</view>
|
|
|
|
|
<view class="padding-xl">
|
2020-09-27 15:39:35 +08:00
|
|
|
|
<input type="text" :adjust-position="false"
|
|
|
|
|
:focus="false"
|
|
|
|
|
v-model="messageContent"
|
|
|
|
|
@focus="InputFocus"
|
|
|
|
|
@blur="InputBlur"
|
|
|
|
|
placeholder="请输入留言"/>
|
2020-09-23 18:53:25 +08:00
|
|
|
|
</view>
|
|
|
|
|
<view class="cu-bar bg-white justify-end">
|
|
|
|
|
<view class="action">
|
|
|
|
|
<button class="cu-btn line-blue text-blue" @tap="hideModal">取消</button>
|
|
|
|
|
<button class="cu-btn bg-blue margin-left" @tap="clickPromptConfirm">确定</button>
|
|
|
|
|
</view>
|
2020-09-16 09:25:13 +08:00
|
|
|
|
</view>
|
|
|
|
|
</view>
|
|
|
|
|
</view>
|
|
|
|
|
</view>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
import request from '@/util/request.js';
|
2020-09-23 18:53:25 +08:00
|
|
|
|
import uniFav from '@/components/uni-fav/uni-fav.vue';
|
2020-10-10 10:44:32 +08:00
|
|
|
|
import avatar from "@/pages/components/avatar/avatar.vue";
|
2020-09-16 09:25:13 +08:00
|
|
|
|
export default {
|
2020-09-17 20:01:50 +08:00
|
|
|
|
components: {
|
2020-10-10 10:44:32 +08:00
|
|
|
|
avatar,
|
2020-09-23 18:53:25 +08:00
|
|
|
|
uniFav
|
2020-09-17 20:01:50 +08:00
|
|
|
|
},
|
2020-09-16 09:25:13 +08:00
|
|
|
|
data() {
|
|
|
|
|
return {
|
2020-09-27 15:39:35 +08:00
|
|
|
|
//键盘高度
|
|
|
|
|
InputBottom: 0,
|
2020-09-16 09:25:13 +08:00
|
|
|
|
//文章信息
|
2020-09-27 15:39:35 +08:00
|
|
|
|
noticeInfo: {},
|
|
|
|
|
//文章ID
|
|
|
|
|
noticeId: '',
|
2020-09-16 09:25:13 +08:00
|
|
|
|
//有无留言
|
|
|
|
|
noMessage: false,
|
|
|
|
|
//留言列表
|
2020-09-17 20:01:50 +08:00
|
|
|
|
messageList: [],
|
2020-09-23 18:53:25 +08:00
|
|
|
|
//留言窗口
|
|
|
|
|
messageDialog: false,
|
|
|
|
|
//留言内容
|
|
|
|
|
messageContent: '',
|
2020-12-19 12:13:27 +08:00
|
|
|
|
//是否有留言功能
|
|
|
|
|
isMessage: true
|
2020-09-16 09:25:13 +08:00
|
|
|
|
}
|
|
|
|
|
},
|
2020-09-27 15:39:35 +08:00
|
|
|
|
onLoad(option) {
|
|
|
|
|
this.noticeId = option.noticeId;
|
2020-12-19 12:13:27 +08:00
|
|
|
|
this.isMessage = option.isMessage || true;
|
2020-09-27 15:39:35 +08:00
|
|
|
|
},
|
|
|
|
|
onReady() {
|
2020-09-16 09:25:13 +08:00
|
|
|
|
|
|
|
|
|
},
|
2020-09-27 15:39:35 +08:00
|
|
|
|
async mounted() {
|
|
|
|
|
await this.getMessageList();
|
|
|
|
|
await this.updateReadNumber();
|
2020-09-16 09:25:13 +08:00
|
|
|
|
},
|
2020-09-18 21:13:55 +08:00
|
|
|
|
onPullDownRefresh () {
|
|
|
|
|
uni.startPullDownRefresh();
|
|
|
|
|
},
|
2020-09-16 09:25:13 +08:00
|
|
|
|
methods: {
|
2020-09-27 15:39:35 +08:00
|
|
|
|
/**
|
|
|
|
|
* 浏览量+1
|
|
|
|
|
*/
|
|
|
|
|
updateReadNumber() {
|
|
|
|
|
request.post("/hs/updateReadNumber",{
|
|
|
|
|
noticeId: this.noticeInfo.id,
|
|
|
|
|
number: Number(this.noticeInfo.read_number)+1
|
|
|
|
|
}).then(res=>{
|
|
|
|
|
console.log("浏览量+1",res);
|
|
|
|
|
if (res.data > 0) {
|
|
|
|
|
this.getMessageList()
|
|
|
|
|
} else {
|
|
|
|
|
uni.showToast({
|
|
|
|
|
icon: "none",
|
|
|
|
|
title: "服务器出了小差,请稍后再试"
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
},err => {
|
|
|
|
|
console.log("err",err)
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
/**
|
|
|
|
|
* 收藏
|
|
|
|
|
*/
|
|
|
|
|
collection(option) {
|
|
|
|
|
const URL = {
|
|
|
|
|
"0": "/hs/addCollection",
|
|
|
|
|
"1": "/hs/cancelCollection",
|
|
|
|
|
}
|
|
|
|
|
request.post(URL[option],{
|
|
|
|
|
noticeId: this.noticeInfo.id,
|
|
|
|
|
userId: uni.getStorageSync("userInfo").user_id,
|
|
|
|
|
}).then(res=>{
|
|
|
|
|
console.log("收藏/取消收藏",res);
|
|
|
|
|
if (res.data > 0) {
|
|
|
|
|
this.getMessageList()
|
|
|
|
|
}
|
|
|
|
|
},err => {
|
|
|
|
|
console.log("err",err)
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
/**
|
|
|
|
|
* 调整弹框高度
|
|
|
|
|
*/
|
|
|
|
|
InputFocus(e) {
|
|
|
|
|
this.InputBottom = e.detail.height
|
|
|
|
|
},
|
|
|
|
|
InputBlur(e) {
|
|
|
|
|
this.InputBottom = 0
|
|
|
|
|
},
|
2020-09-23 18:53:25 +08:00
|
|
|
|
/**
|
|
|
|
|
* 关闭留言窗口
|
|
|
|
|
*/
|
|
|
|
|
hideModal() {
|
|
|
|
|
this.messageDialog = false;
|
|
|
|
|
},
|
2020-09-21 18:02:14 +08:00
|
|
|
|
/**
|
2020-09-27 15:39:35 +08:00
|
|
|
|
* 跳转人员页面
|
2020-09-21 18:02:14 +08:00
|
|
|
|
* @param {Object} item
|
|
|
|
|
*/
|
|
|
|
|
goToUserInfo(item) {
|
2020-09-27 15:39:35 +08:00
|
|
|
|
if (item.author_id === uni.getStorageSync("userInfo").user_id) {
|
2020-09-21 18:02:14 +08:00
|
|
|
|
uni.switchTab({
|
|
|
|
|
url: '/pages/tabbar/my/my'
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
uni.navigateTo({
|
2020-09-27 15:39:35 +08:00
|
|
|
|
url: `/pages/person-info-page/person-info-page?userId=${item.author_id}`
|
2020-09-21 18:02:14 +08:00
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
},
|
2020-09-17 20:01:50 +08:00
|
|
|
|
/**
|
|
|
|
|
* 点击留言弹出输入框确定
|
|
|
|
|
*/
|
2020-09-23 18:53:25 +08:00
|
|
|
|
clickPromptConfirm() {
|
|
|
|
|
if (this.messageContent === '') {
|
2020-09-18 21:13:55 +08:00
|
|
|
|
uni.showToast({
|
|
|
|
|
icon: 'none',
|
|
|
|
|
title: '请输入留言,亲'
|
|
|
|
|
})
|
|
|
|
|
} else {
|
|
|
|
|
request.post('/hs/addMessage',{
|
|
|
|
|
noticeId: this.noticeInfo.id,
|
|
|
|
|
userId: uni.getStorageSync("userInfo").user_id,
|
2020-09-23 18:53:25 +08:00
|
|
|
|
content: this.messageContent
|
2020-09-18 21:13:55 +08:00
|
|
|
|
}).then(res=>{
|
|
|
|
|
console.log("新增留言结果",res);
|
|
|
|
|
if (res.data === 1) {
|
2020-09-23 18:53:25 +08:00
|
|
|
|
this.messageDialog = false;
|
2020-09-18 21:13:55 +08:00
|
|
|
|
uni.showToast({
|
|
|
|
|
icon: 'loading',
|
|
|
|
|
title: '留言成功',
|
|
|
|
|
});
|
|
|
|
|
setTimeout(()=>{
|
|
|
|
|
this.getMessageList();
|
2020-09-27 15:39:35 +08:00
|
|
|
|
},1000);
|
2020-09-18 21:13:55 +08:00
|
|
|
|
}
|
|
|
|
|
},err=>{
|
|
|
|
|
console.log("err",err);
|
|
|
|
|
})
|
|
|
|
|
}
|
2020-09-17 20:01:50 +08:00
|
|
|
|
},
|
|
|
|
|
/**
|
|
|
|
|
* 获取留言
|
|
|
|
|
*/
|
2020-09-16 09:25:13 +08:00
|
|
|
|
getMessageList() {
|
2020-09-27 15:39:35 +08:00
|
|
|
|
return request.post('/hs/getOneContent',{
|
|
|
|
|
id: this.noticeId,
|
|
|
|
|
userId: uni.getStorageSync("userInfo").user_id
|
|
|
|
|
}).then(res=>{
|
2020-09-17 20:01:50 +08:00
|
|
|
|
this.noMessage = res.data.message.length === 0 ? true : false;
|
2020-09-27 15:39:35 +08:00
|
|
|
|
this.noticeInfo = res.data.content;
|
2020-09-17 20:01:50 +08:00
|
|
|
|
this.messageList = res.data.message;
|
2020-09-16 09:25:13 +08:00
|
|
|
|
console.log("一条数据数据",res);
|
|
|
|
|
},err=>{
|
|
|
|
|
console.log("err",err);
|
2020-09-27 15:39:35 +08:00
|
|
|
|
});
|
2020-09-16 09:25:13 +08:00
|
|
|
|
},
|
2020-09-17 20:01:50 +08:00
|
|
|
|
/**
|
|
|
|
|
* 新增留言(打开弹框)
|
|
|
|
|
*/
|
2020-09-16 09:25:13 +08:00
|
|
|
|
addMessage() {
|
2020-09-23 18:53:25 +08:00
|
|
|
|
this.messageDialog = true;
|
2020-09-16 09:25:13 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style scoped>
|
2020-09-27 15:39:35 +08:00
|
|
|
|
.blue{
|
|
|
|
|
border: 1rpx solid #1296DB!important;
|
|
|
|
|
}
|
|
|
|
|
.grey{
|
|
|
|
|
border: 1rpx solid #989898!important;
|
|
|
|
|
}
|
|
|
|
|
.title-content{
|
|
|
|
|
width: calc(100% - 200rpx);
|
|
|
|
|
text-align: center;
|
|
|
|
|
}
|
2020-09-23 18:53:25 +08:00
|
|
|
|
.padding-xl input{
|
|
|
|
|
background-color: #FFFFFF;
|
|
|
|
|
text-align: left;
|
|
|
|
|
}
|
|
|
|
|
.one-message{
|
|
|
|
|
margin-bottom: 20rpx;
|
|
|
|
|
}
|
2020-09-18 21:13:55 +08:00
|
|
|
|
.page .top, .one-message{
|
|
|
|
|
background-color: #FFFFFF;
|
|
|
|
|
border-radius: 10rpx;
|
|
|
|
|
padding: 20rpx;
|
|
|
|
|
}
|
2020-09-23 18:53:25 +08:00
|
|
|
|
.content {
|
2020-09-17 20:01:50 +08:00
|
|
|
|
background-color: #F1F1F1;
|
|
|
|
|
width: 100%;
|
2020-09-23 18:53:25 +08:00
|
|
|
|
padding: 20rpx;
|
2020-09-17 20:01:50 +08:00
|
|
|
|
border-radius: 10rpx;
|
2020-09-23 18:53:25 +08:00
|
|
|
|
}
|
|
|
|
|
textarea{
|
|
|
|
|
text-indent: 32rpx;
|
|
|
|
|
line-height: 1.5;
|
|
|
|
|
width: 100%;
|
|
|
|
|
height: 100%;
|
2020-09-17 20:01:50 +08:00
|
|
|
|
}
|
2020-09-16 09:25:13 +08:00
|
|
|
|
.message-title .left{
|
|
|
|
|
color: #a7a7a7;
|
|
|
|
|
}
|
|
|
|
|
.message-title .right{
|
|
|
|
|
color: #1296DB;
|
|
|
|
|
}
|
|
|
|
|
.message-title{
|
|
|
|
|
padding: 20rpx;
|
|
|
|
|
display: flex;
|
|
|
|
|
flex-flow: wrap;
|
|
|
|
|
justify-content: space-between;
|
|
|
|
|
}
|
|
|
|
|
.message .name{
|
|
|
|
|
color: #a7a7a7;
|
|
|
|
|
margin-bottom: 10rpx;
|
|
|
|
|
}
|
|
|
|
|
.left .message{
|
|
|
|
|
margin-left: 32rpx;
|
|
|
|
|
}
|
|
|
|
|
.one-message .left{
|
|
|
|
|
display: flex;
|
|
|
|
|
justify-content: center;
|
|
|
|
|
align-items: center;
|
|
|
|
|
}
|
|
|
|
|
.one-message{
|
|
|
|
|
display: flex;
|
|
|
|
|
padding: 20rpx;
|
|
|
|
|
justify-content: space-between;
|
|
|
|
|
align-items: center;
|
|
|
|
|
}
|
|
|
|
|
.no-message{
|
|
|
|
|
text-align: center;
|
|
|
|
|
padding: 20rpx 0;
|
|
|
|
|
}
|
|
|
|
|
.reading-volume, .fabulous, .no-message, .message-fabulous{
|
|
|
|
|
color: #1296DB;
|
|
|
|
|
}
|
|
|
|
|
.fabulous image, .message-fabulous image{
|
|
|
|
|
width: 36rpx;
|
|
|
|
|
height: 36rpx;
|
|
|
|
|
display: inline-block;
|
|
|
|
|
}
|
|
|
|
|
.label{
|
2020-09-23 18:53:25 +08:00
|
|
|
|
margin: 20rpx 0;
|
2020-09-16 09:25:13 +08:00
|
|
|
|
border-radius: 10rpx;
|
|
|
|
|
width: 4rem;
|
2020-09-18 21:13:55 +08:00
|
|
|
|
font-size: 30rpx;
|
2020-09-16 09:25:13 +08:00
|
|
|
|
text-align: center;
|
|
|
|
|
color: #ff9041;
|
|
|
|
|
border: 1rpx solid #ff9041;
|
|
|
|
|
}
|
|
|
|
|
.content{
|
|
|
|
|
padding: 20rpx!important;
|
|
|
|
|
}
|
2020-09-23 18:53:25 +08:00
|
|
|
|
.feedback{
|
|
|
|
|
padding: 20rpx;
|
|
|
|
|
background-color: #FFFFFF;
|
|
|
|
|
margin-top: 20rpx;
|
|
|
|
|
}
|
2020-09-16 09:25:13 +08:00
|
|
|
|
.author-and-time, .feedback{
|
|
|
|
|
display: flex;
|
|
|
|
|
}
|
|
|
|
|
.author{
|
|
|
|
|
color: #08ACEE;
|
|
|
|
|
}
|
|
|
|
|
.time{
|
|
|
|
|
color: #a5a5a5;
|
|
|
|
|
}
|
|
|
|
|
.author, .time, .reading-volume, .fabulous{
|
|
|
|
|
display: flex;
|
|
|
|
|
justify-content: center;
|
|
|
|
|
align-items: center;
|
|
|
|
|
padding-left: 20rpx;
|
|
|
|
|
height: 60rpx;
|
|
|
|
|
line-height: 60rpx;
|
|
|
|
|
}
|
|
|
|
|
.title{
|
2020-09-23 18:53:25 +08:00
|
|
|
|
padding: 20rpx 0;
|
2020-09-16 09:25:13 +08:00
|
|
|
|
font-size: 36rpx;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
</style>
|