quotations.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. <template>
  2. <view>
  3. <view>
  4. <scroll-view class="scroll-view_H" scroll-x="true" @scroll="scroll" scroll-left="120">
  5. <uni-grid :column="5" @change="change" showBorder="false" square="false">
  6. <uni-grid-item v-for="item in categories" :index="item.id">
  7. <view class="grid-item-box">
  8. <image class="image" :src="loadImgSrc(item.icon)" mode="aspectFit"></image>
  9. <text class="text">{{ item.productName }}</text>
  10. </view>
  11. </uni-grid-item>
  12. </uni-grid>
  13. </scroll-view>
  14. </view>
  15. <view class="uni-container">
  16. <uni-table>
  17. <uni-tr>
  18. <uni-th width="80" align="center">地区</uni-th>
  19. <uni-th width="80" align="center">名称</uni-th>
  20. <uni-th width="80" align="center">类型</uni-th>
  21. <uni-th width="80" align="center">价格</uni-th>
  22. <uni-th width="100" align="center">时间</uni-th>
  23. </uni-tr>
  24. <uni-tr v-for="(item, index) in quotationsList" :key="index">
  25. <uni-td align="center">{{ item.area+item.address }}
  26. </uni-td>
  27. <uni-td align="center">{{ item.productName }}
  28. </uni-td>
  29. <uni-td align="center">
  30. <view class="name">{{ item.type }}</view>
  31. </uni-td>
  32. <uni-td align="center">{{ item.price }}
  33. </uni-td>
  34. <uni-td align="center">{{ item.createTime }}
  35. </uni-td>
  36. </uni-tr>
  37. </uni-table>
  38. <uni-load-more :status="status" :content-text="contentText"/>
  39. <uni-fab ref="fab" :horizontal="right" :vertical="bottom"
  40. @fabClick="fabClick()"/>
  41. </view>
  42. </view>
  43. </template>
  44. <script>
  45. import {listConfig, listQuotations} from "@/api/quotations/quotations";
  46. import upload from '../../components/upload/index.vue'
  47. export default {
  48. components: {
  49. upload
  50. },
  51. data() {
  52. return {
  53. //是否显示弹出层
  54. open: false,
  55. //悬浮按钮右对齐
  56. right: 'right',
  57. //悬浮按钮下对齐
  58. bottom: 'bottom',
  59. //分类列表
  60. categories: [
  61. // 这里是一级分类的数据
  62. ],
  63. // 行情列表
  64. quotationsList: [
  65. // 这里是列表的数据
  66. ],
  67. //查询参数
  68. queryParams: {
  69. pageNum: 1,
  70. pageSize: 15,
  71. id: null,
  72. status:"1",
  73. },
  74. //加载更多
  75. status: 'more',
  76. contentText: {
  77. contentdown: '查看更多',
  78. contentrefresh: '加载中',
  79. contentnomore: '没有更多'
  80. },
  81. //表单数据
  82. form: {},
  83. imageList: []
  84. }
  85. },
  86. onPullDownRefresh() {
  87. this.queryParams.pageNum = 1;
  88. this.quotationsList = [];
  89. this.getList()
  90. },
  91. //上拉加载
  92. onReachBottom() {
  93. if (this.status === 'noMore') {
  94. return;
  95. }
  96. this.queryParams.pageNum++;
  97. this.getList();
  98. },
  99. onLoad() {
  100. this.getList();
  101. },
  102. methods: {
  103. getList(row) {
  104. // 这里是获取列表的方法
  105. listQuotations(this.queryParams).then(response => {
  106. if (this.queryParams.pageNum === 1) {
  107. this.quotationsList = this.dataFormat(response.rows)
  108. } else {
  109. this.quotationsList = this.quotationsList.concat(this.dataFormat(response.rows));
  110. }
  111. // 判断是否还有更多数据
  112. if (response.rows.length < this.queryParams.pageSize) {
  113. this.status = 'noMore'; // 没有更多数据
  114. } else {
  115. this.status = 'more'; // 还有更多数据
  116. }
  117. });
  118. //获取分类树的方法
  119. listConfig().then(response => {
  120. this.categories = response.data.quotations.filter(item => item.homeDisplay === "1");
  121. });
  122. uni.stopPullDownRefresh();
  123. },
  124. dataFormat(rows) {
  125. return rows.map(item => {
  126. let date = new Date(item.createTime);
  127. item.createTime = date.toLocaleDateString('zh-CN', {dateStyle: 'short'});
  128. return item;
  129. });
  130. },
  131. //根据分类id查询列表
  132. change(e) {
  133. console.log(e)
  134. const type = e.detail.index;
  135. uni.navigateTo({
  136. url: `../quotations/quotationsSecond?type=${type}`
  137. });
  138. },
  139. //悬浮按钮点击事件
  140. fabClick() {
  141. uni.navigateTo({
  142. url: '../quotations/quotationsForm'
  143. });
  144. },
  145. updateImg(imgList) {
  146. this.imageList = imgList;
  147. }
  148. }
  149. }
  150. </script>
  151. <style>
  152. .grid-item-box {
  153. flex: 1;
  154. // position: relative;
  155. /* #ifndef APP-NVUE */
  156. display: flex;
  157. /* #endif */
  158. flex-direction: column;
  159. align-items: center;
  160. justify-content: center;
  161. padding: 0 0;
  162. }
  163. .image {
  164. height: 100%;
  165. width: 100%;
  166. }
  167. .uni-container{
  168. align-items: center;
  169. }
  170. </style>