Commit 558b3e323a4c7383059145e27c0faad24b5014a0

Authored by wdn127929
1 parent 02a21966

配置录入电话姓名开关

@@ -54,6 +54,7 @@ class GetDzSellerConfSunModel { @@ -54,6 +54,7 @@ class GetDzSellerConfSunModel {
54 String saiyouyun; 54 String saiyouyun;
55 Bookinginfo bookinginfo; 55 Bookinginfo bookinginfo;
56 String isAllowUpdate; 56 String isAllowUpdate;
  57 + List<String> isShowRnamePhone;
57 58
58 GetDzSellerConfSunModel( 59 GetDzSellerConfSunModel(
59 {this.id, 60 {this.id,
@@ -79,7 +80,8 @@ class GetDzSellerConfSunModel { @@ -79,7 +80,8 @@ class GetDzSellerConfSunModel {
79 this.isMarketing, 80 this.isMarketing,
80 this.saiyouyun, 81 this.saiyouyun,
81 this.bookinginfo, 82 this.bookinginfo,
82 - this.isAllowUpdate}); 83 + this.isAllowUpdate,
  84 + this.isShowRnamePhone});
83 85
84 GetDzSellerConfSunModel.fromJson(Map<String, dynamic> json) { 86 GetDzSellerConfSunModel.fromJson(Map<String, dynamic> json) {
85 id = json['id']; 87 id = json['id'];
@@ -110,6 +112,15 @@ class GetDzSellerConfSunModel { @@ -110,6 +112,15 @@ class GetDzSellerConfSunModel {
110 ? new Bookinginfo.fromJson(json['bookinginfo']) 112 ? new Bookinginfo.fromJson(json['bookinginfo'])
111 : null; 113 : null;
112 isAllowUpdate = json['is_allow_update'] ?? '1'; 114 isAllowUpdate = json['is_allow_update'] ?? '1';
  115 +
  116 + isShowRnamePhone = [];
  117 +
  118 + if (json['is_show_ranme_phone'] != null &&
  119 + json['is_show_ranme_phone'] != '') {
  120 + convert.json.decode(json['is_show_ranme_phone']).forEach((v) {
  121 + isShowRnamePhone.add(v);
  122 + });
  123 + }
113 } 124 }
114 125
115 Map<String, dynamic> toJson() { 126 Map<String, dynamic> toJson() {
@@ -140,7 +151,29 @@ class GetDzSellerConfSunModel { @@ -140,7 +151,29 @@ class GetDzSellerConfSunModel {
140 data['bookinginfo'] = this.bookinginfo.toJson(); 151 data['bookinginfo'] = this.bookinginfo.toJson();
141 } 152 }
142 data['is_allow_update'] = this.isAllowUpdate; 153 data['is_allow_update'] = this.isAllowUpdate;
  154 + data['is_show_ranme_phone'] = this.isShowRnamePhone;
  155 + return data;
  156 + }
  157 +}
143 158
  159 +class InputSetting {
  160 + String uid;
  161 + String isShowName;
  162 + String isShowPhone;
  163 +
  164 + InputSetting({this.uid, this.isShowName, this.isShowPhone});
  165 +
  166 + InputSetting.fromJson(Map<String, dynamic> json) {
  167 + uid = json['uid'];
  168 + isShowName = json['is_show_name'];
  169 + isShowPhone = json['is_show_phone'];
  170 + }
  171 +
  172 + Map<String, dynamic> toJson() {
  173 + final Map<String, dynamic> data = new Map<String, dynamic>();
  174 + data['uid'] = this.uid;
  175 + data['is_show_name'] = this.isShowName;
  176 + data['is_show_phone'] = this.isShowPhone;
144 return data; 177 return data;
145 } 178 }
146 } 179 }
@@ -308,6 +308,11 @@ class InvicationPageState extends State<InvicationPage> @@ -308,6 +308,11 @@ class InvicationPageState extends State<InvicationPage>
308 bus.on("refresh_photo_invication", (args) { 308 bus.on("refresh_photo_invication", (args) {
309 _getTablesPhoto(); 309 _getTablesPhoto();
310 }); 310 });
  311 + bus.on("getDzSellerConf", (args) {
  312 + getDzSellerConf();
  313 + });
  314 +
  315 +
311 316
312 // Utils.changeStatusColor(color: Colors.transparent); 317 // Utils.changeStatusColor(color: Colors.transparent);
313 318
@@ -424,6 +429,9 @@ class InvicationPageState extends State<InvicationPage> @@ -424,6 +429,9 @@ class InvicationPageState extends State<InvicationPage>
424 bus.off("refresh_coupon_invitation"); 429 bus.off("refresh_coupon_invitation");
425 bus.off("refresh_invitaion_info"); 430 bus.off("refresh_invitaion_info");
426 bus.off("refresh_photo_invication"); 431 bus.off("refresh_photo_invication");
  432 + bus.off("getDzSellerConf");
  433 +
  434 +
427 WidgetsBinding.instance.removeObserver(this); //销毁观察者 435 WidgetsBinding.instance.removeObserver(this); //销毁观察者
428 if (_timer != null) { 436 if (_timer != null) {
429 _timer.cancel(); 437 _timer.cancel();
@@ -5215,11 +5223,18 @@ class InvicationPageState extends State<InvicationPage> @@ -5215,11 +5223,18 @@ class InvicationPageState extends State<InvicationPage>
5215 myModel = Provider.of<MyModel>(context, listen: true); 5223 myModel = Provider.of<MyModel>(context, listen: true);
5216 return SafeArea( 5224 return SafeArea(
5217 child: Scaffold( 5225 child: Scaffold(
5218 - appBar: SystemAppBar('预订安排', titleColor: MyColours.color_438E93,  
5219 - onTap: () {  
5220 - needBack = true;  
5221 - _showConfirmWidget(needBack: true);  
5222 - }), 5226 + appBar: SystemAppBar(
  5227 + '预订安排',
  5228 + titleColor: MyColours.color_438E93,
  5229 + onTap: () {
  5230 + needBack = true;
  5231 + _showConfirmWidget(needBack: true);
  5232 + },
  5233 + rightImgName: 'set_g.png',
  5234 + onTapRight: () {
  5235 + NavigatorUtil.goInputNamePhoneSettingPage(context);
  5236 + },
  5237 + ),
5223 backgroundColor: Colors.white, 5238 backgroundColor: Colors.white,
5224 // resizeToAvoidBottomInset: false, 5239 // resizeToAvoidBottomInset: false,
5225 body: InkWell( 5240 body: InkWell(
1 import 'package:flutter/material.dart'; 1 import 'package:flutter/material.dart';
  2 +import 'package:flutter_screenutil/flutter_screenutil.dart';
  3 +import 'package:one_key/models/GetDzSellerConfModel.dart';
2 import 'package:one_key/widgets/system_app_bar.dart'; 4 import 'package:one_key/widgets/system_app_bar.dart';
  5 +import 'package:provider/provider.dart';
3 6
  7 +import '../../provider/marketing_center_provider.dart';
  8 +import '../../provider/user_model.dart';
  9 +import '../../res/colors.dart';
  10 +import '../../utils/event_bus.dart';
  11 +import '../../utils/screen_util.dart';
  12 +import '../../utils/utils.dart';
  13 +import '../../widgets/MyDivider.dart';
  14 +import '../../widgets/round_button.dart';
  15 +import 'dart:convert';
  16 +
  17 +/**
  18 + * 姓名和电话输入的时候是否需要自动匹配
  19 + */
4 class InputNamePhoneSettingPage extends StatefulWidget { 20 class InputNamePhoneSettingPage extends StatefulWidget {
5 InputNamePhoneSettingPage({Key key}) : super(key: key); 21 InputNamePhoneSettingPage({Key key}) : super(key: key);
6 22
@@ -10,12 +26,164 @@ class InputNamePhoneSettingPage extends StatefulWidget { @@ -10,12 +26,164 @@ class InputNamePhoneSettingPage extends StatefulWidget {
10 } 26 }
11 27
12 class _InputNamePhoneSettingPageState extends State<InputNamePhoneSettingPage> { 28 class _InputNamePhoneSettingPageState extends State<InputNamePhoneSettingPage> {
  29 + bool nameSwich = true;
  30 + bool phoneSwich = true;
  31 +
  32 + MarketingCenterProvider marketingCenterProvider;
  33 +
  34 + @override
  35 + void initState() {
  36 + // TODO: implement initState
  37 + super.initState();
  38 +
  39 + WidgetsBinding.instance.addPostFrameCallback((_) async {
  40 + getDzSellerConf();
  41 + });
  42 + }
  43 +
  44 + getDzSellerConf() async {
  45 + bool success = await marketingCenterProvider.getDzSellerConf(context);
  46 + if (success && marketingCenterProvider.dzSellerConfModel != null) {
  47 + if (marketingCenterProvider.dzSellerConfModel.isShowRnamePhone.length >
  48 + 0) {
  49 + String uid = Provider.of<UserModel>(context, listen: false).user.openid;
  50 + marketingCenterProvider.dzSellerConfModel.isShowRnamePhone
  51 + .forEach((element) {
  52 + List subdata = element.split('-');
  53 + if (subdata[0] == uid) {
  54 + //设置过
  55 + phoneSwich = subdata[1] == '1' ? true : false;
  56 + nameSwich = subdata[2] == '1' ? true : false;
  57 + setState(() {});
  58 + }
  59 + });
  60 + }
  61 + }
  62 + }
  63 +
  64 + Widget _itemSmsWidget(bool isSelect, String title,
  65 + {GestureTapCallback onTap}) {
  66 + return Column(
  67 + children: [
  68 + InkWell(
  69 + onTap: onTap,
  70 + child: Padding(
  71 + padding: EdgeInsets.only(
  72 + left: w(16), top: w(14), bottom: w(3), right: w(12)),
  73 + child: Row(
  74 + mainAxisAlignment: MainAxisAlignment.spaceBetween,
  75 + children: [
  76 + Text(
  77 + title,
  78 + style: TextStyle(
  79 + color: MyColours.color_515151, fontSize: font(14)),
  80 + ),
  81 + Spacer(),
  82 + Container(
  83 + margin: EdgeInsets.symmetric(
  84 + horizontal: w(7), vertical: w(4)),
  85 + child: Image.asset(
  86 + Utils.getImgPath(isSelect ? 'swich_on' : 'swich_off'),
  87 + width: w(44),
  88 + ),
  89 + )
  90 + // RoundButton(
  91 + // text: '预览',
  92 + // gradientStart: MyColours.color_ffffff,
  93 + // gradientEnd: MyColours.color_ffffff,
  94 + // borderColor: MyColours.color_438E93,
  95 + // textColor: MyColours.color_438E93,
  96 + // radius: ScreenUtil().setWidth(22),
  97 + // fontSize: 24,
  98 + // width: w(72),
  99 + // height: ScreenUtil().setWidth(44),
  100 + // isBold: true,
  101 + // onPressed: () {
  102 + // NavigatorUtil.goMarkingPreviewPage(context);
  103 + // },
  104 + // ),
  105 + ]))),
  106 + Padding(
  107 + padding: EdgeInsets.only(left: w(16)),
  108 + child: MyDivider(double.infinity, w(0.5),
  109 + color: MyColours.color_E7E7E7)),
  110 + ],
  111 + );
  112 + }
  113 +
  114 + _setConfing() async {
  115 + List<String> setting =
  116 + marketingCenterProvider.dzSellerConfModel.isShowRnamePhone;
  117 + String uid = Provider.of<UserModel>(context, listen: false).user.openid;
  118 +
  119 + marketingCenterProvider.dzSellerConfModel.isShowRnamePhone
  120 + .forEach((element) {
  121 + List subdata = element.split('-');
  122 + if (subdata[0] == uid) {
  123 + //设置过
  124 + setting.remove(element); //如果有,则移除,重新设置
  125 + }
  126 + });
  127 + String inputSetting =
  128 + '${uid}-${phoneSwich ? '1' : '0'}-${nameSwich ? '1' : '0'}';
  129 +
  130 + setting.add(inputSetting);
  131 +
  132 + bool success = await marketingCenterProvider.setConfing(
  133 + context,
  134 + {
  135 + 'sid': Provider.of<UserModel>(context, listen: false).user.sellerid,
  136 + 'key': 'is_show_ranme_phone',
  137 + 'value': json.encode(setting)
  138 + },
  139 + needToast: false);
  140 + if (success) {
  141 + //刷新预订安排页面的配置
  142 + bus.emit('getDzSellerConf');
  143 + Navigator.pop(context);
  144 + }
  145 + }
  146 +
13 @override 147 @override
14 Widget build(BuildContext context) { 148 Widget build(BuildContext context) {
  149 + marketingCenterProvider =
  150 + Provider.of<MarketingCenterProvider>(context, listen: true);
15 return Scaffold( 151 return Scaffold(
  152 + backgroundColor: MyColours.color_ffffff,
16 appBar: SystemAppBar('信息录入辅助设置'), 153 appBar: SystemAppBar('信息录入辅助设置'),
17 - body: SingleChildScrollView(  
18 - 154 + body: Column(
  155 + children: [
  156 + Expanded(
  157 + child: SingleChildScrollView(
  158 + child: Column(
  159 + children: [
  160 + _itemSmsWidget(phoneSwich, '录入电话号码时,自动填充已有客户信息', onTap: () {
  161 + setState(() {
  162 + phoneSwich = !phoneSwich;
  163 + });
  164 + }),
  165 + _itemSmsWidget(nameSwich, '录入客户姓名时,自动填充已有电话信息', onTap: () {
  166 + setState(() {
  167 + nameSwich = !nameSwich;
  168 + });
  169 + }),
  170 + ],
  171 + ),
  172 + )),
  173 + Container(
  174 + padding: EdgeInsets.only(
  175 + left: w(45), top: w(12), bottom: w(25), right: w(45)),
  176 + child: RoundButton(
  177 + text: '保存',
  178 + // width: ScreenUtil().setWidth(280 * 2),
  179 + height: ScreenUtil().setWidth(41 * 2),
  180 + radius: ScreenUtil().setWidth(10),
  181 + isBold: true,
  182 + fontSize: 32,
  183 + onPressed: () {
  184 + _setConfing();
  185 + }))
  186 + ],
19 ), 187 ),
20 ); 188 );
21 } 189 }
@@ -268,8 +268,10 @@ class NavigatorUtil { @@ -268,8 +268,10 @@ class NavigatorUtil {
268 } 268 }
269 269
270 /// 优惠券历史列表 270 /// 优惠券历史列表
271 - static void goCouponHistoryPage(BuildContext context,int index, {replace = false}) {  
272 - _navigateTo(context, "${Routes.coupon_history}?index=${index}", replace: replace); 271 + static void goCouponHistoryPage(BuildContext context, int index,
  272 + {replace = false}) {
  273 + _navigateTo(context, "${Routes.coupon_history}?index=${index}",
  274 + replace: replace);
273 } 275 }
274 276
275 /// 创建优惠券 277 /// 创建优惠券
@@ -1917,4 +1919,13 @@ class NavigatorUtil { @@ -1917,4 +1919,13 @@ class NavigatorUtil {
1917 "${Routes.coupon_poster_page}?id=$id&use=${FluroConvertUtils.object2string(use)}&couponSunModel=${FluroConvertUtils.object2string(couponSunModel)}", 1919 "${Routes.coupon_poster_page}?id=$id&use=${FluroConvertUtils.object2string(use)}&couponSunModel=${FluroConvertUtils.object2string(couponSunModel)}",
1918 replace: replace); 1920 replace: replace);
1919 } 1921 }
  1922 +
  1923 + ///录入姓名和电话是否自动提示设置
  1924 + static Future<dynamic> goInputNamePhoneSettingPage(
  1925 + BuildContext context, {
  1926 + replace = false,
  1927 + }) {
  1928 + return _navigateTo(context, "${Routes.input_name_phone_setting_page}",
  1929 + replace: replace);
  1930 + }
1920 } 1931 }
@@ -208,6 +208,7 @@ import '../pages/my/feast_manage/feast_setmeal_manage_edit_page.dart'; @@ -208,6 +208,7 @@ import '../pages/my/feast_manage/feast_setmeal_manage_edit_page.dart';
208 import '../pages/my/feast_manage/feast_type_page.dart'; 208 import '../pages/my/feast_manage/feast_type_page.dart';
209 import '../pages/my/feast_manage/feast_wine_manage_edit_page.dart'; 209 import '../pages/my/feast_manage/feast_wine_manage_edit_page.dart';
210 import '../pages/my/feast_manage/feast_wine_manage_page.dart'; 210 import '../pages/my/feast_manage/feast_wine_manage_page.dart';
  211 +import '../pages/my/input_name_phone_setting_page.dart';
211 import '../pages/my/marketing_center/book_notification/book_info_page.dart'; 212 import '../pages/my/marketing_center/book_notification/book_info_page.dart';
212 import '../pages/my/marketing_center/book_notification/chef_introduce_page.dart'; 213 import '../pages/my/marketing_center/book_notification/chef_introduce_page.dart';
213 import '../pages/my/marketing_center/book_notification/dish_show_page.dart'; 214 import '../pages/my/marketing_center/book_notification/dish_show_page.dart';
@@ -2357,7 +2358,6 @@ var orderEditListShowPageHandle = new Handler( @@ -2357,7 +2358,6 @@ var orderEditListShowPageHandle = new Handler(
2357 oftenList.add(MenuSunModel.fromJson2(item)); 2358 oftenList.add(MenuSunModel.fromJson2(item));
2358 } 2359 }
2359 } 2360 }
2360 -  
2361 2361
2362 String planPrice = params["planPrice"].first; 2362 String planPrice = params["planPrice"].first;
2363 2363
@@ -3257,3 +3257,18 @@ var couponPosterPageHandle = new Handler( @@ -3257,3 +3257,18 @@ var couponPosterPageHandle = new Handler(
3257 child: 3257 child:
3258 CouponPosterPage(id: id, use: use, couponSunModel: couponSunModel)); 3258 CouponPosterPage(id: id, use: use, couponSunModel: couponSunModel));
3259 }); 3259 });
  3260 +
  3261 +///姓名和电话录入是是否提示配置
  3262 +
  3263 +var inputNamePhoneSettingPageHandle = new Handler(
  3264 + handlerFunc: (BuildContext context, Map<String, List<Object>> params) {
  3265 + // String id = params["id"].first;
  3266 + // // String smsTemplate = params["smsTemplate"].first;
  3267 + // CouponUse use = CouponUse.fromJson(
  3268 + // json.decode(FluroConvertUtils.fluroCnParamsDecode(params["use"].first)));
  3269 + // CouponSunModel couponSunModel = CouponSunModel.fromJson(json.decode(
  3270 + // FluroConvertUtils.fluroCnParamsDecode(params["couponSunModel"].first)));
  3271 + return ChangeNotifierProvider<MarketingCenterProvider>(
  3272 + create: (_) => MarketingCenterProvider(),
  3273 + child: InputNamePhoneSettingPage());
  3274 +});
@@ -307,15 +307,13 @@ class Routes { @@ -307,15 +307,13 @@ class Routes {
307 307
308 static String export_book_data_page = "/export_book_data_page"; //预订数据导出页面 308 static String export_book_data_page = "/export_book_data_page"; //预订数据导出页面
309 309
310 - static String sms_template_setting_page = "/sms_template_setting_page"; //短信模版设置 310 + static String sms_template_setting_page =
  311 + "/sms_template_setting_page"; //短信模版设置
311 312
312 static String coupon_poster_page = "/coupon_poster_page"; //优惠券海报 313 static String coupon_poster_page = "/coupon_poster_page"; //优惠券海报
313 314
314 -  
315 -  
316 -  
317 -  
318 - 315 + static String input_name_phone_setting_page =
  316 + "/input_name_phone_setting_page"; //姓名和电话录入配置页
319 317
320 static void configureRoutes(FluroRouter router) { 318 static void configureRoutes(FluroRouter router) {
321 router.notFoundHandler = new Handler( 319 router.notFoundHandler = new Handler(
@@ -581,17 +579,15 @@ class Routes { @@ -581,17 +579,15 @@ class Routes {
581 579
582 router.define(areas_select_page, handler: areasSelectPageHandle); 580 router.define(areas_select_page, handler: areasSelectPageHandle);
583 581
584 -router.define(export_book_data_page, handler: exportBookDataPageHandle);  
585 -  
586 -router.define(sms_template_setting_page, handler: smsTemplateSettingPageHandle);  
587 -  
588 -  
589 -router.define(coupon_poster_page, handler: couponPosterPageHandle);  
590 - 582 + router.define(export_book_data_page, handler: exportBookDataPageHandle);
591 583
  584 + router.define(sms_template_setting_page,
  585 + handler: smsTemplateSettingPageHandle);
592 586
  587 + router.define(coupon_poster_page, handler: couponPosterPageHandle);
593 588
594 589
  590 + router.define(input_name_phone_setting_page, handler: inputNamePhoneSettingPageHandle);
595 591
596 } 592 }
597 } 593 }