messageList.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. <template>
  2. <view class="container">
  3. <scroll-view class="message-list-box" scroll-y="true" @scrolltolower="handleLoadMore()">
  4. <view class="message-row" v-for="(item, index1) in messageList" :key="index1">
  5. <image class="message-head" :src="item.headImg"></image>
  6. <view class="message-info-box">
  7. <view class="message-name">{{item.userName}}</view>
  8. <view class="message-date">{{item.leaMsgTime}}</view>
  9. <view class="message-text">{{item.leaMsgContent}}</view>
  10. <view class="message-img-box" v-for="(site, index2) in item.orderLeaImgResVOs" :key="index2">
  11. <image class="message-img" :src="site.imgUrl"></image>
  12. </view>
  13. </view>
  14. </view>
  15. </scroll-view>
  16. <view class="message-handle">
  17. <u-button type="success" shape="circle" :ripple="true" @click="addMessage" class="handle-custom">发布留言</u-button>
  18. </view>
  19. <u-top-tips ref="uTips"></u-top-tips>
  20. </view>
  21. </template>
  22. <script>
  23. const NET = require('@/utils/request')
  24. const API = require('@/config/api')
  25. export default {
  26. data() {
  27. return {
  28. orderId: '',
  29. tenantCode: '',
  30. pageIndex: 1,
  31. isOver: false,
  32. messageList: [],
  33. }
  34. },
  35. onLoad(options) {
  36. this.orderId = options.orderId
  37. this.tenantCode = options.tenantCode
  38. },
  39. onShow() {
  40. this.pageIndex = 1
  41. this.messageList = []
  42. this.getMessageList()
  43. },
  44. onPullDownRefresh() {
  45. this.pageIndex = 1
  46. this.messageList = []
  47. this.getMessageList('refresh')
  48. },
  49. methods: {
  50. // 懒加载
  51. handleLoadMore() {
  52. if (!this.isOver) {
  53. this.pageIndex++
  54. this.getMessageList()
  55. }
  56. },
  57. // 获取全部留言
  58. getMessageList(type) {
  59. NET.request(API.getMessageList + this.pageIndex + '/10', {
  60. flag: 1,
  61. orderId: this.orderId
  62. }, 'GET').then(res => {
  63. if (type == 'refresh') {
  64. uni.stopPullDownRefresh();
  65. }
  66. this.isOver = res.data.list.length != 10
  67. this.messageList = this.messageList.concat(res.data.list)
  68. }).catch(error => {
  69. this.$refs.uTips.show({
  70. title: error.data.msg,
  71. type: 'warning',
  72. })
  73. })
  74. },
  75. // 新增留言
  76. addMessage() {
  77. uni.navigateTo({
  78. url: '/pagesMain/messageForm?orderId=' + this.orderId + '&tenantCode=' + this.tenantCode
  79. });
  80. },
  81. }
  82. }
  83. </script>
  84. <style lang="less" scoped>
  85. page {
  86. width: 100%;
  87. height: 100%;
  88. }
  89. .container {
  90. width: 100%;
  91. height: 100%;
  92. float: left;
  93. position: relative;
  94. .message-list-box {
  95. width: 100%;
  96. height: calc(100% - 70px);
  97. float: left;
  98. .message-row {
  99. width: calc(100% - 30px);
  100. float: left;
  101. padding-bottom: 15px;
  102. border-bottom: 1px solid #F6F6F6;
  103. margin: 0 15px 15px 15px;
  104. .message-head {
  105. width: 50px;
  106. height: 50px;
  107. object-fit: cover;
  108. float: left;
  109. border-radius: 50%;
  110. overflow: hidden;
  111. }
  112. .message-info-box {
  113. width: calc(100% - 75px);
  114. float: right;
  115. .message-name {
  116. width: 50%;
  117. height: 30px;
  118. float: left;
  119. font-size: 15px;
  120. font-family: PingFang SC;
  121. color: #333333;
  122. line-height: 30px;
  123. overflow: hidden;
  124. text-overflow: ellipsis;
  125. white-space: nowrap;
  126. }
  127. .message-date {
  128. width: 50%;
  129. height: 30px;
  130. float: left;
  131. font-size: 12px;
  132. font-family: PingFang SC;
  133. color: #666666;
  134. text-align: right;
  135. line-height: 30px;
  136. overflow: hidden;
  137. text-overflow: ellipsis;
  138. white-space: nowrap;
  139. }
  140. .message-text {
  141. width: 100%;
  142. height: 20px;
  143. float: left;
  144. font-size: 12px;
  145. font-family: PingFang SC;
  146. color: #666666;
  147. line-height: 20px;
  148. overflow: hidden;
  149. text-overflow: ellipsis;
  150. white-space: nowrap;
  151. }
  152. .message-img-box {
  153. width: 100%;
  154. float: left;
  155. .message-img {
  156. width: 76px;
  157. height: 76px;
  158. object-fit: cover;
  159. float: left;
  160. margin: 0 10px 10px 0;
  161. }
  162. }
  163. }
  164. }
  165. }
  166. .message-handle {
  167. width: calc(100% - 30px);
  168. height: 40px;
  169. position: fixed;
  170. bottom: 20px;
  171. left: 15px;
  172. .handle-custom {
  173. background-color: #51A539;
  174. }
  175. }
  176. }
  177. </style>