李志伟 3 vuotta sitten
vanhempi
commit
b4a23fba42

+ 1
- 0
android/app/src/main/AndroidManifest.xml Näytä tiedosto

@@ -24,6 +24,7 @@
24 24
     <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
25 25
     <!--允许读设备等信息,用于问题排查-->
26 26
     <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
27
+
27 28
    <application
28 29
         android:label="worker_client"
29 30
         android:name="${applicationName}"

+ 11
- 11
lib/models/app.dart Näytä tiedosto

@@ -35,17 +35,17 @@ class AppController extends GetxController {
35 35
     super.onInit();
36 36
 
37 37
     // 尝试获取 location
38
-    requireLocation(onLocationChange).then((loc) {
39
-      _location = loc;
40
-    }).catchError((e) {
41
-      print(e);
42
-
43
-      showAlert(
44
-        title: '获取定位失败',
45
-        message: e.message,
46
-        onConfirm: () => exit(1),
47
-      );
48
-    });
38
+    // requireLocation(onLocationChange).then((loc) {
39
+    //   _location = loc;
40
+    // }).catchError((e) {
41
+    //   print(e);
42
+    //
43
+    //   showAlert(
44
+    //     title: '获取定位失败',
45
+    //     message: e.message,
46
+    //     onConfirm: () => exit(1),
47
+    //   );
48
+    // });
49 49
 
50 50
     // // 尝试获取一次人员信息
51 51
     // getCurrent().then((person) {

+ 1
- 0
lib/models/entities/Job.dart Näytä tiedosto

@@ -57,6 +57,7 @@ class Job {
57 57
   String? workerName;
58 58
 
59 59
   Job();
60
+
60 61
   Job.fromJson(Map<String, dynamic> json)
61 62
       : jobId = json["jobId"],
62 63
         dispatchId = json["dispatchId"],

+ 7
- 19
lib/pages/Login/index.dart Näytä tiedosto

@@ -9,6 +9,7 @@ import 'package:get/get.dart';
9 9
 import 'package:worker_client/widgets/Cell.dart';
10 10
 import 'package:worker_client/widgets/GradientButton.dart';
11 11
 import 'package:worker_client/pages/home/index.dart';
12
+import 'package:worker_client/widgets/MyButton/index.dart';
12 13
 import '../../models/entities/person.dart';
13 14
 import '../../services/user.dart';
14 15
 
@@ -240,27 +241,14 @@ class _Login extends State<Login> {
240 241
                 //找到了 下面就是置底
241 242
                 const Spacer(),
242 243
                 Center(
243
-                  child: SizedBox(
244
-                    width: 315.w,
245
-                    height: 49.h,
246
-                    child: GradientButton(
247
-                        colors: const [
248
-                          Color(0xFFA0E067),
249
-                          Color(0xFF00AE39),
250
-                        ],
251
-                        borderRadius: BorderRadius.all(Radius.circular(24.5.w)),
252
-                        onPressed: disableLogin ? null : handleLogin,
253
-                        child: Text(
254
-                          '登录',
255
-                          style: TextStyle(
256
-                            fontSize: 17.sp,
257
-                            fontWeight: FontWeight.bold,
258
-                          ),
259
-                        )),
260
-                  ),
244
+                  child: MyButton(
245
+                      text: '登录',
246
+                      type: 0,
247
+                      disable: disableLogin,
248
+                      onClick: handleLogin),
261 249
                 ),
262 250
                 Container(
263
-                  margin: EdgeInsets.fromLTRB(0, 30.h, 0, 0),
251
+                  margin: EdgeInsets.fromLTRB(0, 21.h, 0, 0),
264 252
                   child: GestureDetector(
265 253
                     onTap: () {
266 254
                       setState(() {

+ 45
- 0
lib/pages/detail/index.dart Näytä tiedosto

@@ -0,0 +1,45 @@
1
+import 'package:flutter/material.dart';
2
+import 'package:flutter/src/widgets/framework.dart';
3
+import 'package:get/get.dart';
4
+import 'package:worker_client/models/entities/Job.dart';
5
+import 'package:worker_client/services/job.dart';
6
+import 'package:worker_client/widgets/MyCard/index.dart';
7
+import 'package:worker_client/widgets/layout/BasicPage.dart';
8
+
9
+class Detail extends BasicPage {
10
+  final job = Rx<Job>(Job());
11
+  @override
12
+  void beforeShow() {
13
+    super.beforeShow();
14
+    if (Get.arguments != null) {
15
+      //请求详情接口
16
+      getJobDetail(Get.arguments['id'].toString())
17
+          .then((value) => {job(Job.fromJson(value))});
18
+    }
19
+  }
20
+
21
+  void changeJob(Job item) {}
22
+  void goDetail(Job item) {}
23
+  @override
24
+  Widget builder(BuildContext context) {
25
+    naviTitle = '详情';
26
+    return Container(
27
+        alignment: Alignment.topCenter,
28
+        child: Column(
29
+          children: [
30
+            Obx(() => MyCard(
31
+                  item: job(),
32
+                  job: true,
33
+                  detail: true,
34
+                  onClick: () {
35
+                    changeJob(job());
36
+                  },
37
+                  goDetail: () {
38
+                    goDetail(job());
39
+                  },
40
+                  buttomText: job().status == 0 ? '开始作业' : '完成作业',
41
+                ))
42
+          ],
43
+        ));
44
+  }
45
+}

+ 97
- 67
lib/pages/home/widgets/home/index.dart Näytä tiedosto

@@ -7,6 +7,7 @@ import 'package:worker_client/models/entities/Job.dart';
7 7
 import 'package:worker_client/pages/home/widgets/home/widgets/headers.dart';
8 8
 import 'package:worker_client/services/banner.dart';
9 9
 import 'package:worker_client/services/job.dart';
10
+import 'package:worker_client/widgets/MoreList.dart';
10 11
 import 'package:worker_client/widgets/MyCard/index.dart';
11 12
 
12 13
 class HomePage extends StatefulWidget {
@@ -18,89 +19,118 @@ class HomePage extends StatefulWidget {
18 19
 
19 20
 class _HomePageState extends State<HomePage> {
20 21
   final bannerList = Rx<List<BannerModel>>([]);
21
-  final jobList = Rx<List<Job>>([]);
22
+  List<Job> jobList = [];
22 23
   final job = Rx<Job>(Job());
23 24
   @override
24 25
   void initState() {
25 26
     super.initState();
26 27
     getBannerList('bannerWorker').then((res) {
27
-      List<BannerModel> list=[];
28
+      List<BannerModel> list = [];
28 29
       for (var item in res) {
29 30
         list.add(BannerModel.fromJson(item));
30 31
       }
31
-      bannerList.value=list;
32
-    });
33
-    getJobList().then((res) {
34
-      List<Job> list=[];
35
-      for (var item in res['records']) {
36
-        list.add(Job.fromJson(item));
37
-      }
38
-      jobList.value=list;
32
+      bannerList.value = list;
39 33
     });
40 34
   }
41 35
 
36
+  List<Job> GetList(value) {
37
+    List<Job> list = [];
38
+    value.forEach((item) => {list.add(Job.fromJson(item))});
39
+    return list;
40
+  }
41
+
42
+  Map<String, dynamic> map = {'pageNum': 1};
43
+
44
+  void changeJob(Job item) {}
45
+  void goDetail(Job item) {
46
+    Get.toNamed('/detail', arguments: {'id': item.jobId});
47
+  }
48
+
42 49
   @override
43 50
   Widget build(BuildContext context) {
44
-    return Container(
45
-      decoration: const BoxDecoration(color: Colors.white),
46
-      padding: EdgeInsets.all(15.w),
47
-      child: Column(
48
-        children: [
49
-          const headers(),
50
-          //banner
51
-          Container(
52
-            margin: EdgeInsets.fromLTRB(0, 15.h, 0, 15.h),
53
-            child: Obx(() => CarouselSlider(
54
-                  items: bannerList.value
55
-                      .map((item) => Container(
56
-                            child: Center(
57
-                                child: Image.network(item.thumb.toString(),
58
-                                    fit: BoxFit.cover, width: 345.w)),
59
-                          ))
60
-                      .toList(),
61
-                  options: CarouselOptions(
62
-                    autoPlay: true,
63
-                    enlargeCenterPage: false, //图片中心放大
64
-                    viewportFraction:
65
-                        1, //每个页面应占据的视口部分。默认为 0.8,这意味着每个页面填充 80% 的轮播。
66
-                    // aspectRatio: 1.6,//纵横比
67
-                    height: 214.w,
68
-                    initialPage: 1, //初始页
51
+    return MoreList(
52
+      serves: getJobList,
53
+      params: map,
54
+      getJson: (BuildContext context, List<dynamic> jsonData) {
55
+        jobList = GetList(jsonData);
56
+        return Column(
57
+          children: [
58
+            Container(
59
+              decoration: const BoxDecoration(color: Colors.white),
60
+              padding: EdgeInsets.all(15.w),
61
+              child: Column(
62
+                children: [
63
+                  const headers(),
64
+                  //banner
65
+                  Container(
66
+                    margin: EdgeInsets.fromLTRB(0, 15.h, 0, 15.h),
67
+                    child: Obx(() => CarouselSlider(
68
+                          items: bannerList.value
69
+                              .map((item) => Container(
70
+                                    child: Center(
71
+                                        child: Image.network(
72
+                                            item.thumb.toString(),
73
+                                            fit: BoxFit.cover,
74
+                                            width: 345.w)),
75
+                                  ))
76
+                              .toList(),
77
+                          options: CarouselOptions(
78
+                            autoPlay: true,
79
+                            enlargeCenterPage: false,
80
+                            //图片中心放大
81
+                            viewportFraction: 1,
82
+                            //每个页面应占据的视口部分。默认为 0.8,这意味着每个页面填充 80% 的轮播。
83
+                            // aspectRatio: 1.6,//纵横比
84
+                            height: 214.w,
85
+                            initialPage: 1, //初始页
86
+                          ),
87
+                        )),
69 88
                   ),
70
-                )),
71
-          ),
72
-          Container(
73
-            margin: EdgeInsets.fromLTRB(0, 15.h, 0, 20.h),
74
-            child: Row(
75
-              children: [
76
-                Padding(
77
-                  padding: EdgeInsets.fromLTRB(0, 0, 10.w, 0),
78
-                  child: Image.asset(
79
-                    'images/index/orderList.png',
80
-                    width: 20.w,
89
+                  Container(
90
+                    margin: EdgeInsets.fromLTRB(0, 15.h, 0, 20.h),
91
+                    child: Row(
92
+                      children: [
93
+                        Padding(
94
+                          padding: EdgeInsets.fromLTRB(0, 0, 10.w, 0),
95
+                          child: Image.asset(
96
+                            'images/index/orderList.png',
97
+                            width: 20.w,
98
+                          ),
99
+                        ),
100
+                        Text(
101
+                          '作业列表',
102
+                          style: TextStyle(
103
+                              color: Color(0xff222222),
104
+                              fontSize: 20.sp,
105
+                              fontWeight: FontWeight.w800),
106
+                        )
107
+                      ],
108
+                    ),
81 109
                   ),
82
-                ),
83
-                Text(
84
-                  '作业列表',
85
-                  style: TextStyle(
86
-                      color: Color(0xff222222),
87
-                      fontSize: 20.sp,
88
-                      fontWeight: FontWeight.w800),
89
-                )
90
-              ],
91
-            ),
92
-          ),
93
-          Obx(
94
-            () => Column(
95
-              children: jobList.value
96
-                  .map(
97
-                    (item) => const MyCard(),
98
-                  )
99
-                  .toList(),
110
+                  Column(
111
+                    children: jobList
112
+                        .map(
113
+                          (item) => MyCard(
114
+                            item: item,
115
+                            job: true,
116
+                            detail: false,
117
+                            onClick: () {
118
+                              changeJob(item);
119
+                            },
120
+                            goDetail: () {
121
+                              goDetail(item);
122
+                            },
123
+                            buttomText: item.status == 0 ? '开始作业' : '完成作业',
124
+                          ),
125
+                        )
126
+                        .toList(),
127
+                  ),
128
+                ],
129
+              ),
100 130
             ),
101
-          ),
102
-        ],
103
-      ),
131
+          ],
132
+        );
133
+      },
104 134
     );
105 135
   }
106 136
 }

+ 1
- 0
lib/pages/index.dart Näytä tiedosto

@@ -4,3 +4,4 @@ export 'splash/splash.dart';
4 4
 export 'Login/index.dart';
5 5
 export 'order/index.dart';
6 6
 export 'main/index.dart';
7
+export 'detail/index.dart';

+ 3
- 2
lib/pages/main/index.dart Näytä tiedosto

@@ -1,6 +1,7 @@
1 1
 import 'package:flutter/material.dart';
2 2
 import 'package:worker_client/widgets/layout/BasicPage.dart';
3 3
 
4
+
4 5
 class Main extends BasicPage {
5 6
   Main({Key? key}) : super(key: key) {
6 7
     tabIndex = 2;
@@ -9,6 +10,6 @@ class Main extends BasicPage {
9 10
 
10 11
   @override
11 12
   Widget builder(BuildContext context) {
12
-    return const Text('我是个人中心页面');
13
+    return Text('我是个人中心页面');
13 14
   }
14
-}
15
+}

+ 2
- 3
lib/pages/order/index.dart Näytä tiedosto

@@ -1,7 +1,6 @@
1 1
 import 'package:flutter/material.dart';
2 2
 import 'package:worker_client/widgets/layout/BasicPage.dart';
3 3
 
4
-
5 4
 class Order extends BasicPage {
6 5
   Order({Key? key}) : super(key: key) {
7 6
     tabIndex = 1;
@@ -10,6 +9,6 @@ class Order extends BasicPage {
10 9
 
11 10
   @override
12 11
   Widget builder(BuildContext context) {
13
-    return Text('我是订单列表页面');
12
+    return Text('我是订单列表');
14 13
   }
15
-}
14
+}

+ 1
- 0
lib/routes/pages.dart Näytä tiedosto

@@ -13,4 +13,5 @@ List<GetPage> pages = [
13 13
   GetPage(name: '/order', page: () =>  Order()),
14 14
   GetPage(name: '/', page: () =>  Home()),
15 15
   GetPage(name: '/main', page: () =>  Main()),
16
+  GetPage(name: '/detail', page: () =>  Detail()),
16 17
 ];

+ 1
- 1
lib/services/banner.dart Näytä tiedosto

@@ -11,7 +11,7 @@ Future getBannerList(String position) async {
11 11
   return request('/banner',
12 12
       options: Options(method: 'GET'), data: {'position': position})
13 13
       .catchError((error) => {
14
-    Fluttertoast.showToast(msg: error.error['message']),
14
+    Fluttertoast.showToast(msg: error.error.toString()),
15 15
   });
16 16
 }
17 17
 

+ 7
- 5
lib/services/job.dart Näytä tiedosto

@@ -5,10 +5,12 @@ import 'package:fluttertoast/fluttertoast.dart';
5 5
 /// 作业列表
6 6
 /// @param {*} data
7 7
 /// @returns
8
-Future getJobList() async {
9
-  return request('/work-job', options: Options(method: 'GET'))
8
+Future getJobList( params) async {
9
+  return request('/work-job',
10
+          options: Options(method: 'GET'), queryParameters: params)
10 11
       .catchError((error) => {
11
-            Fluttertoast.showToast(msg: error.error['message']),
12
+            Fluttertoast.showToast(msg: error.error.toString()),
13
+    print(error)
12 14
           });
13 15
 }
14 16
 
@@ -16,8 +18,8 @@ Future getJobList() async {
16 18
 /// @param {*} data
17 19
 /// @returns
18 20
 Future getJobDetail(String id) async {
19
-  return request('/work-job',
20
-          options: Options(method: 'GET'), queryParameters: {'id': id})
21
+  return request('/work-job/$id',
22
+          options: Options(method: 'GET'))
21 23
       .catchError((error) => {
22 24
             Fluttertoast.showToast(msg: error.error['message']),
23 25
           });

+ 99
- 0
lib/widgets/MoreList.dart Näytä tiedosto

@@ -0,0 +1,99 @@
1
+import 'package:flutter/material.dart';
2
+import 'package:get/get.dart';
3
+
4
+typedef GetJson = Widget Function(BuildContext context, List<dynamic> jsonData);
5
+
6
+class MoreList extends StatefulWidget {
7
+  final Future Function(Map params)? serves;
8
+  final Map? params;
9
+  final GetJson? getJson;
10
+  final Widget? child;
11
+
12
+  const MoreList(
13
+      {Key? key,
14
+      required this.serves,
15
+      required this.getJson,
16
+      this.child,
17
+      required this.params})
18
+      : super(key: key);
19
+
20
+  @override
21
+  _MoreList createState() => _MoreList(serves, params);
22
+}
23
+
24
+//传一个serves进来传一个json出去
25
+class _MoreList extends State<MoreList> {
26
+  final Future Function(Map params)? serves;
27
+  final Map? params;
28
+  final jsonData = Rx<List<dynamic>>([]);
29
+  _MoreList(this.serves, this.params);
30
+
31
+  final ScrollController _scrollController = ScrollController();
32
+  final _page = Rx<int>(1);
33
+  bool isLoading = false;
34
+  final hasMore = Rx<bool>(false);
35
+
36
+  @override
37
+  void initState() {
38
+    super.initState();
39
+    getList();
40
+    addEvent();
41
+  }
42
+  void addEvent(){
43
+    _scrollController.addListener(() {
44
+      if (!hasMore.value) {
45
+        print('暂无更多');
46
+        return;
47
+      }
48
+      if (!isLoading &&
49
+          _scrollController.position.pixels >=
50
+              _scrollController.position.maxScrollExtent) {
51
+        _page.value++;
52
+        params!['pageNum'] = _page.value;
53
+        getList();
54
+      }
55
+    });
56
+  }
57
+
58
+  void getList() {
59
+    if (serves != null) {
60
+      isLoading = true;
61
+      serves!(params!).then((res) {
62
+        var list = [];
63
+        list = [...jsonData.value, ...res['records']];
64
+        jsonData.value = list;
65
+        if (res['total'] > jsonData.value.length) {
66
+          hasMore.value = true;
67
+        }else {
68
+          hasMore.value = false;
69
+        }
70
+        isLoading=false;
71
+      });
72
+    }
73
+  }
74
+
75
+  Future onRefresh() {
76
+    return Future.delayed(Duration(seconds: 1), () {
77
+      _page.value = 1;
78
+      jsonData.value = [];
79
+      params!['pageNum'] = _page.value;
80
+      getList();
81
+    });
82
+  }
83
+
84
+  @override
85
+  Widget build(BuildContext context) {
86
+    if (serves == null)
87
+      return ListView(
88
+        children: [widget.child!],
89
+      );
90
+    return RefreshIndicator(
91
+        onRefresh: onRefresh,
92
+        child: ListView.builder(
93
+            controller: _scrollController,
94
+            itemCount: 1,
95
+            itemBuilder: (BuildContext context, int position) {
96
+              return Obx(() => widget.getJson!(context, jsonData.value));
97
+            }));
98
+  }
99
+}

+ 7
- 0
lib/widgets/MyButton/entities/Gradient.dart Näytä tiedosto

@@ -0,0 +1,7 @@
1
+import 'dart:ui';
2
+
3
+class GradientModel {
4
+  final Color beginColor;
5
+  final Color endColor;
6
+  GradientModel(this.beginColor, this.endColor);
7
+}

+ 48
- 0
lib/widgets/MyButton/index.dart Näytä tiedosto

@@ -0,0 +1,48 @@
1
+import 'package:flutter/cupertino.dart';
2
+import 'package:flutter_screenutil/flutter_screenutil.dart';
3
+import 'package:worker_client/widgets/MyButton/entities/Gradient.dart';
4
+
5
+import '../GradientButton.dart';
6
+
7
+class MyButton extends StatelessWidget {
8
+  final String text;
9
+  //type 1 绿色 2 黄色
10
+  final int type;
11
+  //true 有结束动画 false 无变化
12
+  final bool disable;
13
+  //点击事件
14
+  final GestureTapCallback onClick;
15
+
16
+  MyButton(
17
+      {Key? key,
18
+      required this.text,
19
+      required this.type,
20
+      required this.disable,
21
+      required this.onClick})
22
+      : super(key: key);
23
+
24
+  List<GradientModel> Glist=[
25
+    GradientModel(Color(0xFFA0E067), Color(0xFF00AE39)),
26
+    GradientModel(Color(0xFFFFAB8C), Color(0xFFFF703B)),
27
+  ];
28
+  @override
29
+  Widget build(BuildContext context) {
30
+    return Container(
31
+      margin: EdgeInsets.fromLTRB(0, 12.5.h, 0, 9.h),
32
+      width: 315.w,
33
+      height: 49.h,
34
+      child: GradientButton(
35
+          colors: [Glist[type].beginColor,Glist[type].endColor],
36
+          borderRadius: BorderRadius.all(Radius.circular(24.5.w)),
37
+          onPressed: disable ? null : onClick,
38
+          child: Text(
39
+            text,
40
+            style: TextStyle(
41
+              fontSize: 17.sp,
42
+              fontWeight: FontWeight.bold,
43
+              letterSpacing: 2
44
+            ),
45
+          )),
46
+    );
47
+  }
48
+}

+ 8
- 0
lib/widgets/MyCard/entities/ItemColor.dart Näytä tiedosto

@@ -0,0 +1,8 @@
1
+import 'dart:ui';
2
+
3
+class ItemColor{
4
+  final Color borderColor;
5
+  final Color leftColor;
6
+  final Color rightColor;
7
+  ItemColor(this.borderColor, this.leftColor, this.rightColor);
8
+}

+ 170
- 28
lib/widgets/MyCard/index.dart Näytä tiedosto

@@ -1,16 +1,77 @@
1 1
 import 'dart:math';
2 2
 import 'package:flutter/material.dart';
3 3
 import 'package:flutter_screenutil/flutter_screenutil.dart';
4
+import 'package:worker_client/models/entities/Job.dart';
5
+import 'package:worker_client/widgets/MyButton/index.dart';
6
+import 'package:worker_client/widgets/MyCard/entities/ItemColor.dart';
4 7
 import 'package:worker_client/widgets/MyCard/widgets/CardCell.dart';
5 8
 
6
-class MyCard extends StatelessWidget{
9
+class MyCard extends StatelessWidget {
10
+  final Job item;
11
+  final String? type;
12
+  final String? value;
13
+  final String buttomText;
14
+  final bool job;
15
+  final bool detail;
16
+  final GestureTapCallback onClick;
17
+  final GestureTapCallback? goDetail;
18
+  MyCard(
19
+      {Key? key,
20
+      required this.item,
21
+      this.type,
22
+      this.value,
23
+      required this.job,
24
+      required this.detail,
25
+      required this.onClick,
26
+      required this.buttomText,
27
+      this.goDetail})
28
+      : super(key: key);
7 29
 
8
-  const MyCard({Key? key}) : super(key: key);
30
+  List<ItemColor> colors = [
31
+    ItemColor(const Color(0xFFC7C7C7), const Color(0xFF8F8F8F),
32
+        const Color(0xFFC0C0C0)),
33
+    ItemColor(const Color(0xFFFFC937), const Color(0xFFFFAB8C),
34
+        const Color(0xFFFF703B)),
35
+    ItemColor(const Color(0xFF06B03B), const Color(0xFF00AE39),
36
+        const Color(0xFFA0E067)),
37
+  ];
38
+
39
+  String Title() {
40
+    return type == 'machinery'
41
+        ? (item.status == 0
42
+            ? '维修中'
43
+            : (value != null || value == 3)
44
+                ? '空闲中'
45
+                : '使用中')
46
+        : item.status == 0
47
+            ? '待作业'
48
+            : item.status == 1 || item.status == 2
49
+                ? '进行中'
50
+                : item.status == 3
51
+                    ? '已完成'
52
+                    : '';
53
+  }
54
+
55
+  ItemColor CurrentColor() {
56
+    return type == 'machinery'
57
+        ? (item.status == 0
58
+            ? colors[0]
59
+            : (value != null || value == 3)
60
+                ? colors[1]
61
+                : colors[2])
62
+        : item.status == 0
63
+            ? colors[1]
64
+            : item.status == 1 || item.status == 2
65
+                ? colors[2]
66
+                : item.status == 3
67
+                    ? colors[0]
68
+                    : colors[0];
69
+  }
9 70
 
10 71
   @override
11 72
   Widget build(BuildContext context) {
12 73
     return Container(
13
-      margin: EdgeInsets.fromLTRB(0, 0, 0, 15.w),
74
+      margin: EdgeInsets.fromLTRB(0, 7.5.w, 0, 7.5.w),
14 75
       clipBehavior: Clip.hardEdge,
15 76
       width: 345.w,
16 77
       decoration: BoxDecoration(
@@ -37,12 +98,12 @@ class MyCard extends StatelessWidget{
37 98
                   borderRadius: BorderRadius.all(Radius.circular(68.5.w)),
38 99
                   border: Border.all(
39 100
                       width: 1.w,
40
-                      color: Color(0xFFc7c7c7),
101
+                      color: CurrentColor().borderColor,
41 102
                       style: BorderStyle.solid),
42 103
                   gradient: LinearGradient(
43 104
                     colors: [
44
-                      Color(0xFFA0E067),
45
-                      Color(0xFF00AE39),
105
+                      CurrentColor().rightColor,
106
+                      CurrentColor().leftColor,
46 107
                     ],
47 108
                   ),
48 109
                 ),
@@ -51,11 +112,11 @@ class MyCard extends StatelessWidget{
51 112
                   child: Transform.translate(
52 113
                     offset: Offset(38.w, 85.w),
53 114
                     child: Text(
54
-                      '进行中',
115
+                      Title(),
55 116
                       style: TextStyle(
56 117
                           fontSize: 14.sp,
57 118
                           fontWeight: FontWeight.bold,
58
-                          color: Color(0xffffffff)),
119
+                          color: const Color(0xffffffff)),
59 120
                     ),
60 121
                   ),
61 122
                 ),
@@ -92,25 +153,30 @@ class MyCard extends StatelessWidget{
92 153
                       Expanded(
93 154
                         flex: 1,
94 155
                         child: Text(
95
-                          '2025-05-25',
156
+                          item.appointmentDate != null
157
+                              ? item.appointmentDate.toString().substring(0, 10)
158
+                              : '',
96 159
                           style: TextStyle(
97 160
                               fontSize: 17.sp,
98 161
                               color: Color(0xFF101010),
99 162
                               fontWeight: FontWeight.bold),
100 163
                         ),
101 164
                       ),
102
-                      GestureDetector(
103
-                        onTap: () {},
104
-                        child: Container(
105
-                          margin: EdgeInsets.fromLTRB(0, 0, 7.5.w, 0),
106
-                          child: Text(
107
-                            '详情>>',
108
-                            style: TextStyle(
109
-                                fontSize: 17.sp,
110
-                                fontWeight: FontWeight.bold,
111
-                                color: Color(0xFF606060)),
165
+                      Visibility(
166
+                        child: GestureDetector(
167
+                          onTap: goDetail,
168
+                          child: Container(
169
+                            margin: EdgeInsets.fromLTRB(0, 0, 7.5.w, 0),
170
+                            child: Text(
171
+                              '详情>>',
172
+                              style: TextStyle(
173
+                                  fontSize: 17.sp,
174
+                                  fontWeight: FontWeight.bold,
175
+                                  color: Color(0xFF606060)),
176
+                            ),
112 177
                           ),
113 178
                         ),
179
+                        visible: job && !detail,
114 180
                       )
115 181
                     ],
116 182
                   ),
@@ -120,13 +186,90 @@ class MyCard extends StatelessWidget{
120 186
                   height: 30.h,
121 187
                   thickness: 0.5.w,
122 188
                 ),
123
-                CardCell(lable: '订单号', content: 'M-20220424000003', size: 8.6),
124
-                CardCell(lable: '农机名称', content: '源盛第四种农机的第一个农机', size: 2),
125
-                CardCell(lable: '下单人', content: '', size: 8.6),
126
-                CardCell(lable: '手机号', content: '18082043755', size: 8.6),
127
-                CardCell(lable: '订单时间', content: '2022-04-24', size: 2),
128
-                CardCell(lable: '作业时间', content: '2022-04-24 15:54:51 2022-04-25 15:54:51', size: 2),
129
-                CardCell(lable: '订单费用', content: '0.01元', size: 2),
189
+                CardCell(
190
+                    lable: '订单号', content: item.orderNo.toString(), size: 8.6),
191
+                Visibility(
192
+                  child: CardCell(
193
+                      lable: '农机名称',
194
+                      content: item.machineryName.toString(),
195
+                      size: 2),
196
+                  visible: job,
197
+                ),
198
+                Visibility(
199
+                  child: CardCell(
200
+                      lable: '农机类型',
201
+                      content: item.machineryTypeName.toString(),
202
+                      size: 2),
203
+                  visible: job,
204
+                ),
205
+                CardCell(
206
+                    lable: '下单人',
207
+                    content: (item.personName ?? ' ').toString(),
208
+                    size: 8.6),
209
+                CardCell(
210
+                    lable: '手机号', content: item.phone.toString(), size: 8.6),
211
+                CardCell(
212
+                    lable: '订单时间',
213
+                    content: item.createDate != null
214
+                        ? item.createDate.toString().substring(0, 10)
215
+                        : '',
216
+                    size: 2),
217
+                Visibility(
218
+                    child: CardCell(
219
+                        lable: '服务地址',
220
+                        content: item.address.toString(),
221
+                        size: 2),
222
+                    visible: detail),
223
+                Visibility(
224
+                    child: CardCell(
225
+                        lable: '作业时间',
226
+                        content: item.startDate.toString(),
227
+                        size: 2),
228
+                    visible: job),
229
+                Visibility(
230
+                    child: CardCell(
231
+                        lable: '',
232
+                        content: (item.endDate ?? '').toString(),
233
+                        size: 2),
234
+                    visible: job),
235
+                CardCell(
236
+                    lable: '订单费用',
237
+                    content: ((item.charges ?? 0) / 100).toString(),
238
+                    size: 2),
239
+                Visibility(
240
+                  visible: job && item.status != 3,
241
+                  child: MyButton(
242
+                      text: buttomText,
243
+                      type: item.status??0 ,
244
+                      disable: false,
245
+                      onClick: onClick),
246
+                ),
247
+                Visibility(
248
+                  child: Divider(
249
+                    color: Color(0xE5000000),
250
+                    height: 30.h,
251
+                    thickness: 0.5.w,
252
+                  ),
253
+                  visible: !job,
254
+                ),
255
+                Visibility(
256
+                  child: GestureDetector(
257
+                    onTap: goDetail,
258
+                    child: Container(
259
+                      alignment: Alignment.center,
260
+                      width: 345.w,
261
+                      padding: EdgeInsets.fromLTRB(0, 12.5.h, 0, 0),
262
+                      child: const Text(
263
+                        '详情>>',
264
+                        style: TextStyle(
265
+                          fontWeight: FontWeight.bold,
266
+                          color: Color(0xFF606060),
267
+                        ),
268
+                      ),
269
+                    ),
270
+                  ),
271
+                  visible: !job,
272
+                ),
130 273
               ],
131 274
             ),
132 275
           ),
@@ -134,5 +277,4 @@ class MyCard extends StatelessWidget{
134 277
       ),
135 278
     );
136 279
   }
137
-
138
-}
280
+}

+ 1
- 1
lib/widgets/MyCard/widgets/CardCell.dart Näytä tiedosto

@@ -32,7 +32,7 @@ class CardCell extends StatelessWidget {
32 32
             ),
33 33
           ),
34 34
           Text(
35
-            ':',
35
+            lable==''?'    ':':',
36 36
             style: TextStyle(
37 37
               fontSize: 17.sp,
38 38
               color: const Color(0xFF606060),

+ 42
- 0
lib/widgets/amap/amap.dart Näytä tiedosto

@@ -0,0 +1,42 @@
1
+import 'package:amap_flutter_map/amap_flutter_map.dart';
2
+import 'package:amap_flutter_base/amap_flutter_base.dart';
3
+import 'package:flutter/widgets.dart';
4
+
5
+import '/utils/amap/const_config.dart';
6
+
7
+// https://developer.amap.com/api/flutter/guide/map-flutter-plug-in/map-flutter-info
8
+class AMap extends StatelessWidget {
9
+  late AMapController _mapController;
10
+  final LatLng? position;
11
+  final Map<String, Marker> _markers = Map<String, Marker>();
12
+
13
+  AMap({Key? key,  this.position }): super(key: key);
14
+
15
+  void onMapCreated(AMapController controller) {
16
+    _mapController = controller;
17
+  }
18
+
19
+  void _initMarkers() {
20
+    if (null != position) {
21
+      Marker marker = Marker(
22
+        position: position!,
23
+        icon: BitmapDescriptor.fromIconPath("images/locationImage.png")
24
+      );
25
+      _markers[marker.id] = marker;
26
+    }
27
+  }
28
+
29
+  @override
30
+  Widget build(BuildContext context) {
31
+    _initMarkers();
32
+
33
+    return AMapWidget(
34
+      privacyStatement: ConstConfig.amapPrivacyStatement,
35
+      apiKey: ConstConfig.amapApiKeys,
36
+      markers: Set<Marker>.of(_markers.values),
37
+      // 默认是邓州市中心
38
+      initialCameraPosition: const CameraPosition(target: LatLng(32.687732, 112.08745)),
39
+    );
40
+  }
41
+
42
+}

+ 22
- 0
lib/widgets/amap/const_config.dart Näytä tiedosto

@@ -0,0 +1,22 @@
1
+import 'package:amap_flutter_base/amap_flutter_base.dart';
2
+import 'package:amap_flutter_map/amap_flutter_map.dart';
3
+
4
+class ConstConfig {
5
+  ///配置您申请的apikey,在此处配置之后,可以在初始化[AMapWidget]时,通过`apiKey`属性设置
6
+  ///
7
+  ///注意:使用[AMapWidget]的`apiKey`属性设置的key的优先级高于通过Native配置key的优先级,
8
+  ///使用[AMapWidget]的`apiKey`属性配置后Native配置的key将失效,请根据实际情况选择使用
9
+  static const AMapApiKey amapApiKeys = AMapApiKey(
10
+      androidKey: 'b481b4187e24e625fa0056fd0530e663',
11
+      iosKey: '您申请的iOS平台的key');
12
+
13
+  ///高德隐私合规声明,这里只是示例,实际使用中请按照实际参数设置[AMapPrivacyStatement]的'hasContains''hasShow''hasAgree'这三个参数
14
+  ///
15
+  /// 注意:[AMapPrivacyStatement]的'hasContains''hasShow''hasAgree'这三个参数中有一个为false,高德SDK均不会工作,会造成地图白屏等现象
16
+  ///
17
+  /// 高德开发者合规指南请参考:https://lbs.amap.com/agreement/compliance
18
+  ///
19
+  /// 高德SDK合规使用方案请参考:https://lbs.amap.com/news/sdkhgsy
20
+  static const AMapPrivacyStatement amapPrivacyStatement =
21
+  AMapPrivacyStatement(hasContains: true, hasShow: true, hasAgree: true);
22
+}

+ 1
- 1
lib/widgets/layout/BasicPage.dart Näytä tiedosto

@@ -103,7 +103,7 @@ class _BasicPageState extends State<BasicPage> {
103 103
     return Scaffold(
104 104
       appBar: _getAppBar(),
105 105
       body: SafeArea(
106
-        child: _buildChild(context),
106
+        child: widget.builder(context),
107 107
       ),
108 108
       bottomNavigationBar: widget.tabIndex == null ? null : BottomBar(list: BarList, current: widget.tabIndex!),
109 109
     );

+ 7
- 7
pubspec.lock Näytä tiedosto

@@ -126,7 +126,7 @@ packages:
126 126
       name: crypto
127 127
       url: "https://pub.flutter-io.cn"
128 128
     source: hosted
129
-    version: "3.0.1"
129
+    version: "3.0.2"
130 130
   cupertino_icons:
131 131
     dependency: "direct main"
132 132
     description:
@@ -194,7 +194,7 @@ packages:
194 194
       name: flutter_screenutil
195 195
       url: "https://pub.flutter-io.cn"
196 196
     source: hosted
197
-    version: "5.4.0+1"
197
+    version: "5.5.0"
198 198
   flutter_test:
199 199
     dependency: "direct dev"
200 200
     description: flutter
@@ -253,14 +253,14 @@ packages:
253 253
       name: json_annotation
254 254
       url: "https://pub.flutter-io.cn"
255 255
     source: hosted
256
-    version: "4.4.0"
256
+    version: "4.5.0"
257 257
   json_serializable:
258 258
     dependency: "direct main"
259 259
     description:
260 260
       name: json_serializable
261 261
       url: "https://pub.flutter-io.cn"
262 262
     source: hosted
263
-    version: "6.1.6"
263
+    version: "6.2.0"
264 264
   lints:
265 265
     dependency: transitive
266 266
     description:
@@ -344,7 +344,7 @@ packages:
344 344
       name: path_provider_android
345 345
       url: "https://pub.flutter-io.cn"
346 346
     source: hosted
347
-    version: "2.0.12"
347
+    version: "2.0.13"
348 348
   path_provider_ios:
349 349
     dependency: transitive
350 350
     description:
@@ -545,7 +545,7 @@ packages:
545 545
       name: win32
546 546
       url: "https://pub.flutter-io.cn"
547 547
     source: hosted
548
-    version: "2.5.1"
548
+    version: "2.5.2"
549 549
   xdg_directories:
550 550
     dependency: transitive
551 551
     description:
@@ -562,4 +562,4 @@ packages:
562 562
     version: "3.1.0"
563 563
 sdks:
564 564
   dart: ">=2.16.1 <3.0.0"
565
-  flutter: ">=2.8.0"
565
+  flutter: ">=2.8.1"

+ 1
- 1
pubspec.yaml Näytä tiedosto

@@ -42,7 +42,7 @@ dependencies:
42 42
   fluttertoast: ^8.0.9
43 43
   get_storage: ^2.0.3
44 44
   carousel_slider: ^4.0.0
45
-#  location: ^4.3.0
45
+  #  location: ^4.3.0
46 46
   amap_flutter_map: ^3.0.0
47 47
   amap_flutter_location: ^3.0.0
48 48
   permission_handler: ^9.2.0