123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209 |
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="utf-8">
- <title>消息列表-消息中心-创业帮</title>
- <meta name="keywords" content="消息列表-消息中心-创业帮">
- <meta name="description" content="消息列表-消息中心-创业帮">
- <meta content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,shrink-to-fit=no,user-scalable=no" name="viewport" viewport="cover">
- <meta name="apple-mobile-web-app-capable" content="yes">
- <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
- <meta content="telephone=no" name="format-detection">
- <meta content="email=no" name="format-detection">
- <meta name="apple-mobile-web-app-title" content="消息列表-消息中心-创业帮">
- <meta http-equiv="Cache-Control" content="no-siteapp">
- <link rel="stylesheet" href="./static/css/main.css">
- <style>
- ul::-webkit-scrollbar {
- display: none !important;
- }
- </style>
- </head>
- <body class="back-color pb0 bgcf7f7f7 pt0" style="padding-top:0;">
- <div id="app" v-cloak>
- <van-nav-bar class="user_rank_explan_title user_title_normal" :title="noticetype" v-if="toptitleisshow" @click-left="goback" left-arrow>
- <template #left> <img src="./static/images/left.png" alt=""></template>
- </van-nav-bar>
- <div class="notice-list" ref="wrapper2">
- <van-pull-refresh v-model="refreshing" @refresh="onRefresh" :class="noticelist.length === 0 ? 'isnodata':''" style="height:100%;">
- <ul class="pt16 pl16 pr16">
- <van-empty class="custom-image" image="./static/images/empty-img.png" description="暂无数据" v-if="isnodata"></van-empty>
- <van-list v-model="loading" :finished="finished" finished-text="没有更多数据了" @load="onLoad" :immediate-check="false">
- <li class="mb20" v-for="item,index in noticelist" :key="item.Id" @click="articledetail(item.Id,item.MsgType,item.Url,index)">
- <div class="tc">
- <div class="notice-time dib"><span class="cfff db">{{item.CreateDate}}</span></div>
- </div>
- <div class="notice-box pt16 ovh">
- <div class="notice-title">
- <div class="dib rel pr6" v-if="item.ReadFlag !== 1">
- <van-badge content=" " dot></van-badge>
- </div><span class="f16 c333">{{item.Title}}</span>
- </div>
- <div class="notice-img pt8" v-if="item.BgPic !== ''"><img class="db" :src="item.BgPic" style="width:100%;"></div>
- <div class="notice-info pt8 pb16"><span class="f12 c999">{{item.CreateDate}} {{item.Summary}}</span></div>
- <div class="notice-btn van-hairline--top" v-if="item.MsgType !== 2">
- <van-cell title="查看详情" is-link></van-cell>
- </div>
- </div>
- </li>
- </van-list>
- </ul>
- </van-pull-refresh>
- </div>
- </div>
- <script src="./static/js/klm-vv.min.js"></script>
- <script src="./static/js/appfunc.min.js"></script>
- <script src="./static/js/klm-axios-config.js"></script>
- <script src="./static/js/publicfn.js"></script>
- <script>
- // 通过 CDN 引入时不会自动注册 Lazyload 组件
- // 可以通过下面的方式手动注册
- Vue.use(vant.Lazyload);
- PublicLib.SetStatusBarBgColor({bgcolor:'ffffff'});
- //--- PublicLib.SetStatusBarStyle({type:'default', isShow:1});
- // 在 #app 标签下渲染一个按钮组件
- let app = new Vue({
- el: '#app',
- data() {
- return {
- isnodata:false,
- toptitleisshow:false,
- noticetype:'消息',
- noticelist:[],
- //- 滚动加载
- loading: false,
- finished: false,
- //- 刷新
- refreshing: false,
- pageinfo:{
- PageSize:10,
- PageNum:1
- }
- };
- },
- created() {
- this.toptitleisshow = toptitleisshow;
- this.noticetype = PublicLib.getCookieInfo('noticeType');
- if(PublicLib.getCookieInfo('noticeType') === '个人消息'){
- PublicLib.SetTitle({Title:'个人消息'});
- }else{
- PublicLib.SetTitle({Title:'系统消息'});
- };
- //- if(PublicLib.getCookieInfo('userId') === '14'){
- this.getnoticelist('refresh');
- //- }else{
- //- this.isnodata = true
- //- };
- },
- mounted(){
- this.$refs.wrapper2.style.height = `${document.documentElement.clientHeight}px`;
- },
- beforeUpdate(){
- this.$refs.wrapper2.style.height = `${document.documentElement.clientHeight}px`;
- },
- methods: {
- onLoad() {
- if (this.refreshing) {
- //- this.noticelist = [];
- this.refreshing = false;
- this.pageinfo.PageNum = 0;
- };
- this.pageinfo.PageNum++;
- this.getnoticelist();
- },
- onRefresh() {
- // 清空列表数据
- this.finished = false;
- // 重新加载数据
- // 将 loading 设置为 true,表示处于加载状态
- this.loading = true;
- this.pageinfo.PageNum = 1;
- this.getnoticelist('refresh');
- },
- async getnoticelist(type = 'onload'){
- //- PublicLib.ShowLoading({Message:''});
- let requestUrl = '';
- if(PublicLib.getCookieInfo('noticeType') === '个人消息'){
- requestUrl = 'api/v1/msgpersonal/list?t='+Math.random(6);
- }else{
- requestUrl = 'api/v1/msgplacard/list?t='+Math.random(6);
- };
- const UserId = PublicLib.getCookieInfo('userId');
- const res = await getRequest(requestUrl,JSON.stringify({UserId,...this.pageinfo}));
- if(res.status === '1') {
- //- PublicLib.HideLoading();
- if(res.data.length < this.pageinfo.PageSize) {
- this.finished = true;
- };
- if(type === 'refresh'){
- this.noticelist = res.data
- this.refreshing = false;
- }else{
- this.noticelist.push(...res.data);
- };
- if(PublicLib.getCookieInfo('noticeType') === '系统消息'){
- this.noticelist.splice(this.noticelist.length - 1,0,{
- CreateDate:'2022-06-10',
- Title:'转商户型创客',
- Summary:'点击查看商户型创客转换流程',
- ReadFlag:1,
- Id:99999,
- BgPic:'',
- });
- this.noticelist.splice(this.noticelist.length - 6,0,{
- CreateDate:'2022-07-06',
- Title:'创业帮菁英班开始报名啦',
- Summary:'给自己一次改变的机会,点击查看详情',
- ReadFlag:1,
- Id:1000,
- BgPic:'',
- });
- };
- this.loading = false;
- if(this.noticelist.length === 0) {this.isnodata = true}else{this.isnodata = false};
- res.data.forEach(item=>{
- PublicLib.CachePicture({picUrl:item.BgPic});
- });
- }
- },
- goback(){
- PublicLib.GoBack({Level:1});
- },
- async articledetail(id,type,url,index){
- if(id === 1000){
- return PublicLib.Goto({ Url: 'https://mp.weixin.qq.com/s/Gn6XxY9OrvA_UjaIMPTRow' });
- };
- if(id === 99999){
- PublicLib.putCookieInfo('articleId', 113);
- PublicLib.Goto({Url:'user-service-detail'});
- }else{
- await this.readflag(id,index);
- if(type === 2){
- }else if(type === 0){
- PublicLib.putCookieInfo('noticeArticleDetail', id);
- PublicLib.Goto({Url:'notice-detail'});
- }else if(type === 1){
- PublicLib.Goto({Url:url});
- };
- };
- },
- //- 标记为已读
- async readflag(Id,index){
- let requestUrl = '';
- if(PublicLib.getCookieInfo('noticeType') === '个人消息'){
- requestUrl = 'api/v1/msgpersonal/read?t='+Math.random(6);
- }else{
- requestUrl = 'api/v1/msgplacard/read?t='+Math.random(6);
- };
- const UserId = PublicLib.getCookieInfo('userId');
- const res = await postRequest(requestUrl,JSON.stringify({UserId,Id}));
- if(res.status === '1') {
- this.noticelist[index].ReadFlag = 1;
- };
- },
-
- }
- });
- </script>
- </body>
- </html>
|