feast_model.dart
1.89 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
import 'package:flutter/material.dart';
import 'package:one_key/constant/state.dart';
import 'package:one_key/provider/user_model.dart';
import 'package:provider/provider.dart';
import '../constant/constant.dart';
import '../constant/error.dart';
import '../models/filter_btn_model.dart';
import '../models/get_seller_user_by_sellerid_model.dart';
import '../net/base_resp.dart';
import '../net/dio_util.dart';
import '../net/http_url.dart';
import '../utils/utils.dart';
class FeastModel extends ChangeNotifier {
PageState pageState = PageState.Success;
List<FilterBtnModel> sellerManageList = []; //经理数据 ---- 商家编辑页面
///商家详情编辑页面 ------ 获取经理数据
Future<List<FilterBtnModel>> getSellerUserBySellerid(BuildContext context,
{isShowLoading = true}) async {
Map<String, String> params = {
'sellerid': Provider.of<UserModel>(context, listen: false).user.sellerid
};
BaseResp<dynamic> baseResp = await DioUtil()
.request<dynamic>(
context, Method.get, HttpUrl.get_seller_user_by_sellerid,
data: params, showLoading: false)
.catchError((error) {
print(error.toString());
if (error is MyError) {}
});
if (baseResp.code == Constant.status_success) {
List<GetSellerUserBySelleridSunModel> sunmodel =
GetSellerUserBySelleridModel.fromJson(baseResp.responseData).data;
sellerManageList = [];
if (sunmodel != null && sunmodel.length > 0) {
for (GetSellerUserBySelleridSunModel item in sunmodel) {
if (item.nickName != null) {
FilterBtnModel model = FilterBtnModel();
model.id = item.id;
model.title = item.nickName;
sellerManageList.add(model);
}
}
}
} else {
if (baseResp != null) {
Utils.showToast(baseResp.msg ?? "");
}
}
return sellerManageList;
}
}