[baozhangchao] 3 years ago
parent
commit
f5b7f9d714

+ 10
- 6
lib/models/app.dart View File

@@ -5,6 +5,7 @@ import 'package:amap_flutter_location/amap_flutter_location.dart';
5 5
 import 'package:farmer_client/models/entities/person.dart';
6 6
 import 'package:farmer_client/widgets/Modal.dart';
7 7
 import 'package:get/get.dart';
8
+import '../services/user.dart';
8 9
 import '../utils/location.dart';
9 10
 
10 11
 class AppController extends GetxController {
@@ -47,12 +48,15 @@ class AppController extends GetxController {
47 48
       );
48 49
     });
49 50
 
50
-    // // 尝试获取一次人员信息
51
-    // getCurrent().then((person) {
52
-    //   user(person);
53
-    // }).catchError((e) {
54
-    //   print(e);
55
-    // });
51
+
52
+    // 尝试获取一次人员信息
53
+    getCurrent().then((person) {
54
+      print('9personpersonpersonperson+$person');
55
+      user(Person.fromJson(person));
56
+
57
+    }).catchError((e) {
58
+      print(e);
59
+    });
56 60
   }
57 61
 
58 62
   @override

+ 21
- 17
lib/models/entities/person.dart View File

@@ -1,17 +1,18 @@
1
-
2 1
 class Person {
3 2
   String? personId;
4 3
   String? appId;
5 4
   String? openid;
6 5
   String? nickName;
7 6
   String? avatar;
8
-  int? sex;
7
+  num? sex;
9 8
   String? phone;
10 9
   String? userId;
11
-  int? status;
10
+  num? status;
12 11
   String? createDate;
12
+  String? identity;
13
+  String? isOrgManager;
13 14
 
14
-  Person ();
15
+  Person();
15 16
 
16 17
   Person.fromJson(Map<String, dynamic> json)
17 18
       : personId = json["personId"],
@@ -23,20 +24,23 @@ class Person {
23 24
         phone = json["phone"],
24 25
         userId = json["userId"],
25 26
         status = json["status"],
26
-        createDate = json["createDate"];
27
+        createDate = json["createDate"],
28
+        isOrgManager = json["isOrgManager"],
29
+        identity = json["identity"];
27 30
 
28 31
   Map<String, dynamic> toJson() => {
29
-    'personId' : personId,
30
-    'appId' : appId,
31
-    'openid' : openid,
32
-    'nickName' : nickName,
33
-    'avatar' : avatar,
34
-    'sex' : sex,
35
-    'phone' : phone,
36
-    'userId' : userId,
37
-    'status' : status,
38
-    'createDate' : createDate,
32
+        'personId': personId,
33
+        'appId': appId,
34
+        'openid': openid,
35
+        'nickName': nickName,
36
+        'avatar': avatar,
37
+        'sex': sex,
38
+        'phone': phone,
39
+        'userId': userId,
40
+        'status': status,
41
+        'createDate': createDate,
42
+        'isOrgManager': isOrgManager,
43
+         'identity': identity,
44
+
39 45
   };
40 46
 }
41
-
42
-

+ 0
- 3
lib/pages/addAddress/index.dart View File

@@ -90,10 +90,7 @@ class AddAddress extends BasicPage {
90 90
                         msg: '修改地址成功!');
91 91
                     Get.back();
92 92
                   });
93
-                  
94 93
                 }
95
-
96
-
97 94
               }
98 95
             },
99 96
             margin: const EdgeInsets.all(0),

+ 0
- 1
lib/pages/addressList/index.dart View File

@@ -45,7 +45,6 @@ class AddressList extends BasicPage {
45 45
     });
46 46
 
47 47
   }
48
-
49 48
   void onDelete(id) {
50 49
     print(id);
51 50
 

+ 15
- 4
lib/pages/feedback/index.dart View File

@@ -5,6 +5,8 @@ import 'package:flutter_screenutil/flutter_screenutil.dart';
5 5
 import 'package:fluttertoast/fluttertoast.dart';
6 6
 import 'package:get/get.dart';
7 7
 
8
+import '../../services/main.dart';
9
+
8 10
 class Feedback extends BasicPage {
9 11
   final text=Rx<String>('');
10 12
   final isEdit=Rx<bool>(false);
@@ -45,7 +47,11 @@ class Feedback extends BasicPage {
45 47
               },
46 48
             ),
47 49
           ),
