Jelajahi Sumber

接单列表接口对接

daxu0403 7 tahun lalu
induk
melakukan
1664385afa

TEMPAT SAMPAH
android/.gradle/4.10.2/fileHashes/fileHashes.bin


TEMPAT SAMPAH
android/.gradle/4.10.2/fileHashes/fileHashes.lock


TEMPAT SAMPAH
android/.gradle/4.10.2/taskHistory/taskHistory.bin


TEMPAT SAMPAH
android/.gradle/4.10.2/taskHistory/taskHistory.lock


TEMPAT SAMPAH
android/.gradle/buildOutputCleanup/buildOutputCleanup.lock


+ 21 - 2
lib/pages/my_page/revise_password_page.dart

@@ -20,7 +20,7 @@ class _RevisePasswordPageState extends State < RevisePasswordPage > {
   String oldPassword = '';
   String newPassword = '';
   bool submitStatus = false;
-
+  bool loginStatus = true;
 
   @override
   Widget build(BuildContext context) {
@@ -82,7 +82,20 @@ class _RevisePasswordPageState extends State < RevisePasswordPage > {
                         borderRadius: BorderRadius.circular(4),
                       ),
                       child: Center(
-                        child: Text('确认', style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(36), color: Colors.white)),
+                        child:Row(
+                          mainAxisAlignment: MainAxisAlignment.center,
+                          children: <Widget>[
+                              Offstage(
+                                offstage: loginStatus,
+                                child: SizedBox(
+                                  width: ScreenUtil.getInstance().setWidth(45),
+                                  height: ScreenUtil.getInstance().setHeight(45),
+                                  child: Image.asset('lib/images/loading.gif'),
+                                ),
+                              ),
+                             Text('登录', style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(36), color: Colors.white)),
+                          ],
+                        )
                       ),
 
                     ),
