notificationDetails.vue
2.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
<template>
<div class="notificationDetails warp">
<div class="head">
<!-- <router-link to="/message"> -->
<div class="mar-right-10">消息中心</div>
<!-- </router-link> -->
<div class='arrow'></div>
<div class="mar-right-10">公告详情</div>
</div>
<div class="messageDetail" v-loading="loading">
<h1>{{ detail.noticeTitle }}</h1>
<div class="date">{{ detail.createTime }}</div>
<el-divider />
<div class="messageInfo" v-html="detail.noticeContent"></div>
</div>
</div>
</template>
<script>
import Cookie from 'js-cookie'
import {mapGetters, mapMutations} from 'vuex'
import {
getUserInfo
} from '@/api/user/user.js'
import {
getNoticeDetail
} from '@/api/user/notice.js'
export default {
name: 'notificationDetails',
data () {
return {
detail: {},
loading: false
}
},
mounted () {
this.getDetail()
},
computed: {
...mapGetters([
'noticeId'
])
},
watch: {
noticeId: {
handler (newVal, oldVal) {
if (newVal !== oldVal) {
this.getDetail()
}
}
}
},
methods: {
...mapMutations({
setUserInfo: 'SET_USERINFO'
}),
async getDetail () {
this.loading = true
const response = await getNoticeDetail({ noticeId: this.$route.query.id })
const res = response.data
if (res.code === '200') {
this.detail = res.data
if (Cookie.get('token')) {
this.getUserInfoData()
}
this.loading = false
} else {
this.$message.warning(res.message)
}
},
async getUserInfoData () {
const response = await getUserInfo()
const res = response.data
if (res.code === '200') {
this.setUserInfo(res.data)
} else {
this.$message.warning(res.message)
}
}
}
}
</script>
<style lang="scss" scoped>
.notificationDetails {
.head {
width: 100%;
height: 50px;
line-height: 50px;
font-size: 16px;
display: flex;
align-items: center;
.arrow {
background-image: url('../../../../static/image/xiangyou@2x.png');
width: 5px;
height: 10px;
margin-right: 10px;
}
}
.messageDetail {
background: #FFFFFF;
padding: 50px 0;
min-height: 500px;
h1 {
font-size: 40px;
font-weight: bold;
color: #333333;
text-align: center;
margin-bottom: 20px;
}
.date {
font-size: 14px;
font-weight: 400;
color: #666666;
text-align: center;
margin-bottom: 25px;
}
.messageInfo {
min-height: 500px;
p {
font-size: 14px;
color: #666666;
}
}
.messageInfo >>> img{ // 修改v-html渲染的样式
max-width: 100%;
height: auto;
}
}
}
</style>