quotations.vue 4.7 KB

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