[baozhangchao] 3 년 전
부모
커밋
e3e6395121
3개의 변경된 파일31개의 추가작업 그리고 33개의 파일을 삭제
  1. 1
    4
      lib/pages/home/index.dart
  2. 25
    26
      lib/services/homeAPI.dart
  3. 5
    3
      lib/utils/Request.dart

+ 1
- 4
lib/pages/home/index.dart 파일 보기

@@ -1,11 +1,9 @@
1 1
 import 'package:farmer_client/widgets/Modal.dart' as modal;
2 2
 import 'package:farmer_client/widgets/layout/BasicPage.dart';
3 3
 import 'package:flutter/material.dart';
4
-import 'package:get/get.dart';
5 4
 import '../../utils/timer.dart';
6 5
 import './widgets/home/index.dart';
7 6
 
8
-
9 7
 class Home extends BasicPage {
10 8
   Home({Key? key}) : super(key: key) {
11 9
     tabIndex = 0;
@@ -14,7 +12,6 @@ class Home extends BasicPage {
14 12
 
15 13
   @override
16 14
   Widget builder(BuildContext context) {
17
-
18 15
     setTimeout(() {
19 16
       // showDialog(context: Get.overlayContext!, builder: (BuildContext c) {
20 17
       //   return Modal(type: 'dialog', title: '测试', message: '这是一段 message !', onConfirm: () => print('hahahaha'),);
@@ -22,7 +19,7 @@ class Home extends BasicPage {
22 19
       // Get.dialog(Modal(type: 'dialog', title: '测试', message: '这是一段 message !', onConfirm: () => print('hahahaha'),));
23 20
       // modal.showDialog(title: '测试', content: SizedBox(width: 400, height: 300,), onConfirm: () => false);
24 21
     }, 2000);
25
-    
22
+
26 23
     return const HomePage();
27 24
   }
28 25
 }

+ 25
- 26
lib/services/homeAPI.dart 파일 보기

@@ -1,63 +1,62 @@
1
-
2
-
3 1
 import 'package:dio/dio.dart';
4 2
 import 'package:farmer_client/utils/Request.dart';
5 3
 import 'package:fluttertoast/fluttertoast.dart';
6 4
 
7
-
8
-
9 5
 /**
10 6
  * banner轮播图
11 7
  * @param {*} data
12 8
  * @returns
13 9
  */
14
-Future getHomeBanner(String position)async{
15
-  return request('/banner',options: Options(method: 'GET'),data: { 'position': position}).catchError((error) =>
16
-  { Fluttertoast.showToast(
17
-      msg: error.error['message']
18
-  ),});
19
-  
10
+Future getHomeBanner(String position) async {
11
+  return request('/banner',
12
+          options: Options(method: 'GET'), data: {'position': position})
13
+      .catchError((error) => {
14
+            Fluttertoast.showToast(msg: error.error['message']),
15
+          });
20 16
 }
21 17
 
22
-
23
-
24 18
 /**
25 19
  * 农机列表
26 20
  * @param {*} data
27 21
  * @returns
28 22
  */
29
-Future getMachinery(String location)async{
30
-  return request('/machinery',options: Options(method: 'GET'),queryParameters: { 'location': location}).catchError((error) =>
31
-  { Fluttertoast.showToast(
32
-      msg: error.error['message']
33
-  ),});
34
-
23
+Future getMachinery(String location) async {
24
+  return request('/machinery', options: Options(method: 'GET'), queryParameters: {
25
+    'location': location
26
+  }).catchError((error) => {
27
+        Fluttertoast.showToast(msg: error.error['message']),
28
+      });
35 29
 }
36 30
 
37
-
38
-
39 31
 /**
40 32
  * 农机详情
41 33
  * @param {*} data
42 34
  * @returns
43 35
  */
36
+<<<<<<< HEAD
44 37
 Future getMachineryInfo(String id,String location ,bool attached)async{
45 38
   return request('/machinery-summary/$id',options: Options(method: 'GET'),queryParameters: { 'location': location,'attached': attached}).catchError((error) =>
46 39
   { Fluttertoast.showToast(
47 40
       msg: error.error['message']
48 41
   ),});
49 42
 
43
+=======
44
+Future getMachineryInfo(String id, String location, bool attached) async {
45
+  return request('/machinery-summary',
46
+          options: Options(method: 'GET'),
47
+          queryParameters: {'id': id},
48
+          data: {'location': location, 'attached': attached})
49
+      .catchError((error) => {
50
+            Fluttertoast.showToast(msg: error.error['message']),
51
+          });
52
+>>>>>>> 40e1cb063352fdbd66774cfedb970a9d87bd4315
50 53
 }
51 54
 
52
-
53 55
 /**
54 56
  * 农机分类Tab列查询
55 57
  * @param {*} data
56 58
  * @returns
57 59
  */
58
-Future getMachineryType()async{
59
-  return request('/machinery-type',options: Options(method: 'GET'));
60
+Future getMachineryType() async {
61
+  return request('/machinery-type', options: Options(method: 'GET'));
60 62
 }
61
-
62
-
63
-

+ 5
- 3
lib/utils/Request.dart 파일 보기

@@ -37,7 +37,7 @@ Dio createRequest() {
37 37
   var dio = Dio(options);
38 38
   dio.interceptors.add(InterceptorsWrapper(onRequest: (options, handler) {
39 39
     // Do something before request is sent
40
-    options.headers['Authorization'] =  GetStorage().read("token");
40
+    options.headers['Authorization'] = GetStorage().read("token");
41 41
     return handler.next(options); //continue
42 42
     // If you want to resolve the request with some custom data,
43 43
     // you can resolve a `Response` object eg: `handler.resolve(response)`.
@@ -59,7 +59,10 @@ Dio createRequest() {
59 59
 
60 60
       return handler.next(response);
61 61
     } else {
62
-      DioError error = DioError(requestOptions: response.requestOptions, error: response.data, response: response);
62
+      DioError error = DioError(
63
+          requestOptions: response.requestOptions,
64
+          error: response.data,
65
+          response: response);
63 66
       return handler.reject(error);
64 67
     }
65 68
   }, onError: (DioError e, handler) {
@@ -81,7 +84,6 @@ Future request(String path,
81 84
     Options? options,
82 85
     ProgressCallback? onSendProgress,
83 86
     ProgressCallback? onReceiveProgress}) async {
84
-
85 87
   var resp = await instance.request(path,
86 88
       data: data,
87 89
       queryParameters: queryParameters,