瀏覽代碼

订单/分类/农机/我的完善

[baozhangchao] 3 年之前
父節點
當前提交
221d1d1f8d

二進制
images/alipay.png 查看文件


二進制
images/weChatPay.png 查看文件


+ 1
- 2
lib/models/app.dart 查看文件

19
   AMapFlutterLocation? _location;
19
   AMapFlutterLocation? _location;
20
 
20
 
21
   get locationStr {
21
   get locationStr {
22
-    if (null == location) return null;
22
+    if (null == location.value) return null;
23
 
23
 
24
     double longitude = location.value!['longitude'] as double;
24
     double longitude = location.value!['longitude'] as double;
25
     double latitude = location.value!['latitude'] as double;
25
     double latitude = location.value!['latitude'] as double;
51
 
51
 
52
     // 尝试获取一次人员信息
52
     // 尝试获取一次人员信息
53
     getCurrent().then((person) {
53
     getCurrent().then((person) {
54
-      print('9personpersonpersonperson+$person');
55
       user(Person.fromJson(person));
54
       user(Person.fromJson(person));
56
 
55
 
57
     }).catchError((e) {
56
     }).catchError((e) {

+ 19
- 0
lib/models/entities/CardTypeModel.dart 查看文件

1
+class CardTypeModel {
2
+  String? createDate;
3
+  String? name;
4
+  num? status;
5
+  String? typeId;
6
+  CardTypeModel();
7
+
8
+  CardTypeModel.fromJson(Map<String, dynamic> json)
9
+      : createDate = json["createDate"],
10
+        name = json["name"],
11
+        status = json["status"],
12
+        typeId = json["typeId"];
13
+  Map<String, dynamic> toJson() => {
14
+        "createDate": createDate,
15
+        "name": name,
16
+        "status": status,
17
+        "typeId": typeId,
18
+      };
19
+}

+ 19
- 9
lib/pages/MoreCars/index.dart 查看文件

3
 import 'package:flutter_screenutil/flutter_screenutil.dart';
3
 import 'package:flutter_screenutil/flutter_screenutil.dart';
4
 import 'package:get/get.dart';
4
 import 'package:get/get.dart';
5
 
5
 
6
+import '../../models/entities/CardTypeModel.dart';
7
+import '../../services/homeAPI.dart';
6
 import '../../widgets/CarsCard.dart';
8
 import '../../widgets/CarsCard.dart';
7
 import '../../widgets/Search.dart';
9
 import '../../widgets/Search.dart';
8
 
10
 
14
 }
16
 }
15
 
17
 
16
 class _MoreCarsState extends State<MoreCars> with TickerProviderStateMixin {
18
 class _MoreCarsState extends State<MoreCars> with TickerProviderStateMixin {
17
-  late TabController _controller =
18
-      TabController(length: tabText.length, vsync: this);
19
-  List<String> tabText = [
20
-    '全部',
21
-    '播种机',
22
-    '收割机',
23
-    '挺长名字的农机选项分类',
24
-  ];
19
+   late TabController _controller = TabController(length: tabText.value.length, vsync: this);
20
+  final tabText = Rx<List<CardTypeModel>>([]);
21
+
22
+
25
 
23
 
26
   @override
24
   @override
27
   void initState() {
25
   void initState() {
28
     // TODO: implement initState
26
     // TODO: implement initState
29
     super.initState();
27
     super.initState();
28
+
29
+  }
30
+  void _geList (){
31
+    getMachineryType().then((value) {
32
+      final list = <CardTypeModel>[];
33
+      List<String> newTabs =['全部'];
34
+      value['records'].forEach((item) {
35
+        list.add(CardTypeModel.fromJson(item));
36
+
37
+      });
38
+      tabText(list);
39
+    });
30
   }
40
   }
31
 
41
 
32
   @override
42
   @override
74
                   labelColor: Colors.black, //选中文字颜色
84
                   labelColor: Colors.black, //选中文字颜色
75
                   unselectedLabelColor: Color(0xffadadad),
85
                   unselectedLabelColor: Color(0xffadadad),
76
                   // indicatorSize: TabBarIndicatorSize.label, //指示器与文字等宽
86
                   // indicatorSize: TabBarIndicatorSize.label, //指示器与文字等宽
77
-                  tabs: tabText.map((e) => Tab(text: e)).toList(),
87
+                  tabs: tabText.value.map((e) => Tab(text: e.name.toString())).toList(),
78
                   onTap: (int i) {
88
                   onTap: (int i) {
79
                     print('当前+${i}');
89
                     print('当前+${i}');
80
                   },
90
                   },

+ 55
- 44
lib/pages/addressList/index.dart 查看文件

7
 import 'package:flutter_screenutil/flutter_screenutil.dart';
7
 import 'package:flutter_screenutil/flutter_screenutil.dart';
8
 import 'package:fluttertoast/fluttertoast.dart';
8
 import 'package:fluttertoast/fluttertoast.dart';
9
 import 'package:get/get.dart';
9
 import 'package:get/get.dart';
10
+import 'package:farmer_client/widgets/Modal.dart' as modal;
10
 
11
 
11
 import '../../services/address.dart';
12
 import '../../services/address.dart';
12
 
13
 
13
 class AddressList extends BasicPage {
14
 class AddressList extends BasicPage {
14
   bool isBack = false;
15
   bool isBack = false;
15
-  AddressController addressController=AddressController.t;
16
+  AddressController addressController = AddressController.t;
16
   final addressList = Rx<List<Address>>([]);
17
   final addressList = Rx<List<Address>>([]);
17
 
18
 
18
-
19
   @override
19
   @override
20
   void beforeShow() {
20
   void beforeShow() {
21
     super.beforeShow();
21
     super.beforeShow();
31
     }
31
     }
32
   }
32
   }
33
 
33
 
34
-
35
   void onChange(id) {
34
   void onChange(id) {
36
     print(id);
35
     print(id);
37
-    addressDefault(id.toString()).then((value){
36
+    addressDefault(id.toString()).then((value) {
38
       final defaultlist = [...addressList()];
37
       final defaultlist = [...addressList()];
39
       for (var element in addressList()) {
38
       for (var element in addressList()) {
40
         if (element.isDefault == true) {
39
         if (element.isDefault == true) {
43
       }
42
       }
44
       addressList(defaultlist);
43
       addressList(defaultlist);
45
     });
44
     });
46
-
47
   }
45
   }
46
+
48
   void onDelete(id) {
47
   void onDelete(id) {
49
     print(id);
48
     print(id);
50
-
51
-    addressDelete(id).then((value) {
52
-      final newslist = [...addressList()];
53
-      for (var item in addressList()) {
54
-        if (item.addressId == id) {
55
-          newslist.remove(item);
56
-        }
57
-      }
58
-      addressList(newslist);
59
-      Fluttertoast.showToast(msg: '删除成功!');
60
-    });
49
+    modal.showDialog(
50
+        title: '提示',
51
+        content: Container(
52
+          alignment: Alignment.center,
53
+          child: Text('确定要删除此地址吗?'),
54
+        ),
55
+        onCancel: () => true,
56
+        onConfirm: () => {
57
+              addressDelete(id).then((value) {
58
+                final newslist = [...addressList()];
59
+                for (var item in addressList()) {
60
+                  if (item.addressId == id) {
61
+                    newslist.remove(item);
62
+                  }
63
+                }
64
+                addressList(newslist);
65
+                Fluttertoast.showToast(msg: '删除成功!');
66
+              }),
67
+            });
61
   }
68
   }
62
 
69
 
63
   @override
70
   @override
71
             //左对齐
78
             //左对齐
72
             crossAxisAlignment: CrossAxisAlignment.start,
79
             crossAxisAlignment: CrossAxisAlignment.start,
73
             children: [
80
             children: [
74
-              Obx(()=>Column(
75
-                  children: addressList()
76
-                      .asMap()
77
-                      .keys
78
-                      .map(
79
-                        (e) => AddressCard(
80
-                          No: e + 1,
81
-                          item: addressList.value[e],
82
-                          isBack: isBack,
83
-                          onChange: () {
84
-                            onChange(addressList()[e].addressId);
85
-                          },
86
-                          onEdit: () {
87
-                            Get.toNamed('/addAddress',
88
-                                arguments: {'id':addressList.value[e].addressId,'item': addressList.value[e].address.toString()});
89
-                          },
90
-                          onDelete: () {
91
-                            onDelete(addressList.value[e].addressId);
92
-                          },
93
-                          onBack: () {
94
-                            //选择地址
95
-                            addressController.address.value=addressList.value[e];
96
-                            Get.back();
97
-                          },
98
-                        ),
99
-                      )
100
-                      .toList()),),
81
+              Obx(
82
+                () => Column(
83
+                    children: addressList()
84
+                        .asMap()
85
+                        .keys
86
+                        .map(
87
+                          (e) => AddressCard(
88
+                            No: e + 1,
89
+                            item: addressList.value[e],
90
+                            isBack: isBack,
91
+                            onChange: () {
92
+                              onChange(addressList()[e].addressId);
93
+                            },
94
+                            onEdit: () {
95
+                              Get.toNamed('/addAddress', arguments: {
96
+                                'id': addressList.value[e].addressId,
97
+                                'item': addressList.value[e].address.toString()
98
+                              });
99
+                            },
100
+                            onDelete: () {
101
+                              onDelete(addressList.value[e].addressId);
102
+                            },
103
+                            onBack: () {
104
+                              //选择地址
105
+                              addressController.address.value =
106
+                                  addressList.value[e];
107
+                              Get.back();
108
+                            },
109
+                          ),
110
+                        )
111
+                        .toList()),
112
+              ),
101
               DefaultButton(
113
               DefaultButton(
102
                 color: const Color(0xffffffff),
114
                 color: const Color(0xffffffff),
103
                 backColor: const Color(0xFFFF703B),
115
                 backColor: const Color(0xFFFF703B),
118
     );
130
     );
119
   }
131
   }
120
 }
132
 }
121
-

+ 3
- 3
lib/pages/home/widgets/home/index.dart 查看文件

24
 class _HomePageState extends State<HomePage> {
24
 class _HomePageState extends State<HomePage> {
25
   final CarouselController _controller = CarouselController();
25
   final CarouselController _controller = CarouselController();
26
   List<Banners> bannerList = [];
26
   List<Banners> bannerList = [];
27
+  String? location = AppController.t.locationStr;
27
 
28
 
28
   List<CardListModel> machineryLists = [];
29
   List<CardListModel> machineryLists = [];
29
 
30
 
30
   @override
31
   @override
31
   void initState() {
32
   void initState() {
32
     super.initState();
33
     super.initState();
33
-   //  final location = AppController.t.location;
34
    // final long=   location.value!['longitude'].toString() + "," + location.value!['latitude'].toString();
34
    // final long=   location.value!['longitude'].toString() + "," + location.value!['latitude'].toString();
35
    //  print('location+$location,lolongglongng+$long');
35
    //  print('location+$location,lolongglongng+$long');
36
 
36
 
42
       });
42
       });
43
     });
43
     });
44
 
44
 
45
-    getMachinery('122.08400000000002,37.421998333333335').then((value) {
45
+    getMachinery(location??'112.087465,32.687507').then((value) {
46
       setState(() {
46
       setState(() {
47
         value['records'].forEach((item) {
47
         value['records'].forEach((item) {
48
           machineryLists.add(CardListModel.fromJson(item));
48
           machineryLists.add(CardListModel.fromJson(item));
124
                       )
124
                       )
125
                     ],
125
                     ],
126
                   ),
126
                   ),
127
-                  machineryLists.length>=0?
127
+                  machineryLists.length>= 1?
128
                   Column(
128
                   Column(
129
                     children: machineryLists
129
                     children: machineryLists
130
                         .map((item) => CarsCard(item: item))
130
                         .map((item) => CarsCard(item: item))

+ 1
- 1
lib/pages/main/widgets/UserInfo.dart 查看文件

38
                 child: GestureDetector(
38
                 child: GestureDetector(
39
                   child: const Text(
39
                   child: const Text(
40
                     '修改个人信息',
40
                     '修改个人信息',
41
-                    style: TextStyle(color: Colors.white),
41
+                    style: TextStyle(color: Colors.white,fontSize: 14),
42
                   ),
42
                   ),
43
                   onTap: () {
43
                   onTap: () {
44
                     print('修改个人信息');
44
                     print('修改个人信息');

+ 16
- 23
lib/pages/main/widgets/main/index.dart 查看文件

6
 import './widgets/UserInfo.dart';
6
 import './widgets/UserInfo.dart';
7
 import 'package:flutter/material.dart';
7
 import 'package:flutter/material.dart';
8
 import 'package:flutter_screenutil/flutter_screenutil.dart';
8
 import 'package:flutter_screenutil/flutter_screenutil.dart';
9
+import 'package:farmer_client/widgets/Modal.dart' as modal;
9
 
10
 
10
 class MainPage extends StatelessWidget {
11
 class MainPage extends StatelessWidget {
11
   final Address item;
12
   final Address item;
16
 
17
 
17
   GetStorage box = GetStorage();
18
   GetStorage box = GetStorage();
18
 
19
 
20
+  void _userOut(){
21
+    modal.showDialog(title: '提示', content:
22
+    Container(
23
+      alignment: Alignment.center,
24
+      child:  Text('确定要退出登陆吗?'),
25
+    ),onCancel: ()=>true,
26
+        onConfirm: () => {
27
+        box.remove('token'),
28
+    Get.offNamed('/login'),
29
+
30
+  });
31
+  }
32
+
19
 
33
 
20
   @override
34
   @override
21
   Widget build(BuildContext context) {
35
   Widget build(BuildContext context) {
22
-    print('644444444444444+$item');
23
-
24
     return Container(
36
     return Container(
25
       alignment: Alignment.center,
37
       alignment: Alignment.center,
26
       child: Column(
38
       child: Column(
48
                   height: 49.h,
60
                   height: 49.h,
49
                   child: ElevatedButton(
61
                   child: ElevatedButton(
50
                     onPressed: () {
62
                     onPressed: () {
51
-                      showDialog(
52
-                          context: context,
53
-                          builder: (context) {
54
-                            return AlertDialog(
55
-                                content: Text("您确定退出登录吗?"),
56
-                                actions: <Widget>[
57
-                                  TextButton(
58
-                                    child: Text("取消"),
59
-                                    onPressed: () {
60
-                                      Navigator.pop(context, 'Cancle');
61
-                                    },
62
-                                  ),
63
-                                  TextButton(
64
-                                      child: Text("确定"),
65
-                                      onPressed: () {
66
-                                        Navigator.pop(context, "Ok");
67
-                                        box.remove('token');
68
-                                        Get.offNamed('/login');
69
-                                      })
70
-                                ]);
71
-                          });
63
+                      _userOut();
64
+
72
                     },
65
                     },
73
                     child: const Text(
66
                     child: const Text(
74
                       "退出登陆",
67
                       "退出登陆",

+ 1
- 1
lib/pages/main/widgets/main/widgets/UserInfo.dart 查看文件

44
                 child: GestureDetector(
44
                 child: GestureDetector(
45
                   child: const Text(
45
                   child: const Text(
46
                     '修改个人信息',
46
                     '修改个人信息',
47
-                    style: TextStyle(color: Colors.white),
47
+                    style: TextStyle(color: Colors.white,fontSize: 14),
48
                   ),
48
                   ),
49
                   onTap: () {
49
                   onTap: () {
50
                     Get.toNamed('/userInfo');
50
                     Get.toNamed('/userInfo');

+ 2
- 4
lib/pages/order/widgets/order/index.dart 查看文件

22
   void initState() {
22
   void initState() {
23
     // TODO: implement initState
23
     // TODO: implement initState
24
     super.initState();
24
     super.initState();
25
-
26
     getOrderList(true).then((value) {
25
     getOrderList(true).then((value) {
27
       final list = <OrderListAll>[];
26
       final list = <OrderListAll>[];
28
-
29
       setState(() {
27
       setState(() {
30
         value['records'].forEach((item) {
28
         value['records'].forEach((item) {
31
           list.add(OrderListAll.fromJson(item));
29
           list.add(OrderListAll.fromJson(item));
39
 
37
 
40
   @override
38
   @override
41
   Widget build(BuildContext context) {
39
   Widget build(BuildContext context) {
42
-    return orderListItem.value.length >= 0?
40
+    return orderListItem().length>0?
43
       Column(
41
       Column(
44
       children: [
42
       children: [
45
         Container(
43
         Container(
74
         Column(
72
         Column(
75
           mainAxisSize: MainAxisSize.min,
73
           mainAxisSize: MainAxisSize.min,
76
           children:
74
           children:
77
-          orderListItem.value.map((item) => OrderListCard(item: item)).toList(),
75
+          orderListItem().map((item) => OrderListCard(item: item)).toList(),
78
         ),
76
         ),
79
       ],
77
       ],
80
     ):NullCard(text: '您还没有新的订单!');
78
     ):NullCard(text: '您还没有新的订单!');

+ 226
- 121
lib/pages/orderInfo/index.dart 查看文件

16
 //   StyleObj ({ required this.title, required this.styleColor});
16
 //   StyleObj ({ required this.title, required this.styleColor});
17
 // }
17
 // }
18
 
18
 
19
-
20
-
21
 class OrderPageInfo extends BasicPage {
19
 class OrderPageInfo extends BasicPage {
22
-  final id=Rx<String>('');
23
-  final orderStateText=Rx<String>('待支付');
24
-  final orderStateColor=Rx<Color>(Colors.black);
20
+  final id = Rx<String>('');
21
+  final orderStateText = Rx<String>('待支付');
22
+  final orderStateColor = Rx<Color>(Colors.black);
25
   final orderInfoContent = Rx<OrderInfoModel>(OrderInfoModel());
23
   final orderInfoContent = Rx<OrderInfoModel>(OrderInfoModel());
26
-
27
   // orderStates
24
   // orderStates
28
 
25
 
29
   @override
26
   @override
42
     }
39
     }
43
   }
40
   }
44
 
41
 
45
-
46
   @override
42
   @override
47
   Widget builder(BuildContext context) {
43
   Widget builder(BuildContext context) {
48
     naviTitle = '订单详情';
44
     naviTitle = '订单详情';
49
 
45
 
50
     return Column(
46
     return Column(
51
       children: [
47
       children: [
52
-        Obx(() =>
53
-            OrderInfoCard(
54
-                item: orderInfoContent(),
55
-                orderStateText: orderStateText(),
56
-                orderStateColor: orderStateColor()
57
-            ),
48
+        Obx(
49
+          () => OrderInfoCard(
50
+              item: orderInfoContent(),
51
+              orderStateText: orderStateText(),
52
+              orderStateColor: orderStateColor()),
53
+        ),
54
+        // Obx(() => _BottomWidget(id: id())),
55
+
56
+        Obx(
57
+          () => Container(
58
+              padding: EdgeInsets.fromLTRB(15, 50.w, 15, 0),
59
+              child: _bottomJudgment(id.value)),
58
         ),
60
         ),
59
-        Obx(()=>_BottomWidget(id: id()))
60
-        // orderStateText=='已完成'?  Text('')
61
-        //     :orderStateText== '进行中' ?Text('')
62
-        //     :orderStateText=='待评价'? DefaultButton(
63
-        //   color: const Color(0xffffffff),
64
-        //   backColor: const Color(0xFFFF703B),
65
-        //   width: 300.w,
66
-        //   height: 49.h,
67
-        //   text: '评价',
68
-        //   onPressed: () {
69
-        //     Fluttertoast.showToast(msg: '评价成功!');
70
-        //     Get.offAllNamed('/');
71
-        //   },
72
-        //   margin: const EdgeInsets.all(0),
73
-        //   fontSize: 20.sp,
74
-        //   radius: 24.5.w,
75
-        // )
76
-        //     :orderStateText=='待作业'?DefaultButton(
77
-        //   color: const Color(0xffffffff),
78
-        //   backColor: const Color(0xFFFF703B),
79
-        //   width: 300.w,
80
-        //   height: 49.h,
81
-        //   text: '退单',
82
-        //   onPressed: () {
83
-        //     Fluttertoast.showToast(msg: '评价成功!');
84
-        //     Get.offAllNamed('/');
85
-        //   },
86
-        //   margin: const EdgeInsets.all(0),
87
-        //   fontSize: 20.sp,
88
-        //   radius: 24.5.w,
89
-        // )
90
-        //     :orderStateText=='待付款'?_BottomWidget
91
-        //     :orderStateText=='已退单'?Text('')
92
-        //     :orderStateText=='退单申请中'?DefaultButton(
93
-        //   color: const Color(0xffffffff),
94
-        //   backColor: const Color(0xFFFF703B),
95
-        //   width: 300.w,
96
-        //   height: 49.h,
97
-        //   text: orderStateText,
98
-        //   onPressed: () {
99
-        //     Fluttertoast.showToast(msg: '评价成功!');
100
-        //     Get.offAllNamed('/');
101
-        //   },
102
-        //   margin: const EdgeInsets.all(0),
103
-        //   fontSize: 20.sp,
104
-        //   radius: 24.5.w,
105
-        // ):Text(''),
106
-
107
-        // Spacer(),
108
       ],
61
       ],
109
     );
62
     );
110
   }
63
   }
64
+
65
+  Widget _bottomJudgment(String id) {
66
+    return orderStateText.value == '已完成'
67
+        ? Text('')
68
+        : orderStateText.value == '进行中'
69
+            ? Text('')
70
+            : orderStateText.value == '待评价'
71
+                ? DefaultButton(
72
+                    color: const Color(0xffffffff),
73
+                    backColor: const Color(0xFFFF703B),
74
+                    width: 300.w,
75
+                    height: 49.h,
76
+                    text: '评价',
77
+                    onPressed: () {
78
+                      Fluttertoast.showToast(msg: '评价成功!');
79
+                      Get.offNamed('/order');
80
+                    },
81
+                    margin: const EdgeInsets.all(0),
82
+                    fontSize: 20.sp,
83
+                    radius: 24.5.w,
84
+                  )
85
+                : orderStateText.value == '待作业'
86
+                    ? DefaultButton(
87
+                        color: const Color(0xffffffff),
88
+                        backColor: const Color(0xFFFF703B),
89
+                        width: 300.w,
90
+                        height: 49.h,
91
+                        text: '退单',
92
+                        onPressed: () {
93
+                          modal.showDialog(
94
+                              title: '提示',
95
+                              content: Container(
96
+                                alignment: Alignment.center,
97
+                                child: Text('确定要申请退单吗?'),
98
+                              ),
99
+                              onCancel: () => true,
100
+                              onConfirm: () => {
101
+                                    orderRefund(id).then((value) {
102
+                                      Fluttertoast.showToast(msg: '退单成功!');
103
+                                      Get.offNamed('/order');
104
+                                    }),
105
+                                  });
106
+                        },
107
+                        margin: const EdgeInsets.all(0),
108
+                        fontSize: 20.sp,
109
+                        radius: 24.5.w,
110
+                      )
111
+                    : orderStateText.value == '已付款'
112
+                        ? DefaultButton(
113
+                            color: const Color(0xffffffff),
114
+                            backColor: const Color(0xFFFF703B),
115
+                            width: 300.w,
116
+                            height: 49.h,
117
+                            text: '退单',
118
+                            onPressed: () {
119
+                              modal.showDialog(
120
+                                  title: '提示',
121
+                                  content: Container(
122
+                                    alignment: Alignment.center,
123
+                                    child: Text('确定要申请退单吗?'),
124
+                                  ),
125
+                                  onCancel: () => true,
126
+                                  onConfirm: () => {
127
+                                        orderRefund(id).then((value) {
128
+                                          Fluttertoast.showToast(msg: '退单成功!');
129
+                                          Get.offNamed('/order');
130
+                                        }),
131
+                                      });
132
+                            },
133
+                            margin: const EdgeInsets.all(0),
134
+                            fontSize: 20.sp,
135
+                            radius: 24.5.w,
136
+                          )
137
+                        : orderStateText.value == '待付款'
138
+                            ? _BottomWidget(
139
+                                id: id,
140
+                              )
141
+                            : orderStateText.value == '已退单'
142
+                                ? Text('')
143
+                                : orderStateText.value == '退单申请中'
144
+                                    ? Text(orderStateText.value)
145
+                                    : Text('');
146
+  }
111
 }
147
 }
112
 
148
 
113
 class _BottomWidget extends StatelessWidget {
149
 class _BottomWidget extends StatelessWidget {
114
   final id;
150
   final id;
115
-  const _BottomWidget({Key? key, required this.id}) : super(key: key);
151
+  final resultMessage = Rx<String>('---');
116
 
152
 
153
+  _BottomWidget({Key? key, required this.id}) : super(key: key);
117
 
154
 
118
-  void _orderDeletels (){
119
-    modal.showDialog(title: '测试', content: SizedBox(width: 400, height: 300,), onConfirm: () => true);
120
-    // orderDelete(id).then((value) {
121
-    //   Fluttertoast.showToast(
122
-    //       msg: '订单取消成功!'
123
-    //   );
124
-    //   Get.offNamed('/order');
125
-    // });
155
+  void _orderDeletels() {
156
+    modal.showDialog(
157
+        title: '提示',
158
+        content: Container(
159
+          alignment: Alignment.center,
160
+          child: Text('确定要取消此订单吗?'),
161
+        ),
162
+        onCancel: () => true,
163
+        onConfirm: () => {
164
+              orderDelete(id).then((value) {
165
+                Fluttertoast.showToast(msg: '订单取消成功!');
166
+                Get.offNamed('/order');
167
+              })
168
+            });
126
   }
169
   }
127
 
170
 
171
+  //显示底部弹框的功能
172
+  void showBottomSheet(context) {
173
+    //用于在底部打开弹框的效果
174
+    showModalBottomSheet(
175
+        context: context,
176
+        isScrollControlled: false,
177
+        backgroundColor: Colors.white,
178
+        shape: RoundedRectangleBorder(
179
+            borderRadius: BorderRadius.all(Radius.circular(10))),
180
+        builder: (BuildContext context) {
181
+          return Container(
182
+            height: 200.w, //对话框高度就是此高度
183
+            child: Center(
184
+                child: Column(
185
+              children: [
186
+                Padding(
187
+                  padding: EdgeInsets.fromLTRB(0, 25.w, 0, 34.w),
188
+                  child: Text(
189
+                    "支付方式",
190
+                    style:
191
+                        TextStyle(fontSize: 17.sp, fontWeight: FontWeight.bold),
192
+                  ),
193
+                ),
194
+                Padding(
195
+                  padding: EdgeInsets.fromLTRB(15.w, 0, 15.w, 0),
196
+                  child: ListTile(
197
+                    contentPadding: EdgeInsets.symmetric(horizontal: 0.0),
198
+                    // 这边使用了contentPadding
199
+                    leading: Image(
200
+                      image: AssetImage('images/alipay.png'),
201
+                      width: 30.w,
202
+                      height: 30.w,
203
+                    ),
204
+                    title: Transform(
205
+                      transform: Matrix4.translationValues(-15, 0.0, 0.0),
206
+                      child: Text("支付宝",
207
+                          style: TextStyle(
208
+                              fontSize: 18.sp, color: Color(0xff333333))),
209
+                    ),
210
+                    trailing: Image(
211
+                      image: AssetImage('images/userRight.png'),
212
+                      width: 10.w,
213
+                      height: 18.w,
214
+                    ),
215
+                  ),
216
+                ),
217
+                Padding(
218
+                  padding: EdgeInsets.fromLTRB(15.w, 0, 15.w, 0),
219
+                  child: ListTile(
220
+                    onTap: (){
128
 
221
 
222
+                    },
223
+                    contentPadding: EdgeInsets.symmetric(horizontal: 0.0),
224
+                    // 这边使用了contentPadding
225
+                    leading: Image(
226
+                      image: AssetImage('images/weChatPay.png'),
227
+                      width: 30.w,
228
+                      height: 30.w,
229
+                    ),
230
+                    title: Transform(
231
+                      transform: Matrix4.translationValues(-15, 0.0, 0.0),
232
+                      child: Text("微信",
233
+                          style: TextStyle(
234
+                              fontSize: 18.sp, color: Color(0xff333333))),
235
+                    ),
236
+                    trailing: Image(
237
+                      image: AssetImage('images/userRight.png'),
238
+                      width: 10.w,
239
+                      height: 18.w,
240
+                    ),
241
+                  ),
242
+                ),
243
+              ],
244
+            )),
245
+          );
246
+        });
247
+  }
129
 
248
 
130
   @override
249
   @override
131
   Widget build(BuildContext context) {
250
   Widget build(BuildContext context) {
132
-
133
     return Container(
251
     return Container(
134
-      height: 100.w,
135
       alignment: Alignment.bottomCenter,
252
       alignment: Alignment.bottomCenter,
136
-      margin: EdgeInsets.fromLTRB(15.w, 0, 15.w, 50.h),
137
       child: Row(
253
       child: Row(
138
         mainAxisAlignment: MainAxisAlignment.spaceBetween,
254
         mainAxisAlignment: MainAxisAlignment.spaceBetween,
139
         children: [
255
         children: [
140
-          Container(
256
+          SizedBox(
141
             width: 150.w,
257
             width: 150.w,
142
             height: 49.h,
258
             height: 49.h,
143
-            margin: EdgeInsets.fromLTRB(0, 30.w, 0, 30.w),
144
-            alignment: Alignment.bottomCenter,
145
-            child: SizedBox(
146
-                  width: 150.w,
147
-                  height: 49.h,
148
-              child: ElevatedButton(
149
-                onPressed: () {
150
-                  _orderDeletels();
151
-                },
152
-                child: const Text(
153
-                  "取消",
154
-                  style: TextStyle(
155
-                      fontSize: 18,
156
-                      color: Color(0xFFFF703B),
157
-                      fontWeight: FontWeight.bold),
158
-                ),
159
-                style: ButtonStyle(
160
-                  side: MaterialStateProperty.all(
161
-                      BorderSide(width: 1, color: Color(0xFFFF703B))), //边框
162
-                  elevation: MaterialStateProperty.all(0),
163
-                  backgroundColor: MaterialStateProperty.all(Colors.white),
164
-                  shape: MaterialStateProperty.all(
165
-                    RoundedRectangleBorder(
166
-                        borderRadius:
167
-                        BorderRadius.all(Radius.circular(24.4))),
168
-                  ),
259
+            child: ElevatedButton(
260
+              onPressed: () {
261
+                _orderDeletels();
262
+              },
263
+              child: const Text(
264
+                "取消",
265
+                style: TextStyle(
266
+                    fontSize: 18,
267
+                    color: Color(0xFFFF703B),
268
+                    fontWeight: FontWeight.bold),
269
+              ),
270
+              style: ButtonStyle(
271
+                side: MaterialStateProperty.all(
272
+                    BorderSide(width: 1, color: Color(0xFFFF703B))), //边框
273
+                elevation: MaterialStateProperty.all(0),
274
+                backgroundColor: MaterialStateProperty.all(Colors.white),
275
+                shape: MaterialStateProperty.all(
276
+                  RoundedRectangleBorder(
277
+                      borderRadius: BorderRadius.all(Radius.circular(24.4))),
169
                 ),
278
                 ),
170
               ),
279
               ),
171
             ),
280
             ),
172
           ),
281
           ),
173
-      Container(
174
-        margin: EdgeInsets.fromLTRB(0, 30.w, 0, 30.w),
175
-        alignment: Alignment.bottomCenter,
176
-        child: DefaultButton(
177
-            color: const Color(0xffffffff),
178
-            backColor: const Color(0xFFFF703B),
179
-            width: 150.w,
180
-            height: 49.h,
181
-            text: '支付',
182
-            onPressed: () {
183
-              Fluttertoast.showToast(msg: '支付成功!');
184
-              Get.offAllNamed('/');
185
-            },
186
-            margin: const EdgeInsets.all(0),
187
-            fontSize: 20.sp,
188
-            radius: 24.5.w,
282
+          SizedBox(
283
+            child: DefaultButton(
284
+              color: const Color(0xffffffff),
285
+              backColor: const Color(0xFFFF703B),
286
+              width: 150.w,
287
+              height: 49.h,
288
+              text: '支付',
289
+              onPressed: () {
290
+                showBottomSheet(context);
291
+                // Fluttertoast.showToast(msg: '支付成功!');
292
+                // Get.offAllNamed('/');
293
+              },
294
+              margin: const EdgeInsets.all(0),
295
+              fontSize: 20.sp,
296
+              radius: 24.5.w,
297
+            ),
189
           ),
298
           ),
190
-      ),
191
         ],
299
         ],
192
       ),
300
       ),
193
     );
301
     );
194
   }
302
   }
195
 }
303
 }
196
-
197
-
198
-

+ 65
- 41
lib/pages/search/index.dart 查看文件

1
+import 'dart:async';
2
+
1
 import 'package:farmer_client/widgets/layout/BasicPage.dart';
3
 import 'package:farmer_client/widgets/layout/BasicPage.dart';
2
 import 'package:flutter/material.dart';
4
 import 'package:flutter/material.dart';
3
 import 'package:flutter_screenutil/flutter_screenutil.dart';
5
 import 'package:flutter_screenutil/flutter_screenutil.dart';
6
+import 'package:get/get.dart';
7
+import 'package:get/get_rx/src/rx_types/rx_types.dart';
4
 
8
 
9
+import '../../models/app.dart';
10
+import '../../models/entities/CardListModel.dart';
11
+import '../../services/homeAPI.dart';
12
+import '../../widgets/CarsCard.dart';
5
 import '../../widgets/NullCard.dart';
13
 import '../../widgets/NullCard.dart';
14
+import 'dart:async';
6
 
15
 
7
 class SearchPage extends BasicPage {
16
 class SearchPage extends BasicPage {
17
+  final cardSearchList = Rx<List<CardListModel>>([]);
18
+  var location = AppController.t.locationStr;
19
+
20
+
21
+  void _onChange(String value){
22
+      print(location);
23
+      searchMachinery(location.toString(),value).then((value) {
24
+        final list = <CardListModel>[];
25
+        value['records'].forEach((item) {
26
+          list.add(CardListModel.fromJson(item));
27
+        });
28
+        cardSearchList(list);
29
+      });
30
+
31
+  }
8
 
32
 
9
   @override
33
   @override
10
   Widget builder(BuildContext context) {
34
   Widget builder(BuildContext context) {
11
     naviTitle = '搜索';
35
     naviTitle = '搜索';
12
     return Container(
36
     return Container(
13
-
14
         child: Column(children: [
37
         child: Column(children: [
15
-          Container(
16
-            width: 345.w,
17
-            height: 34.h,
18
-            margin: EdgeInsets.symmetric(vertical: 15.h, horizontal: 15.w),
19
-            padding: EdgeInsets.symmetric(vertical: 0, horizontal: 10.w),
20
-            decoration: BoxDecoration(
21
-                color: Color(0xFFf8f8f8),
22
-                borderRadius: BorderRadius.all(Radius.circular(17.w))),
23
-            child: Row(
24
-              mainAxisAlignment: MainAxisAlignment.center,
25
-              children: [
26
-                Image.asset(
27
-                  'images/icons/search.png',
28
-                  width: 15.w,
29
-                  height: 15.w,
30
-                ),
31
-                Container(
32
-                  width: 300.w,
33
-                  margin: EdgeInsets.fromLTRB(5.w, 0, 0, 0),
34
-                  child: TextField(
35
-                    style: TextStyle(fontSize: 14.sp),
36
-                    decoration: const InputDecoration(
37
-                      isCollapsed: true,
38
-                      hintText: '搜索关键字查询',
39
-                      border: InputBorder.none,
40
-                      counterText: '', //去掉计数
41
-                      floatingLabelBehavior: FloatingLabelBehavior.never,
42
-                    ),
43
-                    onChanged: (e) {
44
-                      print(999);
45
-                    },
46
-                  ),
38
+      Container(
39
+        width: 345.w,
40
+        height: 34.h,
41
+        margin: EdgeInsets.symmetric(vertical: 15.h, horizontal: 15.w),
42
+        padding: EdgeInsets.symmetric(vertical: 0, horizontal: 10.w),
43
+        decoration: BoxDecoration(
44
+            color: Color(0xFFf8f8f8),
45
+            borderRadius: BorderRadius.all(Radius.circular(17.w))),
46
+        child: Row(
47
+          mainAxisAlignment: MainAxisAlignment.center,
48
+          children: [
49
+            Image.asset(
50
+              'images/icons/search.png',
51
+              width: 15.w,
52
+              height: 15.w,
53
+            ),
54
+            Container(
55
+              width: 300.w,
56
+              margin: EdgeInsets.fromLTRB(5.w, 0, 0, 0),
57
+              child: TextField(
58
+                style: TextStyle(fontSize: 14.sp),
59
+                decoration: const InputDecoration(
60
+                  isCollapsed: true,
61
+                  hintText: '搜索关键字查询',
62
+                  border: InputBorder.none,
63
+                  counterText: '', //去掉计数
64
+                  floatingLabelBehavior: FloatingLabelBehavior.never,
47
                 ),
65
                 ),
48
-              ],
66
+                onChanged: (e) {
67
+                  _onChange(e);
68
+                },
69
+              ),
49
             ),
70
             ),
50
-          ),
51
-          Column(
52
-            children: [
53
-              NullCard(text: '暂无农机信息'),
54
-            ],
55
-          )
56
-        ]));
71
+          ],
72
+        ),
73
+      ),
74
+          Obx(()=>Column(
75
+              children:
76
+              cardSearchList.value.length>0?
77
+                  cardSearchList().map((item) => CarsCard(item: item)).toList()
78
+                  :  [NullCard(text: '暂无农机信息!')],
79
+            ))
80
+    ]));
57
   }
81
   }
58
 }
82
 }

+ 15
- 0
lib/services/homeAPI.dart 查看文件

29
       });
29
       });
30
 }
30
 }
31
 
31
 
32
+/**
33
+ * 农机列表搜索
34
+ * @param {*} data
35
+ * @returns
36
+ */
37
+Future searchMachinery(String location,String? q,) async {
38
+  return request('/machinery', options: Options(method: 'GET'), queryParameters: {
39
+    'location': location,'q':q,
40
+  },data: {'q':q,'location':location}).catchError((error) => {
41
+    Fluttertoast.showToast(msg: error.error['message']),
42
+  });
43
+}
44
+
45
+
46
+
32
 /**
47
 /**
33
  * 农机详情
48
  * 农机详情
34
  * @param {*} data
49
  * @param {*} data

+ 14
- 0
lib/services/orderAPI.dart 查看文件

59
   { Fluttertoast.showToast(
59
   { Fluttertoast.showToast(
60
       msg: error.error['message']
60
       msg: error.error['message']
61
   ),});
61
   ),});
62
+}
63
+
62
 
64
 
65
+/**
66
+ * --------------订单退款-----------------
67
+ * @param {*} data
68
+ * @returns
69
+ */
70
+Future orderRefund (String id)async{
71
+  return request('/order/$id/refund',options: Options(method: 'PUT')).catchError((error) =>
72
+  { Fluttertoast.showToast(
73
+      msg: error.error['message']
74
+  ),});
63
 }
75
 }
76
+
77
+

+ 1
- 1
lib/widgets/OrderInfoCard.dart 查看文件

161
                                   fontSize: 16,
161
                                   fontSize: 16,
162
                                   fontWeight: FontWeight.bold)),
162
                                   fontWeight: FontWeight.bold)),
163
                           TextSpan(
163
                           TextSpan(
164
-                              text: orderStateText??'未支付',
164
+                              text: orderStateText==null?'未支付':orderStateText=='已付款'? '已付款,待调度':orderStateText,
165
                               style: TextStyle(
165
                               style: TextStyle(
166
                                   color:orderStateColor??Colors.black,
166
                                   color:orderStateColor??Colors.black,
167
                                   fontSize: 16,
167
                                   fontSize: 16,