base_info_provider.dart
5 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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
import 'package:flutter/material.dart';
import 'package:one_key/constant/constant.dart';
import 'package:one_key/constant/error.dart';
import 'package:one_key/models/base_info_model.dart';
import 'package:one_key/models/seller_phone_model.dart';
import 'package:one_key/models/table_photo_model.dart';
import 'package:one_key/net/base_resp.dart';
import 'package:one_key/net/dio_util.dart';
import 'package:one_key/net/http_url.dart';
import 'package:one_key/provider/user_model.dart';
import 'package:one_key/utils/utils.dart';
import 'package:provider/provider.dart';
class BaseIndoProvider with ChangeNotifier {
BaseInfoSunModel baseInfoSunModel; //客户经理基础信息
List<String> photoList = []; //商家图片信息
///客户经理添加/修改基本信息
Future<dynamic> setCustomerActivityBaseinfo(
BuildContext context, Map<String, String> params,
{isShowLoading = true}) async {
BaseResp<dynamic> baseResp = await DioUtil()
.request<dynamic>(
context, Method.get, HttpUrl.set_customer_activity_baseinfo,
data: params, showLoading: isShowLoading)
.catchError((error) {
print(error.toString());
if (error is MyError) {}
return false;
});
if (baseResp.code == Constant.status_success) {
if (baseResp.data != null) {
// coupons = baseResp.data['aid'].split('');
return true;
} else {
// Utils.showToast(baseResp.msg ?? "修改失败");
return false;
}
} else {
if (baseResp != null) {
// Utils.showToast(baseResp.msg ?? "");
}
return false;
}
}
///客户经理获取基本信息
Future<bool> getCustomerActivityBaseinfo(
BuildContext context, Map<String, String> params,
{isShowLoading = true}) async {
BaseResp<dynamic> baseResp = await DioUtil()
.request<dynamic>(
context, Method.get, HttpUrl.get_customer_activity_baseinfo,
data: params, showLoading: isShowLoading)
.catchError((error) {
print(error.toString());
Map<String, String> params = {
'sellerid':
Provider.of<UserModel>(context, listen: false).user.sellerid,
"uid": Provider.of<UserModel>(context, listen: false).user.openid,
};
getCustomerActivityBaseinfo(context, params, isShowLoading: false);
if (error is MyError) {}
});
if (baseResp.code == Constant.status_success) {
if (baseResp.data == null || baseResp.data == false) {
return false;
} else {
baseInfoSunModel = BaseInfoModel.fromJson(baseResp.responseData).data;
// for (int i = 0; i < couponListSelect.length; i++) {
// coupons.add(couponListSelect[i].id);
// // couponsShow.add(couponTemp[i].id);
// }
// hasModify = true;
notifyListeners();
return true;
}
} else {
if (baseResp != null) {
Utils.showToast(baseResp.msg ?? "");
}
return false;
}
}
// ///根据商家ID获取对应类型图片
// Future<bool> getSellerPhotoById(
// BuildContext context, Map<String, String> params,
// {isShowLoading = true}) async {
// BaseResp<dynamic> baseResp = await DioUtil()
// .request<dynamic>(context, Method.get, HttpUrl.get_seller_photo_by_id,
// data: params, showLoading: isShowLoading)
// .catchError((error) {
// print(error.toString());
// if (error is MyError) {}
// });
// if (baseResp.code == Constant.status_success) {
// if (baseResp.data == null || baseResp.data == false) {
// return false;
// } else {
// photoList = SellerPhoneModel.fromJson(baseResp.responseData).data;
// // for (int i = 0; i < couponListSelect.length; i++) {
// // coupons.add(couponListSelect[i].id);
// // // couponsShow.add(couponTemp[i].id);
// // }
// // hasModify = true;
// notifyListeners();
// return true;
// }
// } else {
// if (baseResp != null) {
// Utils.showToast(baseResp.msg ?? "");
// }
// return false;
// }
// }
///App获取多个桌位关联图片
Future<dynamic> getTablesPhoto(
BuildContext context, Map<String, String> params,
{isShowLoading = true}) async {
BaseResp<dynamic> baseResp = await DioUtil()
.request<dynamic>(context, Method.get, HttpUrl.get_tables_photo,
data: params, showLoading: isShowLoading)
.catchError((error) {
print(error.toString());
if (error is MyError) {}
});
if (baseResp.code == Constant.status_success) {
if (baseResp.data == null) {
} else {
List<TablePhotoSunModel> tablePhotoList =
TablePhotoModel.fromJson(baseResp.responseData).data;
for (int i = 0; i < tablePhotoList.length; i++) {
photoList.add(tablePhotoList[i].url);
}
notifyListeners();
}
} else {
if (baseResp != null) {
Utils.showToast(baseResp.msg ?? "");
}
return [];
}
}
}