finance_provider.dart
2.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import 'package:flutter/material.dart';
import 'package:one_key/provider/user_model.dart';
import 'package:provider/provider.dart';
import '../constant/constant.dart';
import '../constant/error.dart';
import '../constant/state.dart';
import '../models/payment_code_model.dart';
import '../net/base_resp.dart';
import '../net/dio_util.dart';
import '../net/http_url.dart';
import '../utils/utils.dart';
class FinanceProvider extends ChangeNotifier {
PageState pageState = PageState.Loading;
String paymentCodeUrl = '';
///客户经理获取所创建活动列表
Future createPayQrcode(
BuildContext context,
{isShowLoading = true}) async {
try {
Map<String, String?> params = {
'sellerid':Provider.of<UserModel>(context,listen: false).user!.sellerid,
};
BaseResp<dynamic> baseResp = await DioUtil().request<dynamic>(
context, Method.post, HttpUrl.create_pay_qrcode,
data: params, showLoading: false);
if (baseResp.code == Constant.status_success) {
if (baseResp.data.isEmpty) {
// if (isShowLoading) {
pageState = PageState.Empty;
// }
} else {
// if (isShowLoading) {
pageState = PageState.Success;
// }
}
paymentCodeUrl =
PaymentCodeModel.fromJson(baseResp.responseData!).data ?? '';
} else {
if (isShowLoading) {
pageState = PageState.ConnectivityError;
}
if (baseResp != null) {
Utils.showToast(baseResp.msg ?? "");
}
}
notifyListeners();
} catch (error) {
print(error.toString());
if (error is MyError) {
if (isShowLoading) {
switch (error.type) {
case 1:
pageState = PageState.ConnectivityError;
break;
case 2:
pageState = PageState.ConnectivityTimeOut;
break;
default:
pageState = PageState.ConnectivityError;
break;
}
}
}
notifyListeners();
}
}
}