[baozhangchao] 3 years ago
parent
commit
17c8a326b2

+ 1
- 1
lib/models/app.dart View File

@@ -18,7 +18,7 @@ class AppController extends GetxController {
18 18
   AMapFlutterLocation? _location;
19 19
 
20 20
   get locationStr {
21
-    if (null == location.value) return null;
21
+    if (null == location) return null;
22 22
 
23 23
     double longitude = location.value!['longitude'] as double;
24 24
     double latitude = location.value!['latitude'] as double;

+ 73
- 6
lib/models/entities/CardInfo.dart View File

@@ -1,4 +1,18 @@
1
+List<ContentImageList> jsonToContentList(list) {
2
+  List<ContentImageList> contList = [];
3
+  list.forEach((item) {
4
+    contList.add(ContentImageList.fromJson(item));
5
+  });
6
+  return contList;
7
+}
1 8
 
9
+List<BannerImageList> jsonToImagesList(list) {
10
+  List<BannerImageList> contList = [];
11
+  list.forEach((item) {
12
+    contList.add(BannerImageList.fromJson(item));
13
+  });
14
+  return contList;
15
+}
2 16
 
3 17
 class CardInfo {
4 18
   // @ApiModelProperty(value = "农机Id")
@@ -10,7 +24,7 @@ class CardInfo {
10 24
   // @ApiModelProperty(value = "类型名称")
11 25
   String? typeName;
12 26
   // @ApiModelProperty(value = "农机价格")
13
-  int? price;
27
+  num? price;
14 28
   // @ApiModelProperty(value = "主图")
15 29
   String? thumb;
16 30
 
@@ -33,10 +47,9 @@ class CardInfo {
33 47
   int? status;
34 48
 
35 49
   // @ApiModelProperty(value = "内容详情")
36
-  late List<dynamic>? contentList;
37
-
50
+   List<ContentImageList>? contentList=[];
38 51
   // @ApiModelProperty(value = "图片列表")
39
-  late List<dynamic>? imagesList;
52
+   List<BannerImageList>? imagesList=[];
40 53
 
41 54
   CardInfo();
42 55
 
@@ -53,8 +66,8 @@ class CardInfo {
53 66
         orgName = json["orgName"],
54 67
         jobStatus = json["jobStatus"],
55 68
         status = json["status"],
56
-        contentList = json["contentList"],
57
-        imagesList = json["imagesList"];
69
+        contentList = jsonToContentList(json["contentList"]),
70
+        imagesList = jsonToImagesList(json["imagesList"]);
58 71
   Map<String, dynamic> toJson() => {
59 72
         'machineryId': machineryId,
60 73
         'name': name,
@@ -72,3 +85,57 @@ class CardInfo {
72 85
         'imagesList': imagesList,
73 86
       };
74 87
 }
88
+
89
+class ContentImageList {
90
+  String? content;
91
+  String? contentType;
92
+  String? createDate;
93
+  String? extId;
94
+  String? sort;
95
+  String? targetId;
96
+  String? targetType;
97
+  ContentImageList();
98
+
99
+  ContentImageList.fromJson(Map<String, dynamic> json)
100
+      : content = json["content"],
101
+        contentType = json["contentType"],
102
+        createDate = json["createDate"],
103
+        extId = json["extId"],
104
+        sort = json["sort"],
105
+        targetId = json["targetId"],
106
+        targetType = json["targetType"];
107
+  Map<String, dynamic> toJson() => {
108
+        'content': content,
109
+        'contentType': contentType,
110
+        'createDate': createDate,
111
+        'extId': extId,
112
+        'sort': sort,
113
+        'targetId': targetId,
114
+        'targetType': targetType,
115
+      };
116
+}
117
+
118
+class BannerImageList {
119
+  String? createDate;
120
+  String? imageId;
121
+  num? status;
122
+  String? targetId;
123
+  String? targetType;
124
+  String? url;
125
+  BannerImageList();
126
+  BannerImageList.fromJson(Map<String, dynamic> json)
127
+      : createDate = json["createDate"],
128
+        imageId = json["imageId"],
129
+        status = json["status"],
130
+        targetId = json["targetId"],
131
+        targetType = json["targetType"],
132
+        url = json["url"];
133
+  Map<String, dynamic> toJson() => {
134
+        'createDate': createDate,
135
+        'imageId': imageId,
136
+        'status': status,
137
+        'targetId': targetId,
138
+        'targetType': targetType,
139
+        'url': url,
140
+      };
141
+}

+ 69
- 0
lib/models/entities/CardListModel.dart View File

@@ -0,0 +1,69 @@
1
+class CardListModel {
2
+  // @ApiModelProperty(value = "农机Id")
3
+  String? machineryId;
4
+  // @ApiModelProperty(value = "名称")
5
+  String? name;
6
+  // @ApiModelProperty(value = "农机类型")
7
+  String? typeId;
8
+  // @ApiModelProperty(value = "类型名称")
9
+  String? typeName;
10
+  // @ApiModelProperty(value = "农机价格")
11
+  num? price;
12
+  // @ApiModelProperty(value = "主图")
13
+  String? thumb;
14
+
15
+  // @ApiModelProperty(value = "当前位置")
16
+  String? location;
17
+
18
+  // @ApiModelProperty(value = "距离")
19
+  double? distance;
20
+
21
+  // @ApiModelProperty(value = "机构ID")
22
+  String? orgId;
23
+
24
+  // @ApiModelProperty(value = "机构名称")
25
+  String? orgName;
26
+
27
+  // @ApiModelProperty(value = "工作状态")
28
+  String? jobStatus;
29
+
30
+  // @ApiModelProperty(value = "状态")
31
+  int? status;
32
+
33
+  // @ApiModelProperty(value = "内容详情")
34
+  List<dynamic>? contentList;
35
+  // @ApiModelProperty(value = "图片列表")
36
+  List<dynamic>? imagesList;
37
+  CardListModel();
38
+  CardListModel.fromJson(Map<String, dynamic> json)
39
+      : machineryId = json["machineryId"],
40
+        name = json["name"],
41
+        typeId = json["typeId"],
42
+        typeName = json["typeName"],
43
+        price = json["price"],
44
+        thumb = json["thumb"],
45
+        location = json["location"],
46
+        distance = json["distance"],
47
+        orgId = json["orgId"],
48
+        orgName = json["orgName"],
49
+        jobStatus = json["jobStatus"],
50
+        status = json["status"],
51
+        contentList = json["contentList"],
52
+        imagesList = json["imagesList"];
53
+  Map<String, dynamic> toJson() => {
54
+        'machineryId': machineryId,
55
+        'name': name,
56
+        'typeId': typeId,
57
+        'typeName': typeName,
58
+        'price': price,
59
+        'thumb': thumb,
60
+        'location': location,
61
+        'distance': distance,
62
+        'orgId': orgId,
63
+        'orgName': orgName,
64
+        'jobStatus': jobStatus,
65
+        'status': status,
66
+        'contentList': contentList,
67
+        'imagesList': imagesList,
68
+      };
69
+}

+ 78
- 0
lib/models/entities/NewsInformationInfoTextModel.dart View File

@@ -0,0 +1,78 @@
1
+
2
+List<ExtendContent> jsonToList(list){
3
+  List<ExtendContent> contList=[];
4
+  list.forEach((item){
5
+    contList.add(ExtendContent.fromJson(item));
6
+  });
7
+  return contList;
8
+}
9
+
10
+
11
+class NewsInformationInfoTextModel {
12
+  String? createDate;
13
+  String? newsId;
14
+  num? status;
15
+  String? thumb;
16
+  String? title;
17
+  String? typeId;
18
+  String? typeName;
19
+  num? weight;
20
+   List<ExtendContent>? contentList=[];
21
+
22
+  NewsInformationInfoTextModel();
23
+
24
+  NewsInformationInfoTextModel.fromJson(Map<String, dynamic> json)
25
+      : newsId = json["newsId"],
26
+        title = json["title"],
27
+        typeId = json["typeId"],
28
+        typeName = json["typeName"],
29
+        thumb = json["thumb"],
30
+        weight = json["weight"],
31
+        status = json["status"],
32
+        createDate = json["createDate"],
33
+        contentList= jsonToList(json["contentList"]);
34
+
35
+
36
+  Map<String, dynamic> toJson() => {
37
+        'newsId': newsId,
38
+        'title': title,
39
+        'typeId': typeId,
40
+        'typeName': typeName,
41
+        'thumb': thumb,
42
+        'weight': weight,
43
+        'status': status,
44
+        'createDate': createDate,
45
+
46
+
47
+      };
48
+}
49
+
50
+class ExtendContent {
51
+  String? content;
52
+  String? contentType;
53
+  String? createDate;
54
+  String? extId;
55
+  num? sort;
56
+  String? targetId;
57
+  String? targetType;
58
+  ExtendContent();
59
+
60
+  ExtendContent.fromJson(Map<String, dynamic> json)
61
+      : content = json["content"],
62
+        contentType = json["contentType"],
63
+        createDate = json["createDate"],
64
+        extId = json["extId"],
65
+        sort = json["sort"],
66
+        targetId = json["targetId"],
67
+        targetType = json["targetType;"];
68
+
69
+  Map<String, dynamic> toJson() => {
70
+        'content': content,
71
+        'contentType': contentType,
72
+        'createDate': createDate,
73
+        'extId': extId,
74
+        'sort': sort,
75
+        'targetId': targetId,
76
+        'targetType': targetType,
77
+      };
78
+}

+ 73
- 35
lib/pages/ArticleInfo/ArticleInfo.dart View File

@@ -1,52 +1,90 @@
1
+import 'package:farmer_client/services/news.dart';
1 2
 import 'package:flutter/material.dart';
2 3
 import 'package:flutter_screenutil/flutter_screenutil.dart';
4
+import 'package:get/get.dart';
5
+import 'package:get/get_core/src/get_main.dart';
3 6
 
7
+import '../../models/entities/NewsInformationInfoTextModel.dart';
8
+import '../../models/entities/NewsInformationModel.dart';
4 9
 import '../../widgets/layout/BasicPage.dart';
5 10
 
6 11
 class ArticleInfo extends BasicPage {
12
+  String newsId = '';
13
+  final newsInfoContent = Rx<NewsInformationInfoTextModel>(NewsInformationInfoTextModel());
14
+  final newsList = Rx<List<ExtendContent>>([]);
7 15
 
8 16
   @override
9
-  Widget builder(BuildContext context) {
10
-    naviTitle='资讯详情';
11
-    return  Container(
12
-          padding: EdgeInsets.fromLTRB(15, 30, 15, 50),
17
+  void beforeShow() {
18
+    // TODO: implement beforeShow
19
+    super.beforeShow();
20
+    if (Get.arguments['newsId'] != null) {
21
+      newsId = Get.arguments['newsId'];
22
+
23
+      getNewsInfo(newsId).then((value) {
24
+        newsInfoContent.value = NewsInformationInfoTextModel.fromJson(value);
25
+        newsList.value =  newsInfoContent.value.contentList!;
13 26
 
14
-          child: Column(
15
-            children: [
16
-              Container(
17
-                alignment: Alignment.center,
18
-                child:  Row(
19
-                  mainAxisAlignment: MainAxisAlignment.center,
20
-                  children: [
21
-                    Image(image: AssetImage('images/icons/decorate.png'),width: 17,),
22
-                    Text('我是22222222222标题',
23
-                    style: TextStyle(
24
-                      fontSize: 17.sp,
25
-                      fontWeight: FontWeight.bold,
27
+      });
26 28
 
27
-                    ),
28
-                    ),
29
-                    Image(image: AssetImage('images/icons/decorate.png'),width: 17),
29
+    }
30
+  }
30 31
 
31
-                  ],
32
+  @override
33
+  Widget builder(BuildContext context) {
34
+    naviTitle = '资讯详情';
35
+    return Container(
36
+      padding: EdgeInsets.fromLTRB(15, 30, 15, 50),
37
+      child: Column(
38
+        children: [
39
+          Container(
40
+            alignment: Alignment.center,
41
+            child: Row(
42
+              mainAxisAlignment: MainAxisAlignment.center,
43
+              children: [
44
+                Image(
45
+                  image: AssetImage('images/icons/decorate.png'),
46
+                  width: 17,
32 47
                 ),
33
-              ),
34
-              Container(
35
-                padding: EdgeInsets.fromLTRB(0, 20, 0, 10),
36
-                width: 344.w,
37
-                child: Text('gr一年之计在于春,连日来,农业生产工作正在热火朝天的进行着:农技人员走村串户指导农户春耕生产,大型拖拉机忙着翻垦农田,植保无人机 ',
38
-                style: TextStyle(
39
-                  fontSize: 14.sp
48
+                Obx(()=>
49
+                    Text(
50
+                      newsInfoContent.value.title.toString(),
51
+                      style: TextStyle(
52
+                        fontSize: 17.sp,
53
+                        fontWeight: FontWeight.bold,
54
+                      ),
55
+                    )
40 56
                 ),
41
-                ) ,
42
-              ),
43
-              Container(
44
-                padding: EdgeInsets.fromLTRB(0, 10, 0,10),
45
-                child: Image(image: AssetImage('images/cars.png'),width:320.w,height:260.w,fit: BoxFit.fill,),
46
-              )
47
-            ],
57
+                Image(
58
+                    image: AssetImage('images/icons/decorate.png'), width: 17),
59
+              ],
60
+            ),
48 61
           ),
62
+          Obx(() => Column(
63
+                children:  newsList.value.map((item) {
64
+                  if (item.contentType != 'image') {
65
+                    return Container(
66
+                      padding: EdgeInsets.fromLTRB(0, 20, 0, 10),
67
+                      width: 344.w,
68
+                      child: Text(
69
+                        item.content.toString(),
70
+                        style: TextStyle(fontSize: 14.sp),
71
+                      ),
72
+                    );
73
+                  } else {
74
+                    return Container(
75
+                      padding: EdgeInsets.fromLTRB(0, 10, 0, 10),
76
+                      child: Image(
77
+                        image: NetworkImage(item.content.toString()),
78
+                        width: 320.w,
79
+                        height: 260.w,
80
+                        fit: BoxFit.fill,
81
+                      ),
82
+                    );
83
+                  }
84
+                }).toList(),
85
+              )),
86
+        ],
87
+      ),
49 88
     );
50
-
51 89
   }
52 90
 }

+ 8
- 5
lib/pages/home/widgets/home/index.dart View File

@@ -4,7 +4,9 @@ import 'package:farmer_client/widgets/NullCard.dart';
4 4
 import 'package:flutter/material.dart';
5 5
 import 'package:flutter_screenutil/flutter_screenutil.dart';
6 6
 import 'package:get/get.dart';
7
+import '../../../../models/app.dart';
7 8
 import '../../../../models/entities/CardInfo.dart';
9
+import '../../../../models/entities/CardListModel.dart';
8 10
 import '../../../../services/homeAPI.dart';
9 11
 import '../../../../widgets/CarsCard.dart';
10 12
 import 'package:farmer_client/models/entities/Banners.dart';
@@ -23,13 +25,14 @@ class _HomePageState extends State<HomePage> {
23 25
   final CarouselController _controller = CarouselController();
24 26
   List<Banners> bannerList = [];
25 27
 
26
-  List<CardInfo> machineryLists = [];
28
+  List<CardListModel> machineryLists = [];
27 29
 
28 30
   @override
29 31
   void initState() {
30 32
     super.initState();
31
-    // final location = AppController.t.location;
32
-    // print('location+$location');
33
+   //  final location = AppController.t.location;
34
+   // final long=   location.value!['longitude'].toString() + "," + location.value!['latitude'].toString();
35
+   //  print('location+$location,lolongglongng+$long');
33 36
 
34 37
     getHomeBanner('banner').then((value) {
35 38
       setState(() {
@@ -39,10 +42,10 @@ class _HomePageState extends State<HomePage> {
39 42
       });
40 43
     });
41 44
 
42
-    getMachinery('112.087433,32.687692').then((value) {
45
+    getMachinery('122.08400000000002,37.421998333333335').then((value) {
43 46
       setState(() {
44 47
         value['records'].forEach((item) {
45
-          machineryLists.add(CardInfo.fromJson(item));
48
+          machineryLists.add(CardListModel.fromJson(item));
46 49
         });
47 50
       });
48 51
     });

+ 26
- 7
lib/pages/infomation/index.dart View File

@@ -1,37 +1,56 @@
1 1
 import 'package:farmer_client/pages/infomation/widgets/Information/index.dart';
2 2
 import 'package:farmer_client/widgets/layout/BasicPage.dart';
3 3
 import 'package:flutter/material.dart';
4
+import 'package:get/get_rx/src/rx_types/rx_types.dart';
5
+import 'package:get/get_state_manager/get_state_manager.dart';
4 6
 
5 7
 import '../../models/entities/NewsInformationModel.dart';
6 8
 import '../../services/news.dart';
7 9
 
8 10
 class Infomation extends BasicPage {
11
+  // List<NewsInformationModel> newsListItem=[];
12
+
9 13
   Infomation({Key? key}) : super(key: key) {
10 14
     tabIndex = 2;
11 15
     naviTitle = '资讯';
12 16
   }
13
-  List<NewsInformationModel> newsListItem = [];
14 17
 
18
+  final newsListItem = Rx<List<NewsInformationModel>>([]);
15 19
 
16 20
 @override
17 21
   void beforeShow() {
22
+
18 23
     // TODO: implement beforeShow
19 24
     super.beforeShow();
20 25
   getNewsList().then((value) {
26
+    final list = <NewsInformationModel>[];
27
+
21 28
      value['records'].forEach((item) {
22
-       newsListItem.add(NewsInformationModel.fromJson(item));
23
-      });
24
-  });
29
+       list.add(NewsInformationModel.fromJson(item));
30
+       print('newsListItem');
31
+
32
+       print(newsListItem.value);
25 33
 
34
+     });
35
+    newsListItem.value=list;
36
+
37
+  });
26 38
 }
27 39
 
28 40
   @override
29 41
   Widget builder(BuildContext context) {
30 42
 
43
+    return Container(
44
+        child:
45
+            Obx(()=>
46
+          Column(
47
+            mainAxisSize: MainAxisSize.min,
48
+            children:newsListItem.value.map((item) => Information(item: item,)).toList(),
49
+          )
31 50
 
32
-    return  Column(
33
-      mainAxisSize: MainAxisSize.min,
34
-      children: newsListItem.map((item) => Information(item: item)).toList(),
51
+            )
35 52
     );
53
+
54
+
36 55
   }
37 56
 }

+ 60
- 54
lib/pages/infomation/widgets/Information/index.dart View File

@@ -13,71 +13,77 @@ class Information extends StatefulWidget {
13 13
   const Information({Key? key, required this.item}) : super(key: key);
14 14
 
15 15
   @override
16
-  State<Information> createState() => _InformationState();
17
-
16
+  State<Information> createState() => _InformationState(item);
18 17
   // getNewsList
19 18
 }
20 19
 
21 20
 class _InformationState extends State<Information> {
22
-  late final NewsInformationModel item;
21
+  final NewsInformationModel item;
22
+
23
+
24
+  _InformationState(this.item);
23 25
 
24 26
 
25 27
   @override
26 28
   Widget build(BuildContext context) {
27
-    return Column(
28
-      children: [
29
-        // ListTile用不好
30
-        GestureDetector(
31
-          child: Container(
32
-              padding: EdgeInsets.fromLTRB(0, 30, 0, 30),
33
-              decoration: const BoxDecoration(
34
-                  border: Border(
35
-                      bottom: BorderSide(width: 0.5, color: Color(0x20000000)
29
+    return Container(
30
+      child:   Column(
31
+        children: [
32
+          // ListTile用不好
33
+          GestureDetector(
34
+            child: Container(
35
+                padding: EdgeInsets.fromLTRB(0, 30, 0, 30),
36
+                decoration: const BoxDecoration(
37
+                    border: Border(
38
+                        bottom: BorderSide(width: 0.5, color: Color(0x20000000)
36 39
                           // 0x17000000
37
-                          ))),
38
-              child: Row(
39
-                children: [
40
-                  Container(
41
-                    margin: EdgeInsets.fromLTRB(15, 0, 11, 0),
42
-                    width: 100,
43
-                    height: 100,
44
-                    decoration: BoxDecoration(
45
-                      image: DecorationImage(
46
-                        image: AssetImage('images/cars.png'),
47
-                        fit: BoxFit.cover,
40
+                        ))),
41
+                child: Row(
42
+                  children: [
43
+                    Container(
44
+                      margin: EdgeInsets.fromLTRB(15, 0, 11, 0),
45
+                      width: 100,
46
+                      height: 100,
47
+                      decoration: BoxDecoration(
48
+                        image: DecorationImage(
49
+                          image: NetworkImage(item.thumb.toString()),
50
+                          fit: BoxFit.cover,
51
+                        ),
52
+                        borderRadius: BorderRadius.circular(12),
48 53
                       ),
49
-                      borderRadius: BorderRadius.circular(12),
50 54
                     ),
51
-                  ),
52
-                  Column(
53
-                    crossAxisAlignment: CrossAxisAlignment.start,
54
-                    children: [
55
-                      Container(
56
-                        width: 240.w,
57
-                        padding: EdgeInsets.fromLTRB(0, 0, 0, 30),
58
-                        child: Text('',
59
-                            softWrap: true,
60
-                            maxLines: 2,
61
-                            textAlign: TextAlign.left,
62
-                            overflow: TextOverflow.ellipsis,
63
-                            style: TextStyle(
64
-                              fontSize: 17.sp,
65
-                              fontWeight: FontWeight.bold,
66
-                            )),
67
-                      ),
68
-                      Container(
69
-
70
-                        child: Text(''),
71
-                      )
72
-                    ],
73
-                  )
74
-                ],
75
-              )),
76
-          onTap: () {
77
-            Get.to(ArticleInfo());
78
-          },
79
-        ),
80
-      ],
55
+                    Column(
56
+                      crossAxisAlignment: CrossAxisAlignment.start,
57
+                      children: [
58
+                        Container(
59
+                          width: 240.w,
60
+                          padding: EdgeInsets.fromLTRB(0, 0, 0, 30),
61
+                          child: Text(item.title!.toString(),
62
+                              softWrap: true,
63
+                              maxLines: 2,
64
+                              textAlign: TextAlign.left,
65
+                              overflow: TextOverflow.ellipsis,
66
+                              style: TextStyle(
67
+                                fontSize: 17.sp,
68
+                                fontWeight: FontWeight.bold,
69
+                              )),
70
+                        ),
71
+                        Container(
72
+                          child: Text(
73
+                              item.createDate!=null? DateFormat("yyyy-MM-dd").format(DateTime.parse(item.createDate.toString())):item.createDate.toString(),),
74
+                        )
75
+                      ],
76
+                    )
77
+                  ],
78
+                )),
79
+            onTap: () {
80
+              Get.to(ArticleInfo(),arguments: {'newsId':item.newsId});
81
+            },
82
+          ),
83
+        ],
84
+      ),
81 85
     );
86
+
87
+
82 88
   }
83 89
 }

+ 18
- 3
lib/pages/machinery/detail/index.dart View File

@@ -1,10 +1,15 @@
1
-
1
+import 'package:farmer_client/models/entities/CardInfo.dart';
2 2
 import 'package:farmer_client/widgets/layout/BasicPage.dart';
3 3
 import 'package:flutter/material.dart';
4 4
 import 'package:get/get.dart';
5
+import '../../../services/homeAPI.dart';
5 6
 import 'widgets/detail.dart';
6 7
 
7 8
 class MachineryDetailPage extends BasicPage {
9
+  String markId = '';
10
+  final machineryInfoContent = Rx<CardInfo>(CardInfo());//全部详情
11
+  final machineryListBanner = Rx<List<BannerImageList>>([]);//banner轮播
12
+  final machineryListContent= Rx<List<ContentImageList>>([]);//图文详情
8 13
   // 响应预约事件
9 14
   void handleClick() {
10 15
     Get.toNamed('/orderConfirmation');
@@ -14,6 +19,17 @@ class MachineryDetailPage extends BasicPage {
14 19
   void beforeShow() {
15 20
     // TODO: implement onMounted
16 21
     super.beforeShow();
22
+    if (Get.arguments['id'] != null) {
23
+     markId = Get.arguments['id'];
24
+      getMachineryInfo(markId, '122.08400000000002,37.421998333333335', true).then((value) {
25
+        machineryInfoContent.value=CardInfo.fromJson(value);
26
+        machineryListBanner.value=machineryInfoContent.value.imagesList!;
27
+        machineryListContent.value=machineryInfoContent.value.contentList!;
28
+
29
+        print('222222222222222222+$value');
30
+      });
31
+
32
+    }
17 33
     print("----show----detail page--------------");
18 34
   }
19 35
 
@@ -27,7 +43,6 @@ class MachineryDetailPage extends BasicPage {
27 43
   @override
28 44
   Widget builder(BuildContext context) {
29 45
     naviTitle = "查看详情";
30
-    return page(context: context, handleClick: handleClick);
46
+    return Obx(()=>page(context: context, handleClick: handleClick,item:machineryInfoContent.value,bnnerItem:machineryListBanner.value,contentItem:machineryListContent.value));
31 47
   }
32
-
33 48
 }

+ 29
- 6
lib/pages/machinery/detail/widgets/detail.dart View File

@@ -1,4 +1,5 @@
1 1
 
2
+import 'package:carousel_slider/carousel_slider.dart';
2 3
 import 'package:farmer_client/pages/machinery/widgets/DefLayout.dart';
3 4
 import 'package:farmer_client/pages/machinery/widgets/RoundButton.dart';
4 5
 import 'package:flutter/widgets.dart';
@@ -6,9 +7,15 @@ import 'package:flutter/material.dart';
6 7
 import 'package:flutter_screenutil/flutter_screenutil.dart';
7 8
 import 'package:farmer_client/widgets/ExtendContentList.dart';
8 9
 import 'package:farmer_client/models/entities/ExtendContent.dart';
10
+import 'package:get/get.dart';
11
+import '../../../../models/entities/CardInfo.dart';
9 12
 import '../../widgets/summary.dart';
10 13
 
11
-Widget page({ required BuildContext context, VoidCallback? handleClick}) {
14
+Widget page({ required BuildContext context, VoidCallback? handleClick,required CardInfo item,required List<BannerImageList> bnnerItem,required List<ContentImageList> contentItem}) {
15
+  print('88888888888888+$item');
16
+
17
+
18
+
12 19
   final img = 'https://yz-websit.oss-cn-hangzhou.aliyuncs.com/xlk/index-icon19.jpg';
13 20
 
14 21
   final list = <ExtendContent>[
@@ -22,23 +29,39 @@ Widget page({ required BuildContext context, VoidCallback? handleClick}) {
22 29
   ];
23 30
 
24 31
   return DefLayout(
25
-      head: Image.network(img, fit: BoxFit.cover),
32
+      head: CarouselSlider(
33
+        items: bnnerItem
34
+            .map((item) => Container(
35
+          child: Center(
36
+              child: Image.network(item.url.toString(),
37
+                  fit: BoxFit.fitWidth, width: 370.w)),
38
+        ))
39
+            .toList(),
40
+        options: CarouselOptions(
41
+          autoPlay: true,
42
+          enlargeCenterPage: false, //图片中心放大
43
+          viewportFraction: 1, //每个页面应占据的视口部分。默认为 0.8,这意味着每个页面填充 80% 的轮播。
44
+          // aspectRatio: 1.6,//纵横比
45
+          height: 214.w,
46
+          initialPage: 1, //初始页
47
+        ),
48
+      ),
26 49
       children: [
27 50
         DefLayout.card(
28 51
           top: DefLayout.headHeight - DefLayout.offset,
29 52
           padding: EdgeInsets.only(top: 45.w, left: 15.w, right: 15.w, bottom: 20.w),
30
-          child: _content(context, list, handleClick),
53
+          child: _content(context, handleClick,item,contentItem),
31 54
         )
32 55
       ]
33 56
   );
34 57
 }
35 58
 
36
-Widget _content(BuildContext context, List<ExtendContent> list, VoidCallback? handleClick) {
59
+Widget _content(BuildContext context, VoidCallback? handleClick, CardInfo item,List<ContentImageList> contentItem) {
37 60
   return Column(
38 61
     children: [
39
-      summary(),
62
+     summary(item: item),
40 63
       _sectionHead('农机详情'),
41
-      ExtendContentList(list: list),
64
+      ExtendContentList(item: contentItem,),
42 65
       SizedBox(height: 20.w,),
43 66
       RoundButton(text: "预约", onPressed: handleClick,)
44 67
     ],

+ 1
- 1
lib/pages/machinery/map/widgets/detail.dart View File

@@ -39,7 +39,7 @@ Widget page({ required BuildContext context, VoidCallback? handleClick}) {
39 39
 Widget _content(BuildContext context, VoidCallback? handleClick) {
40 40
   return Column(
41 41
     children: [
42
-      summary(),
42
+      // summary(),
43 43
       RoundButton(text: "预约", onPressed: handleClick,),
44 44
     ],
45 45
   );

+ 1
- 1
lib/pages/machinery/widgets/DefLayout.dart View File

@@ -8,7 +8,7 @@ class DefLayout extends StatelessWidget {
8 8
 
9 9
   DefLayout({Key? key, required this.head, required this.children}): super(key: key);
10 10
 
11
-  static double headHeight = 250.w;
11
+  static double headHeight = 214.w;
12 12
   static double offset = 20.w;
13 13
 
14 14
   static Widget card({required double top, required Widget child, double? height, EdgeInsetsGeometry? padding}) {

+ 14
- 10
lib/pages/machinery/widgets/summary.dart View File

@@ -4,24 +4,28 @@ import 'package:flutter_screenutil/flutter_screenutil.dart';
4 4
 
5 5
 import 'package:farmer_client/widgets/LinearGradientText.dart';
6 6
 
7
-Widget summary() {
7
+import '../../../models/entities/CardInfo.dart';
8
+
9
+Widget summary({required CardInfo item}) {
10
+
8 11
   return Column(
9 12
     children: [
10
-      _title(),
13
+      _title(item: item),
11 14
       SizedBox(height: 20.w,),
12
-      _desc(),
15
+      _desc(item: item),
13 16
       SizedBox(height: 20.w,),
14
-      _detail(),
17
+      _detail(item: item),
15 18
       SizedBox(height: 20.w,),
16 19
     ],
17 20
   );
18 21
 }
19 22
 
20
-Widget _title() {
23
+Widget _title({required CardInfo item}) {
24
+
21 25
   return Row(
22 26
     children: [
23 27
       Expanded(
24
-          child: Text("收割机001--S001",
28
+          child: Text(item.name.toString(),
25 29
               style: TextStyle(
26 30
                 color: const Color(0xFF222222),
27 31
                 fontSize: 18.sp,
@@ -40,7 +44,7 @@ Widget _title() {
40 44
             text: TextSpan(
41 45
                 children: <InlineSpan>[
42 46
                   TextSpan(
43
-                      text: "450",
47
+                      text: ((item.price??0)/100).toString(),
44 48
                       style: TextStyle(
45 49
                         fontSize: 22.sp,
46 50
                         fontWeight: FontWeight.bold,
@@ -66,7 +70,7 @@ Widget _title() {
66 70
   );
67 71
 }
68 72
 
69
-Widget _desc() {
73
+Widget _desc({required CardInfo item}) {
70 74
   return Row(
71 75
     children: [
72 76
       Icon(Icons.location_on_outlined, size: 16.sp,),
@@ -78,9 +82,9 @@ Widget _desc() {
78 82
   );
79 83
 }
80 84
 
81
-Widget _detail() {
85
+Widget _detail({required CardInfo item}) {
82 86
   return Container(
83 87
     alignment: Alignment.centerLeft,
84
-    child: Text("农机手1的收割机", style: TextStyle(color: const Color(0xFF222222), fontSize: 15.sp),),
88
+    child: Text(item.orgName.toString(), style: TextStyle(color: const Color(0xFF222222), fontSize: 15.sp),),
85 89
   );
86 90
 }

+ 10
- 4
lib/pages/order/widgets/order/index.dart View File

@@ -1,6 +1,7 @@
1 1
 import 'package:farmer_client/widgets/NullCard.dart';
2 2
 import 'package:flutter/material.dart';
3 3
 import 'package:flutter_screenutil/flutter_screenutil.dart';
4
+import 'package:get/get_rx/src/rx_types/rx_types.dart';
4 5
 
5 6
 import '../../../../models/entities/OrderListAll.dart';
6 7
 import '../../../../services/orderAPI.dart';
@@ -15,7 +16,7 @@ class OrderPage extends StatefulWidget {
15 16
 }
16 17
 
17 18
 class _OrderPageState extends State<OrderPage> {
18
-  List<OrderListAll> orderListItem = [];
19
+  final orderListItem = Rx<List<OrderListAll>>([]);
19 20
 
20 21
   @override
21 22
   void initState() {
@@ -23,17 +24,22 @@ class _OrderPageState extends State<OrderPage> {
23 24
     super.initState();
24 25
 
25 26
     getOrderList(true).then((value) {
27
+      final list = <OrderListAll>[];
28
+
26 29
       setState(() {
27 30
         value['records'].forEach((item) {
28
-          orderListItem.add(OrderListAll.fromJson(item));
31
+          list.add(OrderListAll.fromJson(item));
32
+
29 33
         });
30 34
       });
35
+      orderListItem(list);
36
+
31 37
     });
32 38
   }
33 39
 
34 40
   @override
35 41
   Widget build(BuildContext context) {
36
-    return orderListItem.length >= 0?
42
+    return orderListItem.value.length >= 0?
37 43
       Column(
38 44
       children: [
39 45
         Container(
@@ -68,7 +74,7 @@ class _OrderPageState extends State<OrderPage> {
68 74
         Column(
69 75
           mainAxisSize: MainAxisSize.min,
70 76
           children:
71
-          orderListItem.map((item) => OrderListCard(item: item)).toList(),
77
+          orderListItem.value.map((item) => OrderListCard(item: item)).toList(),
72 78
         ),
73 79
       ],
74 80
     ):NullCard(text: '您还没有新的订单!');

+ 1
- 1
lib/services/homeAPI.dart View File

@@ -42,7 +42,7 @@ Future getMachinery(String location)async{
42 42
  * @returns
43 43
  */
44 44
 Future getMachineryInfo(String id,String location ,bool attached)async{
45
-  return request('/machinery-summary',options: Options(method: 'GET'),queryParameters: { 'id': id},data: {'location': location,'attached': attached}).catchError((error) =>
45
+  return request('/machinery-summary/$id',options: Options(method: 'GET'),queryParameters: { 'location': location,'attached': attached}).catchError((error) =>
46 46
   { Fluttertoast.showToast(
47 47
       msg: error.error['message']
48 48
   ),});

+ 8
- 3
lib/widgets/CarsCard.dart View File

@@ -5,13 +5,14 @@ import 'package:get/get.dart';
5 5
 import 'package:get/get_core/src/get_main.dart';
6 6
 
7 7
 import '../models/entities/CardInfo.dart';
8
+import '../models/entities/CardListModel.dart';
8 9
 import '../pages/OrderConfirmation/index.dart';
9 10
 import '../pages/machinery/detail/index.dart';
10 11
 import '../pages/machinery/map/index.dart';
11 12
 import 'LinearGradientText.dart';
12 13
 
13 14
 class CarsCard extends StatefulWidget {
14
-  final CardInfo item;
15
+  final CardListModel item;
15 16
 
16 17
   const CarsCard({Key? key, required this.item}) : super(key: key);
17 18
 
@@ -20,7 +21,7 @@ class CarsCard extends StatefulWidget {
20 21
 }
21 22
 
22 23
 class _CarsCardPage extends State<CarsCard> {
23
-  final CardInfo item;
24
+  final CardListModel item;
24 25
   _CarsCardPage(this.item);
25 26
 
26 27
   @override
@@ -36,7 +37,7 @@ class _CarsCardPage extends State<CarsCard> {
36 37
         children: [
37 38
           GestureDetector(
38 39
             onTap: () {
39
-              Get.to(MachineryDetailPage());
40
+              Get.to(MachineryDetailPage(),arguments: {'id':item.machineryId});
40 41
             },
41 42
             child: Image.network(
42 43
               item.thumb.toString(),
@@ -53,8 +54,12 @@ class _CarsCardPage extends State<CarsCard> {
53 54
               verticalDirection: VerticalDirection.up,
54 55
               children: <Widget>[
55 56
                 Container(
57
+                  width: 210.w,
56 58
                   child: Text(
57 59
                     item.name.toString(),
60
+                    softWrap: true,
61
+                    textAlign: TextAlign.left,
62
+                    overflow: TextOverflow.ellipsis,
58 63
                     style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
59 64
                   ),
60 65
                 ),

+ 47
- 15
lib/widgets/ExtendContentList.dart View File

@@ -1,13 +1,16 @@
1 1
 
2 2
 import 'package:flutter/widgets.dart';
3 3
 import 'package:flutter_screenutil/flutter_screenutil.dart';
4
+import 'package:get/get_rx/src/rx_types/rx_types.dart';
5
+import 'package:get/get_state_manager/src/rx_flutter/rx_obx_widget.dart';
4 6
 
7
+import '../models/entities/CardInfo.dart';
5 8
 import '../models/entities/ExtendContent.dart';
6 9
 
7 10
 class ExtendContentList extends StatelessWidget {
8
-  final List<ExtendContent> list;
11
+  final List<ContentImageList> item;
9 12
 
10
-  ExtendContentList({ Key? key, required this.list }) : super(key: key);
13
+  const ExtendContentList({ Key? key, required this.item }) : super(key: key);
11 14
   
12 15
   Widget? _image(String? content) {
13 16
     if (null == content || content.isEmpty) return null;
@@ -21,21 +24,50 @@ class ExtendContentList extends StatelessWidget {
21 24
 
22 25
   @override
23 26
   Widget build(BuildContext context) {
27
+    //
28
+    // List<Widget> _widgets = [];
29
+    // Container(
30
+    //   child: item.contentType == "image" ? _image(item.content) : _text(item.content),
31
+    // );
32
+    // for (var i = 0; i < item.length; i += 1) {
33
+    //   if (i != 0 ) {
34
+    //     _widgets.add(SizedBox(height: 20.w,));
35
+    //   }
36
+    //   var item = item[i];
37
+    //   _widgets.add(Container(
38
+    //     child: item.contentType == "image" ? _image(item.content) : _text(item.content),
39
+    //   ));
40
+    // }
24 41
 
25
-    List<Widget> _widgets = [];
26
-    for (var i = 0; i < list.length; i += 1) {
27
-      if (i != 0 ) {
28
-        _widgets.add(SizedBox(height: 20.w,));
29
-      }
30
-      var item = list[i];
31
-      _widgets.add(Container(
32
-        child: item.contentType == "image" ? _image(item.content) : _text(item.content),
33
-      ));
34
-    }
35
-
36
-    return Column(
37
-      children: _widgets,
42
+    return  Container(
43
+      child:  Column(
44
+        children:  item.map((item) {
45
+          if (item.contentType != 'image') {
46
+
47
+            return Container(
48
+              padding: EdgeInsets.fromLTRB(0, 20, 0, 10),
49
+              width: 344.w,
50
+              child: Text(
51
+                item.content.toString(),
52
+                style: TextStyle(fontSize: 14.sp),
53
+              ),
54
+            );
55
+          } else {
56
+            return Container(
57
+              padding: EdgeInsets.fromLTRB(0, 10, 0, 10),
58
+              child: Image(
59
+                image: NetworkImage(item.content.toString()),
60
+                width: 320.w,
61
+                height: 260.w,
62
+                fit: BoxFit.cover,
63
+              ),
64
+
65
+            );
66
+          }
67
+        }).toList(),
68
+      ),
38 69
     );
70
+
39 71
   }
40 72
 
41 73
 }

+ 4
- 2
lib/widgets/OrderInfoCard.dart View File

@@ -1,4 +1,5 @@
1 1
 import 'package:farmer_client/models/entities/OrderInfoModel.dart';
2
+import 'package:farmer_client/pages/index.dart';
2 3
 import 'package:flutter/material.dart';
3 4
 import 'package:flutter_screenutil/flutter_screenutil.dart';
4 5
 import 'package:get/get.dart';
@@ -120,7 +121,7 @@ class OrderInfoCard extends StatelessWidget {
120 121
                                   fontWeight: FontWeight.bold)),
121 122
                           TextSpan(
122 123
                           // '${DateFormat("yyyy-MM-dd").format(item.appointmentDate.toString())}'
123
-                              text: DateFormat("yyyy-MM-dd").format(DateTime.parse(item.appointmentDate.toString())),
124
+                              text:item.appointmentDate!=null? DateFormat("yyyy-MM-dd").format(DateTime.parse(item.appointmentDate.toString())):item.appointmentDate.toString(),
124 125
                               style: TextStyle(
125 126
                                   color: Color(0xff222222),
126 127
                                   fontSize: 16,
@@ -139,7 +140,8 @@ class OrderInfoCard extends StatelessWidget {
139 140
                                   fontSize: 16,
140 141
                                   fontWeight: FontWeight.bold)),
141 142
                           TextSpan(
142
-                              text: DateFormat("yyyy-MM-dd").format(DateTime.parse(item.createDate.toString())),
143
+                              // text: DateFormat("yyyy-MM-dd").format(DateTime.parse(item.createDate!.toString())),
144
+                              text:item.createDate!=null? DateFormat("yyyy-MM-dd").format(DateTime.parse(item.createDate.toString())):item.createDate.toString(),
143 145
 
144 146
                               style: TextStyle(
145 147
                                   color: Color(0xff222222),