notice-list.html 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  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. <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/klm-axios-config.js"></script>
  51. <script>
  52. // 通过 CDN 引入时不会自动注册 Lazyload 组件
  53. // 可以通过下面的方式手动注册
  54. Vue.use(vant.Lazyload);
  55. // 在 #app 标签下渲染一个按钮组件
  56. let app = new Vue({
  57. el: '#app',
  58. data() {
  59. return {
  60. isnodata:false,
  61. toptitleisshow:false,
  62. noticetype:'消息',
  63. noticelist:[],
  64. //- 滚动加载
  65. loading: false,
  66. finished: false,
  67. //- 刷新
  68. refreshing: false,
  69. pageinfo:{
  70. PageSize:10,
  71. PageNum:1
  72. }
  73. };
  74. },
  75. created() {
  76. this.toptitleisshow = toptitleisshow;
  77. this.noticetype = PublicLib.getCookieInfo('noticeType');
  78. this.getnoticelist();
  79. },
  80. methods: {
  81. onLoad() {
  82. if (this.refreshing) {
  83. this.noticelist = [];
  84. this.refreshing = false;
  85. this.pageinfo.PageNum = 0;
  86. };
  87. this.pageinfo.PageNum++;
  88. this.getnoticelist();
  89. },
  90. onRefresh() {
  91. // 清空列表数据
  92. this.finished = false;
  93. // 重新加载数据
  94. // 将 loading 设置为 true,表示处于加载状态
  95. this.loading = true;
  96. this.onLoad();
  97. },
  98. async getnoticelist(){
  99. PublicLib.ShowLoading({Message:''});
  100. let requestUrl = '';
  101. if(PublicLib.getCookieInfo('noticeType') === '个人消息'){
  102. requestUrl = '/api/v1/msgpersonal/list';
  103. }else{
  104. requestUrl = '/api/v1/msgplacard/list';
  105. };
  106. const UserId = PublicLib.getCookieInfo('userId');
  107. const res = await getRequest(requestUrl,JSON.stringify({UserId,...this.pageinfo}));
  108. if(res.status === '1') {
  109. PublicLib.HideLoading();
  110. if(res.data.length < this.pageinfo.PageSize) {
  111. this.finished = true;
  112. };
  113. this.noticelist.push(...res.data);
  114. console.log(res)
  115. this.loading = false;
  116. if(this.noticelist.length === 0) {this.isnodata = true}else{this.isnodata = false};
  117. res.data.forEach(item=>{
  118. PublicLib.CachePicture({picUrl:item.BgPic});
  119. });
  120. }
  121. },
  122. goback(){
  123. PublicLib.GoBack({Level:1});
  124. },
  125. articledetail(id,type,url,index){
  126. if(type === 2){
  127. this.readflag(id,index);
  128. }else if(type === 0){
  129. PublicLib.putCookieInfo('noticeArticleDetail', id);
  130. PublicLib.Goto({Url:'notice-detail'});
  131. }else if(type === 1){
  132. PublicLib.Goto({Url:url});
  133. };
  134. },
  135. //- 标记为已读
  136. async readflag(Id,index){
  137. let requestUrl = '';
  138. if(PublicLib.getCookieInfo('noticeType') === '个人消息'){
  139. requestUrl = '/api/v1/msgpersonal/read';
  140. }else{
  141. requestUrl = '/api/v1/msgplacard/read';
  142. };
  143. const UserId = PublicLib.getCookieInfo('userId');
  144. const res = await postRequest(requestUrl,JSON.stringify({UserId,Id}));
  145. if(res.status === '1') {
  146. this.noticelist[index].ReadFlag = 1;
  147. }
  148. },
  149. }
  150. });
  151. </script>
  152. </body>
  153. </html>