ソースを参照

更改tabbar切换模式

daxu0403 7 年 前
コミット
0ea427e884

BIN
android/.gradle/4.10.2/fileHashes/fileHashes.bin


BIN
android/.gradle/4.10.2/fileHashes/fileHashes.lock


BIN
android/.gradle/4.10.2/taskHistory/taskHistory.bin


BIN
android/.gradle/4.10.2/taskHistory/taskHistory.lock


BIN
android/.gradle/buildOutputCleanup/buildOutputCleanup.lock


+ 21 - 22
lib/pages/my_page.dart

@@ -23,36 +23,35 @@ class _MyPageState extends State < MyPage > with AutomaticKeepAliveClientMixin {
 
   bool check = false;
   String _siteName = "请选择站点";
-  List<String> stationList = [];
+  List < String > stationList = [];
   Station stationObj;
-  String name='物流';
+  String name = '物流';
   @override
   bool get wantKeepAlive => true;
-  
+
   @override
   void initState() {
     // TODO: implement initState
     super.initState();
-    getStationList().then((resp){
-      if(resp.success && resp.code==1){
+    getStationList().then((resp) {
+      if (resp.success && resp.code == 1) {
         stationObj = resp;
-        List<String> tempList = [];
-        for(int i=0;i<stationObj.data.length;i++){
+        List < String > tempList = [];
+        for (int i = 0; i < stationObj.data.length; i++) {
           tempList.add(stationObj.data[i].name.toString());
         }
-        getKey('nickName').then((value){
+        getKey('nickName').then((value) {
           setState(() {
             stationList = tempList;
             name = value;
+            _siteName = tempList[0];
+          });
         });
-        });
-        setState(() {
-            stationList = tempList;
-        });
-      }else{
+        setKey('stationId', stationObj.data[0].id.toString());
+      } else {
 
       }
-      
+
     });
   }
 
@@ -325,18 +324,18 @@ class _MyPageState extends State < MyPage > with AutomaticKeepAliveClientMixin {
           ],
         )
       ),
-      onTap: (){
-         showDialog < Null > (
+      onTap: () {
+        showDialog < Null > (
           context: context, //BuildContext对象
           barrierDismissible: false,
           builder: (BuildContext context) {
             return new LoadingDialog( //调用对话框
-              text:'确认退出?',childCallback: (val){
-                if(val){
-                    Navigator.pushReplacement(context, MaterialPageRoute(builder: (context){
-                        return LoginPage();
-                      }));
-                }else{
+              text: '确认退出?', childCallback: (val) {
+                if (val) {
+                  Navigator.pushReplacement(context, MaterialPageRoute(builder: (context) {
+                    return LoginPage();
+                  }));
+                } else {
                   return;
                 }
               },

+ 35 - 19
lib/pages/order_taking_page.dart

@@ -19,17 +19,39 @@ class _OrderTakingPageState extends State < OrderTakingPage > with AutomaticKeep
 
   ScrollController _scrollController = ScrollController(); //初始化滚动轴监控对象
   List listObj = [];
-
-
+  List lineList=[];
+   List<PopupMenuEntry<String>> widgets=[];
   @override
   void initState() {
-    // TODO: implement initState
     super.initState();
     getOrderList().then((resp) {
       setState(() {
         listObj = resp.orderList;
       });
     });
+    getKey('stationId').then((value){
+      getLineFromStation(value).then((resp){
+        if(resp.success && resp.code==1){
+          setState(() {
+            lineList = resp.data;
+          });
+          List<PopupMenuEntry<String>> tempWidgets = [];
+          for(int i=0;i<lineList.length;i++){
+            tempWidgets.add(
+              PopupMenuItem<String>(
+                value: lineList[i].name,
+                child: Text(lineList[i].name,)
+              )
+            );
+          }
+          print(lineList.length);
+          setState(() {
+            widgets =tempWidgets;
+          });
+          print(widgets.length);
+        }
+      });
+    });
     _scrollController.addListener(() {
       if (_scrollController.position.pixels == _scrollController.position.maxScrollExtent) {
         print("滑到底部了");
@@ -49,7 +71,6 @@ class _OrderTakingPageState extends State < OrderTakingPage > with AutomaticKeep
 
   @override
   void dispose() {
-    // TODO: implement dispose
     super.dispose();
     _scrollController.dispose();
     print('接单页listView滚动监听销毁了');
@@ -66,25 +87,20 @@ class _OrderTakingPageState extends State < OrderTakingPage > with AutomaticKeep
           backgroundColor: Color.fromRGBO(64, 98, 254, 1),
           actions: < Widget > [
             Container(
-              child: PopupMenuButton < String > (
+              child: PopupMenuButton(
                 icon: Icon(Icons.add_circle_outline),
                 offset: Offset(0, 60),
                 padding: EdgeInsets.zero,
                 //child: IconButton(icon: Image.asset('lib/images/icon_shaixuan.png', scale: 1.8, ),onPressed: (){},),
-                itemBuilder: (BuildContext context) => < PopupMenuEntry < String >> [
-                  PopupMenuItem < String > (
-                    child: Text("hahahahahh"),
-                  ),
-                  PopupMenuDivider(height: 1.0),
-                  PopupMenuItem < String > (
-                    child: Text("hahahahahh"),
-                  ),
-                  PopupMenuDivider(height: 1.0),
-                  PopupMenuItem < String > (
-                    child: Text("hahahahahh"),
-                  ),
-                  PopupMenuDivider(height: 1.0),
-                ]
+                itemBuilder: (BuildContext context){
+                  return widgets;
+                  // <PopupMenuEntry<String>>[
+                  //    PopupMenuItem<String>(
+                  //     value: '1111',
+                  //     child: Text('lineList[0].name',)
+                  //   )
+                  // ];
+                }
               )
             ),
           ],

+ 9 - 1
lib/util/api.dart

@@ -74,9 +74,17 @@ Future getOrderList() async {
   return orderList;
 }
 
-//获取所站点
+//获取所站点
 Future getStationList() async{
   var response = await Http().get('app/station/station_list');
   var stationList = Station.fromJson(response);
   return stationList;
+}
+
+//根据站点获取线路
+Future getLineFromStation(String stationId)async{
+  var response  =await Http().get('app/station/station_line_all_list',data:{'stationId':stationId});
+  var lineList = StationLine.fromJson(response);
+  print(lineList.toString());
+  return lineList;
 }

+ 38 - 0
lib/util/models.dart

@@ -152,4 +152,42 @@ class StationList{
       status: json['status']
     );
   }
+}
+
+//站点线路
+class StationLine{
+  bool success;
+  int code;
+  String msg;
+  List<LineObj> data;
+
+  StationLine({this.success,this.code,this.msg,this.data});
+
+  factory StationLine.fromJson(Map<String,dynamic> json){
+    var list = json['data'] as List;
+    List<LineObj> tempList = list.map((i)=>LineObj.fromJson(i)).toList();
+
+    return StationLine(
+      success: json['success'],
+      code:json['code'],
+      msg:json['msg'],
+      data:tempList
+    );
+  }
+}
+
+class LineObj{
+  String code;
+  int id;
+  String name;
+
+  LineObj({this.code,this.name,this.id});
+
+  factory LineObj.fromJson(Map<String,dynamic> json){
+    return LineObj(
+      code:json['code'],
+      id:json['id'],
+      name:json['name']
+    );
+  }
 }