comment_manage_provider.dart
4.23 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
148
149
150
151
152
import 'package:flutter/material.dart';
import 'package:one_key/constant/state.dart';
import 'package:video_compress/video_compress.dart';
import '../constant/constant.dart';
import '../constant/error.dart';
import '../models/comments_label_model.dart';
import '../models/comments_model.dart';
import '../net/base_resp.dart';
import '../net/dio_util.dart';
import '../net/http_url.dart';
import '../utils/utils.dart';
class CommentManageProvider extends ChangeNotifier {
PageState pageState = PageState.Loading;
List<CommentsSunModel> commentsData = [];
List<CommentsLabelSunModel> commentsLabeldata = [];
///回复商家评价
Future<dynamic> setComment(BuildContext context, Map<String, String> params,
{isShowLoading = true}) async {
BaseResp<dynamic> baseResp = await DioUtil()
.request<dynamic>(context, Method.post, HttpUrl.set_comment,
data: params, showLoading: isShowLoading)
.catchError((error) {
print(error.toString());
if (error is MyError) {
// switch (error.type) {
// case 1:
// pageState = PageState.ConnectivityError;
// break;
// case 2:
// pageState = PageState.ConnectivityTimeOut;
// break;
// default:
// pageState = PageState.ConnectivityError;
// break;
// }
}
// notifyListeners();
return false;
});
if (baseResp.code == Constant.status_success) {
notifyListeners();
return true;
// } else {
// return false;
// }
} else {
if (baseResp != null) {
Utils.showToast(baseResp.msg ?? "");
}
notifyListeners();
return false;
}
}
///获取标签
Future<dynamic> getCountCommentLabel(
BuildContext context, Map<String, String> params,
{isShowLoading = true}) async {
BaseResp<dynamic> baseResp = await DioUtil()
.request<dynamic>(context, Method.post, HttpUrl.get_count_comment_label,
data: params, showLoading: isShowLoading)
.catchError((error) {
print(error.toString());
if (error is MyError) {
// switch (error.type) {
// case 1:
// pageState = PageState.ConnectivityError;
// break;
// case 2:
// pageState = PageState.ConnectivityTimeOut;
// break;
// default:
// pageState = PageState.ConnectivityError;
// break;
// }
}
// notifyListeners();
return false;
});
if (baseResp.code == Constant.status_success) {
commentsLabeldata =
CommentsLabelModel.fromJson(baseResp.responseData).data;
notifyListeners();
return true;
// } else {
// return false;
// }
} else {
if (baseResp != null) {
Utils.showToast(baseResp.msg ?? "");
}
notifyListeners();
return false;
}
}
///获取评价列表
Future<dynamic> getSellerComments(
BuildContext context, Map<String, String> params,
{isShowLoading = true}) async {
BaseResp<dynamic> baseResp = await DioUtil()
.request<dynamic>(context, Method.post, HttpUrl.get_seller_comments,
data: params, showLoading: isShowLoading)
.catchError((error) {
print(error.toString());
if (error is MyError) {
switch (error.type) {
case 1:
pageState = PageState.ConnectivityError;
break;
case 2:
pageState = PageState.ConnectivityTimeOut;
break;
default:
pageState = PageState.ConnectivityError;
break;
}
}
notifyListeners();
return false;
});
if (baseResp.code == Constant.status_success) {
commentsData = CommentsModel.fromJson(baseResp.responseData).data;
if (commentsData.length == 0) {
pageState = PageState.Empty;
} else {
pageState = PageState.Success;
}
notifyListeners();
return true;
// } else {
// return false;
// }
} else {
if (baseResp != null) {
Utils.showToast(baseResp.msg ?? "");
}
pageState = PageState.ConnectivityError;
notifyListeners();
return false;
}
}
}