李志伟 преди 3 години
родител
ревизия
01bb5470f0
променени са 4 файла, в които са добавени 78 реда и са изтрити 23 реда
  1. 6
    5
      lib/models/app.dart
  2. 65
    17
      lib/models/entities/person.dart
  3. 2
    0
      lib/pages/Login/index.dart
  4. 5
    1
      lib/pages/main/index.dart

+ 6
- 5
lib/models/app.dart Целия файл

@@ -2,6 +2,7 @@
2 2
 import 'dart:io';
3 3
 
4 4
 import 'package:amap_flutter_location/amap_flutter_location.dart';
5
+import 'package:worker_client/services/user.dart';
5 6
 import '/models/entities/person.dart';
6 7
 import '/widgets/Modal.dart';
7 8
 import 'package:get/get.dart';
@@ -49,11 +50,11 @@ class AppController extends GetxController {
49 50
     });
50 51
 
51 52
     // // 尝试获取一次人员信息
52
-    // getCurrent().then((person) {
53
-    //   user(person);
54
-    // }).catchError((e) {
55
-    //   print(e);
56
-    // });
53
+    getCurrent().then((person) {
54
+      user(Person.fromJson(person));
55
+    }).catchError((e) {
56
+      print(e);
57
+    });
57 58
   }
58 59
 
59 60
   @override

+ 65
- 17
lib/models/entities/person.dart Целия файл

@@ -1,15 +1,60 @@
1
+// class Person {
2
+//   String? personId;
3
+//   String? appId;
4
+//   String? openid;
5
+//   String? nickName;
6
+//   String? userName;
7
+//   String? avatar;
8
+//   int? sex;
9
+//   String? phone;
10
+//   String? userId;
11
+//   int? status;
12
+//   String? createDate;
13
+//
14
+//   Person();
15
+//
16
+//   Person.fromJson(Map<String, dynamic> json)
17
+//       : personId = json["personId"],
18
+//         appId = json["appId"],
19
+//         openid = json["openid"],
20
+//         nickName = json["nickName"],
21
+//         userName = json["userName"],
22
+//         avatar = json["avatar"],
23
+//         sex = json["sex"],
24
+//         phone = json["phone"],
25
+//         userId = json["userId"],
26
+//         status = json["status"],
27
+//         createDate = json["createDate"];
28
+//
29
+//   Map<String, dynamic> toJson() => {
30
+//         'personId': personId,
31
+//         'appId': appId,
32
+//         'openid': openid,
33
+//         'nickName': nickName,
34
+//         'userName': userName,
35
+//         'avatar': avatar,
36
+//         'sex': sex,
37
+//         'phone': phone,
38
+//         'userId': userId,
39
+//         'status': status,
40
+//         'createDate': createDate,
41
+//       };
42
+// }
43
+
44
+
1 45
 class Person {
2 46
   String? personId;
3 47
   String? appId;
4 48
   String? openid;
5 49
   String? nickName;
6
-  String? userName;
7 50
   String? avatar;
8
-  int? sex;
51
+  num? sex;
9 52
   String? phone;
10 53
   String? userId;
11
-  int? status;
54
+  num? status;
12 55
   String? createDate;
56
+  String? identity;
57
+  bool? isOrgManager;
13 58
 
14 59
   Person();
15 60
 
@@ -18,25 +63,28 @@ class Person {
18 63
         appId = json["appId"],
19 64
         openid = json["openid"],
20 65
         nickName = json["nickName"],
21
-        userName = json["userName"],
22 66
         avatar = json["avatar"],
23 67
         sex = json["sex"],
24 68
         phone = json["phone"],
25 69
         userId = json["userId"],
26 70
         status = json["status"],
27
-        createDate = json["createDate"];
71
+        createDate = json["createDate"],
72
+        isOrgManager = json["isOrgManager"],
73
+        identity = json["identity"];
28 74
 
29 75
   Map<String, dynamic> toJson() => {
30
-        'personId': personId,
31
-        'appId': appId,
32
-        'openid': openid,
33
-        'nickName': nickName,
34
-        'userName': userName,
35
-        'avatar': avatar,
36
-        'sex': sex,
37
-        'phone': phone,
38
-        'userId': userId,
39
-        'status': status,
40
-        'createDate': createDate,
41
-      };
76
+    'personId': personId,
77
+    'appId': appId,
78
+    'openid': openid,
79
+    'nickName': nickName,
80
+    'avatar': avatar,
81
+    'sex': sex,
82
+    'phone': phone,
83
+    'userId': userId,
84
+    'status': status,
85
+    'createDate': createDate,
86
+    'isOrgManager': isOrgManager,
87
+    'identity': identity,
88
+
89
+  };
42 90
 }

+ 2
- 0
lib/pages/Login/index.dart Целия файл

@@ -85,7 +85,9 @@ class _Login extends State<Login> {
85 85
             userInfo(Person.fromJson(res['person']));
86 86
             Fluttertoast.showToast(msg: '登录成功!');
87 87
             Get.offNamed('/home');
88
+            // print(userInfo);
88 89
           }).catchError((err) {
90
+            print(err);
89 91
             Fluttertoast.showToast(msg: err);
90 92
           });
91 93
         } else {

+ 5
- 1
lib/pages/main/index.dart Целия файл

@@ -13,7 +13,7 @@ class Main extends BasicPage {
13 13
     tabIndex = 2;
14 14
     naviTitle = '我的';
15 15
   }
16
-  var store = AppController.t;
16
+  AppController store = AppController.t;
17 17
   GetStorage box = GetStorage();
18 18
 
19 19
   void loginOut() {
@@ -34,12 +34,15 @@ class Main extends BasicPage {
34 34
 
35 35
   @override
36 36
   Widget builder(BuildContext context) {
37
+    print(store.user);
38
+
37 39
     return Container(
38 40
       decoration: const BoxDecoration(color: Colors.white),
39 41
       child: ListView(
40 42
         children: [
41 43
           Stack(
42 44
             children: [
45
+              Obx(()=>
43 46
               Positioned(
44 47
                 top: 0,
45 48
                 child: Container(
@@ -110,6 +113,7 @@ class Main extends BasicPage {
110 113
                   ),
111 114
                 ),
112 115
               ),
116
+              ),
113 117
               Positioned(
114 118
                 right: 0,
115 119
                 top: 0,