Преглед на файлове

修改密码接口对接

daxu0403 преди 7 години
родител
ревизия
c8477ec62f

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


+ 86 - 25
lib/pages/my_page/revise_password_page.dart

@@ -1,6 +1,8 @@
 import 'package:flutter/material.dart';
 import 'package:flutter_screenutil/flutter_screenutil.dart';
 import '../../util/session.dart';
+import '../../showAlert.dart';
+import '../../util/api.dart';
 
 class RevisePasswordPage extends StatefulWidget {
   final Widget child;
@@ -14,6 +16,12 @@ class RevisePasswordPage extends StatefulWidget {
 }
 
 class _RevisePasswordPageState extends State < RevisePasswordPage > {
+
+  String oldPassword = '';
+  String newPassword = '';
+  bool submitStatus = false;
+
+
   @override
   Widget build(BuildContext context) {
     return Scaffold(
@@ -37,44 +45,97 @@ class _RevisePasswordPageState extends State < RevisePasswordPage > {
                   Padding(
                     padding: EdgeInsets.only(bottom: ScreenUtil.getInstance().setHeight(60)),
                     child: TextField(
+                      obscureText: true,
                       decoration: InputDecoration(
                         border: UnderlineInputBorder(),
                         hintText: "请输入旧密码",
                         hintStyle: TextStyle(fontSize: ScreenUtil.getInstance().setSp(32), color: Color.fromRGBO(155, 155, 155, 1)),
                       ),
+                      onChanged: (value) {
+                        setState(() {
+                          oldPassword = value;
+                        });
+                      },
                     ),
                   ),
                   Padding(
                     padding: EdgeInsets.only(bottom: ScreenUtil.getInstance().setHeight(125)),
-                    child:TextField(
-                    cursorColor: Color.fromRGBO(153, 153, 153, 0.5),
-                    decoration: InputDecoration(
-                      hintText: "请输入新密码",
-                      hintStyle: TextStyle(fontSize: ScreenUtil.getInstance().setSp(32), color: Color.fromRGBO(155, 155, 155, 1)),
-                    ),
-                  )
+                    child: TextField(
+                      obscureText: true,
+                      cursorColor: Color.fromRGBO(153, 153, 153, 0.5),
+                      decoration: InputDecoration(
+                        hintText: "请输入新密码",
+                        hintStyle: TextStyle(fontSize: ScreenUtil.getInstance().setSp(32), color: Color.fromRGBO(155, 155, 155, 1)),
+                      ),
+                      onChanged: (value) {
+                        setState(() {
+                          newPassword = value;
+                        });
+                      },
+                    )
                   ),
                   InkWell(
-                    child:Container(
-                    height: ScreenUtil.getInstance().setHeight(100),
-                    decoration: BoxDecoration(
-                      color: Color.fromRGBO(64,98,254,1),
-                      borderRadius: BorderRadius.circular(4),
-                    ),
-                    child: Center(
-                      child: Text('确认',style:TextStyle(fontSize:ScreenUtil.getInstance().setSp(36),color: Colors.white )),
+                    child: Container(
+                      height: ScreenUtil.getInstance().setHeight(100),
+                      decoration: BoxDecoration(
+                        color: (oldPassword != '' && newPassword != '') ? Color.fromRGBO(64, 98, 254, 1) : Colors.grey,
+                        borderRadius: BorderRadius.circular(4),
+                      ),
+                      child: Center(
+                        child: Text('确认', style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(36), color: Colors.white)),
+                      ),
+
                     ),
-                  ), 
-                  onTap: (){
-                   getKey('phone').then((value){
-                       print(value);
-                   });
-                    getKey('s').then((value){
-                      print(value);
-                    });
-                  },
+                    onTap: () {
+                      if (oldPassword == '' || newPassword == '') {
+                        return;
+                      }
+                      getKey('password').then((value) {
+                        if (value != oldPassword) {
+                          showDialog < Null > (
+                            context: context, //BuildContext对象
+                            barrierDismissible: false,
+                            builder: (BuildContext context) {
+                              return new LoadingDialog( //调用对话框
+                                text: '旧密码错误,请重新输入', childCallback: (val) {},
+                              );
+                            });
+                        } else {
+                          updataPasswrod(oldPassword, newPassword).then((resp){
+                            if(resp.success && resp.code==1){
+                              setKey('password', newPassword);
+                              showDialog < Null > (
+                                context: context, //BuildContext对象
+                                barrierDismissible: false,
+                                builder: (BuildContext context) {
+                                  return new LoadingDialog( //调用对话框
+                                    text: '修改成功', childCallback: (val) {
+                                      if(val){
+                                        Navigator.pop(context);
+                                      }
+                                    },
+                                  );
+                                });
+                            }else{
+                              showDialog < Null > (
+                                context: context, //BuildContext对象
+                                barrierDismissible: false,
+                                builder: (BuildContext context) {
+                                  return new LoadingDialog( //调用对话框
+                                    text: resp.msg, childCallback: (val) {
+                                      if(val){
+                                        Navigator.pop(context);
+                                      }
+                                    },
+                                  );
+                                });
+                            }
+                          });
+                        }
+                      });
+                    },
                   )
-                  
+
                 ],
               ),
             )

+ 138 - 72
lib/pages/order_taking_page.dart

@@ -19,40 +19,30 @@ class _OrderTakingPageState extends State < OrderTakingPage > with AutomaticKeep
 
   ScrollController _scrollController = ScrollController(); //初始化滚动轴监控对象
   List listObj = [];
-  List lineList=[];
-   List<PopupMenuEntry<String>> widgets=[];
+  List lineList = [];
+  String stationId;
+  List < bool > checkStatusList = [];
+  bool showLineStatus = true;
   @override
   void initState() {
     super.initState();
-    getOrderList().then((resp) {
-      setState(() {
-        listObj = resp.orderList;
-      });
-    });
+    // 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);
-        }
+      setState(() {
+        stationId = value;
       });
+      getLine(value);
     });
     _scrollController.addListener(() {
+      if(!showLineStatus){
+        setState(() {
+          showLineStatus = true;
+        });
+      }
       if (_scrollController.position.pixels == _scrollController.position.maxScrollExtent) {
         print("滑到底部了");
         // getOrderList().then((resp) {
@@ -63,18 +53,31 @@ class _OrderTakingPageState extends State < OrderTakingPage > with AutomaticKeep
       }
       //print(_scrollController.position.pixels);
     });
