刘浩男 1 year ago
parent
commit
7262295b57
3 changed files with 116 additions and 33 deletions
  1. 24 1
      pages.json
  2. 53 11
      pages/quotations/quotations.vue
  3. 39 21
      pages/quotations/quotationsSecond.vue

+ 24 - 1
pages.json

@@ -237,12 +237,35 @@
 			"style": {
 				"usingComponents": {},
 				"navigationBarBackgroundColor": "#07c160",
+				"enablePullDownRefresh": true,
+				"onReachBottomDistance" : 5,
 				"navigationBarTextStyle": "white",
 				"navigationBarTitleText": "行情"
 
 
 			}
-		}, {
+		},
+		{
+			"path": "pages/quotations/quotationsForm",
+			"style": {
+				"usingComponents": {},
+				"navigationBarBackgroundColor": "#07c160",
+				"navigationBarTextStyle": "white",
+				"navigationBarTitleText": "新增行情列表"
+			}
+		},
+		{
+			"path": "pages/quotations/quotationsSecond",
+			"style": {
+				"usingComponents": {},
+				"navigationBarBackgroundColor": "#07c160",
+				"enablePullDownRefresh": true,
+				"onReachBottomDistance" : 5,
+				"navigationBarTextStyle": "white",
+				"navigationBarTitleText": "行情列表"
+			}
+		},
+		{
 			"path": "pages/toGovernmentList/toGovernmentList",
 			"style": {
 				"usingComponents": {},

+ 53 - 11
pages/quotations/quotations.vue

@@ -15,12 +15,15 @@
     <view class="uni-container">
       <uni-table>
         <uni-tr>
+          <uni-th width="80" align="center">地区</uni-th>
           <uni-th width="80" align="center">名称</uni-th>
           <uni-th width="80" align="center">类型</uni-th>
           <uni-th width="80" align="center">价格</uni-th>
           <uni-th width="100" align="center">时间</uni-th>
         </uni-tr>
         <uni-tr v-for="(item, index) in quotationsList" :key="index">
+          <uni-td align="center">{{ item.area+item.address }}
+          </uni-td>
           <uni-td align="center">{{ item.productName }}
           </uni-td>
           <uni-td align="center">
@@ -32,6 +35,7 @@
           </uni-td>
         </uni-tr>
       </uni-table>
+      <uni-load-more :status="status" :content-text="contentText"/>
       <uni-fab ref="fab" :horizontal="right" :vertical="bottom"
                @fabClick="fabClick()"/>
     </view>
@@ -64,31 +68,66 @@ export default {
       ],
       //查询参数
       queryParams: {
-        // pageNum: 1,
-        // pageSize: 10,
+        pageNum: 1,
+        pageSize: 15,
         id: null,
       },
+      //加载更多
+      status: 'more',
+      contentText: {
+        contentdown: '查看更多',
+        contentrefresh: '加载中',
+        contentnomore: '没有更多'
+      },
+
       //表单数据
       form: {},
       imageList: []
     }
   },
