Commit bf559990 authored by 胡占生's avatar 胡占生 🇨🇳

fix:消息中心 初始构建,接口联调,样式修复

parent 49dc353d
...@@ -11,8 +11,8 @@ ...@@ -11,8 +11,8 @@
<div class="con"> <div class="con">
<van-tabs v-model="activeName" color="#247df7" title-inactive-colo="#d0d1d1" title-active-color="#000000" sticky <van-tabs v-model="activeName" color="#247df7" title-inactive-colo="#d0d1d1" title-active-color="#000000" sticky
offset-top="1.333333rem" @change="changeTab"> offset-top="1.333333rem" @change="changeTab">
<van-tab title="消息提醒(14)" name="消息提醒"> <van-tab :title="`消息提醒(${dangerNewsNum})`" name="消息提醒">
<info-tip></info-tip> <info-tip @getList="getBadgeNumber"></info-tip>
</van-tab> </van-tab>
<!-- <van-tab title="预警提醒" name="预警提醒" > <!-- <van-tab title="预警提醒" name="预警提醒" >
<Warning></Warning> <Warning></Warning>
...@@ -20,8 +20,8 @@ ...@@ -20,8 +20,8 @@
<!-- <van-tab title="SOS求救" name="SOS求救"> <!-- <van-tab title="SOS求救" name="SOS求救">
<Iso></Iso> <Iso></Iso>
</van-tab> --> </van-tab> -->
<van-tab title="待办事项(20)" name="待办事项"> <van-tab :title="`待办事项(${messageNewsNum})`" name="待办事项">
<wait-event></wait-event> <wait-event @getList="getBadgeNumber"></wait-event>
</van-tab> </van-tab>
</van-tabs> </van-tabs>
</div> </div>
...@@ -36,6 +36,9 @@ import infoTip from "./infoTip"; ...@@ -36,6 +36,9 @@ import infoTip from "./infoTip";
import waitEvent from "./waitEvent"; import waitEvent from "./waitEvent";
// import Warning from "./warning"; // import Warning from "./warning";
// import Iso from "./iso"; // import Iso from "./iso";
import {
badgeNumber,
} from "@/service/message";
import tabBar from "@/components/TabBar"; import tabBar from "@/components/TabBar";
export default { export default {
components: { components: {
...@@ -48,9 +51,12 @@ export default { ...@@ -48,9 +51,12 @@ export default {
data() { data() {
return { return {
activeName: "消息提醒", activeName: "消息提醒",
messageNewsNum:0,
dangerNewsNum:0,
}; };
}, },
mounted() { mounted() {
this.getBadgeNumber()
// 判断路由跳转有没有带text // 判断路由跳转有没有带text
if (this.$route.params.text) { if (this.$route.params.text) {
this.activeName = this.$route.params.text; this.activeName = this.$route.params.text;
...@@ -87,6 +93,13 @@ export default { ...@@ -87,6 +93,13 @@ export default {
// 把点击的页卡名字纯到缓存中 // 把点击的页卡名字纯到缓存中
sessionStorage.setItem("infoActiveName", title); sessionStorage.setItem("infoActiveName", title);
}, },
//获取未读消息数
getBadgeNumber() {
badgeNumber().then(res => {
this.messageNewsNum = res.data.待办事项;
this.dangerNewsNum= res.data.消息信息;
});
}
} }
}; };
</script> </script>
......
<template> <template>
<div> <div>
<van-pull-refresh
v-model="isLoading"
success-text="刷新成功"
@refresh="onRefresh"
>
<div class="message-wrap"> <div class="message-wrap">
<!-- 搜索 --> <!-- 搜索 -->
<div class="search-wrap"> <div class="search-wrap">
...@@ -46,7 +51,7 @@ ...@@ -46,7 +51,7 @@
</van-badge> </van-badge>
<van-overlay :show="showIndex == index"> <van-overlay :show="showIndex == index">
<div class="wrapper" @click.stop="closeOverlay"> <div class="wrapper" @click.stop="closeOverlay">
<van-button round color="#4ABD85" @click="touchstart(item)"> <van-button round color="#4ABD85" @click="readme(item)">
详情 详情
</van-button> </van-button>
</div> </div>
...@@ -60,6 +65,7 @@ ...@@ -60,6 +65,7 @@
</van-list> </van-list>
</div> </div>
</div> </div>
</van-pull-refresh>
</div> </div>
</template> </template>
...@@ -77,6 +83,7 @@ export default { ...@@ -77,6 +83,7 @@ export default {
data() { data() {
return { return {
searchVal: "", searchVal: "",
isLoading: false,
showIndex: null, // 是否显示遮罩层 showIndex: null, // 是否显示遮罩层
activeIndex: 0, activeIndex: 0,
activeVal: "全部", activeVal: "全部",
...@@ -105,7 +112,16 @@ export default { ...@@ -105,7 +112,16 @@ export default {
mounted() { mounted() {
}, },
methods: { methods: {
// 搜索事件 //下拉刷新
onRefresh() {
setTimeout(() => {
this.$toast("刷新成功");
this.isLoading = false;
this.reset()
this.getList();
this.$emit('getList')
}, 1000);
},
// 搜索事件 // 搜索事件
onSearch:debounce(function(){ onSearch:debounce(function(){
this.messageList=[] this.messageList=[]
...@@ -172,6 +188,17 @@ export default { ...@@ -172,6 +188,17 @@ export default {
this.$toast.fail('加载失败,请稍后再试'); this.$toast.fail('加载失败,请稍后再试');
}); });
}, },
readme(item){
let formData=new FormData()
formData.append('id',item.id)
postFun("messageInfo/changeRead", formData)
.then(res => {
this.showIndex = null;
this.$router.push({
path: item.appUrl,
});
})
},
touchstart(index, item) { touchstart(index, item) {
if (this.showIndex != null) { if (this.showIndex != null) {
this.showIndex = null; this.showIndex = null;
......
<template> <template>
<div> <div>
<van-pull-refresh
v-model="isLoading"
success-text="刷新成功"
@refresh="onRefresh"
>
<div class="message-wrap"> <div class="message-wrap">
<!-- 搜索 --> <!-- 搜索 -->
<div class="search-wrap"> <div class="search-wrap">
<van-search v-model="searchVal" placeholder="搜索" @input="onSearch" /> <van-search v-model="searchVal" placeholder="搜索" @input="onSearch" />
</div> </div>
<!-- 标签 -->
<div class="category-wrap">
<span
class="my-tag-style"
:class="index == activeIndex ? 'active' : ''"
v-for="(item, index) in messageCategory"
:key="item.key"
@click="clickCategory(index, item.category)"
>{{ item.category }}</span
>
</div>
<!-- 内容列表 --> <!-- 内容列表 -->
<div class="con-list" @touchmove="showIndex = null"> <div class="con-list" @touchmove="showIndex = null">
<van-list <van-list
...@@ -44,6 +60,7 @@ ...@@ -44,6 +60,7 @@
</van-list> </van-list>
</div> </div>
</div> </div>
</van-pull-refresh>
</div> </div>
</template> </template>
...@@ -55,8 +72,24 @@ export default { ...@@ -55,8 +72,24 @@ export default {
data() { data() {
return { return {
searchVal: "", searchVal: "",
isLoading: false,
activeIndex: 0,
showIndex: null, // 是否显示遮罩层 showIndex: null, // 是否显示遮罩层
messageList: [], messageList: [],
messageCategory: [
{
key: "0",
category: "待办",
},
{
key: "1",
category: "已办",
},
{
key: "2",
category: "全部",
},
],
loading: false, // 列表滚动到底部会触发load事件 loading: false, // 列表滚动到底部会触发load事件
finished: false, // 列表数据全部加载完成 finished: false, // 列表数据全部加载完成
pageSize: 10, pageSize: 10,
...@@ -66,14 +99,38 @@ export default { ...@@ -66,14 +99,38 @@ export default {
mounted() { mounted() {
}, },
methods: { methods: {
//下拉刷新
onRefresh() {
setTimeout(() => {
this.$toast("刷新成功");
this.isLoading = false;
this.reset()
this.getList();
// this.$parent.$parent.$parent.$parent.getBadgeNumber();
this.$emit('getList')
}, 1000);
},
// 搜索事件 // 搜索事件
onSearch:debounce(function(){ onSearch:debounce(function(){
this.messageList=[] this.messageList=[]
this.pageNum=1 this.pageNum=1
this.finished = false this.finished = false
this.loading = true this.loading = true
let formData = new FormData(); if (this.activeIndex == 0) {
formData.append("keyword", this.searchVal); let formData = new FormData();
formData.append("status", 0);
formData.append("keyword", this.searchVal);
this.getList(formData);
} else if (this.activeIndex == 1) {
let formData = new FormData();
formData.append("status", 1);
formData.append("keyword", this.searchVal);
this.getList(formData);
} else if (this.activeIndex == 2) {
let formData = new FormData();
formData.append("keyword", this.searchVal);
this.getList(formData);
}
this.getList(formData) this.getList(formData)
},500), },500),
getList(Data) { getList(Data) {
...@@ -88,7 +145,15 @@ export default { ...@@ -88,7 +145,15 @@ export default {
pageNum:this.pageNum, pageNum:this.pageNum,
} }
let formData let formData
formData = new FormData(); if (this.activeIndex == 0) {
formData = new FormData();
formData.append("status", 0);
} else if (this.activeIndex == 1) {
formData = new FormData();
formData.append("status", 1);
} else if (this.activeIndex == 2) {
formData = new FormData()
}
if(this.searchVal){ if(this.searchVal){
formData.append("keyword", this.searchVal); formData.append("keyword", this.searchVal);
} }
...@@ -107,29 +172,32 @@ export default { ...@@ -107,29 +172,32 @@ export default {
}, },
touchstart(index, item) { touchstart(index, item) {
console.log('%c [ item ]-104', 'font-size:13px; background:pink; color:#bf2c9f;', item) let formData=new FormData()
if (this.showIndex != null) { formData.append('id',item.id)
this.showIndex = null; postFun("messageInfo/changeRead", formData)
return; .then(res => {
} this.showIndex = null;
if(item.appUrl){ this.$router.push({
this.$router.push({ path: item.appUrl,
name: item.appUrl, });
// name: 'center',
params: {
id: item.pid,
mainId:item.mainId,
path:item.appUrl,
nodeId:item.nodeId,
theme:item.theme
}
// params: {
// id: item.pid,
// pageName:'noticeWait'
// },
}) })
} // if (this.showIndex != null) {
this.showIndex = index; // this.showIndex = null;
// return;
// }
// if(item.appUrl){
// this.$router.push({
// name: item.appUrl,
// params: {
// id: item.pid,
// mainId:item.mainId,
// path:item.appUrl,
// nodeId:item.nodeId,
// theme:item.theme
// }
// })
// }
// this.showIndex = index;
}, },
closeOverlay() { closeOverlay() {
this.showIndex = null; this.showIndex = null;
...@@ -258,6 +326,19 @@ export default { ...@@ -258,6 +326,19 @@ export default {
// break; // break;
// } // }
}, },
// 点击类别
clickCategory(index, data) {
this.showIndex = null;
this.activeIndex = index;
this.reset()
this.getList()
},
reset(){
this.messageList=[]
this.pageNum=1
this.finished = false
this.loading = true
},
} }
}; };
</script> </script>
...@@ -269,6 +350,7 @@ export default { ...@@ -269,6 +350,7 @@ export default {
background-color: #f0f1f5; background-color: #f0f1f5;
// 标签 // 标签
.category-wrap { .category-wrap {
margin-bottom: 10px;
.my-tag-style { .my-tag-style {
width: 75px; width: 75px;
height: 21px; height: 21px;
...@@ -288,7 +370,7 @@ export default { ...@@ -288,7 +370,7 @@ export default {
} }
// 搜索 // 搜索
.search-wrap { .search-wrap {
margin: 10px 0; margin: 0 0 10px 0;
.van-search { .van-search {
border-radius: 5px; border-radius: 5px;
padding: 5px 12px; padding: 5px 12px;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment