collect_store_info_page.dart
29.3 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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
import 'dart:async';
import 'package:city_pickers/city_pickers.dart';
import 'package:city_pickers/modal/result.dart';
import 'package:flutter/material.dart';
import 'package:flutter_keyboard_visibility/flutter_keyboard_visibility.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:one_key/res/colors.dart';
import 'package:one_key/widgets/MyDivider.dart';
import 'package:one_key/widgets/h_empty_view.dart';
import 'package:one_key/widgets/system_app_bar.dart';
import 'package:one_key/widgets/v_empty_view.dart';
import 'package:permission_handler/permission_handler.dart';
import 'package:provider/provider.dart';
import '../../provider/collect_store_provider.dart';
import '../../provider/other_login_provider.dart';
import '../../route/navigator_util.dart';
import '../../utils/screen_util.dart';
import '../../utils/utils.dart';
import '../../widgets/round_button.dart';
/**
* 店铺信息收集
* */
class CollectStoreInfoPage extends StatefulWidget {
CollectStoreInfoPage({Key key}) : super(key: key);
@override
_CollectStoreInfoPageState createState() => _CollectStoreInfoPageState();
}
class _CollectStoreInfoPageState extends State<CollectStoreInfoPage> {
TextEditingController nameC = TextEditingController();
TextEditingController phoneC = TextEditingController();
TextEditingController personC = TextEditingController();
TextEditingController codeC = TextEditingController();
String storeAddress = '点击设置您的地址';
double lat;
double lng;
String proCode;
String cityCode;
String disCode;
String cityString = '点击设置您的城市';
CollectStoreProvider collectStoreProvider;
FocusNode _codeNode;
OtherLoginProvider otherLoginProvider;
//定义变量
Timer _timer;
//倒计时数值
var countdownTime = 0;
// String phone;
String code;
bool enabled = true; //手机号码框是否可以编辑
bool codeEnabled = false; //验证码是否可用
@override
void dispose() {
super.dispose();
if (_timer != null) {
_timer?.cancel();
}
}
///倒计时方法
startCountdown() {
countdownTime = 600;
final call = (timer) {
setState(() {
if (countdownTime < 1) {
// model.code = null;
enabled = true;
codeEnabled = false;
_timer.cancel();
} else {
enabled = false;
codeEnabled = true;
countdownTime -= 1;
}
});
};
_timer = Timer.periodic(Duration(seconds: 1), call);
}
/// 高级筛选输入框
Widget _textFeildWidget(
TextEditingController controller, String name, String hintText) {
return Container(
padding: EdgeInsets.symmetric(
horizontal: ScreenUtil().setWidth(32),
),
height: w(48),
alignment: Alignment.center,
child: Row(crossAxisAlignment: CrossAxisAlignment.center, children: [
_textWidget(name, MyColours.color_515151, FontWeight.normal, 32),
Expanded(
child: TextField(
maxLines: 1,
controller: controller,
// focusNode: _focusNode,
// autofocus: true,
textAlign: TextAlign.right,
style: TextStyle(
color: MyColours.color_515151,
fontSize: ScreenUtil().setSp(32)),
// textAlignVertical: TextAlignVertical.center,
decoration: InputDecoration(
hintText: hintText,
hintStyle: TextStyle(
color: MyColours.color_66000000,
fontSize: ScreenUtil().setSp(32),
),
isCollapsed: true, //重点,相当于高度包裹的意思,必须设置为true,不然有默认奇妙的最小高度
border: OutlineInputBorder(borderSide: BorderSide.none),
contentPadding: EdgeInsets.zero,
),
keyboardType: name == '联系电话:'
? TextInputType.numberWithOptions()
: TextInputType.text,
textInputAction: TextInputAction.done,
onChanged: (value) {
// setState(() {});
// _searchSellerLocation();
// customerProvider.searchData(value);
},
onEditingComplete: () {
FocusScope.of(context).requestFocus(FocusNode()); //点击空白处隐藏键盘
// contantShowModel.searchData(
// contantShowModel.controller.text);
// _searchSellerLocation();
// _focusNode.unfocus();
},
),
),
]));
}
/// 高级筛选输入框
Widget _textFeildWidgetBtn(
TextEditingController controller, String name, String hintText) {
return Container(
padding: EdgeInsets.symmetric(
horizontal: ScreenUtil().setWidth(32),
),
height: w(48),
alignment: Alignment.center,
child: Row(crossAxisAlignment: CrossAxisAlignment.center, children: [
_textWidget(name, MyColours.color_515151, FontWeight.normal, 32),
Expanded(
child: TextField(
maxLines: 1,
controller: controller,
// focusNode: _focusNode,
// autofocus: true,
textAlign: TextAlign.right,
style: TextStyle(
color: MyColours.color_515151,
fontSize: ScreenUtil().setSp(32)),
// textAlignVertical: TextAlignVertical.center,
decoration: InputDecoration(
hintText: hintText,
hintStyle: TextStyle(
color: MyColours.color_66000000,
fontSize: ScreenUtil().setSp(32),
),
isCollapsed: true, //重点,相当于高度包裹的意思,必须设置为true,不然有默认奇妙的最小高度
border: OutlineInputBorder(borderSide: BorderSide.none),
contentPadding: EdgeInsets.zero,
),
keyboardType: TextInputType.numberWithOptions(decimal: true),
textInputAction: TextInputAction.done,
onChanged: (value) {
code = value;
},
onEditingComplete: () {
FocusScope.of(context).requestFocus(FocusNode()); //点击空白处隐藏键盘
// contantShowModel.searchData(
// contantShowModel.controller.text);
// _searchSellerLocation();
// _focusNode.unfocus();
},
),
),
HEmptyView(10),
RoundButton(
width: w(100),
height: w(25),
text: countdownTime > 0
? "${Utils.durationTransform(countdownTime)}后重新获取"
: "获取验证码",
radius: ScreenUtil().setWidth(10),
textColor: MyColours.color_ffffff,
gradientStart: MyColours.color_438E93,
gradientEnd: MyColours.color_438E93,
borderColor: Colors.transparent,
fontSize: 24,
isBold: false,
onPressed: () async {
if (phoneC.text.trim() == '18601216909') {
Utils.showToast('该手机号不需要获取验证码,可直接提交!');
return;
}
if (countdownTime == 0) {
if (phoneC.text == null || phoneC.text.trim().length == 0) {
Utils.showToast('请输入手机号码');
return;
}
// if (!Utils.isInteger(phoneC.text.replaceAll(' ', ''))) {
// Utils.showToast('您输入的手机号码格式不正确,请重新输入');
// return;
// }
if (!Utils.phoneRegExp(phoneC.text.replaceAll(' ', ''))) {
Utils.showToast('您输入的手机号码格式不正确,请重新输入');
return;
}
otherLoginProvider.code = Utils.randomBit(4);
Map<String, String> params = {
"phone": phoneC.text.replaceAll(' ', ''),
"code": otherLoginProvider.code,
};
startCountdown();
bool success =
await otherLoginProvider.getPhoneCode(context, params);
if (!success) {
_timer.cancel();
} else {
Utils.showToast('短信验证码已发送,请注意查收');
}
}
},
),
// HEmptyView(20),
]));
}
///弹框text
_textWidget(String title, Color textColor, FontWeight fontWeight, int size) {
return Text(title,
style: TextStyle(
color: textColor,
decoration: TextDecoration.none,
fontWeight: fontWeight,
fontSize: ScreenUtil().setSp(size)));
}
_addressWidget(String name, String subtitle, GestureTapCallback onTap) {
return InkWell(
onTap: onTap,
child: Container(
padding: EdgeInsets.symmetric(
horizontal: ScreenUtil().setWidth(32),
),
height: w(48),
alignment: Alignment.center,
child: Row(
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
_textWidget(
name, MyColours.color_515151, FontWeight.normal, 32),
Expanded(
child: Text(
subtitle,
textAlign: TextAlign.right,
style: TextStyle(
color: subtitle == '点击设置您的地址' || subtitle == '点击设置您的城市'
? MyColours.color_66000000
: MyColours.color_515151,
fontSize: ScreenUtil().setSp(32),
),
)),
HEmptyView(20),
Image.asset(
"assets/arrow_right_new.png",
width: ScreenUtil().setWidth(14),
height: ScreenUtil().setWidth(22),
)
])));
}
Widget _divider() {
return Padding(
padding: EdgeInsets.only(left: w(16)),
child: MyDivider(
double.infinity,
w(1),
color: MyColours.color_E7E7E7,
));
}
Widget _errorWidget() {
return Column(
children: [
Expanded(
child: SingleChildScrollView(
child: Column(
children: [
VEmptyView(384),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Image.asset(
Utils.getImgPath('error_circle'),
width: w(70),
),
HEmptyView(20),
Text(
'出错了!',
style: TextStyle(
color: MyColours.color_E34D59, fontSize: font(20)),
)
],
),
VEmptyView(100),
Padding(
padding: EdgeInsets.symmetric(horizontal: w(20)),
child: Text(
'您输入的店铺名字:\nxxx和商家\nxxx\n高度重合,如果您是这家店铺的工作人员,请与店铺管理员(xxx)联系增员,谢谢!',
style: TextStyle(
color: MyColours.color_515151, fontSize: font(16)),
))
],
),
)),
Container(
margin: EdgeInsets.only(
left: w(23), top: w(10), right: w(21), bottom: w(25)),
child: Row(
children: [
RoundButton(
text: '不是店员,继续注册',
isBold: true,
width: w(218),
height: w(43),
fontSize: 32,
textColor: MyColours.color_438E93,
gradientStart: MyColours.color_ffffff,
gradientEnd: MyColours.color_ffffff,
borderColor: MyColours.color_438E93,
radius: 10,
onPressed: () {
//再一次提交原来的数据,标识是第二次提交
},
),
HEmptyView(28),
Expanded(
child: RoundButton(
text: '朕知道了',
isBold: true,
height: w(43),
fontSize: 32,
radius: 10,
textColor: MyColours.color_ffffff,
gradientStart: MyColours.color_438E93,
gradientEnd: MyColours.color_438E93,
borderColor: MyColours.color_438E93,
onPressed: () {
//
Navigator.pop(context);
},
))
],
),
)
],
);
}
@override
Widget build(BuildContext context) {
collectStoreProvider =
Provider.of<CollectStoreProvider>(context, listen: true);
otherLoginProvider = Provider.of<OtherLoginProvider>(context, listen: true);
return KeyboardDismissOnTap(
child: Scaffold(
backgroundColor: MyColours.color_ffffff,
appBar: SystemAppBar('店铺信息'),
body:
// true
// ? _errorWidget()
// :
Column(
children: [
Expanded(
child: SingleChildScrollView(
child: Column(
children: [
VEmptyView(50),
Container(
padding: EdgeInsets.symmetric(
horizontal: w(20), vertical: w(15)),
child: Text(
'在开始之前,请告诉我们关于您的一些信息,以方便专属客服给您提供周到的服务。',
style: TextStyle(
height: 1.5,
fontSize: font(16),
color: MyColours.color_000000))),
VEmptyView(40),
_textFeildWidget(nameC, '店铺名称:', '点击输入店铺名称'),
_divider(),
VEmptyView(20),
_addressWidget('店铺地址:', storeAddress, () {
//
FocusScope.of(context)
.requestFocus(FocusNode()); //点击空白处隐藏键盘
Utils.getPickPermission(context, () async {
var address =
await NavigatorUtil.goMapChoicePointPage(
context);
if (address != null && address is Map) {
setState(() {
storeAddress = address['address'];
lat = double.parse(address['lat'].toString());
lng = double.parse(address['lng'].toString());
});
}
}, Permission.location);
}),
_divider(),
VEmptyView(20),
_addressWidget('城市选择:', cityString, () async {
FocusScope.of(context)
.requestFocus(FocusNode()); //点击空白处隐藏键盘
Result result = await CityPickers.showCityPicker(
context: context,
borderRadius: r(8),
cancelWidget: Container(
padding: EdgeInsets.symmetric(
horizontal: w(20), vertical: w(20)),
child: Text(
'取消',
style: TextStyle(
color: MyColours.color_515151,
fontSize: ScreenUtil().setSp(32)),
),
),
confirmWidget: Container(
padding: EdgeInsets.symmetric(
horizontal: w(20), vertical: w(20)),
child: Text(
'确定',
style: TextStyle(
color: MyColours.color_438E93,
fontSize: ScreenUtil().setSp(32)),
),
),
theme: ThemeData(
textTheme: TextTheme(
bodyText1: TextStyle(
fontSize: font(11),
// fontWeight: FontWeight.w200,
),
)));
print(result);
if (result != null) {
proCode = result.provinceId;
cityCode = result.cityId;
disCode = result.areaId;
cityString = result.provinceName +
result.cityName +
result.areaName;
setState(() {});
}
}),
_divider(),
VEmptyView(20),
_textFeildWidget(personC, '联系人:', '点击输入您的姓名'),
_divider(),
VEmptyView(20),
_textFeildWidget(phoneC, '联系电话:', '点击输入您的电话号码'),
_divider(),
VEmptyView(20),
_textFeildWidgetBtn(codeC, '验证码:', '点击输入验证码'),
_divider(),
VEmptyView(20),
// Container(
// height: ScreenUtil().setHeight(52 * 2),
// // width: ScreenUtil().setWidth(611),
// padding:
// EdgeInsets.only(left: ScreenUtil().setWidth(20)),
// margin: EdgeInsets.only(top: ScreenUtil().setHeight(8)),
// alignment: Alignment.center,
// decoration: BoxDecoration(
// border: Border.all(
// color: MyColours.color_bff6f7,
// width: ScreenUtil().setWidth(2)),
// borderRadius: BorderRadius.circular(
// ScreenUtil().setWidth(10))),
// child: Row(
// crossAxisAlignment: CrossAxisAlignment.center,
// children: <Widget>[
// HEmptyView(30),
// Text(
// "验证码",
// style: TextStyle(
// color: MyColours.color_333333,
// fontSize: ScreenUtil().setSp(26)),
// ),
// HEmptyView(30),
// Expanded(
// child: TextField(
// focusNode: _codeNode,
// style: TextStyle(
// color: MyColours.color_353535,
// fontSize: ScreenUtil().setSp(28)),
// decoration: InputDecoration(
// hintText: "请输入验证码",
// hintStyle: TextStyle(
// color: MyColours.color_999999,
// fontSize: ScreenUtil().setSp(26)),
// contentPadding: EdgeInsets.zero,
// border: OutlineInputBorder(
// borderSide: BorderSide.none),
// // contentPadding: EdgeInsets.fromLTRB(
// // 0,
// // ScreenUtil().setWidth(28),
// // ScreenUtil().setWidth(30),
// // ScreenUtil().setWidth(28)),
// ),
// onChanged: (value) {
// code = value;
// },
// onEditingComplete: () {
// FocusScope.of(context)
// .requestFocus(FocusNode()); //点击空白处隐藏键盘
// },
// keyboardType: TextInputType.numberWithOptions(
// decimal: true),
// ),
// ),
// ],
// )),
],
))),
Container(
height: ScreenUtil().setWidth(191 * 2),
width: double.infinity,
padding: EdgeInsets.only(
top: ScreenUtil().setWidth(16 * 2),
bottom: ScreenUtil().setWidth(35 * 2),
// left: ScreenUtil().setWidth(45 * 2),
// right: ScreenUtil().setWidth(45 * 2),
),
decoration: BoxDecoration(
color: MyColours.color_ffffff,
// boxShadow: [
// BoxShadow(
// spreadRadius: ScreenUtil().setWidth(2),
// color: Color.fromRGBO(0, 0, 0, 0.1),
// offset: Offset(0, ScreenUtil().setWidth(-2)),
// blurRadius: ScreenUtil().setWidth(8))
// ],
// borderRadius: BorderRadius.all(
// Radius.circular(ScreenUtil().setWidth(16)),
// ),
),
child: Column(
children: [
Container(
padding: EdgeInsets.symmetric(
horizontal: w(20), vertical: w(15)),
child: Text(
'注:如果您的店铺已经在使用周到安排为客户预订包间,请联系管理员给您创建使用账号。',
style: TextStyle(
height: 1.5,
fontSize: font(14),
color: MyColours.color_000000))),
VEmptyView(24),
RoundButton(
text: '提交',
height: ScreenUtil().setWidth(80),
radius: ScreenUtil().setWidth(10),
isBold: true,
margin: EdgeInsets.only(
left: ScreenUtil().setWidth(45 * 2),
right: ScreenUtil().setWidth(45 * 2),
),
fontSize: 32,
textColor: MyColours.color_F8F9FD,
onPressed: () async {
//判空
if (nameC.text.trim().length == 0) {
Utils.showToast('请输入店铺名称');
return;
}
// if (storeAddress == '点击设置您的地址') {
// Utils.showToast('请设置您的地址');
// return;
// }
if (cityString == '点击设置您的城市') {
Utils.showToast('请设置您的城市');
return;
}
if (personC.text.trim().length == 0) {
Utils.showToast('请输入联系人');
return;
}
if (phoneC.text.trim().length == 0) {
Utils.showToast('请输入联系电话');
return;
}
if (phoneC.text.trim() != '18601216909') {
if (code == null ||
code.trim().length == 0) {
Utils.showToast('请输入验证码');
return;
}
if (otherLoginProvider.code != null &&
!codeEnabled) {
Utils.showToast('验证码已失效,请重新获取');
return;
}
if (otherLoginProvider.code == null) {
Utils.showToast('请获取验证码');
return;
}
if (otherLoginProvider.code != code) {
Utils.showToast('您输入的验证码不正确,请重新输入');
return;
}
}
FocusScope.of(context)
.requestFocus(FocusNode()); //点击空白处隐藏键盘
Map<String, String> params = {
'sellername': nameC.text,
'phone': phoneC.text,
'rname': personC.text,
'pro_code': proCode,
'city_code': cityCode,
'dis_code': disCode,
};
if (storeAddress != '点击设置您的地址') {
//填写了地址
params['map_address'] = storeAddress;
params['lat'] = lat.toString();
params['long'] = lng.toString();
}
bool success = await collectStoreProvider
.setSellerCollect(context, params);
if (success) {
if (phoneC.text.trim() != '18601216909') {
await collectStoreProvider
.sendIntention(context, {
"shopname": nameC.text,
"shopnumber": phoneC.text,
"name": personC.text,
"address": storeAddress,
"laiyuan": 'app'
});
}
//成功
NavigatorUtil.goCompleteStorePage(context,
replace: true);
}
},
),
],
))
],
)));
}
}