+  }
 
+
+  void getLine(value){
+    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);
+            }
+          }
+          stationId = value;
+        });
+      }
+    });
   }
 
   @override
   bool get wantKeepAlive => true;
 
-  @override
-  void dispose() {
-    super.dispose();
-    _scrollController.dispose();
-    print('接单页listView滚动监听销毁了');
-  }
 
   @override
   Widget build(BuildContext context) {
@@ -86,48 +89,112 @@ class _OrderTakingPageState extends State < OrderTakingPage > with AutomaticKeep
           centerTitle: true,
           backgroundColor: Color.fromRGBO(64, 98, 254, 1),
           actions: < Widget > [
-            Container(
-              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){
-                  return widgets;
-                  // <PopupMenuEntry<String>>[
-                  //    PopupMenuItem<String>(
-                  //     value: '1111',
-                  //     child: Text('lineList[0].name',)
-                  //   )
-                  // ];
+            IconButton(icon: Icon(Icons.add_circle_outline),
+              onPressed: () {
+                setState(() {
+                  showLineStatus = !showLineStatus;
+                });
+                if (!showLineStatus) {
+                  getKey('stationId').then((value) {
+                    if(stationId!=value){
+                      getLine(value);
+                    }
+                  });
                 }
-              )
-            ),
-          ],
+              }, )
+          ]
         ),
-        body: 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, //回调方法
-            child: ListView.builder(
-              controller: _scrollController,
-              itemCount: listObj.length + 1,
-              itemBuilder: (BuildContext context, int index) { //itemBuilder实际上就是一个map的循环
-                if (index < listObj.length) {
-                  return OrderCardContainer(order: listObj[index], index: index, callback: (val) => deleteOrder(val));
-                }
-                return _getMoreWidget();
+        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, //回调方法
+                  child: ListView.builder(
+                    controller: _scrollController,
+                    itemCount: listObj.length + 1,
+                    itemBuilder: (BuildContext context, int index) { //itemBuilder实际上就是一个map的循环
+                      if (index < listObj.length) {
+                        return OrderCardContainer(order: listObj[index], index: index, callback: (val) => deleteOrder(val));
+                      }
+                      return _getMoreWidget();
+                    },
+                  )
+                ),
+              ),
+              onTap: () {
+                setState(() {
+                  showLineStatus = true;
+                });
               },
