myNoticeList.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. <template>
  2. <view class="container">
  3. <uni-nav-bar fixed :border="false" backgroundColor="#fff" title="系统通知" :statusBar="true"
  4. left-icon="left" @clickLeft="$navBack()">
  5. <!-- #ifndef MP-WEIXIN -->
  6. <template v-slot:right>
  7. <image class="righticon" src="/static/image/readall.png" mode="aspectFill" @click="handleReadAll"></image>
  8. </template>
  9. <!-- #endif -->
  10. </uni-nav-bar>
  11. <view class="container-body">
  12. <mescroll-body ref="mescrollRef" @init="mescrollInit" @down="downCallback" @up="upCallback" :down="downOption" :up="upOption">
  13. <view>
  14. <view class="list-item" v-for="item in dataList" :key="item.id" @click.stop="handleDetail(item)">
  15. <view class="new" v-if="item.isRead != 1 && isallRead!=1"></view>
  16. <view class="list-item-head border-line">
  17. <view>{{item.title}}</view>
  18. <view class="time">{{item.createTime}}</view>
  19. </view>
  20. <view class="list-item-con">
  21. <view class="">{{item.content}}</view>
  22. <image class="img" v-if="item.imgUrl" :src="item.imgUrl" mode="aspectFill"></image>
  23. </view>
  24. </view>
  25. </view>
  26. </mescroll-body>
  27. </view>
  28. </view>
  29. </template>
  30. <script>
  31. import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
  32. import { getPushLog } from "@/api/user.js"
  33. import { getPushLogRead } from "@/api/user.js"
  34. export default {
  35. mixins: [MescrollMixin],
  36. data() {
  37. return {
  38. mescroll:null,
  39. downOption: { //下拉刷新
  40. use:true,
  41. auto: true // 不自动加载 (mixin已处理第一个tab触发downCallback)
  42. },
  43. upOption: {
  44. onScroll:false,
  45. use: true, // 是否启用上拉加载; 默认true
  46. page: {
  47. pae: 0, // 当前页码,默认0,回调之前会加1,即callback(page)会从1开始
  48. size: 10 // 每页数据的数量,默认10
  49. },
  50. noMoreSize: 10, // 配置列表的总数量要大于等于5条才显示'-- END --'的提示
  51. textNoMore:"已经到底了",
  52. empty: {
  53. icon:'https://cos.his.cdwjyyh.com/fs/20240423/cf4a86b913a04341bb44e34bb4d37aa2.png',
  54. tip: '暂无数据'
  55. }
  56. },
  57. dataList: [],
  58. isallRead: 0
  59. }
  60. },
  61. methods: {
  62. mescrollInit(mescroll) {
  63. this.mescroll = mescroll;
  64. },
  65. /*下拉刷新的回调 */
  66. downCallback(mescroll) {
  67. mescroll.resetUpScroll()
  68. },
  69. upCallback(page) {
  70. //联网加载数据
  71. let that = this;
  72. let data = {
  73. pageNum: page.num,
  74. pageSize: page.size
  75. };
  76. getPushLog(data).then(res => {
  77. if(res.code==200){
  78. //设置列表数据
  79. if (page.num == 1) {
  80. that.dataList = res.rows;
  81. } else {
  82. that.dataList = that.dataList.concat(res.rows);
  83. }
  84. that.mescroll.endBySize(res.rows.length, res.total);
  85. }else{
  86. uni.showToast({
  87. icon:'none',
  88. title: "请求失败",
  89. });
  90. that.dataList = [];
  91. that.mescroll.endErr();
  92. }
  93. });
  94. },
  95. handleDetail(item) {
  96. console.log("qxj handleDetail");
  97. console.log(item);
  98. if(item.url) {
  99. uni.navigateTo({url: item.url});
  100. this.setReadAll('item',item);
  101. }else{
  102. this.setReadAll('item',item);
  103. }
  104. },
  105. handleReadAll() {
  106. uni.showModal({
  107. title: '',
  108. content: '确定标记所有未读消息为已读吗?',
  109. success: (res)=> {
  110. if (res.confirm) {
  111. this.setReadAll('all')
  112. }
  113. }
  114. });
  115. },
  116. setReadAll(type,item) {
  117. const param = type=="all" ? [] : [item.id]
  118. if(type!="all" &&item.isRead == 1) {
  119. return
  120. }
  121. getPushLogRead(param).then(res=>{
  122. if(res.code == 200) {
  123. setTimeout(e => {
  124. this.$updateMsgDot();
  125. }, 1000);
  126. if(type=="all") {
  127. this.isallRead = 1
  128. uni.showToast({
  129. title: res.msg,
  130. icon: 'none'
  131. });
  132. } else {
  133. item.isRead = 1
  134. }
  135. }
  136. })
  137. },
  138. }
  139. }
  140. </script>
  141. <style lang="scss" scoped>
  142. .container {
  143. }
  144. .righticon {
  145. width: 48rpx;
  146. height: 48rpx;
  147. margin-right: 16rpx;
  148. }
  149. .container-body {
  150. padding: 24rpx;
  151. padding-bottom: calc(var(--window-bottom) + 24rpx);
  152. box-sizing: border-box;
  153. }
  154. .new {
  155. position: absolute;
  156. display: inline-block;
  157. right: 4px;
  158. top: 4px;
  159. background: red;
  160. width: 11px;
  161. height: 11px;
  162. border-radius: 50%;
  163. color: #ffffff;
  164. }
  165. .list-item {
  166. position: relative;
  167. margin-bottom: 24rpx;
  168. background-color: #fff;
  169. border-radius: 16rpx;
  170. overflow: hidden;
  171. font-family: PingFang SC, PingFang SC;
  172. font-weight: 400;
  173. font-size: 28rpx;
  174. color: #555;
  175. word-break: break-all;
  176. &-head {
  177. padding: 24rpx;
  178. font-size: 32rpx;
  179. font-weight: 500;
  180. color: #000;
  181. .time {
  182. font-size: 24rpx;
  183. color: #999999;
  184. }
  185. }
  186. &-con {
  187. padding: 24rpx;
  188. .img {
  189. width: 100%;
  190. height: 300rpx;
  191. margin-top: 16rpx;
  192. }
  193. }
  194. }
  195. </style>