message.vue 3.2 KB

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