消息通知

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",
"style": {
"navigationBarTitleText": "消息通知"
"navigationStyle": "custom"
}
},
{
@ -227,6 +227,13 @@
"style": {
"navigationBarTitleText": "职业预约"
}
},
{
"path" : "pages/YNEduApp/index/notices",
"style" :
{
"navigationBarTitleText" : "公告通知"
}
}
],
"globalStyle": {

View File

@ -28,7 +28,7 @@
scrollable
color="#808080"
background-color="transparent"
:text="msgList.length > 0 ? msgList[0].noticeName : '暂无消息'"
:text="text"
@click="handleMsg"
/>
<view class="my-task">
@ -48,7 +48,7 @@
<div>{{ item.trainPercentage }}%</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">
<image src="/static/eduImg/no-task.png"></image>
<span>可联系管理员发布</span>
@ -92,7 +92,7 @@ export default {
}
],
taskList: [],
msgList: []
text: '暂无公告'
}
},
onLoad() {
@ -153,7 +153,7 @@ export default {
})
},
//
async getMsgList() {
getMsgList() {
uni.request({
url: config.bmwUrl + '/studentUsers/getNoticeList',
method: 'post',
@ -162,16 +162,17 @@ export default {
Authorization: uni.getStorageSync('access_token')
},
success: res => {
console.log('🚀 ~ getMsgList ~ res:', res)
this.msgList = res.data
console.log('🚀 ~ getMsgList ~ this.msgList:', this.msgList)
console.log('🚀 ~ getMsgList ~ res:', res.data[0].noticeName)
this.text = res.data[0].noticeName
console.log('🚀 ~ getMsgList ~ this.text:', this.text)
}
})
},
//
handleMsg() {
console.log('🚀 ~ handleMsg ~ handleMsg:')
uni.navigateTo({
url: '/pages/YNEduApp/user/myMsg'
url: '/pages/YNEduApp/index/notices'
})
},
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>
<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>
<u-navbar title="消息通知" @leftClick="leftClick" placeholder />
<u-swipe-action class="swipe-wrapper">
<u-swipe-action-item
: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>
</template>
@ -15,6 +30,14 @@ export default {
return {
userId: uni.getStorageSync('userId'),
token: uni.getStorageSync('access_token'),
options: [
{
text: '删除',
style: {
backgroundColor: '#f56c6c'
}
}
],
//
msgList: []
}
@ -24,29 +47,81 @@ export default {
},
methods: {
//
async getMsgList() {
getMsgList() {
uni.request({
url: config.bmwUrl + '/studentUsers/getNoticeList',
method: 'post',
data: {},
url: config.bmwUrl + '/users/getMsgInform',
method: 'get',
data: {
page: 1,
limit: 999
},
header: {
Authorization: this.token
},
success: res => {
res = res.data
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,
// -
handleOption(item) {
console.log('🚀 ~ handleOption ~ item:', item)
if (item.isRead == '0') {
this.markRead(item)
}
uni.navigateTo({
url: `/pages/YNEduApp/user/msgDetail?params=${JSON.stringify(params)}`
this.deleteMsg(item)
},
//
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>
<style lang="scss" scoped>
.msg-list {
margin: 10px;
.swipe-wrapper {
padding: 10px;
background: #fff;
border-radius: 5px;
.msg-title {
font-size: 16px;
color: #333;
}
.msg-time {
font-size: 14px;
color: #999;
margin-top: 5px;
.swipe-item {
border-radius: 5px;
margin: 10px 0;
.swipe-action {
padding: 10px;
border-radius: 5px;
word-break: break-all;
.action-title {
display: flex;
align-items: center;
.tip {
margin-right: 3px;
width: 5px;
height: 5px;
background-color: red;
border-radius: 50%;
}
}
}
}
}
</style>

View File

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