message.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. <template>
  2. <view class="container">
  3. <!-- 每一个消息区域 -->
  4. <view class="box" v-for="item in msgList" :key="item.id" @click="handleRead(item)">
  5. <view class="box_time">{{ item.updateTime }}</view>
  6. <view class="box_info">
  7. <view class="info_circle" :class="{ while: item.isRead === 1 }"></view>
  8. <view class="info_icon">
  9. <img src="../../static/images/repairsImg/msg.png" />
  10. </view>
  11. <view class="info_msg">
  12. <view class="msg_title">{{ item.content }}</view>
  13. <view class="msg_order">订单号:{{ item.recordNo }}</view>
  14. </view>
  15. </view>
  16. </view>
  17. <!-- 没有数据时展示的图片 -->
  18. <view class="no_data" v-if="msgList.length === 0">
  19. <img src="../../pagesClockIn/static/imgs/nodata.png" />
  20. <view>暂无数据</view>
  21. </view>
  22. </view>
  23. </template>
  24. <script>
  25. export default {
  26. data() {
  27. return {
  28. // 信息列表
  29. msgList: [],
  30. // 用户id
  31. userId: '',
  32. // 当前页
  33. currentPage: 1,
  34. // 每页多少条
  35. pageCount: 10,
  36. // 总条数
  37. total: null
  38. }
  39. },
  40. onLoad(options) {
  41. const repairsUserInfo = uni.getStorageSync('repairsUserInfo')
  42. this.userId = repairsUserInfo.userId
  43. },
  44. onShow() {
  45. this.msgList = []
  46. this.currentPage = 1
  47. this.getMsgList()
  48. },
  49. // 页面上拉触底回调
  50. onReachBottom() {
  51. if (this.total > this.msgList.length) {
  52. this.currentPage++
  53. this.getMsgList()
  54. } else {
  55. uni.showToast({
  56. title: '没有更多数据了',
  57. icon: 'none'
  58. })
  59. }
  60. },
  61. methods: {
  62. // 点击信息回调
  63. async handleRead(item) {
  64. // 未读信息
  65. if (item.isRead === 0) {
  66. const res = await this.$myRequest_repairs({
  67. url: '/repairSystemMessages/readSystemMessage',
  68. data: {
  69. id: item.id
  70. }
  71. })
  72. // console.log(res)
  73. if (res.code === '200') {
  74. uni.navigateTo({
  75. url: `/pagesRepairs/repairDetails/repairDetails?id=${item.recordId}`
  76. })
  77. }
  78. } else {
  79. uni.navigateTo({
  80. url: `/pagesRepairs/repairDetails/repairDetails?id=${item.recordId}`
  81. })
  82. }
  83. },
  84. // 获取列表信息
  85. async getMsgList() {
  86. const res = await this.$myRequest_repairs({
  87. url: '/repairSystemMessages/querySystemMessagePage',
  88. data: {
  89. currentPage: this.currentPage,
  90. pageCount: this.pageCount,
  91. userId: this.userId
  92. }
  93. })
  94. // console.log(res)
  95. if (res.code === '200') {
  96. this.total = res.data.totalCount
  97. this.msgList = [...this.msgList, ...res.data.list]
  98. }
  99. }
  100. }
  101. }
  102. </script>
  103. <style lang="scss" scoped>
  104. .container {
  105. width: 100vw;
  106. min-height: 100vh;
  107. background-color: #f2f2f2;
  108. overflow-y: auto;
  109. .box {
  110. margin-top: 10rpx;
  111. height: 194rpx;
  112. background-color: #fff;
  113. .box_time {
  114. height: 76rpx;
  115. line-height: 76rpx;
  116. text-align: center;
  117. color: #999999;
  118. font-size: 24rpx;
  119. }
  120. .box_info {
  121. display: flex;
  122. align-items: center;
  123. margin-left: 30rpx;
  124. .info_circle {
  125. width: 16rpx;
  126. height: 16rpx;
  127. border-radius: 50%;
  128. background-color: #d43030;
  129. }
  130. .while {
  131. background-color: #fff;
  132. }
  133. .info_icon {
  134. margin: 0 8rpx;
  135. width: 90rpx;
  136. height: 90rpx;
  137. img {
  138. width: 100%;
  139. height: 100%;
  140. }
  141. }
  142. .info_msg {
  143. flex: 1;
  144. overflow: hidden;
  145. .msg_title {
  146. font-size: 32rpx;
  147. font-weight: bold;
  148. overflow: hidden;
  149. text-overflow: ellipsis;
  150. white-space: nowrap;
  151. }
  152. .msg_order {
  153. margin-top: 10rpx;
  154. color: #808080;
  155. font-size: 24rpx;
  156. }
  157. }
  158. }
  159. }
  160. .no_data {
  161. text-align: center;
  162. color: #b3b3b3;
  163. font-size: 24rpx;
  164. img {
  165. margin: 215rpx auto 0;
  166. width: 480rpx;
  167. height: 508rpx;
  168. }
  169. }
  170. }
  171. </style>