quotations.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  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. },
  73. //加载更多
  74. status: 'more',
  75. contentText: {
  76. contentdown: '查看更多',
  77. contentrefresh: '加载中',
  78. contentnomore: '没有更多'
  79. },
  80. //表单数据
  81. form: {},
  82. imageList: []
  83. }
  84. },
  85. onPullDownRefresh() {
  86. this.queryParams.pageNum = 1;
  87. this.quotationsList = [];
  88. this.getList()
  89. },
  90. //上拉加载
  91. onReachBottom() {
  92. if (this.status === 'noMore') {
  93. return;
  94. }
  95. this.queryParams.pageNum++;
  96. this.getList();
  97. },
  98. onLoad() {
  99. this.getList();
  100. },
  101. methods: {
  102. getList(row) {
  103. // 这里是获取列表的方法
  104. listQuotations(this.queryParams).then(response => {
  105. if (this.queryParams.pageNum === 1) {
  106. this.quotationsList = this.dataFormat(response.rows)
  107. } else {
  108. this.quotationsList = this.quotationsList.concat(this.dataFormat(response.rows));
  109. }
  110. // 判断是否还有更多数据
  111. if (response.rows.length < this.queryParams.pageSize) {
  112. this.status = 'noMore'; // 没有更多数据
  113. } else {
  114. this.status = 'more'; // 还有更多数据
  115. }
  116. });
  117. //获取分类树的方法
  118. listConfig().then(response => {
  119. this.categories = response.data.quotations.filter(item => item.homeDisplay === "1");
  120. });
  121. uni.stopPullDownRefresh();
  122. },
  123. dataFormat(rows) {
  124. return rows.map(item => {
  125. let date = new Date(item.createTime);
  126. item.createTime = date.toLocaleDateString('zh-CN', {dateStyle: 'short'});
  127. return item;
  128. });
  129. },
  130. //根据分类id查询列表
  131. change(e) {
  132. console.log(e)
  133. const type = e.detail.index;
  134. uni.navigateTo({
  135. url: `../quotations/quotationsSecond?type=${type}`
  136. });
  137. },
  138. //悬浮按钮点击事件
  139. fabClick() {
  140. uni.navigateTo({
  141. url: '../quotations/quotationsForm'
  142. });
  143. },
  144. updateImg(imgList) {
  145. this.imageList = imgList;
  146. }
  147. }
  148. }
  149. </script>
  150. <style>
  151. .grid-item-box {
  152. flex: 1;
  153. // position: relative;
  154. /* #ifndef APP-NVUE */
  155. display: flex;
  156. /* #endif */
  157. flex-direction: column;
  158. align-items: center;
  159. justify-content: center;
  160. padding: 0 0;
  161. }
  162. .image {
  163. height: 100%;
  164. width: 100%;
  165. }
  166. .uni-container{
  167. align-items: center;
  168. }
  169. </style>