5bbfac44
易尊强
28号下午提交
|
1
2
3
|
<template>
<view class="page">
<view class="list-box">
|
6edbea35
“wangming”
1
|
4
5
|
<view class="item" v-for="(it,index) in messageList" :key="index"
@click="toDetail(it.MessageEntity,it.MessageReceiveEntity.MessageId)">
|
5bbfac44
易尊强
28号下午提交
|
6
7
8
9
10
11
12
13
|
<view class="info">
<view class="title">
{{it.MessageEntity.Title}}
</view>
<view class="desc">
{{it.MessageEntity.BodyText}}
</view>
</view>
|
6edbea35
“wangming”
1
|
14
|
<view class="isRead" style="background: red;" v-if="it.MessageReceiveEntity.IsRead === 0">
|
5bbfac44
易尊强
28号下午提交
|
15
16
|
未读
</view>
|
6edbea35
“wangming”
1
|
17
|
<view class="isRead" style="background: #009e00;" v-else>
|
5bbfac44
易尊强
28号下午提交
|
18
19
20
21
22
23
24
25
26
27
28
29
|
已读
</view>
</view>
</view>
</view>
</template>
<script>
import request from '@/utils/request.js'
export default {
data() {
return {
|
6edbea35
“wangming”
1
|
30
|
messageList: [],
|
6c679290
易尊强
3/6a上午
|
31
32
|
isAdmin: false,
baseUrl: 'http://deyanggaoxin.fengshiyun.com'
|
5bbfac44
易尊强
28号下午提交
|
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
}
},
onShow() {
this.getUser()
this.getAdminNoticeTell()
},
onLoad() {
this.getUser()
this.getAdminNoticeTell()
},
methods: {
// 获取用户信息
getUser() {
if (uni.getStorageSync('user')) {
let userCode = uni.getStorageSync("user")
console.log(userCode)
|
6edbea35
“wangming”
1
|
49
|
if (userCode.userInfo.userId === 'admin') {
|
5bbfac44
易尊强
28号下午提交
|
50
51
52
|
this.isAdmin = true
}
console.log('用户已登录!')
|
6edbea35
“wangming”
1
|
53
|
} else {
|
5bbfac44
易尊强
28号下午提交
|
54
55
56
|
uni.showToast({
title: '请登录',
icon: 'none',
|
6edbea35
“wangming”
1
|
57
|
duration: 1500
|
5bbfac44
易尊强
28号下午提交
|
58
59
60
61
62
63
64
65
66
|
})
// setTimeout(() => {
// uni.reLaunch({
// url: '/pages/login/index'
// })
// })
}
},
// 获取消息通知
|
6edbea35
“wangming”
1
|
67
|
getAdminNoticeTell() {
|
5bbfac44
易尊强
28号下午提交
|
68
|
request({
|
6edbea35
“wangming”
1
|
69
70
71
72
73
74
|
url: '/api/extend/demo/GetMessageList',
method: 'get',
data: {}
}).then(res => {
console.log('通知列表', res)
if (res.code == 200) {
|
5bbfac44
易尊强
28号下午提交
|
75
76
77
78
79
|
this.messageList = JSON.parse(JSON.stringify(res.data))
}
})
},
// 跳转到消息详情
|
6edbea35
“wangming”
1
|
80
|
toDetail(it, id) {
|
5bbfac44
易尊强
28号下午提交
|
81
82
|
let link = JSON.parse(it.bodyJson)
// let id = it.Id
|
6edbea35
“wangming”
1
|
83
|
console.log('link', link.link)
|
5bbfac44
易尊强
28号下午提交
|
84
85
86
87
88
89
90
91
92
93
94
95
|
// uni.navigateTo({
// url:link.link + `?data=${JSON.stringify(link.reid)}`
// })
// this.API.updateInfo({MessageId:id}).then(res=>{
// console.log("修改已读",res)
// if(res.code == 200){
// console.log('成功修改')
// uni.navigateTo({
// url:link.link + `?data=${JSON.stringify(link.reid)}`
// })
// }
// })
|
6c679290
易尊强
3/6a上午
|
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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
|
if (link.type === '公文办理通知') {
this.download(link.link)
} else {
uni.navigateTo({
url: link.link + `?data=${JSON.stringify(link.reid)}`
})
}
if (link.type === '公文办理通知') {
this.download(link.link)
} else if (link.type === '表单填报通知') {
uni.navigateTo({
url: link.link + `?id=${link.reid}`
})
} else {
uni.navigateTo({
url: link.link + `?data=${JSON.stringify(link.reid)}`
})
}
// request({
// url: `/api/extend/demo/UpdateIsReadEnd?MessageId=${id}`,
// method: 'put',
// data: {}
// }).then(res => {
// console.log("修改已读", res)
// if (res.code == 200) {
// console.log('成功修改')
// if (link.type === '公文办理通知') {
// this.download(link.link)
// } else {
// uni.navigateTo({
// url: link.link + `?data=${JSON.stringify(link.reid)}`
// })
// }
// if (link.type === '公文办理通知') {
// this.download(link.link)
// } else if (link.type === '表单填报通知') {
// uni.navigateTo({
// url: link.link + `?id=${link.reid}`
// })
// } else {
// uni.navigateTo({
// url: link.link + `?data=${JSON.stringify(link.reid)}`
// })
// }
// }
// })
},
download(it) {
uni.downloadFile({
url: this.baseUrl + it, //下载地址接口返回
success: (data) => {
if (data.statusCode === 200) {
//文件保存到本地
uni.saveFile({
tempFilePath: data.tempFilePath, //临时路径
success: function(res) {
uni.showToast({
icon: 'none',
mask: true,
title: '文件已保存:' + res.savedFilePath, //保存路径
duration: 3000,
});
setTimeout(() => {
//打开文档查看
uni.openDocument({
filePath: res.savedFilePath,
success: function(res) {
// console.log('打开文档成功');
}
});
}, 3000)
}
});
}
},
fail: (err) => {
that.loadelshow = false
console.log(err);
uni.showToast({
icon: 'none',
mask: true,
title: '失败请重新下载',
});
},
});
},
|
5bbfac44
易尊强
28号下午提交
|
184
185
186
187
188
|
}
}
</script>
<style lang="scss" scoped>
|
6edbea35
“wangming”
1
|
189
|
.page {
|
5bbfac44
易尊强
28号下午提交
|
190
|
width: 100%;
|
80d8fbe3
易尊强
2/29下午
|
191
192
|
height: 100vh;
overflow: scroll;
|
5bbfac44
易尊强
28号下午提交
|
193
194
|
background-color: #f3f3f3;
}
|
6edbea35
“wangming”
1
|
195
196
|
.list-box {
|
5bbfac44
易尊强
28号下午提交
|
197
198
199
200
|
width: 96%;
margin: 0 auto;
overflow-y: scroll;
}
|
6edbea35
“wangming”
1
|
201
202
|
.item {
|
5bbfac44
易尊强
28号下午提交
|
203
204
205
206
207
208
209
210
|
width: 100%;
background-color: white;
border-radius: 30rpx;
padding: 30rpx;
margin-top: 20rpx;
display: flex;
justify-content: space-between;
align-items: center;
|
6edbea35
“wangming”
1
|
211
212
|
.info {
|
5bbfac44
易尊强
28号下午提交
|
213
214
|
display: flex;
flex-direction: column;
|
6edbea35
“wangming”
1
|
215
|
|
80d8fbe3
易尊强
2/29下午
|
216
|
// align-items: center;
|
6edbea35
“wangming”
1
|
217
|
.title {
|
5bbfac44
易尊强
28号下午提交
|
218
219
220
|
font-size: 36rpx;
font-weight: bold;
}
|
6edbea35
“wangming”
1
|
221
222
|
.desc {
|
5bbfac44
易尊强
28号下午提交
|
223
224
225
226
|
// width: 400rpx;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
|
6edbea35
“wangming”
1
|
227
|
margin-left: 18rpx;
|
5bbfac44
易尊强
28号下午提交
|
228
229
|
}
}
|
6edbea35
“wangming”
1
|
230
231
|
.isRead {
|
5bbfac44
易尊强
28号下午提交
|
232
|
color: red;
|
6edbea35
“wangming”
1
|
233
234
235
236
|
margin-right: 10rpx;
padding: 6rpx 18rpx;
border-radius: 5px;
color: #f3f3f3;
|
5bbfac44
易尊强
28号下午提交
|
237
238
|
}
}
|
6edbea35
“wangming”
1
|
239
|
</style>
|