Yansen 2 lat temu
rodzic
commit
32c990f37d

+ 1
- 0
android/app/build.gradle Wyświetl plik

@@ -57,6 +57,7 @@ android {
57 57
     dependencies {
58 58
         implementation('com.amap.api:3dmap:9.1.0')
59 59
         implementation('com.amap.api:location:6.1.0')
60
+        api 'com.alipay.sdk:alipaysdk-android:+@aar'
60 61
     }
61 62
 
62 63
     buildTypes {

+ 3
- 3
lib/services/account.dart Wyświetl plik

@@ -1,6 +1,7 @@
1 1
 import 'package:dio/dio.dart';
2 2
 import '../utils/Request.dart';
3
-import 'package:fluttertoast/fluttertoast.dart';
3
+
4
+import 'showError.dart';
4 5
 
5 6
 /// 账户余额
6 7
 /// @param {*} data
@@ -15,6 +16,5 @@ Future getAccount() async {
15 16
 Future getLogList(params) async {
16 17
   return request('/account-log',
17 18
           options: Options(method: 'GET'), queryParameters: params)
18
-      .catchError((error) =>
19
-          {Fluttertoast.showToast(msg: error.error.toString()), print(error)});
19
+      .catchError(showError);
20 20
 }

+ 2
- 3
lib/services/amap.dart Wyświetl plik

@@ -1,6 +1,6 @@
1 1
 import 'package:dio/dio.dart';
2 2
 import '../utils/Request.dart';
3
-import 'package:fluttertoast/fluttertoast.dart';
3
+import 'showError.dart';
4 4
 
5 5
 /// 添加银行卡
6 6
 /// @param {*} data
@@ -10,6 +10,5 @@ Future setAmap(params) async {
10 10
     '/amap',
11 11
     options: Options(method: 'POST'),
12 12
     queryParameters: params,
13
-  ).catchError(
14
-      (error) => {Fluttertoast.showToast(msg: error.error.toString())});
13
+  ).catchError(showError);
15 14
 }

+ 5
- 10
lib/services/bank.dart Wyświetl plik

@@ -1,6 +1,7 @@
1 1
 import 'package:dio/dio.dart';
2 2
 import '../utils/Request.dart';
3
-import 'package:fluttertoast/fluttertoast.dart';
3
+
4
+import 'showError.dart';
4 5
 
5 6
 /// 银行列表
6 7
 /// @param {*} data
@@ -23,9 +24,7 @@ Future getBankCardList(params) async {
23 24
 /// @returns
24 25
 Future getBankCardDetail(String id) async {
25 26
   return request('/bankcard/$id', options: Options(method: 'GET'))
26
-      .catchError((error) => {
27
-            Fluttertoast.showToast(msg: error.error['message']),
28
-          });
27
+      .catchError(showError);
29 28
 }
30 29
 
31 30
 /// 添加银行卡
@@ -36,9 +35,7 @@ Future addBankCard(data) async {
36 35
     '/bankcard',
37 36
     options: Options(method: 'POST'),
38 37
     data: data,
39
-  ).catchError((error) => {
40
-        Fluttertoast.showToast(msg: error.error['message']),
41
-      });
38
+  ).catchError(showError);
42 39
 }
43 40
 
44 41
 /// 解绑银行卡
