notice-list1.html 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  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 pt0" style="padding-top:0;">
  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. <ul class="pt16 pl16 pr16">
  25. <van-empty class="custom-image" image="./static/images/empty-img.png" description="暂无数据" v-if="isnodata"></van-empty>
  26. <van-list v-model="loading" :finished="finished" finished-text="没有更多数据了" @load="onLoad" :immediate-check="false">
  27. <li class="mb20" v-for="item,index in noticelist" :key="item.Id" @click="articledetail(item.Id,item.MsgType,item.Url,index)">
  28. <div class="tc">
  29. <div class="notice-time dib"><span class="cfff db">{{item.CreateDate}}</span></div>
  30. </div>
  31. <div class="notice-box pt16 ovh">
  32. <div class="notice-title">
  33. <div class="dib rel pr6" v-if="item.ReadFlag !== 1">
  34. <van-badge content=" " dot></van-badge>
  35. </div><span class="f16 c333">{{item.Title}}</span>
  36. </div>
  37. <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>
  38. <div class="notice-info pt8 pb16"><span class="f12 c999">{{item.CreateDate}} {{item.Title}}</span></div>
  39. <div class="notice-btn van-hairline--top" v-if="item.MsgType !== 2">
  40. <van-cell title="查看详情" is-link></van-cell>
  41. </div>
  42. </div>
  43. </li>
  44. </van-list>
  45. </ul>
  46. </van-pull-refresh>
  47. </div>
  48. </div>
  49. <script src="./static/js/klm-vv.min.js"></script>
  50. <script src="./static/js/appfunc.min.js"></script>
  51. <script src="./static/js/klm-axios-config.js"></script>
  52. <script src="./static/js/publicfn.js"></script>
  53. <script>
  54. // 通过 CDN 引入时不会自动注册 Lazyload 组件
  55. // 可以通过下面的方式手动注册
  56. Vue.use(vant.Lazyload);
  57. PublicLib.SetStatusBarBgColor({bgcolor:'ffffff'});
  58. //--- PublicLib.SetStatusBarStyle({type:'default', isShow:1});
  59. // 在 #app 标签下渲染一个按钮组件
  60. let app = new Vue({
  61. el: '#app',
  62. data() {
  63. return {
  64. isnodata:true,
  65. toptitleisshow:false,
  66. noticetype:'消息',
  67. noticelist:[],
  68. //- 滚动加载
  69. loading: false,
  70. finished: false,
  71. //- 刷新
  72. refreshing: false,
  73. pageinfo:{
  74. PageSize:10,
  75. PageNum:1
  76. }
  77. };
  78. },
  79. created() {
  80. this.toptitleisshow = toptitleisshow;
  81. this.noticetype = PublicLib.getCookieInfo('noticeType');
  82. //- this.getnoticelist();
  83. },
  84. methods: {
  85. onLoad() {
  86. if (this.refreshing) {
  87. this.noticelist = [];
  88. this.refreshing = false;
  89. this.pageinfo.PageNum = 0;
  90. };
  91. this.pageinfo.PageNum++;
  92. //- this.getnoticelist();
  93. this.loading = false;
  94. },
  95. onRefresh() {
  96. // 清空列表数据
  97. this.finished = false;
  98. // 重新加载数据
  99. // 将 loading 设置为 true,表示处于加载状态
  100. this.loading = true;
  101. this.onLoad();
  102. },
  103. async getnoticelist(){
  104. PublicLib.ShowLoading({Message:''});
  105. let requestUrl = '';
  106. if(PublicLib.getCookieInfo('noticeType') === '个人消息'){
  107. requestUrl = 'api/v1/msgpersonal/list';
  108. }else{
  109. requestUrl = 'api/v1/msgplacard/list';
  110. };
  111. const UserId = PublicLib.getCookieInfo('userId');
  112. const res = await getRequest(requestUrl,JSON.stringify({UserId,...this.pageinfo}));
  113. if(res.status === '1') {
  114. PublicLib.HideLoading();
  115. if(res.data.length < this.pageinfo.PageSize) {
  116. this.finished = true;
  117. };
  118. this.noticelist.push(...res.data);
  119. this.loading = false;
  120. if(this.noticelist.length === 0) {this.isnodata = true}else{this.isnodata = false};
  121. res.data.forEach(item=>{
  122. PublicLib.CachePicture({picUrl:item.BgPic});
  123. });
  124. }
  125. },
  126. goback(){
  127. PublicLib.GoBack({Level:1});
  128. },
  129. articledetail(id,type,url,index){
  130. if(type === 2){
  131. this.readflag(id,index);
  132. }else if(type === 0){
  133. PublicLib.putCookieInfo('noticeArticleDetail', id);
  134. PublicLib.Goto({Url:'notice-detail'});
  135. }else if(type === 1){
  136. PublicLib.Goto({Url:url});
  137. };
  138. },
  139. //- 标记为已读
  140. async readflag(Id,index){
  141. let requestUrl = '';
  142. if(PublicLib.getCookieInfo('noticeType') === '个人消息'){
  143. requestUrl = 'api/v1/msgpersonal/read';
  144. }else{
  145. requestUrl = 'api/v1/msgplacard/read';
  146. };
  147. const UserId = PublicLib.getCookieInfo('userId');
  148. const res = await postRequest(requestUrl,JSON.stringify({UserId,Id}));
  149. if(res.status === '1') {
  150. this.noticelist[index].ReadFlag = 1;
  151. };
  152. },
  153. }
  154. });
  155. </script>
  156. </body>
  157. </html>