|
@@ -3,6 +3,7 @@ import 'package:flutter/material.dart'; |
|
@@ -3,6 +3,7 @@ import 'package:flutter/material.dart'; |
|
3
|
import 'package:flutter_picker/flutter_picker.dart';
|
3
|
import 'package:flutter_picker/flutter_picker.dart';
|
|
4
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
4
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
5
|
import 'package:fluttertoast/fluttertoast.dart';
|
5
|
import 'package:fluttertoast/fluttertoast.dart';
|
|
|
|
6
|
+import 'package:one_key/constant/state.dart';
|
|
6
|
import 'package:one_key/models/coupon_model.dart';
|
7
|
import 'package:one_key/models/coupon_model.dart';
|
|
7
|
import 'package:one_key/provider/coupon_provider.dart';
|
8
|
import 'package:one_key/provider/coupon_provider.dart';
|
|
8
|
import 'package:one_key/provider/user_model.dart';
|
9
|
import 'package:one_key/provider/user_model.dart';
|
|
@@ -17,13 +18,17 @@ import 'package:one_key/widgets/system_app_bar.dart'; |
|
@@ -17,13 +18,17 @@ import 'package:one_key/widgets/system_app_bar.dart'; |
|
17
|
import 'package:one_key/widgets/v_empty_view.dart';
|
18
|
import 'package:one_key/widgets/v_empty_view.dart';
|
|
18
|
import 'package:provider/provider.dart';
|
19
|
import 'package:provider/provider.dart';
|
|
19
|
|
20
|
|
|
|
|
21
|
+import '../../widgets/page_exception.dart';
|
|
|
|
22
|
+
|
|
20
|
/**
|
23
|
/**
|
|
21
|
* 新建券
|
24
|
* 新建券
|
|
22
|
*/
|
25
|
*/
|
|
23
|
|
26
|
|
|
24
|
class CouponDetailPage extends StatefulWidget {
|
27
|
class CouponDetailPage extends StatefulWidget {
|
|
25
|
final CouponSunModel couponSunModel;
|
28
|
final CouponSunModel couponSunModel;
|
|
26
|
- CouponDetailPage({Key key, this.couponSunModel}) : super(key: key);
|
29
|
+ final String idstr;
|
|
|
|
30
|
+ CouponDetailPage({Key key, this.couponSunModel, this.idstr})
|
|
|
|
31
|
+ : super(key: key);
|
|
27
|
|
32
|
|
|
28
|
@override
|
33
|
@override
|
|
29
|
_CouponDetailPageState createState() => _CouponDetailPageState();
|
34
|
_CouponDetailPageState createState() => _CouponDetailPageState();
|
|
@@ -33,14 +38,33 @@ class _CouponDetailPageState extends State<CouponDetailPage> { |
|
@@ -33,14 +38,33 @@ class _CouponDetailPageState extends State<CouponDetailPage> { |
|
33
|
ScrollController controller = ScrollController();
|
38
|
ScrollController controller = ScrollController();
|
|
34
|
final heightCell = ScreenUtil().setWidth(80);
|
39
|
final heightCell = ScreenUtil().setWidth(80);
|
|
35
|
CouponProvider couponProvider;
|
40
|
CouponProvider couponProvider;
|
|
|
|
41
|
+ PageState pageState = PageState.Loading;
|
|
36
|
|
42
|
|
|
37
|
@override
|
43
|
@override
|
|
38
|
void initState() {
|
44
|
void initState() {
|
|
39
|
super.initState();
|
45
|
super.initState();
|
|
40
|
|
46
|
|
|
41
|
- if(widget.couponSunModel == null){
|
|
|
|
42
|
-
|
47
|
+ WidgetsBinding.instance.addPostFrameCallback((_) {
|
|
|
|
48
|
+ if (widget.idstr != null && widget.idstr != 'null') {
|
|
|
|
49
|
+ _getActivityById();
|
|
|
|
50
|
+ } else {
|
|
|
|
51
|
+ couponProvider.couponSunModel = widget.couponSunModel;
|
|
|
|
52
|
+ pageState = PageState.Success;
|
|
|
|
53
|
+ setState(() {});
|
|
|
|
54
|
+ }
|
|
|
|
55
|
+ });
|
|
|
|
56
|
+ }
|
|
|
|
57
|
+
|
|
|
|
58
|
+ _getActivityById() async {
|
|
|
|
59
|
+ pageState = PageState.Loading;
|
|
|
|
60
|
+ bool success =
|
|
|
|
61
|
+ await couponProvider.getActivityById(context, {'id': widget.idstr});
|
|
|
|
62
|
+ if (success) {
|
|
|
|
63
|
+ pageState = PageState.Success;
|
|
|
|
64
|
+ } else {
|
|
|
|
65
|
+ pageState = PageState.ConnectivityError;
|
|
43
|
}
|
66
|
}
|
|
|
|
67
|
+ setState(() {});
|
|
44
|
}
|
68
|
}
|
|
45
|
|
69
|
|
|
46
|
///时间选择
|
70
|
///时间选择
|
|
@@ -123,121 +147,145 @@ class _CouponDetailPageState extends State<CouponDetailPage> { |
|
@@ -123,121 +147,145 @@ class _CouponDetailPageState extends State<CouponDetailPage> { |
|
123
|
Widget build(BuildContext context) {
|
147
|
Widget build(BuildContext context) {
|
|
124
|
couponProvider = Provider.of<CouponProvider>(context, listen: true);
|
148
|
couponProvider = Provider.of<CouponProvider>(context, listen: true);
|
|
125
|
return Scaffold(
|
149
|
return Scaffold(
|
|
126
|
- backgroundColor: MyColours.color_ffffff,
|
|
|
|
127
|
- appBar: SystemAppBar(
|
|
|
|
128
|
- '优惠券详情',
|
|
|
|
129
|
- onTap: () {
|
|
|
|
130
|
- Navigator.pop(context);
|
|
|
|
131
|
- },
|
|
|
|
132
|
- ),
|
|
|
|
133
|
- body: Column(children: [
|
|
|
|
134
|
- Expanded(
|
|
|
|
135
|
- child: SingleChildScrollView(
|
|
|
|
136
|
- controller: controller,
|
|
|
|
137
|
- physics: BouncingScrollPhysics(),
|
|
|
|
138
|
- child: Padding(
|
|
|
|
139
|
- padding: EdgeInsets.symmetric(
|
|
|
|
140
|
- horizontal: ScreenUtil().setWidth(32)),
|
|
|
|
141
|
- child: Column(
|
|
|
|
142
|
- children: [
|
|
|
|
143
|
- VEmptyView(56),
|
|
|
|
144
|
- _item(
|
|
|
|
145
|
- '券类型',
|
|
|
|
146
|
- widget.couponSunModel.isType == '1'
|
|
|
|
147
|
- ? widget.couponSunModel.isExamine == '1'
|
|
|
|
148
|
- ? '店铺优惠券(核销券)'
|
|
|
|
149
|
- : '店铺优惠券'
|
|
|
|
150
|
- : '我的优惠券'),
|
|
|
|
151
|
- Container(
|
|
|
|
152
|
- height: ScreenUtil().setWidth(2),
|
|
|
|
153
|
- color: MyColours.color_E7E7E7,
|
|
|
|
154
|
- ),
|
|
|
|
155
|
- VEmptyView(24),
|
|
|
|
156
|
- _item('券名称', widget.couponSunModel.aname),
|
|
|
|
157
|
- Container(
|
|
|
|
158
|
- height: ScreenUtil().setWidth(2),
|
|
|
|
159
|
- color: MyColours.color_E7E7E7,
|
|
|
|
160
|
- ),
|
|
|
|
161
|
- VEmptyView(24),
|
|
|
|
162
|
- _item('券要求', widget.couponSunModel.desc),
|
|
|
|
163
|
- Container(
|
|
|
|
164
|
- height: ScreenUtil().setWidth(2),
|
|
|
|
165
|
- color: MyColours.color_E7E7E7,
|
|
|
|
166
|
- ),
|
|
|
|
167
|
- VEmptyView(24),
|
|
|
|
168
|
- _item(
|
|
|
|
169
|
- '有效期从',
|
|
|
|
170
|
- Utils.getDateStrFromJiekou(
|
|
|
|
171
|
- widget.couponSunModel.stime)),
|
|
|
|
172
|
- Container(
|
|
|
|
173
|
- height: ScreenUtil().setWidth(2),
|
|
|
|
174
|
- color: MyColours.color_E7E7E7,
|
|
|
|
175
|
- ),
|
|
|
|
176
|
- VEmptyView(24),
|
|
|
|
177
|
- _item(
|
|
|
|
178
|
- '有效期至',
|
|
|
|
179
|
- Utils.getDateStrFromJiekou(
|
|
|
|
180
|
- widget.couponSunModel.etime)),
|
|
|
|
181
|
- widget.couponSunModel.isType == '1'
|
|
|
|
182
|
- ? Column(
|
|
|
|
183
|
- crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
184
|
- children: [
|
|
|
|
185
|
- Container(
|
|
|
|
186
|
- height: ScreenUtil().setWidth(2),
|
|
|
|
187
|
- color: MyColours.color_E7E7E7,
|
|
|
|
188
|
- ),
|
|
|
|
189
|
- VEmptyView(24),
|
|
|
|
190
|
- _item('创建人', widget.couponSunModel.uid),
|
|
|
|
191
|
- ],
|
|
|
|
192
|
- )
|
|
|
|
193
|
- : SizedBox(),
|
|
|
|
194
|
- widget.couponSunModel.isType == '1'
|
|
|
|
195
|
- ? Column(
|
|
|
|
196
|
- crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
197
|
- children: [
|
|
|
|
198
|
- Container(
|
|
|
|
199
|
- height: ScreenUtil().setWidth(2),
|
|
|
|
200
|
- color: MyColours.color_E7E7E7,
|
|
|
|
201
|
- ),
|
|
|
|
202
|
- VEmptyView(24),
|
|
|
|
203
|
- _select(
|
|
|
|
204
|
- '谁可以发放',
|
|
|
|
205
|
- '查看',
|
|
|
|
206
|
- () async {
|
|
|
|
207
|
- await NavigatorUtil.goCouponToPersonnalPage(
|
|
|
|
208
|
- context, widget.couponSunModel.uidList,
|
|
|
|
209
|
- onlyShow: true);
|
|
|
|
210
|
- },
|
|
|
|
211
|
- )
|
|
|
|
212
|
- ],
|
|
|
|
213
|
- )
|
|
|
|
214
|
- : SizedBox(),
|
|
|
|
215
|
- widget.couponSunModel.explain != null &&
|
|
|
|
216
|
- widget.couponSunModel.explain != ''
|
|
|
|
217
|
- ? Container(
|
150
|
+ backgroundColor: MyColours.color_ffffff,
|
|
|
|
151
|
+ appBar: SystemAppBar(
|
|
|
|
152
|
+ '优惠券详情',
|
|
|
|
153
|
+ onTap: () {
|
|
|
|
154
|
+ Navigator.pop(context);
|
|
|
|
155
|
+ },
|
|
|
|
156
|
+ ),
|
|
|
|
157
|
+ body: Consumer<CouponProvider>(builder: (context, model, _) {
|
|
|
|
158
|
+ if (pageState != PageState.Success) {
|
|
|
|
159
|
+ return ExceptionPage(
|
|
|
|
160
|
+ pageState: pageState,
|
|
|
|
161
|
+ callback: () {
|
|
|
|
162
|
+ _getActivityById();
|
|
|
|
163
|
+ },
|
|
|
|
164
|
+ emptyMsg: "暂时没有数据哦,",
|
|
|
|
165
|
+ emptyImg: "empty_search",
|
|
|
|
166
|
+ showMsg: "加载中,请稍后...",
|
|
|
|
167
|
+ );
|
|
|
|
168
|
+ } else {
|
|
|
|
169
|
+ return Column(children: [
|
|
|
|
170
|
+ Expanded(
|
|
|
|
171
|
+ child: SingleChildScrollView(
|
|
|
|
172
|
+ controller: controller,
|
|
|
|
173
|
+ physics: BouncingScrollPhysics(),
|
|
|
|
174
|
+ child: Padding(
|
|
|
|
175
|
+ padding: EdgeInsets.symmetric(
|
|
|
|
176
|
+ horizontal: ScreenUtil().setWidth(32)),
|
|
|
|
177
|
+ child: Column(
|
|
|
|
178
|
+ children: [
|
|
|
|
179
|
+ VEmptyView(56),
|
|
|
|
180
|
+ _item(
|
|
|
|
181
|
+ '券类型',
|
|
|
|
182
|
+ couponProvider.couponSunModel.isType == '1'
|
|
|
|
183
|
+ ? couponProvider.couponSunModel.isExamine ==
|
|
|
|
184
|
+ '1'
|
|
|
|
185
|
+ ? '店铺优惠券(核销券)'
|
|
|
|
186
|
+ : '店铺优惠券'
|
|
|
|
187
|
+ : '我的优惠券'),
|
|
|
|
188
|
+ Container(
|
|
218
|
height: ScreenUtil().setWidth(2),
|
189
|
height: ScreenUtil().setWidth(2),
|
|
219
|
color: MyColours.color_E7E7E7,
|
190
|
color: MyColours.color_E7E7E7,
|
|
220
|
- )
|
|
|
|
221
|
- : SizedBox(),
|
|
|
|
222
|
- widget.couponSunModel.explain != null &&
|
|
|
|
223
|
- widget.couponSunModel.explain != ''
|
|
|
|
224
|
- ? VEmptyView(24)
|
|
|
|
225
|
- : SizedBox(),
|
|
|
|
226
|
- widget.couponSunModel.explain != null &&
|
|
|
|
227
|
- widget.couponSunModel.explain != ''
|
|
|
|
228
|
- ? _item('券说明', widget.couponSunModel.explain)
|
|
|
|
229
|
- : SizedBox(),
|
|
|
|
230
|
- Container(
|
|
|
|
231
|
- height: ScreenUtil().setWidth(2),
|
|
|
|
232
|
- color: MyColours.color_E7E7E7,
|
|
|
|
233
|
- ),
|
|
|
|
234
|
- VEmptyView(24),
|
|
|
|
235
|
- _item('券状态',
|
|
|
|
236
|
- widget.couponSunModel.status == '1' ? '发放中' : '停用')
|
|
|
|
237
|
- ],
|
|
|
|
238
|
- ))),
|
|
|
|
239
|
- )
|
|
|
|
240
|
- ]),
|
|
|
|
241
|
- );
|
191
|
+ ),
|
|
|
|
192
|
+ VEmptyView(24),
|
|
|
|
193
|
+ _item('券名称', couponProvider.couponSunModel.aname),
|
|
|
|
194
|
+ Container(
|
|
|
|
195
|
+ height: ScreenUtil().setWidth(2),
|
|
|
|
196
|
+ color: MyColours.color_E7E7E7,
|
|
|
|
197
|
+ ),
|
|
|
|
198
|
+ VEmptyView(24),
|
|
|
|
199
|
+ _item('券要求', couponProvider.couponSunModel.desc),
|
|
|
|
200
|
+ Container(
|
|
|
|
201
|
+ height: ScreenUtil().setWidth(2),
|
|
|
|
202
|
+ color: MyColours.color_E7E7E7,
|
|
|
|
203
|
+ ),
|
|
|
|
204
|
+ VEmptyView(24),
|
|
|
|
205
|
+ _item(
|
|
|
|
206
|
+ '有效期从',
|
|
|
|
207
|
+ Utils.getDateStrFromJiekou(
|
|
|
|
208
|
+ couponProvider.couponSunModel.stime)),
|
|
|
|
209
|
+ Container(
|
|
|
|
210
|
+ height: ScreenUtil().setWidth(2),
|
|
|
|
211
|
+ color: MyColours.color_E7E7E7,
|
|
|
|
212
|
+ ),
|
|
|
|
213
|
+ VEmptyView(24),
|
|
|
|
214
|
+ _item(
|
|
|
|
215
|
+ '有效期至',
|
|
|
|
216
|
+ Utils.getDateStrFromJiekou(
|
|
|
|
217
|
+ couponProvider.couponSunModel.etime)),
|
|
|
|
218
|
+ couponProvider.couponSunModel.isType == '1'
|
|
|
|
219
|
+ ? Column(
|
|
|
|
220
|
+ crossAxisAlignment:
|
|
|
|
221
|
+ CrossAxisAlignment.start,
|
|
|
|
222
|
+ children: [
|
|
|
|
223
|
+ Container(
|
|
|
|
224
|
+ height: ScreenUtil().setWidth(2),
|
|
|
|
225
|
+ color: MyColours.color_E7E7E7,
|
|
|
|
226
|
+ ),
|
|
|
|
227
|
+ VEmptyView(24),
|
|
|
|
228
|
+ _item('创建人',
|
|
|
|
229
|
+ couponProvider.couponSunModel.uid),
|
|
|
|
230
|
+ ],
|
|
|
|
231
|
+ )
|
|
|
|
232
|
+ : SizedBox(),
|
|
|
|
233
|
+ couponProvider.couponSunModel.isType == '1'
|
|
|
|
234
|
+ ? Column(
|
|
|
|
235
|
+ crossAxisAlignment:
|
|
|
|
236
|
+ CrossAxisAlignment.start,
|
|
|
|
237
|
+ children: [
|
|
|
|
238
|
+ Container(
|
|
|
|
239
|
+ height: ScreenUtil().setWidth(2),
|
|
|
|
240
|
+ color: MyColours.color_E7E7E7,
|
|
|
|
241
|
+ ),
|
|
|
|
242
|
+ VEmptyView(24),
|
|
|
|
243
|
+ _select(
|
|
|
|
244
|
+ '谁可以发放',
|
|
|
|
245
|
+ '查看',
|
|
|
|
246
|
+ () async {
|
|
|
|
247
|
+ await NavigatorUtil
|
|
|
|
248
|
+ .goCouponToPersonnalPage(
|
|
|
|
249
|
+ context,
|
|
|
|
250
|
+ couponProvider
|
|
|
|
251
|
+ .couponSunModel.uidList,
|
|
|
|
252
|
+ onlyShow: true);
|
|
|
|
253
|
+ },
|
|
|
|
254
|
+ )
|
|
|
|
255
|
+ ],
|
|
|
|
256
|
+ )
|
|
|
|
257
|
+ : SizedBox(),
|
|
|
|
258
|
+ couponProvider.couponSunModel.explain != null &&
|
|
|
|
259
|
+ couponProvider.couponSunModel.explain != ''
|
|
|
|
260
|
+ ? Container(
|
|
|
|
261
|
+ height: ScreenUtil().setWidth(2),
|
|
|
|
262
|
+ color: MyColours.color_E7E7E7,
|
|
|
|
263
|
+ )
|
|
|
|
264
|
+ : SizedBox(),
|
|
|
|
265
|
+ couponProvider.couponSunModel.explain != null &&
|
|
|
|
266
|
+ couponProvider.couponSunModel.explain != ''
|
|
|
|
267
|
+ ? VEmptyView(24)
|
|
|
|
268
|
+ : SizedBox(),
|
|
|
|
269
|
+ couponProvider.couponSunModel.explain != null &&
|
|
|
|
270
|
+ couponProvider.couponSunModel.explain != ''
|
|
|
|
271
|
+ ? _item('券说明',
|
|
|
|
272
|
+ couponProvider.couponSunModel.explain)
|
|
|
|
273
|
+ : SizedBox(),
|
|
|
|
274
|
+ Container(
|
|
|
|
275
|
+ height: ScreenUtil().setWidth(2),
|
|
|
|
276
|
+ color: MyColours.color_E7E7E7,
|
|
|
|
277
|
+ ),
|
|
|
|
278
|
+ VEmptyView(24),
|
|
|
|
279
|
+ _item(
|
|
|
|
280
|
+ '券状态',
|
|
|
|
281
|
+ couponProvider.couponSunModel.status == '1'
|
|
|
|
282
|
+ ? '发放中'
|
|
|
|
283
|
+ : '停用')
|
|
|
|
284
|
+ ],
|
|
|
|
285
|
+ ))),
|
|
|
|
286
|
+ )
|
|
|
|
287
|
+ ]);
|
|
|
|
288
|
+ }
|
|
|
|
289
|
+ }));
|
|
242
|
}
|
290
|
}
|
|
243
|
} |
291
|
} |