Showing
4 changed files
with
689 additions
and
0 deletions
| 1 | +// import 'dart:io'; | ||
| 2 | + | ||
| 3 | +// import 'package:flutter/material.dart'; | ||
| 4 | +// import 'package:flutter_screenutil/flutter_screenutil.dart'; | ||
| 5 | +// import 'package:one_key/app.dart'; | ||
| 6 | +// import 'package:one_key/models/get_seller_info_model.dart'; | ||
| 7 | +// import 'package:one_key/models/user.dart'; | ||
| 8 | +// import 'package:one_key/provider/create_store_model.dart'; | ||
| 9 | +// import 'package:one_key/provider/user_model.dart'; | ||
| 10 | +// import 'package:one_key/res/colors.dart'; | ||
| 11 | +// import 'package:one_key/utils/utils.dart'; | ||
| 12 | +// import 'package:one_key/widgets/round_button.dart'; | ||
| 13 | +// import 'package:one_key/widgets/system_app_bar.dart'; | ||
| 14 | +// import 'package:one_key/widgets/v_empty_view.dart'; | ||
| 15 | +// import 'package:provider/provider.dart'; | ||
| 16 | +// import 'package:tpns_flutter_plugin/tpns_flutter_plugin.dart'; | ||
| 17 | + | ||
| 18 | +// import '../../utils/event_bus.dart'; | ||
| 19 | + | ||
| 20 | +// class CompleteCreateStorePage extends StatefulWidget { | ||
| 21 | +// CompleteCreateStorePage({Key key}) : super(key: key); | ||
| 22 | + | ||
| 23 | +// @override | ||
| 24 | +// _CompleteCreateStorePageState createState() => | ||
| 25 | +// _CompleteCreateStorePageState(); | ||
| 26 | +// } | ||
| 27 | + | ||
| 28 | +// class _CompleteCreateStorePageState extends State<CompleteCreateStorePage> { | ||
| 29 | +// ///进入某个店铺 | ||
| 30 | +// // _loginStore(context, CheckSellerAccSunModel sunModel) { | ||
| 31 | +// // UserModel userModel = Provider.of<UserModel>(context, listen: false); | ||
| 32 | +// // Map<String, dynamic> seller = sunModel.toJson(); | ||
| 33 | +// // Map<String, dynamic> userMap = { | ||
| 34 | +// // "openid": seller['uid'], | ||
| 35 | +// // "account": seller['account'], | ||
| 36 | +// // "role_name": seller['role_name'], | ||
| 37 | +// // "sellerid": seller['id'], | ||
| 38 | +// // "sellercode": seller['seller_code'], | ||
| 39 | +// // "sellername": seller['sellername'], | ||
| 40 | +// // "sellerphone": seller['seller_tel'], | ||
| 41 | +// // "sellerAddr": '', | ||
| 42 | +// // "scatter": 0, | ||
| 43 | +// // "room": 0, | ||
| 44 | +// // "cassette": 0, | ||
| 45 | +// // "morning": "", | ||
| 46 | +// // "noon": "", | ||
| 47 | +// // "night": "", | ||
| 48 | +// // }; | ||
| 49 | +// // userModel.saveUserInfo(User.fromJson(userMap)); | ||
| 50 | +// // userModel.getSellerInfo( | ||
| 51 | +// // context, | ||
| 52 | +// // {"seller_id": seller['id'], "seller_openid": seller['openid']}, | ||
| 53 | +// // userMap); | ||
| 54 | +// // } | ||
| 55 | + | ||
| 56 | +// ///通过sellerid获取店铺和当前登录人的基本信息 | ||
| 57 | +// _getSellerAndUserData() async { | ||
| 58 | +// CreateStoreModel createStoreModel = | ||
| 59 | +// Provider.of<CreateStoreModel>(context, listen: false); | ||
| 60 | +// Map<String, String> params = { | ||
| 61 | +// "sellerid": createStoreModel.storeInfo.sellerid, | ||
| 62 | +// "openid": App.sp.getString("openid") | ||
| 63 | +// }; | ||
| 64 | + | ||
| 65 | +// await createStoreModel.getStoreInfo(context, params); | ||
| 66 | +// GetSellerInfoSunModel infoSunModel = | ||
| 67 | +// await createStoreModel.getSellerById(context); | ||
| 68 | +// UserModel userModel = Provider.of<UserModel>(context, listen: false); | ||
| 69 | +// Map<String, dynamic> seller = infoSunModel.data.toJson(); | ||
| 70 | +// Map<String, dynamic> user; //= baseResp.data[0]["user"] | ||
| 71 | + | ||
| 72 | +// App.sp.setBool("accountLogin", false); | ||
| 73 | +// if (Platform.isIOS) { | ||
| 74 | +// XgFlutterPlugin().stopXg(); | ||
| 75 | +// } | ||
| 76 | +// if (App.sp.containsKey('table_list')) { | ||
| 77 | +// //退出清空桌位数据 | ||
| 78 | +// App.sp.remove('table_list'); | ||
| 79 | +// } | ||
| 80 | +// if (App.sp.containsKey('specid')) { | ||
| 81 | +// //退出清空销售计价 | ||
| 82 | +// App.sp.remove('specid'); | ||
| 83 | +// App.sp.remove('specs'); | ||
| 84 | +// } | ||
| 85 | +// if (App.sp.containsKey('sellerEdate')) { | ||
| 86 | +// //退出清空店铺过期数据缓存 | ||
| 87 | +// App.sp.remove('sellerEdate'); | ||
| 88 | +// } | ||
| 89 | +// bus.emit('refresh_token'); | ||
| 90 | +// Map<String, dynamic> userMap = { | ||
| 91 | +// "sellerimage": seller['seller_image'], | ||
| 92 | + | ||
| 93 | +// // "sellerphone": seller['seller_tel'], | ||
| 94 | +// "sellerAddr": '', | ||
| 95 | +// "scatter": 0, | ||
| 96 | +// "room": 0, | ||
| 97 | +// "cassette": 0, | ||
| 98 | +// "openid": createStoreModel.userCreateStore.id, | ||
| 99 | +// "account": createStoreModel.userCreateStore.account, | ||
| 100 | +// "role_name": createStoreModel.userCreateStore.role_name, | ||
| 101 | +// "sellerid": createStoreModel.userCreateStore.sellerid, | ||
| 102 | +// "sellercode": createStoreModel.userCreateStore.seller_code, | ||
| 103 | +// "sellername": seller['sellername'], | ||
| 104 | +// "sellerphone": seller['phone'], | ||
| 105 | +// "sellerAddr": '', | ||
| 106 | +// "scatter": 0, | ||
| 107 | +// "room": 0, | ||
| 108 | +// "cassette": 0, | ||
| 109 | +// "morning": "", | ||
| 110 | +// "noon": "", | ||
| 111 | +// "night": "", | ||
| 112 | +// // 'userphone': user['phone'], | ||
| 113 | +// 'token': createStoreModel.userCreateStore.user_token, | ||
| 114 | +// 'nickname': createStoreModel.userCreateStore.nick_name, | ||
| 115 | +// 'edate': seller['edate'] | ||
| 116 | +// }; | ||
| 117 | + | ||
| 118 | +// userModel.saveUserInfo(User.fromJson(userMap)); | ||
| 119 | +// userModel.getSellerInfo( | ||
| 120 | +// context, | ||
| 121 | +// {"seller_id": seller['id'], "seller_openid": seller['openid']}, | ||
| 122 | +// userMap); | ||
| 123 | +// } | ||
| 124 | + | ||
| 125 | +// @override | ||
| 126 | +// Widget build(BuildContext context) { | ||
| 127 | +// return Scaffold( | ||
| 128 | +// backgroundColor: Colors.white, | ||
| 129 | +// appBar: SystemAppBar( | ||
| 130 | +// '', | ||
| 131 | +// onTap: () { | ||
| 132 | +// Navigator.pop(context); | ||
| 133 | +// }, | ||
| 134 | +// ), | ||
| 135 | +// body: InkWell( | ||
| 136 | +// onTap: () { | ||
| 137 | +// FocusScope.of(context).requestFocus(FocusNode()); //点击空白处隐藏键盘 | ||
| 138 | +// }, | ||
| 139 | +// child: Container( | ||
| 140 | +// padding: EdgeInsets.symmetric( | ||
| 141 | +// horizontal: ScreenUtil().setWidth(70), | ||
| 142 | +// vertical: ScreenUtil().setWidth(80)), | ||
| 143 | +// child: SingleChildScrollView( | ||
| 144 | +// child: Column( | ||
| 145 | +// crossAxisAlignment: CrossAxisAlignment.center, | ||
| 146 | +// children: [ | ||
| 147 | +// Image.asset( | ||
| 148 | +// Utils.getImgPath('complete'), | ||
| 149 | +// width: ScreenUtil().setWidth(120), | ||
| 150 | +// ), | ||
| 151 | +// VEmptyView(60), | ||
| 152 | +// Text( | ||
| 153 | +// '店铺已创建成功', | ||
| 154 | +// style: TextStyle( | ||
| 155 | +// fontWeight: FontWeight.bold, | ||
| 156 | +// fontSize: ScreenUtil().setSp(32), | ||
| 157 | +// color: MyColours.color_333333), | ||
| 158 | +// ), | ||
| 159 | +// VEmptyView(220), | ||
| 160 | +// // RoundButton( | ||
| 161 | +// // radius: ScreenUtil().setWidth(10), | ||
| 162 | +// // text: '继续创建桌位', | ||
| 163 | +// // fontSize: 34, | ||
| 164 | +// // gradientStart: MyColours.color_2AB5B7, | ||
| 165 | +// // gradientEnd: MyColours.color_2AB5B7, | ||
| 166 | +// // onPressed: () {}, | ||
| 167 | +// // isBold: false, | ||
| 168 | +// // ), | ||
| 169 | +// // VEmptyView(20), | ||
| 170 | +// RoundButton( | ||
| 171 | +// radius: ScreenUtil().setWidth(10), | ||
| 172 | +// text: '进入店铺', | ||
| 173 | +// fontSize: 34, | ||
| 174 | +// textColor: MyColours.color_2AB5B7, | ||
| 175 | +// gradientStart: Colors.white, | ||
| 176 | +// gradientEnd: Colors.white, | ||
| 177 | +// borderColor: MyColours.color_2AB5B7, | ||
| 178 | +// onPressed: () { | ||
| 179 | +// _getSellerAndUserData(); | ||
| 180 | +// }, | ||
| 181 | +// isBold: false, | ||
| 182 | +// ), | ||
| 183 | +// ]))))); | ||
| 184 | +// } | ||
| 185 | +// } |
lib/pages/login/collect_store_info_page.dart
0 → 100644
| 1 | +import 'package:city_pickers/city_pickers.dart'; | ||
| 2 | +import 'package:city_pickers/modal/result.dart'; | ||
| 3 | +import 'package:flutter/material.dart'; | ||
| 4 | +import 'package:flutter_screenutil/flutter_screenutil.dart'; | ||
| 5 | +import 'package:one_key/res/colors.dart'; | ||
| 6 | +import 'package:one_key/widgets/MyDivider.dart'; | ||
| 7 | +import 'package:one_key/widgets/h_empty_view.dart'; | ||
| 8 | +import 'package:one_key/widgets/system_app_bar.dart'; | ||
| 9 | +import 'package:permission_handler/permission_handler.dart'; | ||
| 10 | +import 'package:provider/provider.dart'; | ||
| 11 | + | ||
| 12 | +import '../../provider/collect_store_provider.dart'; | ||
| 13 | +import '../../route/navigator_util.dart'; | ||
| 14 | +import '../../utils/screen_util.dart'; | ||
| 15 | +import '../../utils/utils.dart'; | ||
| 16 | +import '../../widgets/round_button.dart'; | ||
| 17 | + | ||
| 18 | +/** | ||
| 19 | + * 店铺信息收集 | ||
| 20 | + * */ | ||
| 21 | + | ||
| 22 | +class CollectStoreInfoPage extends StatefulWidget { | ||
| 23 | + CollectStoreInfoPage({Key key}) : super(key: key); | ||
| 24 | + | ||
| 25 | + @override | ||
| 26 | + _CollectStoreInfoPageState createState() => _CollectStoreInfoPageState(); | ||
| 27 | +} | ||
| 28 | + | ||
| 29 | +class _CollectStoreInfoPageState extends State<CollectStoreInfoPage> { | ||
| 30 | + TextEditingController nameC = TextEditingController(); | ||
| 31 | + TextEditingController phoneC = TextEditingController(); | ||
| 32 | + TextEditingController personC = TextEditingController(); | ||
| 33 | + String storeAddress = '点击设置您的地址'; | ||
| 34 | + double lat; | ||
| 35 | + double lng; | ||
| 36 | + String proCode; | ||
| 37 | + String cityCode; | ||
| 38 | + String disCode; | ||
| 39 | + | ||
| 40 | + String cityString = '点击设置您的城市'; | ||
| 41 | + | ||
| 42 | + CollectStoreProvider collectStoreProvider; | ||
| 43 | + | ||
| 44 | + /// 高级筛选输入框 | ||
| 45 | + Widget _textFeildWidget( | ||
| 46 | + TextEditingController controller, String name, String hintText) { | ||
| 47 | + return Container( | ||
| 48 | + padding: EdgeInsets.symmetric( | ||
| 49 | + horizontal: ScreenUtil().setWidth(32), | ||
| 50 | + ), | ||
| 51 | + height: w(48), | ||
| 52 | + alignment: Alignment.center, | ||
| 53 | + child: Row(crossAxisAlignment: CrossAxisAlignment.center, children: [ | ||
| 54 | + _textWidget(name, MyColours.color_515151, FontWeight.normal, 32), | ||
| 55 | + Expanded( | ||
| 56 | + child: TextField( | ||
| 57 | + maxLines: 1, | ||
| 58 | + controller: controller, | ||
| 59 | + // focusNode: _focusNode, | ||
| 60 | + // autofocus: true, | ||
| 61 | + textAlign: TextAlign.right, | ||
| 62 | + style: TextStyle( | ||
| 63 | + color: MyColours.color_515151, | ||
| 64 | + fontSize: ScreenUtil().setSp(32)), | ||
| 65 | + // textAlignVertical: TextAlignVertical.center, | ||
| 66 | + decoration: InputDecoration( | ||
| 67 | + hintText: hintText, | ||
| 68 | + hintStyle: TextStyle( | ||
| 69 | + color: MyColours.color_66000000, | ||
| 70 | + fontSize: ScreenUtil().setSp(32), | ||
| 71 | + ), | ||
| 72 | + isCollapsed: true, //重点,相当于高度包裹的意思,必须设置为true,不然有默认奇妙的最小高度 | ||
| 73 | + border: OutlineInputBorder(borderSide: BorderSide.none), | ||
| 74 | + contentPadding: EdgeInsets.zero, | ||
| 75 | + ), | ||
| 76 | + keyboardType: TextInputType.text, | ||
| 77 | + textInputAction: TextInputAction.done, | ||
| 78 | + | ||
| 79 | + onChanged: (value) { | ||
| 80 | + // setState(() {}); | ||
| 81 | + // _searchSellerLocation(); | ||
| 82 | + // customerProvider.searchData(value); | ||
| 83 | + }, | ||
| 84 | + onEditingComplete: () { | ||
| 85 | + FocusScope.of(context).requestFocus(FocusNode()); //点击空白处隐藏键盘 | ||
| 86 | + // contantShowModel.searchData( | ||
| 87 | + // contantShowModel.controller.text); | ||
| 88 | + // _searchSellerLocation(); | ||
| 89 | + // _focusNode.unfocus(); | ||
| 90 | + }, | ||
| 91 | + ), | ||
| 92 | + ), | ||
| 93 | + ])); | ||
| 94 | + } | ||
| 95 | + | ||
| 96 | + ///弹框text | ||
| 97 | + _textWidget(String title, Color textColor, FontWeight fontWeight, int size) { | ||
| 98 | + return Text(title, | ||
| 99 | + style: TextStyle( | ||
| 100 | + color: textColor, | ||
| 101 | + decoration: TextDecoration.none, | ||
| 102 | + fontWeight: fontWeight, | ||
| 103 | + fontSize: ScreenUtil().setSp(size))); | ||
| 104 | + } | ||
| 105 | + | ||
| 106 | + _addressWidget(String name, String subtitle, GestureTapCallback onTap) { | ||
| 107 | + return InkWell( | ||
| 108 | + onTap: onTap, | ||
| 109 | + child: Container( | ||
| 110 | + padding: EdgeInsets.symmetric( | ||
| 111 | + horizontal: ScreenUtil().setWidth(32), | ||
| 112 | + ), | ||
| 113 | + height: w(48), | ||
| 114 | + alignment: Alignment.center, | ||
| 115 | + child: Row( | ||
| 116 | + // mainAxisAlignment: MainAxisAlignment.spaceBetween, | ||
| 117 | + crossAxisAlignment: CrossAxisAlignment.center, | ||
| 118 | + children: [ | ||
| 119 | + _textWidget( | ||
| 120 | + name, MyColours.color_515151, FontWeight.normal, 32), | ||
| 121 | + Expanded( | ||
| 122 | + child: Text( | ||
| 123 | + subtitle, | ||
| 124 | + textAlign: TextAlign.right, | ||
| 125 | + style: TextStyle( | ||
| 126 | + color: MyColours.color_66000000, | ||
| 127 | + fontSize: ScreenUtil().setSp(32), | ||
| 128 | + ), | ||
| 129 | + )), | ||
| 130 | + HEmptyView(20), | ||
| 131 | + Image.asset( | ||
| 132 | + "assets/arrow_right_new.png", | ||
| 133 | + width: ScreenUtil().setWidth(14), | ||
| 134 | + height: ScreenUtil().setWidth(22), | ||
| 135 | + ) | ||
| 136 | + ]))); | ||
| 137 | + } | ||
| 138 | + | ||
| 139 | + Widget _divider() { | ||
| 140 | + return Padding( | ||
| 141 | + padding: EdgeInsets.only(left: w(16)), | ||
| 142 | + child: MyDivider( | ||
| 143 | + double.infinity, | ||
| 144 | + w(1), | ||
| 145 | + color: MyColours.color_E7E7E7, | ||
| 146 | + )); | ||
| 147 | + } | ||
| 148 | + | ||
| 149 | + @override | ||
| 150 | + Widget build(BuildContext context) { | ||
| 151 | + collectStoreProvider = | ||
| 152 | + Provider.of<CollectStoreProvider>(context, listen: true); | ||
| 153 | + return Scaffold( | ||
| 154 | + backgroundColor: MyColours.color_ffffff, | ||
| 155 | + appBar: SystemAppBar('店铺信息'), | ||
| 156 | + body: Column( | ||
| 157 | + children: [ | ||
| 158 | + Expanded( | ||
| 159 | + child: SingleChildScrollView( | ||
| 160 | + child: Column( | ||
| 161 | + children: [ | ||
| 162 | + Container( | ||
| 163 | + padding: EdgeInsets.symmetric( | ||
| 164 | + horizontal: w(20), vertical: w(15)), | ||
| 165 | + child: Text('在开始之前,请告诉我们关于您的一些信息,以方便专属客服给您提供周到的服务。', | ||
| 166 | + style: TextStyle( | ||
| 167 | + height: 1.5, | ||
| 168 | + fontSize: font(16), | ||
| 169 | + color: MyColours.color_000000))), | ||
| 170 | + _textFeildWidget(nameC, '店铺名称:', '点击输入店铺名称'), | ||
| 171 | + _divider(), | ||
| 172 | + _addressWidget('店铺地址:', storeAddress, () { | ||
| 173 | + // | ||
| 174 | + Utils.getPickPermission(context, () async { | ||
| 175 | + Map address = | ||
| 176 | + await NavigatorUtil.goMapChoicePointPage(context); | ||
| 177 | + if (address != null) { | ||
| 178 | + setState(() { | ||
| 179 | + storeAddress = address['address']; | ||
| 180 | + | ||
| 181 | + lat = double.parse(address['lat'].toString()); | ||
| 182 | + lng = double.parse(address['lng'].toString()); | ||
| 183 | + }); | ||
| 184 | + } | ||
| 185 | + }, Permission.location); | ||
| 186 | + }), | ||
| 187 | + _textFeildWidget(phoneC, '联系电话:', '点击输入您的电话号码'), | ||
| 188 | + _divider(), | ||
| 189 | + _textFeildWidget(personC, '联系人:', '点击输入您的姓名'), | ||
| 190 | + _divider(), | ||
| 191 | + _addressWidget('城市选择:', cityString, () async { | ||
| 192 | + Result result = await CityPickers.showCityPicker( | ||
| 193 | + context: context, | ||
| 194 | + ); | ||
| 195 | + print(result); | ||
| 196 | + proCode = result.provinceId; | ||
| 197 | + cityCode = result.cityId; | ||
| 198 | + disCode = result.areaId; | ||
| 199 | + cityString = | ||
| 200 | + result.provinceName + result.cityName + result.areaName; | ||
| 201 | + setState(() {}); | ||
| 202 | + }), | ||
| 203 | + _divider(), | ||
| 204 | + ], | ||
| 205 | + ))), | ||
| 206 | + Container( | ||
| 207 | + height: ScreenUtil().setWidth(91 * 2), | ||
| 208 | + width: double.infinity, | ||
| 209 | + padding: EdgeInsets.only( | ||
| 210 | + top: ScreenUtil().setWidth(16 * 2), | ||
| 211 | + bottom: ScreenUtil().setWidth(35 * 2), | ||
| 212 | + left: ScreenUtil().setWidth(45 * 2), | ||
| 213 | + right: ScreenUtil().setWidth(45 * 2), | ||
| 214 | + ), | ||
| 215 | + decoration: BoxDecoration( | ||
| 216 | + color: MyColours.color_ffffff, | ||
| 217 | + boxShadow: [ | ||
| 218 | + BoxShadow( | ||
| 219 | + spreadRadius: ScreenUtil().setWidth(2), | ||
| 220 | + color: Color.fromRGBO(0, 0, 0, 0.1), | ||
| 221 | + offset: Offset(0, ScreenUtil().setWidth(-2)), | ||
| 222 | + blurRadius: ScreenUtil().setWidth(8)) | ||
| 223 | + ], | ||
| 224 | + borderRadius: BorderRadius.all( | ||
| 225 | + Radius.circular(ScreenUtil().setWidth(16)), | ||
| 226 | + ), | ||
| 227 | + ), | ||
| 228 | + child: RoundButton( | ||
| 229 | + text: '提交', | ||
| 230 | + height: ScreenUtil().setWidth(80), | ||
| 231 | + radius: ScreenUtil().setWidth(10), | ||
| 232 | + isBold: true, | ||
| 233 | + fontSize: 32, | ||
| 234 | + textColor: MyColours.color_F8F9FD, | ||
| 235 | + onPressed: () async { | ||
| 236 | + //判空 | ||
| 237 | + if (nameC.text.trim().length == 0) { | ||
| 238 | + Utils.showToast('请输入店铺名称'); | ||
| 239 | + return; | ||
| 240 | + } | ||
| 241 | + if (storeAddress == '点击设置您的地址') { | ||
| 242 | + Utils.showToast('请设置您的地址'); | ||
| 243 | + return; | ||
| 244 | + } | ||
| 245 | + if (phoneC.text.trim().length == 0) { | ||
| 246 | + Utils.showToast('请输入联系电话'); | ||
| 247 | + return; | ||
| 248 | + } | ||
| 249 | + if (personC.text.trim().length == 0) { | ||
| 250 | + Utils.showToast('请输联系人'); | ||
| 251 | + return; | ||
| 252 | + } | ||
| 253 | + if (cityString == '点击设置您的城市') { | ||
| 254 | + Utils.showToast('请设置您的城市'); | ||
| 255 | + return; | ||
| 256 | + } | ||
| 257 | + FocusScope.of(context).requestFocus(FocusNode()); //点击空白处隐藏键盘 | ||
| 258 | + Map<String, String> params = { | ||
| 259 | + 'sellername': nameC.text, | ||
| 260 | + 'map_address': storeAddress, | ||
| 261 | + 'phone': phoneC.text, | ||
| 262 | + 'rname': personC.text, | ||
| 263 | + 'pro_code': proCode, | ||
| 264 | + 'city_code': cityCode, | ||
| 265 | + 'dis_code': disCode, | ||
| 266 | + }; | ||
| 267 | + bool success = await collectStoreProvider.setSellerCollect( | ||
| 268 | + context, params); | ||
| 269 | + if (success) { | ||
| 270 | + //成功 | ||
| 271 | + NavigatorUtil.goCompleteStorePage(context, replace: true); | ||
| 272 | + } | ||
| 273 | + }, | ||
| 274 | + ), | ||
| 275 | + ) | ||
| 276 | + ], | ||
| 277 | + )); | ||
| 278 | + } | ||
| 279 | +} |
lib/pages/login/complete_create_store.dart
0 → 100644
| 1 | +import 'dart:io'; | ||
| 2 | + | ||
| 3 | +import 'package:flutter/material.dart'; | ||
| 4 | +import 'package:flutter_screenutil/flutter_screenutil.dart'; | ||
| 5 | +import 'package:one_key/app.dart'; | ||
| 6 | +import 'package:one_key/models/get_seller_info_model.dart'; | ||
| 7 | +import 'package:one_key/models/user.dart'; | ||
| 8 | +import 'package:one_key/provider/create_store_model.dart'; | ||
| 9 | +import 'package:one_key/provider/user_model.dart'; | ||
| 10 | +import 'package:one_key/res/colors.dart'; | ||
| 11 | +import 'package:one_key/utils/utils.dart'; | ||
| 12 | +import 'package:one_key/widgets/round_button.dart'; | ||
| 13 | +import 'package:one_key/widgets/system_app_bar.dart'; | ||
| 14 | +import 'package:one_key/widgets/v_empty_view.dart'; | ||
| 15 | +import 'package:provider/provider.dart'; | ||
| 16 | +import 'package:tpns_flutter_plugin/tpns_flutter_plugin.dart'; | ||
| 17 | + | ||
| 18 | +import '../../utils/event_bus.dart'; | ||
| 19 | +import '../../utils/screen_util.dart'; | ||
| 20 | + | ||
| 21 | +class CompleteCreateStorePage extends StatefulWidget { | ||
| 22 | + CompleteCreateStorePage({Key key}) : super(key: key); | ||
| 23 | + | ||
| 24 | + @override | ||
| 25 | + _CompleteCreateStorePageState createState() => | ||
| 26 | + _CompleteCreateStorePageState(); | ||
| 27 | +} | ||
| 28 | + | ||
| 29 | +class _CompleteCreateStorePageState extends State<CompleteCreateStorePage> { | ||
| 30 | + ///进入某个店铺 | ||
| 31 | + // _loginStore(context, CheckSellerAccSunModel sunModel) { | ||
| 32 | + // UserModel userModel = Provider.of<UserModel>(context, listen: false); | ||
| 33 | + // Map<String, dynamic> seller = sunModel.toJson(); | ||
| 34 | + // Map<String, dynamic> userMap = { | ||
| 35 | + // "openid": seller['uid'], | ||
| 36 | + // "account": seller['account'], | ||
| 37 | + // "role_name": seller['role_name'], | ||
| 38 | + // "sellerid": seller['id'], | ||
| 39 | + // "sellercode": seller['seller_code'], | ||
| 40 | + // "sellername": seller['sellername'], | ||
| 41 | + // "sellerphone": seller['seller_tel'], | ||
| 42 | + // "sellerAddr": '', | ||
| 43 | + // "scatter": 0, | ||
| 44 | + // "room": 0, | ||
| 45 | + // "cassette": 0, | ||
| 46 | + // "morning": "", | ||
| 47 | + // "noon": "", | ||
| 48 | + // "night": "", | ||
| 49 | + // }; | ||
| 50 | + // userModel.saveUserInfo(User.fromJson(userMap)); | ||
| 51 | + // userModel.getSellerInfo( | ||
| 52 | + // context, | ||
| 53 | + // {"seller_id": seller['id'], "seller_openid": seller['openid']}, | ||
| 54 | + // userMap); | ||
| 55 | + // } | ||
| 56 | + | ||
| 57 | + ///通过sellerid获取店铺和当前登录人的基本信息 | ||
| 58 | + _getSellerAndUserData() async { | ||
| 59 | + CreateStoreModel createStoreModel = | ||
| 60 | + Provider.of<CreateStoreModel>(context, listen: false); | ||
| 61 | + Map<String, String> params = { | ||
| 62 | + "sellerid": createStoreModel.storeInfo.sellerid, | ||
| 63 | + "openid": App.sp.getString("openid") | ||
| 64 | + }; | ||
| 65 | + | ||
| 66 | + await createStoreModel.getStoreInfo(context, params); | ||
| 67 | + GetSellerInfoSunModel infoSunModel = | ||
| 68 | + await createStoreModel.getSellerById(context); | ||
| 69 | + UserModel userModel = Provider.of<UserModel>(context, listen: false); | ||
| 70 | + Map<String, dynamic> seller = infoSunModel.data.toJson(); | ||
| 71 | + Map<String, dynamic> user; //= baseResp.data[0]["user"] | ||
| 72 | + | ||
| 73 | + App.sp.setBool("accountLogin", false); | ||
| 74 | + if (Platform.isIOS) { | ||
| 75 | + XgFlutterPlugin().stopXg(); | ||
| 76 | + } | ||
| 77 | + if (App.sp.containsKey('table_list')) { | ||
| 78 | + //退出清空桌位数据 | ||
| 79 | + App.sp.remove('table_list'); | ||
| 80 | + } | ||
| 81 | + if (App.sp.containsKey('specid')) { | ||
| 82 | + //退出清空销售计价 | ||
| 83 | + App.sp.remove('specid'); | ||
| 84 | + App.sp.remove('specs'); | ||
| 85 | + } | ||
| 86 | + if (App.sp.containsKey('sellerEdate')) { | ||
| 87 | + //退出清空店铺过期数据缓存 | ||
| 88 | + App.sp.remove('sellerEdate'); | ||
| 89 | + } | ||
| 90 | + bus.emit('refresh_token'); | ||
| 91 | + Map<String, dynamic> userMap = { | ||
| 92 | + "sellerimage": seller['seller_image'], | ||
| 93 | + | ||
| 94 | + // "sellerphone": seller['seller_tel'], | ||
| 95 | + "sellerAddr": '', | ||
| 96 | + "scatter": 0, | ||
| 97 | + "room": 0, | ||
| 98 | + "cassette": 0, | ||
| 99 | + "openid": createStoreModel.userCreateStore.id, | ||
| 100 | + "account": createStoreModel.userCreateStore.account, | ||
| 101 | + "role_name": createStoreModel.userCreateStore.role_name, | ||
| 102 | + "sellerid": createStoreModel.userCreateStore.sellerid, | ||
| 103 | + "sellercode": createStoreModel.userCreateStore.seller_code, | ||
| 104 | + "sellername": seller['sellername'], | ||
| 105 | + "sellerphone": seller['phone'], | ||
| 106 | + "sellerAddr": '', | ||
| 107 | + "scatter": 0, | ||
| 108 | + "room": 0, | ||
| 109 | + "cassette": 0, | ||
| 110 | + "morning": "", | ||
| 111 | + "noon": "", | ||
| 112 | + "night": "", | ||
| 113 | + // 'userphone': user['phone'], | ||
| 114 | + 'token': createStoreModel.userCreateStore.user_token, | ||
| 115 | + 'nickname': createStoreModel.userCreateStore.nick_name, | ||
| 116 | + 'edate': seller['edate'] | ||
| 117 | + }; | ||
| 118 | + | ||
| 119 | + userModel.saveUserInfo(User.fromJson(userMap)); | ||
| 120 | + userModel.getSellerInfo( | ||
| 121 | + context, | ||
| 122 | + {"seller_id": seller['id'], "seller_openid": seller['openid']}, | ||
| 123 | + userMap); | ||
| 124 | + } | ||
| 125 | + | ||
| 126 | + @override | ||
| 127 | + Widget build(BuildContext context) { | ||
| 128 | + return Scaffold( | ||
| 129 | + backgroundColor: Colors.white, | ||
| 130 | + appBar: SystemAppBar( | ||
| 131 | + '', | ||
| 132 | + onTap: () { | ||
| 133 | + Navigator.pop(context); | ||
| 134 | + }, | ||
| 135 | + ), | ||
| 136 | + body: InkWell( | ||
| 137 | + onTap: () { | ||
| 138 | + FocusScope.of(context).requestFocus(FocusNode()); //点击空白处隐藏键盘 | ||
| 139 | + }, | ||
| 140 | + child: Container( | ||
| 141 | + padding: EdgeInsets.symmetric( | ||
| 142 | + horizontal: ScreenUtil().setWidth(70), | ||
| 143 | + vertical: ScreenUtil().setWidth(80)), | ||
| 144 | + child: SingleChildScrollView( | ||
| 145 | + child: Column( | ||
| 146 | + crossAxisAlignment: CrossAxisAlignment.center, | ||
| 147 | + children: [ | ||
| 148 | + Image.asset( | ||
| 149 | + Utils.getImgPath('complete'), | ||
| 150 | + width: ScreenUtil().setWidth(120), | ||
| 151 | + ), | ||
| 152 | + VEmptyView(60), | ||
| 153 | + Text( | ||
| 154 | + '感谢您的信任!\n我们已经记录了您的信息。客服人员会在第一时间联系您,处理相关事宜。', | ||
| 155 | + style: TextStyle( | ||
| 156 | + // fontWeight: FontWeight.bold, | ||
| 157 | + fontSize: ScreenUtil().setSp(32), | ||
| 158 | + color: MyColours.color_000000), | ||
| 159 | + ), | ||
| 160 | + VEmptyView(220), | ||
| 161 | + // RoundButton( | ||
| 162 | + // radius: ScreenUtil().setWidth(10), | ||
| 163 | + // text: '继续创建桌位', | ||
| 164 | + // fontSize: 34, | ||
| 165 | + // gradientStart: MyColours.color_2AB5B7, | ||
| 166 | + // gradientEnd: MyColours.color_2AB5B7, | ||
| 167 | + // onPressed: () {}, | ||
| 168 | + // isBold: false, | ||
| 169 | + // ), | ||
| 170 | + // VEmptyView(20), | ||
| 171 | + RoundButton( | ||
| 172 | + height: w(43), | ||
| 173 | + radius: ScreenUtil().setWidth(10), | ||
| 174 | + text: '朕知道了', | ||
| 175 | + fontSize: 34, | ||
| 176 | + textColor: MyColours.color_F8F9FD, | ||
| 177 | + gradientStart: MyColours.color_438E93, | ||
| 178 | + gradientEnd: MyColours.color_438E93, | ||
| 179 | + borderColor: MyColours.color_438E93, | ||
| 180 | + onPressed: () { | ||
| 181 | + // _getSellerAndUserData(); | ||
| 182 | + Navigator.pop(context); | ||
| 183 | + }, | ||
| 184 | + isBold: true, | ||
| 185 | + ), | ||
| 186 | + ]))))); | ||
| 187 | + } | ||
| 188 | +} |
lib/provider/collect_store_provider.dart
0 → 100644
| 1 | +import 'package:flutter/material.dart'; | ||
| 2 | + | ||
| 3 | +import '../constant/constant.dart'; | ||
| 4 | +import '../constant/error.dart'; | ||
| 5 | +import '../net/base_resp.dart'; | ||
| 6 | +import '../net/dio_util.dart'; | ||
| 7 | +import '../net/http_url.dart'; | ||
| 8 | +import '../utils/utils.dart'; | ||
| 9 | + | ||
| 10 | +class CollectStoreProvider with ChangeNotifier { | ||
| 11 | + /// 收集店铺信息 | ||
| 12 | + Future<dynamic> setSellerCollect( | ||
| 13 | + BuildContext context, Map<String, String> params, | ||
| 14 | + {isShowLoading = true}) async { | ||
| 15 | + BaseResp<dynamic> baseResp = await DioUtil() | ||
| 16 | + .request<dynamic>(context, Method.get, HttpUrl.set_seller_collect, | ||
| 17 | + data: params, showLoading: isShowLoading) | ||
| 18 | + .catchError((error) { | ||
| 19 | + print(error.toString()); | ||
| 20 | + if (error is MyError) {} | ||
| 21 | + return false; | ||
| 22 | + }); | ||
| 23 | + if (baseResp.code == Constant.status_success) { | ||
| 24 | + // if (baseResp.data == 1) { | ||
| 25 | + // rid = baseResp.data['id']; | ||
| 26 | + return true; | ||
| 27 | + // } else { | ||
| 28 | + // return false; | ||
| 29 | + // } | ||
| 30 | + } else { | ||
| 31 | + if (baseResp != null) { | ||
| 32 | + Utils.showToast(baseResp.msg ?? ""); | ||
| 33 | + } | ||
| 34 | + return false; | ||
| 35 | + } | ||
| 36 | + } | ||
| 37 | +} |
-
Please register or login to post a comment