消息通知

This commit is contained in:
binbin_pan 2024-09-02 16:53:22 +08:00
parent 3a48134bc4
commit 4e7cbe6fe9
5 changed files with 211 additions and 51 deletions

View File

@ -189,7 +189,7 @@
{ {
"path": "pages/YNEduApp/user/myMsg", "path": "pages/YNEduApp/user/myMsg",
"style": { "style": {
"navigationBarTitleText": "消息通知" "navigationStyle": "custom"
} }
}, },
{ {
@ -227,6 +227,13 @@
"style": { "style": {
"navigationBarTitleText": "职业预约" "navigationBarTitleText": "职业预约"
} }
},
{
"path" : "pages/YNEduApp/index/notices",
"style" :
{
"navigationBarTitleText" : "公告通知"
}
} }
], ],
"globalStyle": { "globalStyle": {

View File

@ -28,7 +28,7 @@
scrollable scrollable
color="#808080" color="#808080"
background-color="transparent" background-color="transparent"
:text="msgList.length > 0 ? msgList[0].noticeName : '暂无消息'" :text="text"
@click="handleMsg" @click="handleMsg"
/> />
<view class="my-task"> <view class="my-task">
@ -48,7 +48,7 @@
<div>{{ item.trainPercentage }}%</div> <div>{{ item.trainPercentage }}%</div>
</div> </div>
</div> </div>
<view class="no-task" v-show="taskList.length === 0"> <view class="no-task" v-show="!taskList || taskList.length === 0">
<view class="no-task-img"> <view class="no-task-img">
<image src="/static/eduImg/no-task.png"></image> <image src="/static/eduImg/no-task.png"></image>
<span>可联系管理员发布</span> <span>可联系管理员发布</span>
@ -92,7 +92,7 @@ export default {
} }
], ],
taskList: [], taskList: [],
msgList: [] text: '暂无公告'
} }
}, },
onLoad() { onLoad() {
@ -153,7 +153,7 @@ export default {
}) })
}, },
// //
async getMsgList() { getMsgList() {
uni.request({ uni.request({
url: config.bmwUrl + '/studentUsers/getNoticeList', url: config.bmwUrl + '/studentUsers/getNoticeList',
method: 'post', method: 'post',
@ -162,16 +162,17 @@ export default {
Authorization: uni.getStorageSync('access_token') Authorization: uni.getStorageSync('access_token')
}, },
success: res => { success: res => {
console.log('🚀 ~ getMsgList ~ res:', res) console.log('🚀 ~ getMsgList ~ res:', res.data[0].noticeName)
this.msgList = res.data this.text = res.data[0].noticeName
console.log('🚀 ~ getMsgList ~ this.msgList:', this.msgList) console.log('🚀 ~ getMsgList ~ this.text:', this.text)
} }
}) })
}, },
// //
handleMsg() { handleMsg() {
console.log('🚀 ~ handleMsg ~ handleMsg:')
uni.navigateTo({ uni.navigateTo({
url: '/pages/YNEduApp/user/myMsg' url: '/pages/YNEduApp/index/notices'
}) })
}, },
toggleScan() { toggleScan() {

View File

@ -0,0 +1,72 @@
<template>
<view>
<div class="msg-list" v-for="(item, index) in msgList" :key="index" @click="handleDetail(item)">
<div class="msg-title">{{ item.noticeName }}</div>
<div class="msg-time">{{ item.createTime }}</div>
</div>
</view>
</template>
<script>
import config from '@/config'
export default {
data() {
return {
userId: uni.getStorageSync('userId'),
token: uni.getStorageSync('access_token'),
//
msgList: []
}
},
onLoad() {
this.getMsgList()
},
methods: {
//
async getMsgList() {
uni.request({
url: config.bmwUrl + '/studentUsers/getNoticeList',
method: 'post',
data: {},
header: {
Authorization: this.token
},
success: res => {
console.log('🚀 ~ getMsgList ~ res:', res)
this.msgList = res.data
console.log('🚀 ~ getMsgList ~ this.msgList:', this.msgList)
}
})
},
//
handleDetail(item) {
const params = {
noticeName: item.noticeName,
noticeContent: item.noticeContent
}
uni.navigateTo({
url: `/pages/YNEduApp/user/msgDetail?params=${JSON.stringify(params)}`
})
}
}
}
</script>
<style lang="scss" scoped>
.msg-list {
margin: 10px;
padding: 10px;
background: #fff;
border-radius: 5px;
.msg-title {
font-size: 16px;
color: #333;
}
.msg-time {
font-size: 14px;
color: #999;
margin-top: 5px;
}
}
</style>

View File

@ -1,9 +1,24 @@
<template> <template>
<view> <view>
<div class="msg-list" v-for="(item, index) in msgList" :key="index" @click="handleDetail(item)"> <u-navbar title="消息通知" @leftClick="leftClick" placeholder />
<div class="msg-title">{{ item.noticeName }}</div> <u-swipe-action class="swipe-wrapper">
<div class="msg-time">{{ item.createTime }}</div> <u-swipe-action-item
</div> :options="options"
v-for="(item, index) in msgList"
:key="index"
class="swipe-item"
@click="handleOption(item)"
>
<div class="swipe-action" @click="handleItem(item)">
<div class="action-title">
<div class="tip" v-if="item.isRead == '0'"></div>
<div style="margin-right: 10px; font-size: 16px">{{ item.type == '1' ? '考试通知' : '其他通知' }}</div>
<div style="color: #919ca1">{{ item.updateTime }}</div>
</div>
<div>{{ item.content }}</div>
</div>
</u-swipe-action-item>
</u-swipe-action>
</view> </view>
</template> </template>
@ -15,6 +30,14 @@ export default {
return { return {
userId: uni.getStorageSync('userId'), userId: uni.getStorageSync('userId'),
token: uni.getStorageSync('access_token'), token: uni.getStorageSync('access_token'),
options: [
{
text: '删除',
style: {
backgroundColor: '#f56c6c'
}
}
],
// //
msgList: [] msgList: []
} }
@ -24,29 +47,81 @@ export default {
}, },
methods: { methods: {
// //
async getMsgList() { getMsgList() {
uni.request({ uni.request({
url: config.bmwUrl + '/studentUsers/getNoticeList', url: config.bmwUrl + '/users/getMsgInform',
method: 'post', method: 'get',
data: {}, data: {
page: 1,
limit: 999
},
header: { header: {
Authorization: this.token Authorization: this.token
}, },
success: res => { success: res => {
res = res.data
console.log('🚀 ~ getMsgList ~ res:', res) console.log('🚀 ~ getMsgList ~ res:', res)
this.msgList = res.data this.msgList = res.data
console.log('🚀 ~ getMsgList ~ this.msgList:', this.msgList) console.log('🚀 ~ getMsgList ~ this.msgList:', this.msgList)
} }
}) })
}, },
// // -
handleDetail(item) { handleOption(item) {
const params = { console.log('🚀 ~ handleOption ~ item:', item)
noticeName: item.noticeName, if (item.isRead == '0') {
noticeContent: item.noticeContent, this.markRead(item)
} }
uni.navigateTo({ this.deleteMsg(item)
url: `/pages/YNEduApp/user/msgDetail?params=${JSON.stringify(params)}` },
//
handleItem(item) {
console.log('🚀 ~ handleItem ~ item:', item)
if (item.isRead == '0') {
this.markRead(item)
}
},
//
markRead(item) {
const ids = [item.id]
console.log('🚀 ~ markRead ~ ids:', ids)
uni.request({
url: config.bmwUrl + '/users/markAsRead',
method: 'post',
data: { ids },
header: {
Authorization: this.token
},
success: res => {
console.log('🚀 ~ markRead ~ res:', res)
this.getMsgList()
}
})
},
//
deleteMsg(item) {
const ids = [item.id]
console.log('🚀 ~ deleteMsg ~ ids:', ids)
uni.request({
url: config.bmwUrl + '/users/batchDelete',
method: 'post',
data: { ids },
header: {
Authorization: this.token
},
success: res => {
console.log('🚀 ~ deleteMsg ~ res:', res)
//
uni.reLaunch({
url: '/pages/YNEduApp/user/myMsg'
})
}
})
},
//
leftClick() {
uni.reLaunch({
url: '/pages/YNEduApp/user/user'
}) })
} }
} }
@ -54,19 +129,29 @@ export default {
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.msg-list { .swipe-wrapper {
margin: 10px;
padding: 10px; padding: 10px;
background: #fff; .swipe-item {
border-radius: 5px; border-radius: 5px;
.msg-title { margin: 10px 0;
font-size: 16px;
color: #333; .swipe-action {
} padding: 10px;
.msg-time { border-radius: 5px;
font-size: 14px; word-break: break-all;
color: #999; .action-title {
margin-top: 5px; display: flex;
align-items: center;
.tip {
margin-right: 3px;
width: 5px;
height: 5px;
background-color: red;
border-radius: 50%;
}
}
}
} }
} }
</style> </style>

