Ver Fonte

接单页路线列表状态保存

daxu0403 há 7 anos atrás
pai
commit
2659c62244
1 ficheiros alterados com 26 adições e 12 exclusões
  1. 26 12
      lib/pages/order_taking_page.dart

+ 26 - 12
lib/pages/order_taking_page.dart

@@ -33,14 +33,28 @@ class _OrderTakingPageState extends State < OrderTakingPage > with AutomaticKeep
   void initState() {
     super.initState();
     getLine().then((childValue) {
-      getOrderList(lineIdStr, page).then((resp) {
-        if (isNotError(context, resp)) {
-          setState(() {
-            orderList = OrderListObj.fromJson(resp.data).data.items;
-            hasNextPage = OrderListObj.fromJson(resp.data).data.hasNextPage;
+      getKey('lineIdStr').then((value) {
+        if (value != null) {
+          getOrderList(value, page).then((resp) {
+            if (isNotError(context, resp)) {
+              setState(() {
+                orderList = OrderListObj.fromJson(resp.data).data.items;
+                hasNextPage = OrderListObj.fromJson(resp.data).data.hasNextPage;
+              });
+            }
+          });
+        } else {
+          getOrderList(lineIdStr, page).then((resp) {
+            if (isNotError(context, resp)) {
+              setState(() {
+                orderList = OrderListObj.fromJson(resp.data).data.items;
+                hasNextPage = OrderListObj.fromJson(resp.data).data.hasNextPage;
+              });
+            }
           });
         }
       });
+
     });
     _scrollController.addListener(() {
       if (!showLineStatus) {
@@ -188,16 +202,16 @@ class _OrderTakingPageState extends State < OrderTakingPage > with AutomaticKeep
                     color: Color.fromRGBO(0, 0, 0, 0.7),
                     borderRadius: BorderRadius.all(Radius.circular(4.0))
                   ),
-                  child:lineList.length==0?Center(
-                    child:  Container(
+                  child: lineList.length == 0 ? Center(
+                    child: Container(
                       width: ScreenUtil.getInstance().setWidth(50),
                       height: ScreenUtil.getInstance().setHeight(50),
                       child: CircularProgressIndicator(
-                        
+
                       )
                     ),
-                  ):
-                   ListView.builder(
+                  ) :
+                  ListView.builder(
                     itemCount: lineList.length,
                     itemBuilder: (BuildContext context, int index) { //itemBuilder实际上就是一个map的循环
                       if (index < lineList.length) {
@@ -225,7 +239,7 @@ class _OrderTakingPageState extends State < OrderTakingPage > with AutomaticKeep
           children: < Widget > [
             Padding(
               padding: EdgeInsets.only(right: 10),
-              child: checked ? Icon(Icons.check, color: Colors.white, ) : Icon(Icons.check,color: Color.fromRGBO(0, 0, 0, 0.0,)),
+              child: checked ? Icon(Icons.check, color: Colors.white, ) : Icon(Icons.check, color: Color.fromRGBO(0, 0, 0, 0.0, )),
             ),
             Expanded(
               flex: 1,
@@ -328,7 +342,7 @@ class _OrderTakingPageState extends State < OrderTakingPage > with AutomaticKeep
         hasNextPage = false;
       });
       oldLineIdStr = lineIdStr;
-       setKey('lineIdStr', lineIdStr);
+      setKey('lineIdStr', lineIdStr);
       return;
     }
     lineIdStr = lineIdStr.substring(0, lineIdStr.length - 1);