瀏覽代碼

切换路线请求添加限制条件

daxu0403 7 年之前
父節點
當前提交
8c3bffc892
共有 1 個文件被更改,包括 7 次插入4 次删除
  1. 7 4
      lib/pages/order_taking_page.dart

+ 7 - 4
lib/pages/order_taking_page.dart

@@ -26,6 +26,7 @@ class _OrderTakingPageState extends State < OrderTakingPage > with AutomaticKeep
   List < bool > checkStatusList = [];
   bool showLineStatus = true;
   String lineIdStr = '';
+  String oldLineIdStr = '';
   int page = 1;
   @override
   void initState() {
@@ -290,10 +291,6 @@ class _OrderTakingPageState extends State < OrderTakingPage > with AutomaticKeep
   }
 
   void switchLine(BuildContext context) { //切换线路
-    setState(() {
-      orderList = [];
-      hasNextPage =true;
-    });
     lineIdStr = '';
     for (int i = 0; i < checkStatusList.length; i++) {
       if (checkStatusList[i]) {
@@ -301,6 +298,11 @@ class _OrderTakingPageState extends State < OrderTakingPage > with AutomaticKeep
       }
     }
     lineIdStr = lineIdStr.substring(0, lineIdStr.length - 1);
+    if(oldLineIdStr==lineIdStr) return;
+    setState(() {
+      orderList = [];
+      hasNextPage =true;
+    });
     getOrderList(stationId, lineIdStr, page).then((resp) {
       if(isNotError(context, resp)){
           OrderListObj tempObj =OrderListObj.fromJson(resp.data);
@@ -308,6 +310,7 @@ class _OrderTakingPageState extends State < OrderTakingPage > with AutomaticKeep
             orderList = tempObj.data.items;
             hasNextPage = tempObj.data.hasNextPage;
           });
+          oldLineIdStr =lineIdStr;
       }
     });
   }