lists.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. <template>
  2. <view>
  3. <!-- 顶部导航 -->
  4. <fa-navbar title="列表"></fa-navbar>
  5. <!-- 搜索 -->
  6. <view class="u-p-20 u-bg-white u-flex u-col-center">
  7. <view class="u-flex-1">
  8. <fa-search :mode="2" :custom="true" @change="search"></fa-search>
  9. </view>
  10. <view class="u-p-l-15 u-p-r-5 u-flex u-col-center" v-if="is_show">
  11. <fa-orderby-select :orderList="orderList" :filterList="filterList" showField="title" :multiple="true" @change="goOrderBy"></fa-orderby-select>
  12. </view>
  13. </view>
  14. <view class="u-p-30">
  15. <view class="form-list">
  16. <view class="item u-border-top u-p-30 u-m-b-30 u-bg-white" v-for="(item, index) in list" :key="index" @click="goDetail(item.id)">
  17. <view class="u-m-b-10 u-text-weight title"><text v-text="item.title ? item.title : item.name"></text></view>
  18. <view class="u-line-3 u-tips-color">{{ item.content }}</view>
  19. <view class="u-flex u-flex-wrap u-m-t-30">
  20. <block v-if="item.images">
  21. <view :class="item.images.length == 1 ? 'image' : 'images'" v-for="(res, ik) in item.images" :key="ik">
  22. <u-image width="100%" height="100%" :src="res"></u-image>
  23. </view>
  24. </block>
  25. <block v-else>
  26. <view :class="item.image.length == 1 ? 'image' : 'images'" v-for="(res, ik) in item.image" :key="ik">
  27. <u-image width="100%" height="100%" :src="res"></u-image>
  28. </view>
  29. </block>
  30. </view>
  31. <view class="u-flex u-font-28">{{ item.createtime | timeFrom }}</view>
  32. </view>
  33. </view>
  34. </view>
  35. <!-- 加载更多 -->
  36. <view class="u-p-b-30" v-if="list.length"><u-loadmore bg-color="#f4f6f8" :status="has_more ? status : 'nomore'" /></view>
  37. <!-- 空数据 -->
  38. <view class="fa-empty" v-if="!list.length"><u-empty></u-empty></view>
  39. <!-- 回到顶部 -->
  40. <u-back-top :scroll-top="scrollTop" :icon-style="{ color: theme.bgColor }" :custom-style="{ backgroundColor: lightColor }"></u-back-top>
  41. <!-- 发布留言 -->
  42. <fa-add :icon-style="{ color: theme.bgColor }" :custom-style="{ backgroundColor: lightColor }" @click="publish"></fa-add>
  43. <!-- 底部导航 -->
  44. <fa-tabbar></fa-tabbar>
  45. </view>
  46. </template>
  47. <script>
  48. export default {
  49. onLoad(e) {
  50. let query = this.$Route.query || e || {};
  51. this.diyname = query.diyname || '';
  52. this.getformList();
  53. },
  54. data() {
  55. return {
  56. diyname: '',
  57. is_update: false,
  58. scrollTop: 0,
  59. list: [],
  60. status: 'loadmore',
  61. has_more: false,
  62. page: 1,
  63. orderList: [],
  64. filterList: [],
  65. is_show: false,
  66. query:{},
  67. keyword:''
  68. };
  69. },
  70. methods: {
  71. getformList() {
  72. let data = {
  73. page: this.page,
  74. diyname: this.diyname,
  75. keyword:this.keyword,
  76. ...this.query
  77. };
  78. this.$api.formList(data).then(res => {
  79. if (res.code) {
  80. if (this.is_update) {
  81. this.list = [];
  82. this.is_update = false;
  83. }
  84. let {orderList,filterList,pageList} = res.data;
  85. this.orderList = orderList;
  86. this.filterList = filterList;
  87. this.has_more = pageList.current_page<pageList.last_page;
  88. this.list = [...this.list, ...pageList.data];
  89. this.is_show = true;
  90. } else {
  91. this.$u.toast(res.msg);
  92. }
  93. });
  94. },
  95. goOrderBy(e) {
  96. this.query = e;
  97. this.page = 1;
  98. this.is_update = true;
  99. this.getformList();
  100. },
  101. search(e){
  102. this.keyword = e;
  103. this.page = 1;
  104. this.is_update = true;
  105. this.getformList();
  106. },
  107. goDetail(id) {
  108. this.$Router.push({
  109. path: '/pages/diyform/detail',
  110. query: { id: id, diyname: this.diyname }
  111. });
  112. },
  113. publish() {
  114. this.$Router.push({
  115. path: '/pages/diyform/diyform',
  116. query: { diyname: this.diyname }
  117. });
  118. }
  119. },
  120. onPageScroll(e) {
  121. this.scrollTop = e.scrollTop;
  122. },
  123. onReachBottom() {
  124. if (this.has_more) {
  125. this.status = 'loading';
  126. this.page++;
  127. this.getformList();
  128. }
  129. }
  130. };
  131. </script>
  132. <style lang="scss">
  133. page {
  134. background-color: #f4f6f8;
  135. }
  136. .form-list {
  137. width: 100%;
  138. box-shadow: 0 0 5rpx rgba(0, 134, 243, 0.1);
  139. border-radius: 5rpx;
  140. .item {
  141. margin-bottom: 2rpx;
  142. .images {
  143. width: 30%;
  144. height: 200rpx;
  145. padding-bottom: 30rpx;
  146. &:nth-child(3n-1) {
  147. margin-left: 30rpx;
  148. margin-right: 30rpx;
  149. }
  150. }
  151. .image {
  152. width: 100%;
  153. height: 300rpx;
  154. padding-bottom: 30rpx;
  155. image {
  156. border-radius: 10rpx;
  157. width: 100%;
  158. height: 100%;
  159. }
  160. }
  161. }
  162. }
  163. </style>