@@ -101,6 +114,9 @@ class _RevisePasswordPageState extends State < RevisePasswordPage > {
                               );
                             });
                         } else {
+                          setState(() {
+                            loginStatus = false;
+                          });
                           updataPasswrod(oldPassword, newPassword).then((resp){
                             if(resp.success && resp.code==1){
                               setKey('password', newPassword);
@@ -111,6 +127,9 @@ class _RevisePasswordPageState extends State < RevisePasswordPage > {
                                   return new LoadingDialog( //调用对话框
                                     text: '修改成功', childCallback: (val) {
                                       if(val){
+                                        setState(() {
+                                          loginStatus = true;
+                                        });
                                         Navigator.pop(context);
                                       }
                                     },

+ 70 - 58
lib/pages/order_taking_page.dart

@@ -18,27 +18,34 @@ class OrderTakingPage extends StatefulWidget {
 class _OrderTakingPageState extends State < OrderTakingPage > with AutomaticKeepAliveClientMixin {
 
   ScrollController _scrollController = ScrollController(); //初始化滚动轴监控对象
-  List listObj = [];
+  List < OrderList > orderList = []; //订单列表
+  bool hasNextPage = true;
   List lineList = [];
   String stationId;
   List < bool > checkStatusList = [];
   bool showLineStatus = true;
+  String lineIdStr = '';
+  int page = 1;
   @override
   void initState() {
     super.initState();
-    // getOrderList().then((resp) {
-    //   setState(() {
-    //     listObj = resp.orderList;
-    //   });
-    // });
-    getKey('stationId').then((value){
+    getKey('stationId').then((value) {
       setState(() {
         stationId = value;
       });
-      getLine(value);
+      getLine(value).then((childValue) {
+        getOrderList(value, lineIdStr, page).then((resp) {
+          if (resp.success && resp.code == 1) {
+            setState(() {
+              orderList = resp.data.items;
+              hasNextPage = resp.data.hasNextPage;
+            });
+          }
+        });
+      });
     });
     _scrollController.addListener(() {
-      if(!showLineStatus){
+      if (!showLineStatus) {
         setState(() {
           showLineStatus = true;
         });
@@ -51,26 +58,28 @@ class _OrderTakingPageState extends State < OrderTakingPage > with AutomaticKeep
         //   });
         // });
       }
-      //print(_scrollController.position.pixels);
     });
   }
 
 
-  void getLine(value){
-    getLineFromStation(value).then((resp) {
+  Future getLine(value) async {
+    await getLineFromStation(value).then((resp) {
       if (resp.success && resp.code == 1) {
         setState(() {
           checkStatusList = [];
           lineList = resp.data;
-          for(int i=0;i<lineList.length;i++){
-            if(i==0){
-              checkStatusList.add(true);
-            }else{
-              checkStatusList.add(false);
+          for (int i = 0; i < lineList.length; i++) {
+            checkStatusList.add(true);
+            if (i < lineList.length - 1) {
+              lineIdStr += lineList[i].id.toString() + ',';
+            } else {
+              lineIdStr += lineList[i].id.toString();
             }
           }
           stationId = value;
         });
+        print(lineIdStr);
+        return lineIdStr;
       }
     });
   }
@@ -96,7 +105,7 @@ class _OrderTakingPageState extends State < OrderTakingPage > with AutomaticKeep
                 });
                 if (!showLineStatus) {
                   getKey('stationId').then((value) {
-                    if(stationId!=value){
+                    if (stationId != value) {
                       getLine(value);
                     }
                   });
@@ -106,31 +115,36 @@ class _OrderTakingPageState extends State < OrderTakingPage > with AutomaticKeep
         ),
         body: Stack(
           children: < Widget > [
-            InkWell(
-              child: Container(
-                padding: EdgeInsets.fromLTRB(ScreenUtil.getInstance().setWidth(20), ScreenUtil.getInstance().setWidth(20), ScreenUtil.getInstance().setWidth(20), 0),
-                decoration: BoxDecoration(
-                  color: Color.fromRGBO(246, 246, 254, 1)
-                ),
-                child: RefreshIndicator( //下拉刷新组件
-                  onRefresh: _onRefresh, //回调方法
+            RefreshIndicator(
+              onRefresh: _onRefresh, //回调方法
+              child: InkWell(
+                child: Container(
+                  padding: EdgeInsets.fromLTRB(ScreenUtil.getInstance().setWidth(20), ScreenUtil.getInstance().setWidth(20), ScreenUtil.getInstance().setWidth(20), 0),
+                  decoration: BoxDecoration(
+                    color: Color.fromRGBO(246, 246, 254, 1)
+                  ),
+
+
                   child: ListView.builder(
                     controller: _scrollController,
-                    itemCount: listObj.length + 1,
+                    itemCount: orderList.length + 1,
                     itemBuilder: (BuildContext context, int index) { //itemBuilder实际上就是一个map的循环
-                      if (index < listObj.length) {
-                        return OrderCardContainer(order: listObj[index], index: index, callback: (val) => deleteOrder(val));
+                      if (index < orderList.length) {
+                        return OrderCardContainer(order: orderList[index], index: index, callback: (val) => deleteOrder(val));
+                      }
+                      if (hasNextPage) {
+                        return _getMoreWidget();
                       }
-                      return _getMoreWidget();
                     },
                   )
+
                 ),
+                onTap: () {
+                  setState(() {
+                    showLineStatus = true;
+                  });
+                },
               ),
-              onTap: () {
-                setState(() {
-                  showLineStatus = true;
-                });
-              },
             ),
             Positioned(
               top: 0,
@@ -151,7 +165,7 @@ class _OrderTakingPageState extends State < OrderTakingPage > with AutomaticKeep
                     itemCount: lineList.length,
                     itemBuilder: (BuildContext context, int index) { //itemBuilder实际上就是一个map的循环
                       if (index < lineList.length) {
-                        return _lineWidget(lineList[index],index,checkStatusList[index]);
+                        return _lineWidget(lineList[index], index, checkStatusList[index]);
                       }
                     },
                   ),
@@ -164,7 +178,7 @@ class _OrderTakingPageState extends State < OrderTakingPage > with AutomaticKeep
     );
   }
 
-  Widget _lineWidget(LineObj lineObj,int index,bool checked) {
+  Widget _lineWidget(LineObj lineObj, int index, bool checked) {
     return InkWell(
       child: Container(
         height: ScreenUtil.getInstance().setHeight(80),
@@ -175,7 +189,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,
@@ -186,7 +200,7 @@ class _OrderTakingPageState extends State < OrderTakingPage > with AutomaticKeep
           ],
         ),
       ),
-      onTap: (){
+      onTap: () {
         setState(() {
           checkStatusList[index] = !checked;
         });
@@ -220,22 +234,20 @@ class _OrderTakingPageState extends State < OrderTakingPage > with AutomaticKeep
   }
 
   Future < Null > _onRefresh() async {
-    await getOrderList().then((resp) {
-      setState(() {
-        listObj = resp.orderList;
+    getKey('stationId').then((value) {
+      getOrderList(value, lineIdStr, 1).then((resp) {
+        setState(() {
+          orderList = resp.data.items;
+        });
       });
     });
   }
 
   void deleteOrder(val) {
     setState(() {
-      listObj.removeAt(val);
-      if (listObj.length < 4) {
-        getOrderList().then((resp) {
-          setState(() {
-            listObj.addAll(resp.orderList);
-          });
-        });
+      orderList.removeAt(val);
+      if (orderList.length < 4) {
+
       }
     });
   }
@@ -295,9 +307,9 @@ class _OrderCardContainerState extends State < OrderCardContainer > with SingleT
         child: Column(
           children: < Widget > [
             orderNoRow(widget.order.orderNo, widget.order.createTime),
-            orderAddress(widget.order.startAddress, widget.order.endAddress),
-            orderItem('货物名称', widget.order.itemName, 15),
-            orderItem('货物件数', '${widget.order.itemNo}件', 30),
+            orderAddress(widget.order.receiptCompanyName, widget.order.sendCompanyName),
+            orderItem('货物名称', widget.order.goods, 15),
+            orderItem('货物件数', '${widget.order.goodsQuantity}件', 30),
             orderCutLine(),
             orderBtn(context, animationStatus, controller, str),
             AnimatedOpen(animation: animation, openInfo: widget.order, )
@@ -394,14 +406,14 @@ class AnimatedOpen extends AnimatedWidget {
     );
   }
 }
-Widget orderNoRow(int orderNo, String createTime) { //订单号及时间
+Widget orderNoRow(String orderNo, int createTime) { //订单号及时间
   return Container(
     margin: EdgeInsets.only(bottom: ScreenUtil.getInstance().setHeight(30)),
     child: Row(
       mainAxisAlignment: MainAxisAlignment.spaceBetween,
       children: < Widget > [
         Text("订单号:${orderNo}", style: TextStyle(color: Color.fromRGBO(153, 153, 153, 1), fontSize: ScreenUtil.getInstance().setSp(24)), ),
-        Text(createTime, style: TextStyle(color: Color.fromRGBO(153, 153, 153, 1), fontSize: ScreenUtil.getInstance().setSp(24)), ),
+        Text('${createTime}', style: TextStyle(color: Color.fromRGBO(153, 153, 153, 1), fontSize: ScreenUtil.getInstance().setSp(24)), ),
       ],
     ),
   );
@@ -430,10 +442,10 @@ Widget orderDetailInfo(OrderList obj) { //卡片展开信息
     child: Wrap(
       children: < Widget > [
         orderCutLine(),
-        orderPhone('发件电话', obj.sendPhone, 15),
-        orderItem('发件地址', obj.sendAddress, 30),
-        orderPhone('收件电话', obj.getPhone, 15),
-        orderItem('收件地址', obj.getAddress, 30),
+        orderPhone('发件电话', obj.sendCompanyPhone, 15),
+        orderItem('发件地址', obj.sendCompanyAddress, 30),
+        orderPhone('收件电话', obj.receiptCompanyPhone, 15),
+        orderItem('收件地址', obj.receiptCompanyAddress, 30),
       ],
     )
   );

+ 6 - 61
lib/util/api.dart

@@ -1,6 +1,7 @@
 import 'request.dart';
 import 'models.dart';
 
+const int limit = 10;
 //登录接口
 Future login(phone, passwrod) async {
   var response = await Http().post('app/uzer/logistics/phone_login', data: {
@@ -12,68 +13,13 @@ Future login(phone, passwrod) async {
 }
 
 //获取接单列表
-Future getOrderList() async {
-  //var response = await Http().get("query",data: {"name":"haha"});
-  var resp = {
-    "items": [{
-        "id": 1,
-        "orderNo": 1111,
-        "createTime": "2019/02/11 14:23",
-        "startAddress": "朝阳门大阳汽贸",
-        "endAddress": "香河汽修厂",
-        "itemName": "汽车轮胎",
-        "itemNo": 3,
-        "sendPhone": "010-8788 6890",
-        "sendAddress": "北京市朝阳区朝阳门外大街28号",
-        "getPhone": "010-6734 3426",
-        "getAddress": "河北省廊坊市香河县东大街29号院18栋"
-      },
-      {
-        "id": 2,
-        "orderNo": 2222,
-        "createTime": "2019/02/11 14:23",
-        "startAddress": "香河汽修厂",
-        "endAddress": "朝阳门大阳汽贸",
-        "itemName": "汽车零件",
-        "itemNo": 99,
-        "sendPhone": "010-8788 6890",
-        "sendAddress": "河北省廊坊市香河县东大街29号院18栋",
-        "getPhone": "010-6734 3426",
-        "getAddress": "北京市朝阳区朝阳门外大街28号"
-      },
-      {
-        "id": 2,
-        "orderNo": 2222,
-        "createTime": "2019/02/11 14:23",
-        "startAddress": "香河汽修厂",
-        "endAddress": "朝阳门大阳汽贸",
-        "itemName": "汽车零件",
-        "itemNo": 99,
-        "sendPhone": "010-8788 6890",
-        "sendAddress": "河北省廊坊市香河县东大街29号院18栋",
-        "getPhone": "010-6734 3426",
-        "getAddress": "北京市朝阳区朝阳门外大街28号"
-      }, {
-        "id": 2,
-        "orderNo": 2222,
-        "createTime": "2019/02/11 14:23",
-        "startAddress": "香河汽修厂",
-        "endAddress": "朝阳门大阳汽贸",
-        "itemName": "汽车零件",
-        "itemNo": 99,
-        "sendPhone": "010-8788 6890",
-        "sendAddress": "河北省廊坊市香河县东大街29号院18栋",
-        "getPhone": "010-6734 3426",
-        "getAddress": "北京市朝阳区朝阳门外大街28号"
-      },
-    ],
-    "hasNextPage": true
-  };
-  var orderList = OrderListObj.fromJson(resp);
-  print("获取了OrderList");
-  return orderList;
+Future getOrderList(String stationId,String lineId,int page) async {
+ var response = await Http().post('app/order/wait_order_list_pages',data: {'stationId':stationId,'lineId':lineId,'limit':limit,'page':page});
+  var result = OrderListObj.fromJson(response);
+  return result;
 }
 
+
 //获取所有站点
 Future getStationList() async{
   var response = await Http().get('app/station/station_list');
@@ -85,7 +31,6 @@ Future getStationList() async{
 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;
 }
 

+ 2 - 2
lib/util/config.dart

@@ -1,5 +1,5 @@
 class Config{
   String baseUrl = "https://logistics.5fire.tech/";
-  int connectTimeout = 5000;
-  int receiveTimeout = 5000;
+  int connectTimeout = 30000;
+  int receiveTimeout = 30000;
 }

+ 71 - 43
lib/util/models.dart

@@ -49,64 +49,93 @@ class LoginMap {
 
 //接单页列表
 class OrderListObj {
-  List < OrderList > orderList;
-  bool hasNextPage;
+  bool success;
+  int code;
+  String msg;
+  OrderListData data;
 
   OrderListObj({
-    this.hasNextPage,
-    this.orderList
+   this.success,
+   this.code,
+   this.msg,
+   this.data
   });
 
   factory OrderListObj.fromJson(Map < String, dynamic > json) {
+    return OrderListObj(
+      success: json['success'],
+      code:json['code'],
+      msg:json['msg'],
+      data:OrderListData.fromJson(json['data'])
+    );
+  }
+}
+class OrderListData{
+  bool hasNextPage;
+  List<OrderList> items;
+  int limit;
+  int page;
+  int totalCount;
+  int totalPage;
+
+  OrderListData({
+    this.hasNextPage,
+    this.items,
+    this.limit,
+    this.page,
+    this.totalCount,
+    this.totalPage
+  });
+
+  factory OrderListData.fromJson(Map<String,dynamic>json){
     List list = json['items'] as List;
     List < OrderList > tempOrderList = list.map((i) => OrderList.fromJson(i)).toList();
-    return OrderListObj(
+    return OrderListData(
       hasNextPage: json['hasNextPage'],
-      orderList: tempOrderList
+      items:tempOrderList,
+      limit: json['limit'],
+      page:json['page'],
+      totalCount: json['totalCount'],
+      totalPage: json['totalPage']
     );
   }
-
 }
 class OrderList {
-  int id;
-  int orderNo;
-  String createTime;
-  String startAddress;
-  String endAddress;
-  String itemName;
-  int itemNo;
-  String sendPhone;
-  String sendAddress;
-  String getPhone;
-  String getAddress;
-
+  String orderNo;
+  int createTime;
+  String goods;
+  int goodsQuantity;
+  String receiptCompanyAddress;
+  String receiptCompanyName;
+  String receiptCompanyPhone;
+  String sendCompanyAddress;
+  String sendCompanyName;
+  String sendCompanyPhone;
   OrderList({
-    this.id,
-    this.orderNo,
-    this.createTime,
-    this.startAddress,
-    this.endAddress,
-    this.itemName,
-    this.itemNo,
-    this.sendPhone,
-    this.sendAddress,
-    this.getPhone,
-    this.getAddress
+   this.orderNo,
+   this.createTime,
+   this.goods,
+   this.goodsQuantity,
+   this.receiptCompanyAddress,
+   this.receiptCompanyName,
+   this.receiptCompanyPhone,
+   this.sendCompanyAddress,
+   this.sendCompanyName,
+   this.sendCompanyPhone
   });
 
   factory OrderList.fromJson(Map < String, dynamic > json) {
     return OrderList(
-      id: json['id'],
-      orderNo: json['orderNo'],
-      createTime: json['createTime'],
-      startAddress: json['startAddress'],
-      endAddress: json['endAddress'],
-      itemName: json['itemName'],
-      itemNo: json['itemNo'],
-      sendPhone: json['sendPhone'],
-      sendAddress: json['sendAddress'],
-      getPhone: json['getPhone'],
-      getAddress: json['getAddress']
+     orderNo: json['orderNo'],
+     createTime: json['createTime'],
+     goods: json['goods'],
+     goodsQuantity: json['goodsQuantity'],
+     receiptCompanyAddress: json['receiptCompanyAddress'],
+     receiptCompanyName:json['receiptCompanyName'],
+     receiptCompanyPhone:json['receiptCompanyPhone'],
+     sendCompanyAddress:json['sendCompanyAddress'],
+     sendCompanyName:json['sendCompanyName'],
+     sendCompanyPhone:json['sendCompanyPhone']
     );
   }
 }
@@ -122,9 +151,8 @@ class Station{
 
   factory Station.fromJson(Map<String,dynamic> json){
     List list = json['data'] as List;
-    print(list);
+    print(list.toString());
     List<StationList> tempList = list.map((i)=>StationList.fromJson(i)).toList();
-    print(tempList);
     return Station(
       success: json['success'],
       code:json['code'],

+ 4 - 4
lib/util/request.dart

@@ -58,7 +58,7 @@ class Http {
     cancelToken,
     data = null
   }) async {
-    print('get:::url:$url ,body: $data');
+    //print('get:::url:$url ,body: $data');
     Response response;
     try {
       response = await _dio.get(
@@ -75,7 +75,7 @@ class Http {
         print('get请求发生错误:$e');
       }
     }
-    print(response);
+    //print(response);
     return response.data;
   }
 
@@ -85,7 +85,7 @@ class Http {
     cancelToken,
     data = null
   }) async {
-    print('post请求::: url:$url ,body: $data');
+    //print('post请求::: url:$url ,body: $data');
     Response response;
 
     try {
@@ -103,7 +103,7 @@ class Http {
         print('post请求发生错误:$e');
       }
     }
-    print(response);
+    //print(response);
     return response.data;
   }
 }