messageList.vue 4.5 KB

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