48
-          if(!isEdit.value) Positioned(
50
+          Obx(()=>
51
+          Visibility(
52
+          visible:!isEdit(),
53
+            child:
54
+          Positioned(
49 55
             left: 20.w,
50 56
             top: 5.w,
51 57
             child: Row(
@@ -64,6 +70,8 @@ class Feedback extends BasicPage {
64 70
               ],
65 71
             ),
66 72
           ),
73
+          ),
74
+          ),
67 75
           Positioned(
68 76
             bottom: 25.h,
69 77
             child: DefaultButton(
@@ -73,11 +81,14 @@ class Feedback extends BasicPage {
73 81
               height: 49.h,
74 82
               text: '提交',
75 83
               onPressed: () {
76
-                if (text.value == '') {
84
+                if (text() == '') {
77 85
                   Fluttertoast.showToast(msg: '请输入内容哦');
78 86
                 } else {
79
-                  Fluttertoast.showToast(msg: '提交成功!');
80
-                  Get.back();
87
+                  feedback(text()).then((value) {
88
+                    Fluttertoast.showToast(msg: '提交成功!');
89
+                    Get.back();
90
+                  });
91
+
81 92
                 }
82 93
               },
83 94
               margin: const EdgeInsets.all(0),

+ 0
- 109
lib/pages/home2.dart View File

@@ -1,109 +0,0 @@
1
-import 'package:flutter/cupertino.dart';
2
-import 'package:flutter/material.dart';
3
-import 'package:get/get.dart';
4
-import 'package:flutter_screenutil/flutter_screenutil.dart';
5
-
6
-class Home extends StatefulWidget {
7
-  const Home({Key? key}) : super(key: key);
8
-
9
-  @override
10
-  _Home createState() => _Home();
11
-}
12
-
13
-class _Home extends State<Home> {
14
-  List images = [
15
-    ['images/index/index.png', 'images/index/indexActive.png'],
16
-    ['images/index/job.png', 'images/index/jobActive.png'],
17
-    ['images/index/user.png', 'images/index/userActive.png'],
18
-  ];
19
-
20
-  final List _titles = ['首页', '订单列表', '个人中心'];
21
-  int _currentIndex = 0;
22
-  final tabTextStyleSelected =
23
-  TextStyle(color: const Color(0xFF06B03B),fontSize: 15.sp,fontWeight: FontWeight.bold); //选线卡选中字体颜色
24
-  final tabTextStyleNormal =
25
-  TextStyle(color: const Color(0xFF323232),fontSize: 15.sp,fontWeight: FontWeight.bold); //选项卡未选中字体颜色
26
-  int _tabIndex = 0; //选项卡下标
27
-
28
-  var _body = [Text('我是首页'), Text('我是订单列表'), Text('我是个人中心')];
29
-  TextStyle getTabTextStyle(int curIndex) {
30
-    //设置tabbar 选中和未选中的状态文本
31
-    if (curIndex == _tabIndex) {
32
-      return tabTextStyleSelected;
33
-    }
34
-    return tabTextStyleNormal;
35
-  }
36
-
37
-  Image getTabIcon(int curIndex) {
38
-    //设置tabbar选中和未选中的状态图标
39
-    if (curIndex == _tabIndex) {
40
-      return Image.asset(
41
-        images[curIndex][1],
42
-        width: 20.w,
43
-        height: 20.w,
44
-      );
45
-    }
46
-    return Image.asset(
47
-      images[curIndex][0],
48
-      width: 20.w,
49
-      height: 20.w,
50
-    );
51
-  }
52
-
53
-  Image getTabImage(path) {
54
-    return Image.asset(path, width: 26.w, height: 26.w);
55
-  }
56
-
57
-  // 切换底部选项卡,标题的变化设置
58
-  Text getTabTitle(int curIndex) {
59
-    return Text(_titles[curIndex], style: getTabTextStyle(curIndex));
60
-  }
61
-
62
-  @override
63
-  Widget build(BuildContext context) {
64
-    return Scaffold(
65
-      appBar: AppBar(
66
-        elevation: 0,
67
-        centerTitle: true,
68
-        backgroundColor: Colors.white,
69
-        title: Text(
70
-          '首页',
71
-          style: TextStyle(
72
-              color: Colors.black,
73
-              fontSize: 17.sp,
74
-              letterSpacing: 2,
75
-              fontWeight: FontWeight.bold
76
-          ),
77
-        ),
78
-      ),
79
-      body: _body[_tabIndex],
80
-      bottomNavigationBar: Container(
81
-        height: 65.h,
82
-
83
-        child: Row(
84
-          mainAxisAlignment: MainAxisAlignment.spaceAround,
85
-          children: [
86
-            Column(
87
-              children: [
88
-                getTabIcon(0),
89
-                getTabTitle(0)
90
-              ],
91
-            ),
92
-            Column(
93
-              children: [
94
-                getTabIcon(1),
95
-                getTabTitle(1)
96
-              ],
97
-            ),
98
-            Column(
99
-              children: [
100
-                getTabIcon(2),
101
-                getTabTitle(2)
102
-              ],
103
-            ),
104
-          ],
105
-        ),
106
-      ),
107
-    );
108
-  }
109
-}

+ 1
- 1
lib/pages/login/login.dart View File

@@ -100,7 +100,7 @@ class _RouteLogin extends State<MyRouteLogin> {
100 100
       if (_newValue) {
101 101
         userLogin(handlePhones, handleCodes).then((value) {
102 102
           userInfo(Person.fromJson(value['person']));
103
-          print('已同意协议');
103
+
104 104
 
105 105
           Get.off(Home());
106 106
         });

+ 8
- 8
lib/pages/main/index.dart View File

@@ -13,27 +13,27 @@ class Main extends BasicPage {
13 13
     naviTitle = '我的';
14 14
   }
15 15
   final addressListInfo = Rx<List<Address>>([]);
16
+  final addressInfoContent = Rx<Address>(Address());
17
+
18
+
19
+
16 20
 
17 21
   @override
18 22
   void beforeShow() {
19 23
     // TODO: implement beforeShow
20 24
     super.beforeShow();
21 25
     getAddress().then((value) {
22
-       List<Address> list = [];
26
+      List<Address> list = [];
23 27
       value['records'].forEach((item) {
24 28
         list.add(Address.fromJson(item));
25 29
       });
26
-       addressListInfo(list);
30
+      addressListInfo(list);
31
+      addressInfoContent(addressListInfo()[0]);
27 32
     });
28 33
   }
29 34
 
30
-
31 35
   @override
32 36
   Widget builder(BuildContext context) {
33
-    return Obx(()=> MainPage(
34
-        item:addressListInfo()[0].address.toString()
35
-     )
36
-
37
-    );
37
+    return Obx(()=>MainPage( item: addressInfoContent(),));
38 38
   }
39 39
 }

+ 4
- 18
lib/pages/main/widgets/main/index.dart View File

@@ -1,39 +1,25 @@
1 1
 import 'package:farmer_client/models/entities/Address.dart';
2 2
 import 'package:get/get.dart';
3 3
 import 'package:get_storage/get_storage.dart';
4
-
5 4
 import './widgets/OtherColumn.dart';
6 5
 import './widgets/UserAddress.dart';
7 6
 import './widgets/UserInfo.dart';
8 7
 import 'package:flutter/material.dart';
9 8
 import 'package:flutter_screenutil/flutter_screenutil.dart';
10 9
 
11
-class MainPage extends StatefulWidget {
12
-  final String item;
13
-
10
+class MainPage extends StatelessWidget {
11
+  final Address item;
14 12
 
15 13
 
16
-   MainPage({Key? key, required this.item}) : super(key: key);
17 14
 
18
-  @override
19
-  State<MainPage> createState() => _MainPageState(item);
20
-
21
-}
15
+  MainPage({Key? key, required this.item}) : super(key: key);
22 16
 
23
-class _MainPageState extends State<MainPage> {
24 17
   GetStorage box = GetStorage();
25
-  late String item='请维护详细地址!';
26
-  _MainPageState(this.item);
27 18
 
28
-  @override
29
-  void initState() {
30
-    super.initState();
31
-    print('644444444444444+$item');
32
-
33
-  }
34 19
 
35 20
   @override
36 21
   Widget build(BuildContext context) {
22
+    print('644444444444444+$item');
37 23
 
38 24
     return Container(
39 25
       alignment: Alignment.center,

+ 2
- 3
lib/pages/main/widgets/main/widgets/UserAddress.dart View File

@@ -5,7 +5,7 @@ import 'package:get/get.dart';
5 5
 import '../../../../../models/entities/Address.dart';
6 6
 
7 7
 class UserAddress extends StatelessWidget {
8
-  final String item;
8
+  final Address item;
9 9
 
10 10
   const UserAddress({Key? key, required this.item}) : super(key: key);
11 11
 
@@ -65,8 +65,7 @@ class UserAddress extends StatelessWidget {
65 65
                         ),
66 66
                         Container(
67 67
                           width: 260,
68
-                          child: Text(
69
-                            item != null? item: '请设置默认地址',
68
+                          child:  Text(item!=null?item.address.toString():'请设置详细地址!',
70 69
                             softWrap: true,
71 70
                             maxLines: 1,
72 71
                             textAlign: TextAlign.left,

+ 27
- 15
lib/pages/main/widgets/main/widgets/UserInfo.dart View File

@@ -2,14 +2,19 @@ import 'package:flutter/material.dart';
2 2
 import 'package:flutter_screenutil/flutter_screenutil.dart';
3 3
 import 'package:get/get.dart';
4 4
 
5
+import '../../../../../models/app.dart';
6
+
5 7
 class UserInfo extends StatelessWidget {
6
-  const UserInfo({Key? key}) : super(key: key);
8
+  AppController userInfo = AppController.t;
9
+
10
+   UserInfo({Key? key}) : super(key: key);
7 11
 
8 12
   @override
9 13
   Widget build(BuildContext context) {
14
+    print(userInfo.user().phone);
15
+
10 16
     return Container(
11 17
       margin: EdgeInsets.only(top: 20.0, bottom: 0.0),
12
-
13 18
       alignment: Alignment.center,
14 19
       height: 173.w,
15 20
       width: 345.w,
@@ -52,19 +57,23 @@ class UserInfo extends StatelessWidget {
52 57
                 mainAxisAlignment: MainAxisAlignment.center,
53 58
                 children: [
54 59
                   Container(
60
+                    width: 63.w,
61
+                    height: 63.w,
55 62
                     decoration: BoxDecoration(
56 63
                       shape: BoxShape.circle,
64
+                      image: userInfo.user().avatar!=null?
65
+                      DecorationImage(
66
+                        image: NetworkImage(userInfo.user().avatar.toString()),
67
+                        fit: BoxFit.cover,
68
+                      ): DecorationImage(
69
+                        image: AssetImage('images/userMoren.png')
70
+                      ),
57 71
                       border: Border.all(
58 72
                         color: Colors.white,
59 73
                         width: 2,
60 74
                       ),
61 75
                     ),
62 76
                     margin: EdgeInsets.fromLTRB(30, 0, 15, 0),
63
-                    alignment: Alignment.center,
64
-                    child: Image.asset(
65
-                      "images/userMoren.png",
66
-                      width: 63.w,
67
-                    ),
68 77
                   ),
69 78
                 ],
70 79
               ),
@@ -75,8 +84,9 @@ class UserInfo extends StatelessWidget {
75 84
                   children: [
76 85
                     Container(
77 86
                       margin: EdgeInsets.fromLTRB(0, 0, 0, 10),
78
-                      child: Text(
79
-                        '符西西',
87
+                      child:
88
+                      Text(
89
+                        userInfo.user().nickName!=null?userInfo.user().nickName.toString():'请修改个人信息!',
80 90
                         style: TextStyle(
81 91
                           color: Colors.white,
82 92
                           fontSize: 17,
@@ -85,12 +95,14 @@ class UserInfo extends StatelessWidget {
85 95
                     ),
86 96
                     Container(
87 97
                       margin: EdgeInsets.fromLTRB(0, 10, 0, 0),
88
-                      child: Text(
89
-                        '17775000245',
90
-                        style: TextStyle(
91
-                          color: Colors.white,
92
-                          fontSize: 17,
93
-                        ),
98
+                      child:
99
+                          Text(
100
+                            userInfo.user().phone!=null?userInfo.user().phone.toString():'请修改手机号!',
101
+                            style: TextStyle(
102
+                              color: Colors.white,
103
+                              fontSize: 17,
104
+                            ),
105
+
94 106
                       ),
95 107
                     ),
96 108
                     // const Text(

+ 7
- 7
lib/pages/orderInfo/index.dart View File

@@ -116,13 +116,13 @@ class _BottomWidget extends StatelessWidget {
116 116
 
117 117
 
118 118
   void _orderDeletels (){
119
-    orderDelete(id).then((value) {
120
-      Fluttertoast.showToast(
121
-          msg: '订单取消成功!'
122
-      );
123
-    });
124
-
125
-
119
+    modal.showDialog(title: '测试', content: SizedBox(width: 400, height: 300,), onConfirm: () => true);
120
+    // orderDelete(id).then((value) {
121
+    //   Fluttertoast.showToast(
122
+    //       msg: '订单取消成功!'
123
+    //   );
124
+    //   Get.offNamed('/order');
125
+    // });
126 126
   }
127 127
 
128 128
 

+ 63
- 25
lib/pages/userInfo/index.dart View File

@@ -5,29 +5,63 @@ import 'package:flutter_screenutil/flutter_screenutil.dart';
5 5
 import 'package:fluttertoast/fluttertoast.dart';
6 6
 import 'package:get/get.dart';
7 7
 
8
+import '../../models/app.dart';
9
+import '../../models/entities/person.dart';
10
+import '../../services/user.dart';
11
+
8 12
 class UserInfo extends BasicPage {
9
-  final name =Rx<String>('');
10
-  final phone =Rx<String>('');
13
+  late String name ;
14
+  late String phone;
11 15
   late TextEditingController _cName;
12 16
   late TextEditingController _cPhone;
17
+  AppController userInfo = AppController.t;
18
+
19
+
13 20
   @override
14 21
   void beforeShow() {
15 22
     super.beforeShow();
16
-    _cName = TextEditingController(text: name.value);
17
-    _cPhone = TextEditingController(text: phone.value);
23
+    _cName = TextEditingController(text: userInfo.user().nickName.toString());
24
+    _cPhone = TextEditingController(text:userInfo.user().phone.toString());
25
+    name=userInfo.user().nickName.toString();
26
+    phone=userInfo.user().phone.toString();
18 27
   }
19 28
 
20 29
   bool disableLogin = false;
21 30
   RegExp exp = RegExp(r'^1[3456789]\d{9}$');
22 31
 
32
+  Map<String, dynamic> data = {
33
+
34
+  };
35
+
36
+
23 37
   void handleOk() {
24
-    if (name.value == '' && phone.value == '') {
25
-      Fluttertoast.showToast(msg: '请输入您的信息');
26
-    } else if (phone.value!=''&&!exp.hasMatch(phone.value)) {
38
+    if (name == '' && phone == '') {
39
+      Fluttertoast.showToast(msg: '请输入正确的信息');
40
+      return;
41
+
42
+    } else if (phone==''&&!exp.hasMatch(phone)) {
27 43
       Fluttertoast.showToast(msg: '请输入正确的手机号');
44
+      return;
28 45
     } else {
29
-      Fluttertoast.showToast(msg: '保存成功');
30
-      Get.back();
46
+      data={
47
+        ...userInfo.user().toJson(),
48
+        'avatar':userInfo.user().avatar ?? '',
49
+        'nickName': name,
50
+        'phone': phone
51
+      };
52
+      updateInfo(userInfo.user().personId.toString(),data).then((value) {
53
+        // 尝试获取一次人员信息
54
+        getCurrent().then((person) {
55
+          userInfo.user(Person.fromJson(person));
56
+          Fluttertoast.showToast(msg: '保存成功');
57
+
58
+          Get.back();
59
+
60
+        }).catchError((e) {
61
+          print(e);
62
+        });
63
+
64
+      });
31 65
     }
32 66
   }
33 67
 
@@ -59,19 +93,21 @@ class UserInfo extends BasicPage {
59 93
             child: Row(
60 94
                 mainAxisAlignment: MainAxisAlignment.spaceBetween,
61 95
                 children: [
62
-                  Image.asset(
63
-                    'images/userMoren.png',
64
-                    width: 62.w,
65
-                    height: 62.w,
66
-                  ),
67
-                  Text(
68
-                    '更换头像',
69
-                    style: TextStyle(
70
-                        fontSize: 17.sp,
71
-                        color: Color(0xFF333333),
72
-                        letterSpacing: 2,
73
-                        fontWeight: FontWeight.w500),
96
+                  Container(
97
+                    width: 63.w,
98
+                    height: 63.w,
99
+                    decoration: BoxDecoration(
100
+                      shape: BoxShape.circle,
101
+                      image: userInfo.user().avatar!=null?
102
+                      DecorationImage(
103
+                        image: NetworkImage(userInfo.user().avatar.toString()),
104
+                        fit: BoxFit.cover,
105
+                      ): DecorationImage(
106
+                          image: AssetImage('images/userMoren.png')
107
+                      ),
108
+                    ),
74 109
                   ),
110
+
75 111
                 ]),
76 112
           ),
77 113
           Text(
@@ -119,13 +155,15 @@ class UserInfo extends BasicPage {
119 155
                               FloatingLabelBehavior.never,
120 156
                             ),
121 157
                             onChanged: (e) {
122
-                                name.value = e;
158
+
159
+                                name = e;
160
+                                print(name);
123 161
                             },
124 162
                           ),
125 163
                         ),
126 164
                         GestureDetector(
127 165
                           onTap: () {
128
-                              name.value = '';
166
+                              name = '';
129 167
                             _cName.clear();
130 168
                           },
131 169
                           child: Image.asset(
@@ -184,13 +222,13 @@ class UserInfo extends BasicPage {
184 222
                               FloatingLabelBehavior.never,
185 223
                             ),
186 224
                             onChanged: (e) {
187
-                                phone.value = e;
225
+                                phone = e;
188 226
                             },
189 227
                           ),
190 228
                         ),
191 229
                         GestureDetector(
192 230
                           onTap: () {
193
-                              phone.value = '';
231
+                              phone = '';
194 232
                             _cPhone.clear();
195 233
                           },
196 234
                           child: Image.asset(

+ 21
- 0
lib/services/main.dart View File

@@ -0,0 +1,21 @@
1
+import 'package:dio/dio.dart';
2
+import 'package:farmer_client/utils/Request.dart';
3
+import 'package:fluttertoast/fluttertoast.dart';
4
+
5
+/**
6
+ * 意见反馈
7
+ * @param {*} data
8
+ * @returns
9
+ */
10
+
11
+Future feedback(String content) async {
12
+  return request('/feedback',
13
+      options: Options(method: 'POST'), data: {'content': content})
14
+      .catchError((error) => {
15
+    Fluttertoast.showToast(msg: error.error['message']),
16
+  });
17
+}
18
+
19
+
20
+
21
+

+ 14
- 0
lib/services/user.dart View File

@@ -30,3 +30,17 @@ Future userLogin(String userName,String password) async {
30 30
 Future getCurrent() async {
31 31
   return request('/person/current');
32 32
 }
33
+
34
+
35
+
36
+/**
37
+ * 修改个人信息
38
+ * @param {*}
39
+ * @returns
40
+ */
41
+Future updateInfo(String id, userdata) async {
42
+  return request('/person/$id', options: Options(method: 'PUT'),data: userdata).catchError((error) =>
43
+  { Fluttertoast.showToast(
44
+      msg: error.error['message']
45
+  ),});
46
+}