Blame view

pages/my/adminMessageList/adminMessageList.vue 5.65 KB
5bbfac44   易尊强   28号下午提交
1
2
3
  <template>
  	<view class="page">
  		<view class="list-box">
9b1c150c   “wangming”   1
4
5
6
7
8
9
10
  			<view class="notHave" v-if="isShow" style="transform: translateX(-50%);
  			left: 50%;
  			position: fixed;
  			top: 350px;">
  					暂时还未有信息
  				</view>
  			<view v-else class="item" v-for="(it,index) in messageList" :key="index"
6edbea35   “wangming”   1
11
  				@click="toDetail(it.MessageEntity,it.MessageReceiveEntity.MessageId)">
5bbfac44   易尊强   28号下午提交
12
13
14
15
16
17
18
19
  				<view class="info">
  					<view class="title">
  						{{it.MessageEntity.Title}}
  					</view>
  					<view class="desc">
  						{{it.MessageEntity.BodyText}}
  					</view>
  				</view>
6edbea35   “wangming”   1
20
  				<view class="isRead" style="background: red;" v-if="it.MessageReceiveEntity.IsRead === 0">
5bbfac44   易尊强   28号下午提交
21
22
  					未读
  				</view>
6edbea35   “wangming”   1
23
  				<view class="isRead" style="background: #009e00;" v-else>
5bbfac44   易尊强   28号下午提交
24
25
26
27
28
29
30
31
32
33
34
35
  					已读
  				</view>
  			</view>
  		</view>
  	</view>
  </template>
  
  <script>
  	import request from '@/utils/request.js'
  	export default {
  		data() {
  			return {
6edbea35   “wangming”   1
36
  				messageList: [],
6c679290   易尊强   3/6a上午
37
  				isAdmin: false,
9b1c150c   “wangming”   1
38
39
  				baseUrl: 'https://www.dygxq-es.cn',
  				isShow:false
5bbfac44   易尊强   28号下午提交
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
  			}
  		},
  		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
56
  					if (userCode.userInfo.userId === 'admin') {
5bbfac44   易尊强   28号下午提交
57
58
59
  						this.isAdmin = true
  					}
  					console.log('用户已登录!')
6edbea35   “wangming”   1
60
  				} else {
5bbfac44   易尊强   28号下午提交
61
62
63
  					uni.showToast({
  						title: '请登录',
  						icon: 'none',
6edbea35   “wangming”   1
64
  						duration: 1500
5bbfac44   易尊强   28号下午提交
65
66
67
68
69
70
71
72
73
  					})
  					// setTimeout(() => {
  					// 	uni.reLaunch({
  					// 		url: '/pages/login/index'
  					// 	})
  					// })
  				}
  			},
  			// 获取消息通知
6edbea35   “wangming”   1
74
  			getAdminNoticeTell() {
5bbfac44   易尊强   28号下午提交
75
  				request({
6edbea35   “wangming”   1
76
77
78
79
80
81
  					url: '/api/extend/demo/GetMessageList',
  					method: 'get',
  					data: {}
  				}).then(res => {
  					console.log('通知列表', res)
  					if (res.code == 200) {
5bbfac44   易尊强   28号下午提交
82
  						this.messageList = JSON.parse(JSON.stringify(res.data))
9b1c150c   “wangming”   1
83
84
85
86
87
  						if(this.messageList.length == 0){
  							this.isShow = true
  						}else{
  							this.isShow = false
  						}
5bbfac44   易尊强   28号下午提交
88
89
90
91
  					}
  				})
  			},
  			// 跳转到消息详情
6edbea35   “wangming”   1
92
  			toDetail(it, id) {
5bbfac44   易尊强   28号下午提交
93
94
  				let link = JSON.parse(it.bodyJson)
  				// let id = it.Id
6edbea35   “wangming”   1
95
  				console.log('link', link.link)
5bbfac44   易尊强   28号下午提交
96
97
98
99
100
101
102
103
104
105
106
107
  				// 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上午
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
184
185
186
187
188
189
190
191
192
193
194
195
  				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号下午提交
196
197
198
199
200
  		}
  	}
  </script>
  
  <style lang="scss" scoped>
6edbea35   “wangming”   1
201
  	.page {
5bbfac44   易尊强   28号下午提交
202
  		width: 100%;
80d8fbe3   易尊强   2/29下午
203
204
  		height: 100vh;
  		overflow: scroll;
5bbfac44   易尊强   28号下午提交
205
206
  		background-color: #f3f3f3;
  	}
6edbea35   “wangming”   1
207
208
  
  	.list-box {
5bbfac44   易尊强   28号下午提交
209
210
211
212
  		width: 96%;
  		margin: 0 auto;
  		overflow-y: scroll;
  	}
6edbea35   “wangming”   1
213
214
  
  	.item {
5bbfac44   易尊强   28号下午提交
215
216
217
218
219
220
221
222
  		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
223
224
  
  		.info {
5bbfac44   易尊强   28号下午提交
225
226
  			display: flex;
  			flex-direction: column;
6edbea35   “wangming”   1
227
  
80d8fbe3   易尊强   2/29下午
228
  			// align-items: center;
6edbea35   “wangming”   1
229
  			.title {
5bbfac44   易尊强   28号下午提交
230
231
232
  				font-size: 36rpx;
  				font-weight: bold;
  			}
6edbea35   “wangming”   1
233
234
  
  			.desc {
5bbfac44   易尊强   28号下午提交
235
236
237
238
  				// width: 400rpx;
  				overflow: hidden;
  				white-space: nowrap;
  				text-overflow: ellipsis;
6edbea35   “wangming”   1
239
  				margin-left: 18rpx;
5bbfac44   易尊强   28号下午提交
240
241
  			}
  		}
6edbea35   “wangming”   1
242
243
  
  		.isRead {
5bbfac44   易尊强   28号下午提交
244
  			color: red;
6edbea35   “wangming”   1
245
246
247
248
  			margin-right: 10rpx;
  			padding: 6rpx 18rpx;
  			border-radius: 5px;
  			color: #f3f3f3;
5bbfac44   易尊强   28号下午提交
249
250
  		}
  	}
6edbea35   “wangming”   1
251
  </style>