quotationsSecond.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  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="loadImgSrcLocalhost(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="100" align="center">时间</uni-th>
  22. </uni-tr>
  23. <uni-tr v-for="(item, index) in quotationsList" :key="index">
  24. <uni-td align="center">{{ item.productName }}
  25. </uni-td>
  26. <uni-td align="center">
  27. <view class="name">{{ item.type }}</view>
  28. </uni-td>
  29. <uni-td align="center">{{ item.price }}
  30. </uni-td>
  31. <uni-td align="center">{{ item.createTime }}
  32. </uni-td>
  33. </uni-tr>
  34. </uni-table>
  35. </view>
  36. </view>
  37. </template>
  38. <script>
  39. import {listConfig,QuotationsList, listQuotations} from "@/api/quotations/quotations";
  40. import upload from '../../components/upload/index.vue'
  41. export default {
  42. components: {
  43. upload
  44. },
  45. data() {
  46. return {
  47. //父组件传值
  48. FatherType: '',
  49. //是否显示弹出层
  50. open: false,
  51. //悬浮按钮右对齐
  52. right: 'right',
  53. //悬浮按钮下对齐
  54. bottom: 'bottom',
  55. //分类列表
  56. categories: [
  57. // 这里是一级分类的数据
  58. ],
  59. // 行情列表
  60. quotationsList: [
  61. // 这里是列表的数据
  62. ],
  63. queryParams: {
  64. pageNum: 1,
  65. pageSize: 15,
  66. id: null,
  67. type: null,
  68. },
  69. //表单数据
  70. form: {},
  71. //分类树列表
  72. forms:{},
  73. imageList: []
  74. }
  75. },
  76. onPullDownRefresh() {
  77. this.queryParams.pageNum = 1;
  78. this.quotationsList = [];
  79. this.getList()
  80. },
  81. //上拉加载
  82. onReachBottom() {
  83. if (this.status === 'noMore') {
  84. return;
  85. }
  86. this.queryParams.pageNum++;
  87. this.getList();
  88. },
  89. onLoad(e) {
  90. this.FatherType = e.type;
  91. this.getList();
  92. },
  93. methods: {
  94. getList(row) {
  95. // 这里是获取列表的方法
  96. this.queryParams.type = this.FatherType
  97. listQuotations(this.queryParams).then(response => {
  98. if (this.queryParams.pageNum === 1) {
  99. this.quotationsList = this.dataFormat(response.rows)
  100. } else {
  101. this.quotationsList = this.quotationsList.concat(this.dataFormat(response.rows));
  102. }
  103. // 判断是否还有更多数据
  104. if (response.rows.length < this.queryParams.pageSize) {
  105. this.status = 'noMore'; // 没有更多数据
  106. } else {
  107. this.status = 'more'; // 还有更多数据
  108. }
  109. });
  110. this.forms.parentId = this.FatherType
  111. //获取分类树的方法
  112. QuotationsList(this.forms).then(response => {
  113. //取出response.rows中所有homeDisplay为1的数据
  114. this.categories = response.rows
  115. });
  116. uni.stopPullDownRefresh();
  117. },
  118. //格式化时间
  119. dataFormat(rows) {
  120. return rows.map(item => {
  121. let date = new Date(item.createTime);
  122. item.createTime = date.toLocaleDateString('zh-CN', {dateStyle: 'short'});
  123. return item;
  124. });
  125. },
  126. //根据分类id查询列表
  127. change(e) {
  128. this.queryParams.type = e.detail.index;
  129. listQuotations(this.queryParams).then(response => {
  130. this.quotationsList = response.rows.map(item => {
  131. let date = new Date(item.createTime);
  132. item.createTime = date.toLocaleDateString('zh-CN', {dateStyle: 'short'});
  133. return item;
  134. });
  135. });
  136. },
  137. updateImg(imgList) {
  138. this.imageList = imgList;
  139. }
  140. }
  141. }
  142. </script>
  143. <style>
  144. .grid-item-box {
  145. flex: 1;
  146. // position: relative;
  147. /* #ifndef APP-NVUE */
  148. display: flex;
  149. /* #endif */
  150. flex-direction: column;
  151. align-items: center;
  152. justify-content: center;
  153. padding: 0px 0;
  154. }
  155. .image {
  156. height: 100%;
  157. width: 100%;
  158. }
  159. </style>