+            ),
+            Positioned(
+              top: 0,
+              right: 0,
+              child:
+              Offstage(
+                offstage: showLineStatus,
+                child: Container(
+                  width: ScreenUtil.getInstance().setWidth(350),
+                  height: ScreenUtil.getInstance().setHeight(500),
+                  margin: EdgeInsets.fromLTRB(0, 1, 1, 0),
+                  padding: EdgeInsets.fromLTRB(1, 0, 1, 0),
+                  decoration: BoxDecoration(
+                    color: Color.fromRGBO(0, 0, 0, 0.7),
+                    borderRadius: BorderRadius.all(Radius.circular(4.0))
+                  ),
+                  child: ListView.builder(
+                    itemCount: lineList.length,
+                    itemBuilder: (BuildContext context, int index) { //itemBuilder实际上就是一个map的循环
+                      if (index < lineList.length) {
+                        return _lineWidget(lineList[index],index,checkStatusList[index]);
+                      }
+                    },
+                  ),
+                ),
+              )
             )
-          ),
+          ],
         )
       ),
     );
   }
 
+  Widget _lineWidget(LineObj lineObj,int index,bool checked) {
+    return InkWell(
+      child: Container(
+        height: ScreenUtil.getInstance().setHeight(80),
+        decoration: BoxDecoration(
+          border: BorderDirectional(bottom: BorderSide(color: Colors.white))
+        ),
+        child: Row(
+          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) ),
+            ),
+            Expanded(
+              flex: 1,
+              child: Center(
+                child: Text(lineObj.name, style: TextStyle(color: Colors.white))
+              )
+            )
+          ],
+        ),
+      ),
+      onTap: (){
+        setState(() {
+          checkStatusList[index] = !checked;
+        });
+
+      },
+    );
+  }
+
   Widget _getMoreWidget() {
     return Center(
       child: Padding(
@@ -283,7 +350,7 @@ class _OrderCardContainerState extends State < OrderCardContainer > with SingleT
               ),
             ),
             onTap: () {
-              getKey('stationId').then((value){
+              getKey('stationId').then((value) {
                 print(value);
               });
               showDialog < Null > (
@@ -391,14 +458,13 @@ Widget orderPhone(String key, String value, int marginBottom) {
       ], )
     ),
     onLongPress: () async {
-      String  phone = 'tel:${value}';
+      String phone = 'tel:${value}';
       print(phone);
-      if(await canLaunch(phone)){
+      if (await canLaunch(phone)) {
         await (launch(phone));
-      }else{
+      } else {
         throw 'Could not launch $value';
       }
     },
   );
-}
-
+}

+ 7 - 0
lib/util/api.dart

@@ -87,4 +87,11 @@ Future getLineFromStation(String stationId)async{
   var lineList = StationLine.fromJson(response);
   print(lineList.toString());
   return lineList;
+}
+
+//修改密码
+Future updataPasswrod(oldPassword,newPassword)async{
+  var response = await Http().post('app/uzer/logistics/update_password',data: {'oldPassword':oldPassword,'newPassword':newPassword});
+  var result =UpdataPasswrod.fromJson(response);
+  return result;
 }

+ 19 - 0
lib/util/models.dart

@@ -190,4 +190,23 @@ class LineObj{
       name:json['name']
     );
   }
+}
+
+//修改密码
+class UpdataPasswrod{
+  bool success;
+  int code;
+  String msg;
+  String data;
+
+  UpdataPasswrod({this.success,this.code,this.msg,this.data});
+
+  factory UpdataPasswrod.fromJson(Map<String,dynamic> json){
+    return UpdataPasswrod(
+      success: json['success'],
+      code: json['code'],
+      msg:json['msg'],
+      data:json['data']
+    );
+  }
 }