View File

@ -197,7 +197,7 @@
jwtToken: uni.getStorageSync('App-Token') jwtToken: uni.getStorageSync('App-Token')
} }
const tjparams = { const tjparams = {
username: '14755181965', username: '13908860263',
password: 'YNsbd@123456' password: 'YNsbd@123456'
} }
console.log('🚀 ~ gotoYy ~ tjparams:', tjparams) console.log('🚀 ~ gotoYy ~ tjparams:', tjparams)
@ -248,15 +248,15 @@
'Content-Type': 'application/x-www-form-urlencoded' 'Content-Type': 'application/x-www-form-urlencoded'
}, },
success: res => { success: res => {
console.log(res) console.log('🚀 ~ gotoYy ~ res:', res,)
let req = res.data console.log('🚀 ~ gotoYy ~ res:', res.data.token)
console.log('🚀 ~ getUserInfo ~ req:', req) if (res.statusCode == 200) {
if (req.code == 200) { uni.setStorageSync('tjToken', res.data.token)
// setTimeout(() => { setTimeout(() => {
// uni.reLaunch({ uni.reLaunch({
// url: '/pages/HealthExaminationApp/index/index' url: '/pages/HealthExaminationApp/index/index'
// }) })
// }, 500) }, 500)
} else { } else {
uni.showToast({ uni.showToast({
title: req.message, title: req.message,
@ -272,11 +272,6 @@
}) })
} }
}) })
setTimeout(() => {
uni.reLaunch({
url: '/pages/HealthExaminationApp/index/index'
})
}, 500)
} }
}, },