-  created() {
+  onPullDownRefresh() {
+    this.queryParams.pageNum = 1;
+    this.quotationsList = [];
+    this.getList()
+  },
+  //上拉加载
+  onReachBottom() {
+    if (this.status === 'noMore') {
+      return;
+    }
+    this.queryParams.pageNum++;
+    this.getList();
+  },
+  onLoad() {
     this.getList();
   },
   methods: {
     getList(row) {
       // 这里是获取列表的方法
-      listQuotations().then(response => {
-        this.quotationsList = response.rows.map(item => {
-          let date = new Date(item.createTime);
-          item.createTime = date.toLocaleDateString('zh-CN', {dateStyle: 'short'});
-          return item;
-        });
+      listQuotations(this.queryParams).then(response => {
+        if (this.queryParams.pageNum === 1) {
+          this.quotationsList = this.dataFormat(response.rows)
+        } else {
+          this.quotationsList = this.quotationsList.concat(this.dataFormat(response.rows));
+        }
+        // 判断是否还有更多数据
+        if (response.rows.length < this.queryParams.pageSize) {
+          this.status = 'noMore'; // 没有更多数据
+        } else {
+          this.status = 'more'; // 还有更多数据
+        }
       });
       //获取分类树的方法
       listConfig().then(response => {
-        this.categories = response.data.quotations;
+        this.categories = response.data.quotations.filter(item => item.homeDisplay === "1");
+      });
+      uni.stopPullDownRefresh();
+    },
+    dataFormat(rows) {
+      return rows.map(item => {
+        let date = new Date(item.createTime);
+        item.createTime = date.toLocaleDateString('zh-CN', {dateStyle: 'short'});
+        return item;
       });
     },
     //根据分类id查询列表
@@ -123,13 +162,16 @@ export default {
   flex-direction: column;
   align-items: center;
   justify-content: center;
-  padding: 0px 0;
+  padding: 0 0;
 }
 
 .image {
   height: 100%;
   width: 100%;
 }
+.uni-container{
+  align-items: center;
+}
 
 
 </style>

+ 39 - 21
pages/quotations/quotationsSecond.vue

@@ -32,8 +32,6 @@
           </uni-td>
         </uni-tr>
       </uni-table>
-      <uni-fab ref="fab" :horizontal="right" :vertical="bottom"
-               @fabClick="fabClick()"/>
     </view>
   </view>
 </template>
@@ -64,11 +62,11 @@ export default {
       quotationsList: [
         // 这里是列表的数据
       ],
-      //查询参数
       queryParams: {
-        // pageNum: 1,
-        // pageSize: 10,
+        pageNum: 1,
+        pageSize: 15,
         id: null,
+        type: null,
       },
       //表单数据
       form: {},
@@ -77,6 +75,19 @@ export default {
       imageList: []
     }
   },
+  onPullDownRefresh() {
+    this.queryParams.pageNum = 1;
+    this.quotationsList = [];
+    this.getList()
+  },
+  //上拉加载
+  onReachBottom() {
+    if (this.status === 'noMore') {
+      return;
+    }
+    this.queryParams.pageNum++;
+    this.getList();
+  },
   onLoad(e) {
     this.FatherType = e.type;
     this.getList();
@@ -84,23 +95,36 @@ export default {
   methods: {
     getList(row) {
       // 这里是获取列表的方法
-      this.form.type = this.FatherType
-      listQuotations(this.form).then(response => {
-        this.quotationsList = response.rows.map(item => {
-          let date = new Date(item.createTime);
-          item.createTime = date.toLocaleDateString('zh-CN', {dateStyle: 'short'});
-          return item;
-        });
+      this.queryParams.type = this.FatherType
+      listQuotations(this.queryParams).then(response => {
+        if (this.queryParams.pageNum === 1) {
+          this.quotationsList = this.dataFormat(response.rows)
+        } else {
+          this.quotationsList = this.quotationsList.concat(this.dataFormat(response.rows));
+        }
+        // 判断是否还有更多数据
+        if (response.rows.length < this.queryParams.pageSize) {
+          this.status = 'noMore'; // 没有更多数据
+        } else {
+          this.status = 'more'; // 还有更多数据
+        }
       });
       this.forms.parentId = this.FatherType
       //获取分类树的方法
       QuotationsList(this.forms).then(response => {
         //取出response.rows中所有homeDisplay为1的数据
-        this.categories = response.rows.filter(item => item.homeDisplay === 1);
+        this.categories = response.rows
+      });
+      uni.stopPullDownRefresh();
+    },
+    //格式化时间
+    dataFormat(rows) {
+      return rows.map(item => {
+        let date = new Date(item.createTime);
+        item.createTime = date.toLocaleDateString('zh-CN', {dateStyle: 'short'});
+        return item;
       });
     },
-    //递归查询分类的父级
-
     //根据分类id查询列表
     change(e) {
       this.queryParams.type = e.detail.index;
@@ -112,12 +136,6 @@ export default {
         });
       });
     },
-    //悬浮按钮点击事件
-    fabClick() {
-      uni.navigateTo({
-        url: '../quotations/quotationsForm'
-      });
-    },
     updateImg(imgList) {
       this.imageList = imgList;
     }