Yansen vor 1 Jahr
Ursprung
Commit
c167e07d9c

+ 3
- 0
lib/pages/Login/index.dart Datei anzeigen

@@ -52,6 +52,7 @@ class _Login extends State<Login> {
52 52
   final disableQcode = Rx<bool>(false);
53 53
   final isCheck = Rx<bool>(false);
54 54
   final loginData = Rx<Map>({});
55
+  GetStorage box = GetStorage();
55 56
 
56 57
   void setPhone(e) {
57 58
     loginData.value['phone'] = e;
@@ -89,6 +90,8 @@ class _Login extends State<Login> {
89 90
           EasyLoading.show(status: '登录中', maskType: EasyLoadingMaskType.black);
90 91
           userLogin(loginData.value['phone'], loginData.value['qCode'])
91 92
               .then((res) {
93
+            box.write("token", res['token']);
94
+            box.write("tokenTimeout", res['tokenTimeout']);
92 95
             userInfo(Person.fromJson(res['person']));
93 96
             EasyLoading.dismiss();
94 97
             Fluttertoast.showToast(msg: '登录成功!');

+ 14
- 51
lib/pages/agreement/index.dart Datei anzeigen

@@ -1,6 +1,7 @@
1 1
 import 'package:flutter/cupertino.dart';
2 2
 import 'package:flutter/material.dart';
3 3
 import 'package:flutter_screenutil/flutter_screenutil.dart';
4
+import 'package:get/get.dart';
4 5
 import 'package:worker_client/widgets/layout/BasicPage.dart';
5 6
 
6 7
 class Agreement extends BasicPage {
@@ -10,12 +11,11 @@ class Agreement extends BasicPage {
10 11
     return ListView(
11 12
       children: [
12 13
         Container(
13
-          margin: EdgeInsets.symmetric(vertical: 25.h, horizontal: 15.w),
14
-          child: Column(
15
-            children: [
16
-              Container(
17
-                margin: EdgeInsets.only(bottom: 30.h),
18
-                child: Row(
14
+          padding: EdgeInsets.symmetric(vertical: 15.w, horizontal: 15.w),
15
+          child: SingleChildScrollView(
16
+            child: Column(
17
+              children: [
18
+                Row(
19 19
                   mainAxisAlignment: MainAxisAlignment.center,
20 20
                   children: [
21 21
                     Image.asset(
@@ -25,7 +25,7 @@ class Agreement extends BasicPage {
25 25
                     Container(
26 26
                       margin: EdgeInsets.symmetric(horizontal: 15.5.w),
27 27
                       child: Text(
28
-                        '智慧农机的介绍',
28
+                        '用户协议',
29 29
                         style: TextStyle(
30 30
                             fontSize: 22.sp,
31 31
                             fontWeight: FontWeight.bold,
@@ -39,50 +39,13 @@ class Agreement extends BasicPage {
39 39
                     ),
40 40
                   ],
41 41
                 ),
42
-              ),
43
-              Container(
44
-                margin: EdgeInsets.only(top: 40.h),
45
-                child: Column(
46
-                  children: [
47
-                    Text(
48
-                      '本次更新:',
49
-                      style: TextStyle(
50
-                          fontSize: 16.sp,
51
-                          fontWeight: FontWeight.bold,
52
-                          color: const Color(0xff101010)),
53
-                    ),
54
-                    Text(
55
-                      '--解决了一些已知问题--',
56
-                      style: TextStyle(
57
-                          fontSize: 16.sp,
58
-                          fontWeight: FontWeight.bold,
59
-                          color: const Color(0xff101010)),
60
-                    ),
61
-                  ],
62
-                ),
63
-              ),
64
-              Container(
65
-                margin: EdgeInsets.only(top: 40.h),
66
-                child: Column(
67
-                  children: [
68
-                    Text(
69
-                      '最近更新:',
70
-                      style: TextStyle(
71
-                          fontSize: 16.sp,
72
-                          fontWeight: FontWeight.bold,
73
-                          color: const Color(0xff101010)),
74
-                    ),
75
-                    Text(
76
-                      '--这个页面回头加一个外链进来--',
77
-                      style: TextStyle(
78
-                          fontSize: 16.sp,
79
-                          fontWeight: FontWeight.bold,
80
-                          color: const Color(0xff101010)),
81
-                    ),
82
-                  ],
83
-                ),
84
-              ),
85
-            ],
42
+                Image.network(
43
+                  'https://dz-machinery.oss-cn-nanjing.aliyuncs.com/images/privacy_policy.png',
44
+                  width: Get.width,
45
+                  fit: BoxFit.cover,
46
+                )
47
+              ],
48
+            ),
86 49
           ),
87 50
         ),
88 51
       ],

+ 27
- 46
lib/pages/splash/splash.dart Datei anzeigen

@@ -1,54 +1,35 @@
1
+import 'package:card_swiper/card_swiper.dart';
1 2
 import 'package:flutter/material.dart';
2
-import '../splash/widgets/countdown.dart';
3 3
 import 'package:get/get.dart';
4
-import 'package:flutter_screenutil/flutter_screenutil.dart';
5
-import '../home/index.dart';
4
+import 'package:get_storage/get_storage.dart';
5
+import 'package:worker_client/utils/tool.dart';
6 6
 
7
-class SplashScreen extends StatefulWidget {
7
+class SplashScreen extends StatelessWidget {
8 8
   const SplashScreen({Key? key}) : super(key: key);
9 9
 
10
-  @override
11
-  State<SplashScreen> createState() => _SplashScreen();
12
-}
13
-
14
-class _SplashScreen extends State<SplashScreen> {
15
-  handleOnFinish() {
16
-    Get.off(Home());
17
-  }
18
-
19 10
   @override
20 11
   Widget build(BuildContext context) {
21
-    return Scaffold(
22
-        body: Container(
23
-      decoration: const BoxDecoration(
24
-        image: DecorationImage(
25
-            image: AssetImage("images/splash.png"),
26
-            fit: BoxFit.cover,
27
-            alignment: Alignment.topCenter),
28
-      ),
29
-      child: Stack(
30
-        children: [
31
-          Positioned(
32
-            right: 15.w,
33
-            top: 50.h,
34
-            child: countdown(3, handleOnFinish),
35
-          ),
36
-          Positioned(
37
-            bottom: 0,
38
-            child: Container(
39
-              width: 375.w,
40
-              height: 60.w,
41
-              child: Center(
42
-                child: Image.asset(
43
-                  'images/logo.png',
44
-                  width: 218.w,
45
-                  height: 50.w,
46
-                ),
47
-              ),
48
-            ),
49
-          ),
50
-        ],
51
-      ),
52
-    ));
12
+    GetStorage box = GetStorage();
13
+    var pg = isLogin() ? '/home' : '/login';
14
+    box.write("not-first-load", true);
15
+
16
+    return Scaffold (
17
+        body: Swiper (
18
+          itemBuilder: (BuildContext context,int index){
19
+            var adImg = "https://dz-machinery.oss-cn-nanjing.aliyuncs.com/images/nongji_launch_image_" + (index + 1).toString() + ".png";
20
+            return Image.network(adImg,fit: BoxFit.fill,);
21
+          },
22
+          loop: false,
23
+          itemCount: 3,
24
+          pagination: const SwiperPagination(),
25
+          // control: SwiperControl(),
26
+          onTap: (index) {
27
+            if (index == 2) {
28
+              Get.offNamed(pg);
29
+            }
30
+            // foo
31
+          },
32
+        )
33
+    );
53 34
   }
54
-}
35
+}

+ 8
- 1
lib/routes/pages.dart Datei anzeigen

@@ -1,18 +1,25 @@
1 1
 import 'package:get/get.dart';
2 2
 import 'package:get_storage/get_storage.dart';
3 3
 import 'package:worker_client/pages/index.dart';
4
+import 'package:worker_client/utils/tool.dart';
4 5
 
5 6
 List<GetPage> pages = [
6 7
   GetPage(
7 8
       name: '/',
8 9
       page: () {
9 10
         GetStorage box = GetStorage();
10
-        return box.hasData('token') ? Home() : Login();
11
+        var isFirstLoad = !box.hasData("not-first-load");
12
+
13
+        print("------isFirstLoad------");
14
+        print(isFirstLoad);
15
+
16
+        return isFirstLoad ? const SplashScreen() : ( isLogin() ? Home() : Login() );
11 17
       }),
12 18
   GetPage(name: '/order', page: () => Order()),
13 19
   GetPage(name: '/login', page: () => Login()),
14 20
   GetPage(name: '/home', page: () => Home()),
15 21
   GetPage(name: '/main', page: () => Main()),
22
+  GetPage(name: '/splash', page: () => const SplashScreen()), // SplashScreen
16 23
   GetPage(name: '/jobDetail', page: () => JobDetail()),
17 24
   GetPage(name: '/orderDetail', page: () => OrderDetail()),
18 25
   GetPage(name: '/machineryList', page: () => MachineryList()),

+ 17
- 0
lib/utils/tool.dart Datei anzeigen

@@ -0,0 +1,17 @@
1
+
2
+import 'package:get_storage/get_storage.dart';
3
+
4
+bool isLogin() {
5
+  GetStorage box = GetStorage();
6
+
7
+  print('----tokenTimeout----->');
8
+  print(box.read("tokenTimeout"));
9
+
10
+  if (!box.hasData("tokenTimeout")) {
11
+    return false;
12
+  }
13
+
14
+  DateTime expireTime = DateTime.parse(box.read("tokenTimeout"));
15
+  DateTime lastDate = DateTime.now().subtract(const Duration(minutes: 5));
16
+  return expireTime.isAfter(lastDate);
17
+}

+ 7
- 0
pubspec.lock Datei anzeigen

@@ -71,6 +71,13 @@ packages:
71 71
       url: "https://pub.flutter-io.cn"
72 72
     source: hosted
73 73
     version: "1.0.0"
74
+  card_swiper:
75
+    dependency: "direct main"
76
+    description:
77
+      name: card_swiper
78
+      url: "https://pub.flutter-io.cn"
79
+    source: hosted
80
+    version: "3.0.1"
74 81
   carousel_slider:
75 82
     dependency: "direct main"
76 83
     description:

+ 1
- 0
pubspec.yaml Datei anzeigen

@@ -48,6 +48,7 @@ dependencies:
48 48
   flutter_picker: ^2.0.3
49 49
   flutter_easyloading: ^3.0.3
50 50
   flutter_easyrefresh: ^2.2.1
51
+  card_swiper: ^3.0.1
51 52
 
52 53
 dev_dependencies:
53 54
   flutter_test: