Commit 662bac0486112802b606d0d88895a2468ee08a78

Authored by wdn127929
1 parent 6f0f5277

预订安排页添加优惠按钮

@@ -11,14 +11,14 @@ if (flutterRoot == null) { @@ -11,14 +11,14 @@ if (flutterRoot == null) {
11 throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") 11 throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
12 } 12 }
13 13
14 -def flutterVersionCode = "254" 14 +def flutterVersionCode = "260"
15 if (flutterVersionCode == null) { 15 if (flutterVersionCode == null) {
16 - flutterVersionCode = '254' 16 + flutterVersionCode = '260'
17 } 17 }
18 18
19 -def flutterVersionName = "2.5.4" 19 +def flutterVersionName = "2.6.0"
20 if (flutterVersionName == null) { 20 if (flutterVersionName == null) {
21 - flutterVersionName = '2.5.4' 21 + flutterVersionName = '2.6.0'
22 } 22 }
23 23
24 apply plugin: 'com.android.application' 24 apply plugin: 'com.android.application'
@@ -19,7 +19,8 @@ import 'package:provider/provider.dart'; @@ -19,7 +19,8 @@ import 'package:provider/provider.dart';
19 */ 19 */
20 20
21 class CouponPage extends StatefulWidget { 21 class CouponPage extends StatefulWidget {
22 - CouponPage({Key key}) : super(key: key); 22 + final bool needRefrsh;
  23 + CouponPage({Key key, this.needRefrsh = false}) : super(key: key);
23 24
24 @override 25 @override
25 _CouponPageState createState() => _CouponPageState(); 26 _CouponPageState createState() => _CouponPageState();
@@ -81,110 +82,127 @@ class _CouponPageState extends State<CouponPage> { @@ -81,110 +82,127 @@ class _CouponPageState extends State<CouponPage> {
81 Widget build(BuildContext context) { 82 Widget build(BuildContext context) {
82 couponProvider = Provider.of<CouponProvider>(context, listen: true); 83 couponProvider = Provider.of<CouponProvider>(context, listen: true);
83 return Scaffold( 84 return Scaffold(
84 - backgroundColor: MyColours.color_fefefe, 85 + backgroundColor: MyColours.color_fefefe,
85 appBar: SystemAppBar('线上券', rightImgName: '历史券', onTap: () { 86 appBar: SystemAppBar('线上券', rightImgName: '历史券', onTap: () {
86 - EventBus().emit('changeStatusColor'); 87 + if (widget.needRefrsh) {
  88 + EventBus().emit('refresh_coupon_invitation');
  89 + } else {
  90 + EventBus().emit('changeStatusColor');
  91 + }
  92 +
87 Navigator.of(context).pop(); 93 Navigator.of(context).pop();
88 }, onTapRight: () { 94 }, onTapRight: () {
89 NavigatorUtil.goCouponHistoryPage(context); 95 NavigatorUtil.goCouponHistoryPage(context);
90 }), 96 }),
91 - body: Column(  
92 - children: [  
93 - Expanded(child: Consumer<CouponProvider>(  
94 - builder: (context, model, _) {  
95 - if (model.pageState != PageState.Success) {  
96 - return ExceptionPage(  
97 - pageState: model.pageState,  
98 - callback: () {  
99 - // offset = 0;  
100 - // getMessage(showLoading: true);  
101 - _couponNetworkData();  
102 - },  
103 - emptyMsg: "暂时没有列表信息哦",  
104 - emptyImg: "empty_search",  
105 - showMsg: "加载中,请稍后...",  
106 - );  
107 - } else {  
108 - return EasyRefresh.custom(  
109 - controller: _controller,  
110 - shrinkWrap: true,  
111 - slivers: [  
112 - SliverList(  
113 - delegate: SliverChildBuilderDelegate(  
114 - (BuildContext context, int index) {  
115 - return Container(  
116 - margin: EdgeInsets.all(ScreenUtil().setWidth(40)),  
117 - padding:  
118 - EdgeInsets.all(ScreenUtil().setWidth(30)),  
119 - color: MyColours.color_F0F0F0,  
120 - child: Text(  
121 - '使用说明:需在结账前出示优惠券二维码,店内工作人员微信扫码核销。超过有效期的券,会自动作废并移出列表。优惠券不可找零、兑现。',  
122 - style: TextStyle(  
123 - color: MyColours.color_666666,  
124 - fontSize: ScreenUtil().setSp(24),  
125 - ),  
126 - strutStyle: StrutStyle(  
127 - forceStrutHeight: true,  
128 - height: 1,  
129 - leading: 0.3),  
130 - ));  
131 - }, childCount: 1),  
132 - ),  
133 - SliverList(  
134 - delegate: SliverChildBuilderDelegate(  
135 - (BuildContext context, int index) {  
136 - return CouponItem(  
137 - from: 'quan',  
138 - couponSonModel: couponProvider.couponList[index],  
139 - showBtn: true,  
140 - onPressedSwich: () {  
141 - couponProvider.couponList[index].isOpenBool =  
142 - !couponProvider.couponList[index].isOpenBool;  
143 - _setCustomerActivity(index);  
144 - },  
145 - onPressed: () {  
146 - NavigatorUtil.goCouponDetailPage(  
147 - context, couponProvider.couponList[index]);  
148 - },  
149 - );  
150 - }, childCount: couponProvider.couponList.length),  
151 - )  
152 - ],  
153 - // onRefresh: () async {  
154 - // // offset = 0;  
155 - // // getMessage(showLoading: false);  
156 - // },  
157 - // onLoad: () async {  
158 - // // offset++;  
159 - // // getMessage(showLoading: false);  
160 - // },  
161 - );  
162 - }  
163 - },  
164 - )),  
165 - VEmptyView(20),  
166 - Padding(  
167 - padding: EdgeInsets.fromLTRB(ScreenUtil().setWidth(40), 0,  
168 - ScreenUtil().setWidth(40), ScreenUtil().setWidth(40)),  
169 - child: RoundButton(  
170 - onPressed: () async {  
171 - bool needRefresh =  
172 - await NavigatorUtil.goCouponEditPage(context);  
173 - print(needRefresh);  
174 - if (needRefresh != null && needRefresh) {  
175 - //刷新页面数据  
176 - // _controller.callRefresh();  
177 - _couponNetworkData(); 97 + body: WillPopScope(
  98 + onWillPop: () {
  99 + if (widget.needRefrsh) {
  100 + EventBus().emit('refresh_coupon_invitation');
  101 + } else {
  102 + EventBus().emit('changeStatusColor');
  103 + }
  104 + Navigator.of(context).pop();
  105 + },
  106 + child: Column(
  107 + children: [
  108 + Expanded(child: Consumer<CouponProvider>(
  109 + builder: (context, model, _) {
  110 + if (model.pageState != PageState.Success) {
  111 + return ExceptionPage(
  112 + pageState: model.pageState,
  113 + callback: () {
  114 + // offset = 0;
  115 + // getMessage(showLoading: true);
  116 + _couponNetworkData();
  117 + },
  118 + emptyMsg: "暂时没有列表信息哦",
  119 + emptyImg: "empty_search",
  120 + showMsg: "加载中,请稍后...",
  121 + );
  122 + } else {
  123 + return EasyRefresh.custom(
  124 + controller: _controller,
  125 + shrinkWrap: true,
  126 + slivers: [
  127 + SliverList(
  128 + delegate: SliverChildBuilderDelegate(
  129 + (BuildContext context, int index) {
  130 + return Container(
  131 + margin:
  132 + EdgeInsets.all(ScreenUtil().setWidth(40)),
  133 + padding:
  134 + EdgeInsets.all(ScreenUtil().setWidth(30)),
  135 + color: MyColours.color_F0F0F0,
  136 + child: Text(
  137 + '使用说明:需在结账前出示优惠券二维码,店内工作人员微信扫码核销。超过有效期的券,会自动作废并移出列表。优惠券不可找零、兑现。',
  138 + style: TextStyle(
  139 + color: MyColours.color_666666,
  140 + fontSize: ScreenUtil().setSp(24),
  141 + ),
  142 + strutStyle: StrutStyle(
  143 + forceStrutHeight: true,
  144 + height: 1,
  145 + leading: 0.3),
  146 + ));
  147 + }, childCount: 1),
  148 + ),
  149 + SliverList(
  150 + delegate: SliverChildBuilderDelegate(
  151 + (BuildContext context, int index) {
  152 + return CouponItem(
  153 + from: 'quan',
  154 + couponSonModel:
  155 + couponProvider.couponList[index],
  156 + showBtn: true,
  157 + onPressedSwich: () {
  158 + couponProvider.couponList[index].isOpenBool =
  159 + !couponProvider
  160 + .couponList[index].isOpenBool;
  161 + _setCustomerActivity(index);
  162 + },
  163 + onPressed: () {
  164 + NavigatorUtil.goCouponDetailPage(context,
  165 + couponProvider.couponList[index]);
  166 + },
  167 + );
  168 + }, childCount: couponProvider.couponList.length),
  169 + )
  170 + ],
  171 + // onRefresh: () async {
  172 + // // offset = 0;
  173 + // // getMessage(showLoading: false);
  174 + // },
  175 + // onLoad: () async {
  176 + // // offset++;
  177 + // // getMessage(showLoading: false);
  178 + // },
  179 + );
178 } 180 }
179 }, 181 },
180 - text: '创建新券',  
181 - fontSize: 34,  
182 - isBold: false,  
183 - height: ScreenUtil().setWidth(80),  
184 - width: double.infinity,  
185 - radius: ScreenUtil().setWidth(10),  
186 - ))  
187 - ],  
188 - )); 182 + )),
  183 + VEmptyView(20),
  184 + Padding(
  185 + padding: EdgeInsets.fromLTRB(ScreenUtil().setWidth(40), 0,
  186 + ScreenUtil().setWidth(40), ScreenUtil().setWidth(40)),
  187 + child: RoundButton(
  188 + onPressed: () async {
  189 + bool needRefresh =
  190 + await NavigatorUtil.goCouponEditPage(context);
  191 + print(needRefresh);
  192 + if (needRefresh != null && needRefresh) {
  193 + //刷新页面数据
  194 + // _controller.callRefresh();
  195 + _couponNetworkData();
  196 + }
  197 + },
  198 + text: '创建新券',
  199 + fontSize: 34,
  200 + isBold: false,
  201 + height: ScreenUtil().setWidth(80),
  202 + width: double.infinity,
  203 + radius: ScreenUtil().setWidth(10),
  204 + ))
  205 + ],
  206 + )));
189 } 207 }
190 } 208 }
@@ -14,6 +14,7 @@ import 'package:one_key/provider/base_info_provider.dart'; @@ -14,6 +14,7 @@ import 'package:one_key/provider/base_info_provider.dart';
14 import 'package:one_key/provider/coupon_provider.dart'; 14 import 'package:one_key/provider/coupon_provider.dart';
15 import 'package:one_key/provider/user_model.dart'; 15 import 'package:one_key/provider/user_model.dart';
16 import 'package:one_key/res/colors.dart'; 16 import 'package:one_key/res/colors.dart';
  17 +import 'package:one_key/utils/event_bus.dart';
17 import 'package:one_key/utils/misc.dart'; 18 import 'package:one_key/utils/misc.dart';
18 import 'package:one_key/route/navigator_util.dart'; 19 import 'package:one_key/route/navigator_util.dart';
19 import 'package:one_key/utils/utils.dart'; 20 import 'package:one_key/utils/utils.dart';
@@ -68,6 +69,9 @@ class InvicationPageState extends State<InvicationPage> { @@ -68,6 +69,9 @@ class InvicationPageState extends State<InvicationPage> {
68 _getCustomerActivityBaseinfo(); 69 _getCustomerActivityBaseinfo();
69 _getSellerPhotoById(); 70 _getSellerPhotoById();
70 }); 71 });
  72 + bus.on("refresh_coupon_invitation", (args) {
  73 + _couponNetworkData(isShowLoading: false);
  74 + });
71 Utils.changeStatusColor(color: Colors.transparent); 75 Utils.changeStatusColor(color: Colors.transparent);
72 dateTime = 76 dateTime =
73 DateTime.fromMillisecondsSinceEpoch(int.parse(widget.ddate) * 1000); 77 DateTime.fromMillisecondsSinceEpoch(int.parse(widget.ddate) * 1000);
@@ -77,6 +81,14 @@ class InvicationPageState extends State<InvicationPage> { @@ -77,6 +81,14 @@ class InvicationPageState extends State<InvicationPage> {
77 "${dateTime.year}/${Utils.addZeroNumber(dateTime.month)}/${Utils.addZeroNumber(dateTime.day)} 星期${Utils.formatWeekDayNum(dateTime.weekday)} ${widget.ddateStr}"; 81 "${dateTime.year}/${Utils.addZeroNumber(dateTime.month)}/${Utils.addZeroNumber(dateTime.day)} 星期${Utils.formatWeekDayNum(dateTime.weekday)} ${widget.ddateStr}";
78 } 82 }
79 83
  84 + @override
  85 + void dispose() {
  86 + Utils.changeStatusColor();
  87 + couponProvider.clearSelect();
  88 + bus.off("refresh_coupon_invitation");
  89 + super.dispose();
  90 + }
  91 +
80 _getSellerPhotoById() async { 92 _getSellerPhotoById() async {
81 Map<String, String> params = { 93 Map<String, String> params = {
82 'sellerid': Provider.of<UserModel>(context, listen: false).user.sellerid, 94 'sellerid': Provider.of<UserModel>(context, listen: false).user.sellerid,
@@ -182,13 +194,6 @@ class InvicationPageState extends State<InvicationPage> { @@ -182,13 +194,6 @@ class InvicationPageState extends State<InvicationPage> {
182 } 194 }
183 } 195 }
184 196
185 - @override  
186 - void dispose() {  
187 - Utils.changeStatusColor();  
188 - couponProvider.clearSelect();  
189 - super.dispose();  
190 - }  
191 -  
192 //中间内容显示组件 197 //中间内容显示组件
193 Widget _middleWidget(String title, String content) { 198 Widget _middleWidget(String title, String content) {
194 return Column( 199 return Column(
@@ -374,18 +379,67 @@ class InvicationPageState extends State<InvicationPage> { @@ -374,18 +379,67 @@ class InvicationPageState extends State<InvicationPage> {
374 CrossAxisAlignment.start, 379 CrossAxisAlignment.start,
375 children: [ 380 children: [
376 Padding( 381 Padding(
377 - padding: EdgeInsets.only(  
378 - left: ScreenUtil()  
379 - .setWidth(70)),  
380 - child: Image.network(  
381 - qiniuUrl == ''  
382 - ? 'http://nosqn.colorcun.com/yd_person.png'  
383 - : qiniuUrl,  
384 - width: ScreenUtil()  
385 - .setWidth(143 * 2),  
386 - height: ScreenUtil()  
387 - .setWidth(190 * 2)),  
388 - ), 382 + padding: EdgeInsets.only(
  383 + left: ScreenUtil()
  384 + .setWidth(70)),
  385 + child: Stack(
  386 + alignment:
  387 + Alignment.bottomCenter,
  388 + children: [
  389 + Image.network(
  390 + qiniuUrl == ''
  391 + ? 'http://nosqn.colorcun.com/yd_person.png'
  392 + : qiniuUrl,
  393 + // 'http://nosqn.colorcun.com/yd_person.png',
  394 + width: ScreenUtil()
  395 + .setWidth(143 * 2),
  396 + height: ScreenUtil()
  397 + .setWidth(190 * 2)),
  398 + couponProvider.coupons
  399 + .length ==
  400 + 0
  401 + ? Align(
  402 + alignment: Alignment
  403 + .bottomCenter,
  404 + child: RoundButton(
  405 + width: ScreenUtil()
  406 + .setWidth(
  407 + 86 * 2),
  408 + height:
  409 + ScreenUtil()
  410 + .setWidth(
  411 + 30 *
  412 + 2),
  413 + radius:
  414 + ScreenUtil()
  415 + .setWidth(
  416 + 30),
  417 + space:
  418 + ScreenUtil()
  419 + .setWidth(
  420 + 20),
  421 + text: '添加优惠',
  422 + textColor: MyColours
  423 + .color_ffffff,
  424 + isBold: false,
  425 + fontSize: 28,
  426 + gradientStart:
  427 + MyColours
  428 + .color_199095,
  429 + gradientEnd: MyColours
  430 + .color_199095,
  431 + onPressed: () {
  432 + NavigatorUtil
  433 + .goCouponPage(
  434 + context,
  435 + needRefrsh:
  436 + true);
  437 + },
  438 + ),
  439 + )
  440 + : Container()
  441 + ],
  442 + )),
389 HEmptyView(10), 443 HEmptyView(10),
390 Spacer(), 444 Spacer(),
391 Container( 445 Container(
@@ -907,7 +961,8 @@ class InvicationPageState extends State<InvicationPage> { @@ -907,7 +961,8 @@ class InvicationPageState extends State<InvicationPage> {
907 right: 0, 961 right: 0,
908 child: Container( 962 child: Container(
909 // padding: EdgeInsets.symmetric(horizontal: ScreenUtil().setWidth(16),vertical: ScreenUtil().setWidth(4)), 963 // padding: EdgeInsets.symmetric(horizontal: ScreenUtil().setWidth(16),vertical: ScreenUtil().setWidth(4)),
910 - padding: EdgeInsets.only(bottom: ScreenUtil().setWidth(6)), 964 + padding: EdgeInsets.only(
  965 + bottom: ScreenUtil().setWidth(6)),
911 alignment: Alignment.center, 966 alignment: Alignment.center,
912 width: ScreenUtil().setWidth(62 * 2), 967 width: ScreenUtil().setWidth(62 * 2),
913 height: ScreenUtil().setWidth(42), 968 height: ScreenUtil().setWidth(42),
@@ -165,30 +165,38 @@ class CouponProvider with ChangeNotifier { @@ -165,30 +165,38 @@ class CouponProvider with ChangeNotifier {
165 .catchError((error) { 165 .catchError((error) {
166 print(error.toString()); 166 print(error.toString());
167 if (error is MyError) { 167 if (error is MyError) {
168 - switch (error.type) {  
169 - case 1:  
170 - pageState = PageState.ConnectivityError;  
171 - break;  
172 - case 2:  
173 - pageState = PageState.ConnectivityTimeOut;  
174 - break;  
175 - default:  
176 - pageState = PageState.ConnectivityError;  
177 - break; 168 + if (isShowLoading) {
  169 + switch (error.type) {
  170 + case 1:
  171 + pageState = PageState.ConnectivityError;
  172 + break;
  173 + case 2:
  174 + pageState = PageState.ConnectivityTimeOut;
  175 + break;
  176 + default:
  177 + pageState = PageState.ConnectivityError;
  178 + break;
  179 + }
178 } 180 }
179 } 181 }
180 notifyListeners(); 182 notifyListeners();
181 }); 183 });
182 if (baseResp.code == Constant.status_success) { 184 if (baseResp.code == Constant.status_success) {
183 if (baseResp.data.isEmpty) { 185 if (baseResp.data.isEmpty) {
184 - pageState = PageState.Empty; 186 + if (isShowLoading) {
  187 + pageState = PageState.Empty;
  188 + }
185 } else { 189 } else {
186 - pageState = PageState.Success; 190 + if (isShowLoading) {
  191 + pageState = PageState.Success;
  192 + }
187 } 193 }
188 couponList = CouponModel.fromJson(baseResp.responseData).data; 194 couponList = CouponModel.fromJson(baseResp.responseData).data;
189 notifyListeners(); 195 notifyListeners();
190 } else { 196 } else {
191 - pageState = PageState.ConnectivityError; 197 + if (isShowLoading) {
  198 + pageState = PageState.ConnectivityError;
  199 + }
192 if (baseResp != null) { 200 if (baseResp != null) {
193 Utils.showToast(baseResp.msg ?? ""); 201 Utils.showToast(baseResp.msg ?? "");
194 } 202 }
@@ -164,8 +164,10 @@ class NavigatorUtil { @@ -164,8 +164,10 @@ class NavigatorUtil {
164 } 164 }
165 165
166 /// 优惠券列表 166 /// 优惠券列表
167 - static void goCouponPage(BuildContext context, {replace = false}) {  
168 - _navigateTo(context, "${Routes.coupon}", replace: replace); 167 + static void goCouponPage(BuildContext context,
  168 + {replace = false, needRefrsh = false}) {
  169 + _navigateTo(context, "${Routes.coupon}?needRefrsh=${needRefrsh}",
  170 + replace: replace);
169 } 171 }
170 172
171 /// 优惠券历史列表 173 /// 优惠券历史列表
@@ -250,8 +250,10 @@ var handleInvoiceDetailPageHandler = new Handler( @@ -250,8 +250,10 @@ var handleInvoiceDetailPageHandler = new Handler(
250 var handleCouponPageHandler = new Handler( 250 var handleCouponPageHandler = new Handler(
251 handlerFunc: (BuildContext context, Map<String, List<Object>> params) { 251 handlerFunc: (BuildContext context, Map<String, List<Object>> params) {
252 // String rid = params["rid"].first; 252 // String rid = params["rid"].first;
253 - // bool fromNotify = FluroConvertUtils.string2bool(params["fromNotify"].first);  
254 - return CouponPage(); 253 + bool needRefrsh = FluroConvertUtils.string2bool(params["needRefrsh"].first);
  254 + return CouponPage(
  255 + needRefrsh: needRefrsh,
  256 + );
255 }); 257 });
256 258
257 ///优惠券历史列表 259 ///优惠券历史列表