|
|
|
import 'dart:async';
|
|
|
|
|
|
|
|
import 'package:city_pickers/city_pickers.dart';
|
|
|
|
import 'package:city_pickers/modal/result.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
|
...
|
...
|
@@ -12,6 +14,7 @@ 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';
|
|
...
|
...
|
@@ -32,6 +35,7 @@ class _CollectStoreInfoPageState extends State<CollectStoreInfoPage> { |
|
|
|
TextEditingController nameC = TextEditingController();
|
|
|
|
TextEditingController phoneC = TextEditingController();
|
|
|
|
TextEditingController personC = TextEditingController();
|
|
|
|
TextEditingController codeC = TextEditingController();
|
|
|
|
String storeAddress = '点击设置您的地址';
|
|
|
|
double lat;
|
|
|
|
double lng;
|
|
...
|
...
|
@@ -43,6 +47,48 @@ class _CollectStoreInfoPageState extends State<CollectStoreInfoPage> { |
|
|
|
|
|
|
|
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) {
|
|
...
|
...
|
@@ -75,7 +121,9 @@ class _CollectStoreInfoPageState extends State<CollectStoreInfoPage> { |
|
|
|
border: OutlineInputBorder(borderSide: BorderSide.none),
|
|
|
|
contentPadding: EdgeInsets.zero,
|
|
|
|
),
|
|
|
|
keyboardType: TextInputType.text,
|
|
|
|
keyboardType: name == '联系电话:'
|
|
|
|
? TextInputType.numberWithOptions()
|
|
|
|
: TextInputType.text,
|
|
|
|
textInputAction: TextInputAction.done,
|
|
|
|
|
|
|
|
onChanged: (value) {
|
|
...
|
...
|
@@ -95,6 +143,106 @@ class _CollectStoreInfoPageState extends State<CollectStoreInfoPage> { |
|
|
|
]));
|
|
|
|
}
|
|
|
|
|
|
|
|
/// 高级筛选输入框
|
|
|
|
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,
|
|
...
|
...
|
@@ -154,6 +302,7 @@ class _CollectStoreInfoPageState extends State<CollectStoreInfoPage> { |
|
|
|
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,
|
|
...
|
...
|
@@ -196,12 +345,6 @@ class _CollectStoreInfoPageState extends State<CollectStoreInfoPage> { |
|
|
|
}),
|
|
|
|
_divider(),
|
|
|
|
VEmptyView(20),
|
|
|
|
_textFeildWidget(phoneC, '联系电话:', '点击输入您的电话号码'),
|
|
|
|
_divider(),
|
|
|
|
VEmptyView(20),
|
|
|
|
_textFeildWidget(personC, '联系人:', '点击输入您的姓名'),
|
|
|
|
_divider(),
|
|
|
|
VEmptyView(20),
|
|
|
|
_addressWidget('城市选择:', cityString, () async {
|
|
|
|
FocusScope.of(context)
|
|
|
|
.requestFocus(FocusNode()); //点击空白处隐藏键盘
|
|
...
|
...
|
@@ -247,6 +390,75 @@ class _CollectStoreInfoPageState extends State<CollectStoreInfoPage> { |
|
|
|
}
|
|
|
|
}),
|
|
|
|
_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(
|
|
...
|
...
|
@@ -304,18 +516,39 @@ class _CollectStoreInfoPageState extends State<CollectStoreInfoPage> { |
|
|
|
// Utils.showToast('请设置您的地址');
|
|
|
|
// return;
|
|
|
|
// }
|
|
|
|
if (phoneC.text.trim().length == 0) {
|
|
|
|
Utils.showToast('请输入联系电话');
|
|
|
|
if (cityString == '点击设置您的城市') {
|
|
|
|
Utils.showToast('请设置您的城市');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (personC.text.trim().length == 0) {
|
|
|
|
Utils.showToast('请输入联系人');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (cityString == '点击设置您的城市') {
|
|
|
|
Utils.showToast('请设置您的城市');
|
|
|
|
|
|
|
|
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 = {
|
|
...
|
...
|
@@ -341,7 +574,7 @@ class _CollectStoreInfoPageState extends State<CollectStoreInfoPage> { |
|
|
|
"shopnumber": phoneC.text,
|
|
|
|
"name": personC.text,
|
|
|
|
"address": storeAddress,
|
|
|
|
"laiyuan":'app'
|
|
|
|
"laiyuan": 'app'
|
|
|
|
});
|
|
|
|
//成功
|
|
|
|
NavigatorUtil.goCompleteStorePage(context,
|
...
|
...
|
|