notice-list.html 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <title>消息列表-消息中心-创业帮</title>
  6. <meta name="keywords" content="消息列表-消息中心-创业帮">
  7. <meta name="description" content="消息列表-消息中心-创业帮">
  8. <meta content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,shrink-to-fit=no,user-scalable=no" name="viewport" viewport="cover">
  9. <meta name="apple-mobile-web-app-capable" content="yes">
  10. <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
  11. <meta content="telephone=no" name="format-detection">
  12. <meta content="email=no" name="format-detection">
  13. <meta name="apple-mobile-web-app-title" content="消息列表-消息中心-创业帮">
  14. <meta http-equiv="Cache-Control" content="no-siteapp">
  15. <link rel="stylesheet" href="./static/css/main.css">
  16. </head>
  17. <body class="back-color pb0 bgcf7f7f7">
  18. <div id="app" v-cloak>
  19. <van-nav-bar class="user_rank_explan_title user_title_normal" :title="noticetype" v-if="toptitleisshow" @click-left="goback" left-arrow>
  20. <template #left> <img src="./static/images/left.png" alt=""></template>
  21. </van-nav-bar>
  22. <div class="notice-list">
  23. <van-pull-refresh v-model="refreshing" @refresh="onRefresh" :class="noticelist.length === 0 ? 'isnodata':''">
  24. <van-empty class="custom-image" image="./static/images/no-data.png" description="暂无数据" v-if="noticelist.length === 0"> </van-empty>
  25. <ul class="pt16 pl16 pr16">
  26. <van-empty class="custom-image" image="./static/images/empty-img.png" description="暂无数据" v-if="isnodata"></van-empty>
  27. <van-list v-model="loading" :finished="finished" finished-text="没有更多数据了" @load="onLoad" :immediate-check="false">
  28. <li class="mb20" v-for="item,index in noticelist" :key="item.Id" @click="articledetail(item.Id,item.MsgType,item.Url,index)">
  29. <div class="tc">
  30. <div class="notice-time dib"><span class="cfff db">{{item.CreateDate}}</span></div>
  31. </div>
  32. <div class="notice-box pt16 ovh">
  33. <div class="notice-title">
  34. <div class="dib rel pr6" v-if="item.ReadFlag !== 1">
  35. <van-badge content=" " dot></van-badge>
  36. </div><span class="f16 c333">{{item.Title}}</span>
  37. </div>
  38. <div class="notice-img pt8" v-if="item.BgPic !== ''"><img class="db" :src="PublicLib.CachePicture({picUrl:item.BgPic,domid:'noticeimg' + index})" :id="'noticeimg' + index" style="width:100%;"></div>
  39. <div class="notice-info pt8 pb16"><span class="f12 c999">{{item.CreateDate}} {{item.Title}}</span></div>
  40. <div class="notice-btn van-hairline--top" v-if="item.MsgType !== 2">
  41. <van-cell title="查看详情" is-link></van-cell>
  42. </div>
  43. </div>
  44. </li>
  45. </van-list>
  46. </ul>
  47. </van-pull-refresh>
  48. </div>
  49. </div>
  50. <script src="./static/js/klm-vv.min.js"></script>
  51. <script src="./static/js/klm-axios-config.js"></script>
  52. <script>
  53. // 通过 CDN 引入时不会自动注册 Lazyload 组件
  54. // 可以通过下面的方式手动注册
  55. Vue.use(vant.Lazyload);
  56. // 在 #app 标签下渲染一个按钮组件
  57. let app = new Vue({
  58. el: '#app',
  59. data() {
  60. return {
  61. isnodata:false,
  62. toptitleisshow:false,
  63. noticetype:'消息',
  64. noticelist:[],
  65. //- 滚动加载
  66. loading: false,
  67. finished: false,
  68. //- 刷新
  69. refreshing: false,
  70. pageinfo:{
  71. PageSize:10,
  72. PageNum:1
  73. }
  74. };
  75. },
  76. created() {
  77. this.toptitleisshow = toptitleisshow;
  78. this.noticetype = PublicLib.getCookieInfo('noticeType');
  79. this.getnoticelist();
  80. },
  81. methods: {
  82. onLoad() {
  83. if (this.refreshing) {
  84. this.noticelist = [];
  85. this.refreshing = false;
  86. this.pageinfo.PageNum = 0;
  87. };
  88. this.pageinfo.PageNum++;
  89. this.getnoticelist();
  90. },
  91. onRefresh() {
  92. // 清空列表数据
  93. this.finished = false;
  94. // 重新加载数据
  95. // 将 loading 设置为 true,表示处于加载状态
  96. this.loading = true;
  97. this.onLoad();
  98. },
  99. async getnoticelist(){
  100. //- PublicLib.ShowLoading({Message:''});
  101. let requestUrl = '';
  102. if(PublicLib.getCookieInfo('noticeType') === '个人消息'){
  103. requestUrl = '/api/v1/msgpersonal/list?t='+Math.random(6);
  104. }else{
  105. requestUrl = '/api/v1/msgplacard/list?t='+Math.random(6);
  106. };
  107. const UserId = PublicLib.getCookieInfo('userId');
  108. const res = await getRequest(requestUrl,JSON.stringify({UserId,...this.pageinfo}));
  109. if(res.status === 1) {
  110. PublicLib.HideLoading();
  111. if(res.data.length < this.pageinfo.PageSize) {
  112. this.finished = true;
  113. };
  114. this.noticelist.push(...res.data);
  115. //- console.log(res)
  116. this.loading = false;
  117. if(this.noticelist.length === 0) {this.isnodata = true}else{this.isnodata = false};
  118. res.data.forEach(item=>{
  119. PublicLib.CachePicture({picUrl:item.BgPic});
  120. });
  121. }
  122. },
  123. goback(){
  124. PublicLib.GoBack({Level:1});
  125. },
  126. articledetail(id,type,url,index){
  127. if(type === 2){
  128. this.readflag(id,index);
  129. }else if(type === 0){
  130. PublicLib.putCookieInfo('noticeArticleDetail', id);
  131. PublicLib.Goto({Url:'notice-detail'});
  132. }else if(type === 1){
  133. PublicLib.Goto({Url:url});
  134. };
  135. },
  136. //- 标记为已读
  137. async readflag(Id,index){
  138. let requestUrl = '';
  139. if(PublicLib.getCookieInfo('noticeType') === '个人消息'){
  140. requestUrl = '/api/v1/msgpersonal/read?t='+Math.random(6);
  141. }else{
  142. requestUrl = '/api/v1/msgplacard/read?t='+Math.random(6);
  143. };
  144. const UserId = PublicLib.getCookieInfo('userId');
  145. const res = await postRequest(requestUrl,JSON.stringify({UserId,Id}));
  146. if(res.status === 1) {
  147. this.noticelist[index].ReadFlag = 1;
  148. }
  149. },
  150. }
  151. });
  152. </script>
  153. </body>
  154. </html>