myNoticeList.vue 4.5 KB

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