message.vue 3.6 KB

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