@@ -46,9 +43,7 @@ Future addBankCard(data) async {
46 43
 /// @returns
47 44
 Future unbindBankCard(String id) async {
48 45
   return request('/bankcard/$id', options: Options(method: 'DELETE'))
49
-      .catchError((error) => {
50
-            Fluttertoast.showToast(msg: error.error['message']),
51
-          });
46
+      .catchError(showError);
52 47
 }
53 48
 
54 49
 /// 提现申请

+ 3
- 4
lib/services/banner.dart Wyświetl plik

@@ -1,6 +1,7 @@
1 1
 import 'package:dio/dio.dart';
2 2
 import '../utils/Request.dart';
3
-import 'package:fluttertoast/fluttertoast.dart';
3
+
4
+import 'showError.dart';
4 5
 
5 6
 /**
6 7
  * banner轮播图列表
@@ -10,7 +11,5 @@ import 'package:fluttertoast/fluttertoast.dart';
10 11
 Future getBannerList(String position) async {
11 12
   return request('/banner',
12 13
           options: Options(method: 'GET'), data: {'position': position})
13
-      .catchError((error) => {
14
-            Fluttertoast.showToast(msg: error.error.toString()),
15
-          });
14
+      .catchError(showError);
16 15
 }

+ 3
- 4
lib/services/feedback.dart Wyświetl plik

@@ -1,6 +1,7 @@
1 1
 import 'package:dio/dio.dart';
2 2
 import '../utils/Request.dart';
3
-import 'package:fluttertoast/fluttertoast.dart';
3
+
4
+import 'showError.dart';
4 5
 
5 6
 /**
6 7
  * 意见反馈
@@ -11,7 +12,5 @@ import 'package:fluttertoast/fluttertoast.dart';
11 12
 Future feedback(String content) async {
12 13
   return request('/feedback',
13 14
           options: Options(method: 'POST'), data: {'content': content})
14
-      .catchError((error) => {
15
-            Fluttertoast.showToast(msg: error.error['message']),
16
-          });
15
+      .catchError(showError);
17 16
 }

+ 4
- 6
lib/services/job.dart Wyświetl plik

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

+ 3
- 3
lib/services/machinery.dart Wyświetl plik

@@ -1,6 +1,7 @@
1 1
 import 'package:dio/dio.dart';
2 2
 import '../utils/Request.dart';
3
-import 'package:fluttertoast/fluttertoast.dart';
3
+
4
+import 'showError.dart';
4 5
 
5 6
 /// 农机列表
6 7
 /// @param {*} data
@@ -8,8 +9,7 @@ import 'package:fluttertoast/fluttertoast.dart';
8 9
 Future getMachineryList(params) async {
9 10
   return request('/machinery',
10 11
           options: Options(method: 'GET'), queryParameters: params)
11
-      .catchError((error) =>
12
-          {Fluttertoast.showToast(msg: error.error.toString()), print(error)});
12
+      .catchError(showError);
13 13
 }
14 14
 
15 15
 /// 农机详情

+ 4
- 6
lib/services/order.dart Wyświetl plik

@@ -1,6 +1,7 @@
1 1
 import 'package:dio/dio.dart';
2 2
 import '../utils/Request.dart';
3
-import 'package:fluttertoast/fluttertoast.dart';
3
+
4
+import 'showError.dart';
4 5
 
5 6
 /// 订单列表
6 7
 /// @param {*} data
@@ -8,8 +9,7 @@ import 'package:fluttertoast/fluttertoast.dart';
8 9
 Future getOrderList(params) async {
9 10
   return request('/order',
10 11
           options: Options(method: 'GET'), queryParameters: params)
11
-      .catchError((error) =>
12
-          {Fluttertoast.showToast(msg: error.error.toString()), print(error)});
12
+      .catchError(showError);
13 13
 }
14 14
 
15 15
 /// 订单详情
@@ -17,7 +17,5 @@ Future getOrderList(params) async {
17 17
 /// @returns
18 18
 Future getOrderDetail(String id) async {
19 19
   return request('/order/$id', options: Options(method: 'GET'))
20
-      .catchError((error) => {
21
-            Fluttertoast.showToast(msg: error.error['message']),
22
-          });
20
+      .catchError(showError);
23 21
 }

+ 10
- 0
lib/services/showError.dart Wyświetl plik

@@ -0,0 +1,10 @@
1
+
2
+import 'package:flutter_easyloading/flutter_easyloading.dart';
3
+import 'package:fluttertoast/fluttertoast.dart';
4
+
5
+void showError(error) {
6
+  var err = error.error;
7
+  var msg = err is Map ? err['message'] : err;
8
+  EasyLoading.dismiss();
9
+  Fluttertoast.showToast(msg: msg);
10
+}

+ 3
- 3
lib/services/user.dart Wyświetl plik

@@ -2,14 +2,14 @@ import 'package:dio/dio.dart';
2 2
 import '../utils/Request.dart';
3 3
 import 'package:fluttertoast/fluttertoast.dart';
4 4
 
5
+import 'showError.dart';
6
+
5 7
 Future getSMSCaptch(String phone) async {
6 8
   return request('/sms-captcha',
7 9
       options: Options(method: 'POST'),
8 10
       queryParameters: {'phone': phone}).then((value) {
9 11
     Fluttertoast.showToast(msg: '验证码发送成功!');
10
-  }).catchError((error) {
11
-    Fluttertoast.showToast(msg: error.error['message']);
12
-  });
12
+  }).catchError(showError);
13 13
 }
14 14
 
15 15
 //登录