|
|
|
|
|
|
|
import 'dart:async';
|
|
|
|
import 'dart:convert';
|
|
|
|
import 'dart:io';
|
|
...
|
...
|
@@ -88,9 +87,12 @@ class _StoreBaseInfoPageSimState extends State<StoreBaseInfoPageSim> { |
|
|
|
|
|
|
|
List<String?> imgAll = [];
|
|
|
|
|
|
|
|
List<String> areaCode = [];
|
|
|
|
|
|
|
|
///获取接单时间接口
|
|
|
|
_getReceiveOrdersTime() async {
|
|
|
|
GetSellerInfoSunModel? model = await bookSetTimeModel.getSellerById(context);
|
|
|
|
GetSellerInfoSunModel? model =
|
|
|
|
await bookSetTimeModel.getSellerById(context);
|
|
|
|
setState(() {
|
|
|
|
receiveOrdersTime.start = model!.data!.recStime!.padLeft(5, '0');
|
|
|
|
receiveOrdersTime.end = model.data!.recEtime!.padLeft(5, '0');
|
|
...
|
...
|
@@ -132,7 +134,7 @@ class _StoreBaseInfoPageSimState extends State<StoreBaseInfoPageSim> { |
|
|
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
|
|
|
_uploadImageProvider.mentou.process = 0.01;
|
|
|
|
_uploadImageProvider.mentou.qiniuUrl = '';
|
|
|
|
|
|
|
|
_initAreaCode();
|
|
|
|
// _uploadImageProvider.mentou.file = null;
|
|
|
|
_getQiniuInfo();
|
|
|
|
_getStoreBaseinfo();
|
|
...
|
...
|
@@ -149,6 +151,26 @@ class _StoreBaseInfoPageSimState extends State<StoreBaseInfoPageSim> { |
|
|
|
super.dispose();
|
|
|
|
}
|
|
|
|
|
|
|
|
Future<List<dynamic>> loadJsonData() async {
|
|
|
|
final jsonString = await rootBundle.loadString('assets/areacode.json');
|
|
|
|
return jsonDecode(jsonString);
|
|
|
|
}
|
|
|
|
|
|
|
|
_initAreaCode() async {
|
|
|
|
List<dynamic> temp = await loadJsonData();
|
|
|
|
areaCode = [];
|
|
|
|
temp.forEach((element) {
|
|
|
|
print(element['代码']);
|
|
|
|
areaCode.add(element['代码']);
|
|
|
|
});
|
|
|
|
// temp.map((e) => {areaCode.add(e['代码'])});
|
|
|
|
// //推荐使用
|
|
|
|
// for (var entry in map.entries) {
|
|
|
|
// print('value:${entry.value}');
|
|
|
|
// }
|
|
|
|
print(areaCode); // 使用数据
|
|
|
|
}
|
|
|
|
|
|
|
|
getSellerTemplateConf() async {
|
|
|
|
bool success = await marketingCenterProvider.getSellerTemplateConf(context);
|
|
|
|
if (success && marketingCenterProvider.markDataModel!.store != null) {
|
|
...
|
...
|
@@ -354,11 +376,11 @@ class _StoreBaseInfoPageSimState extends State<StoreBaseInfoPageSim> { |
|
|
|
GetSellerInfoSunModel? itemModel =
|
|
|
|
await _baseIndoProvider.getSellerById(context);
|
|
|
|
if (itemModel != null) {
|
|
|
|
_nameController.text = itemModel.data!.sellername??"";
|
|
|
|
_nameController.text = itemModel.data!.sellername ?? "";
|
|
|
|
|
|
|
|
_timeController.text = itemModel.data!.dailyTime??"";
|
|
|
|
_addressController.text = itemModel.data!.realAddress??"";
|
|
|
|
_introductionController.text = itemModel.data!.sellerdesc??"";
|
|
|
|
_timeController.text = itemModel.data!.dailyTime ?? "";
|
|
|
|
_addressController.text = itemModel.data!.realAddress ?? "";
|
|
|
|
_introductionController.text = itemModel.data!.sellerdesc ?? "";
|
|
|
|
_uploadImageProvider.mentou.qiniuUrl = itemModel.data!.sellerImage;
|
|
|
|
// _uploadImageProvider.notifyListeners();
|
|
|
|
_countName = _nameController.text.trim().length;
|
|
...
|
...
|
@@ -375,7 +397,7 @@ class _StoreBaseInfoPageSimState extends State<StoreBaseInfoPageSim> { |
|
|
|
onePhone = true;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
_phoneController.text = itemModel.data!.sellerTel??"";
|
|
|
|
_phoneController.text = itemModel.data!.sellerTel ?? "";
|
|
|
|
onePhone = true;
|
|
|
|
}
|
|
|
|
mapAddress = {
|
|
...
|
...
|
@@ -403,12 +425,12 @@ class _StoreBaseInfoPageSimState extends State<StoreBaseInfoPageSim> { |
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!Utils.isNumeric1Req(_phoneController.text.trim())) {
|
|
|
|
if (!Utils.isPhoneReq(_phoneController.text.trim())) {
|
|
|
|
Utils.showToast('电话1请输入正确的格式!');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (_phoneController2.text.trim().length > 0 &&
|
|
|
|
!Utils.isNumeric1Req(_phoneController2.text.trim())) {
|
|
|
|
!Utils.isPhoneReq(_phoneController2.text.trim())) {
|
|
|
|
Utils.showToast('电话2请输入正确的格式!');
|
|
|
|
return;
|
|
|
|
}
|
|
...
|
...
|
@@ -456,6 +478,85 @@ class _StoreBaseInfoPageSimState extends State<StoreBaseInfoPageSim> { |
|
|
|
await _setSellerInfoById();
|
|
|
|
}
|
|
|
|
|
|
|
|
TextInputFormatter phoneInputFormatter() {
|
|
|
|
return TextInputFormatter.withFunction((oldValue, newValue) {
|
|
|
|
String text = newValue.text;
|
|
|
|
int numMin = 3;
|
|
|
|
int numMax = 7;
|
|
|
|
String textTemp = text.replaceAll('-', "");
|
|
|
|
if (text.startsWith('0')) {
|
|
|
|
// String string4 = textTemp.substring(0, 4);
|
|
|
|
|
|
|
|
// String string3 = textTemp.substring(0, 3);
|
|
|
|
|
|
|
|
if (textTemp.length > 4) {
|
|
|
|
bool hasNumber4 =
|
|
|
|
areaCode.any((number) => number == textTemp.substring(0, 4));
|
|
|
|
|
|
|
|
if (hasNumber4) {
|
|
|
|
numMin = 4;
|
|
|
|
numMax = 8;
|
|
|
|
} else {
|
|
|
|
bool hasNumber3 =
|
|
|
|
areaCode.any((number) => number == textTemp.substring(0, 3));
|
|
|
|
if (hasNumber3) {
|
|
|
|
numMin = 3;
|
|
|
|
numMax = 7;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if (textTemp.length > 3) {
|
|
|
|
bool hasNumber3 =
|
|
|
|
areaCode.any((number) => number == textTemp.substring(0, 3));
|
|
|
|
if (hasNumber3) {
|
|
|
|
numMin = 3;
|
|
|
|
numMax = 7;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//获取光标左边的文本
|
|
|
|
final positionStr = (text.substring(0, newValue.selection.baseOffset))
|
|
|
|
.replaceAll('-', "");
|
|
|
|
//计算格式化后的光标位置
|
|
|
|
int length = positionStr.length;
|
|
|
|
var position = 0;
|
|
|
|
if (length <= numMin) {
|
|
|
|
position = length;
|
|
|
|
} else if (length <= numMax) {
|
|
|
|
// 因为前面的字符串里面加了一个空格
|
|
|
|
position = length + 1;
|
|
|
|
} else {
|
|
|
|
position = length + 2;
|
|
|
|
}
|
|
|
|
// else if (length <= 11) {
|
|
|
|
// // 因为前面的字符串里面加了两个空格
|
|
|
|
// position = length + 2;
|
|
|
|
// } else {
|
|
|
|
// // 号码本身为 11 位数字,因多了两个空格,故为 13
|
|
|
|
// position = 13;
|
|
|
|
// }
|
|
|
|
// RegExp(r"\s+\b|\b\s")
|
|
|
|
|
|
|
|
//这里格式化整个输入文本
|
|
|
|
text = text.replaceAll('-', "");
|
|
|
|
var string = "";
|
|
|
|
for (int i = 0; i < text.length; i++) {
|
|
|
|
// 这里第 4 位,与第 8 位,我们用空格填充
|
|
|
|
if (i == numMin || i == numMax) {
|
|
|
|
if (text[i] != "-") {
|
|
|
|
string = string + "-";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
string += text[i];
|
|
|
|
}
|
|
|
|
|
|
|
|
return TextEditingValue(
|
|
|
|
text: string,
|
|
|
|
selection: TextSelection.fromPosition(
|
|
|
|
TextPosition(offset: position, affinity: TextAffinity.upstream)),
|
|
|
|
);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
_refreshMarketingInfo() async {
|
|
|
|
//接口
|
|
|
|
Map storeData = {
|
|
...
|
...
|
@@ -466,7 +567,8 @@ class _StoreBaseInfoPageSimState extends State<StoreBaseInfoPageSim> { |
|
|
|
|
|
|
|
if (marketingCenterProvider.markDataModel != null &&
|
|
|
|
marketingCenterProvider.markDataModel!.store != null) {
|
|
|
|
storeData['images'] = marketingCenterProvider.markDataModel!.store!.images;
|
|
|
|
storeData['images'] =
|
|
|
|
marketingCenterProvider.markDataModel!.store!.images;
|
|
|
|
storeData['is_introduce'] =
|
|
|
|
marketingCenterProvider.markDataModel!.store!.isIntroduce;
|
|
|
|
storeData['is_images'] =
|
|
...
|
...
|
@@ -912,7 +1014,7 @@ class _StoreBaseInfoPageSimState extends State<StoreBaseInfoPageSim> { |
|
|
|
return InkWell(
|
|
|
|
onTap: () {
|
|
|
|
Utils.getPickPermission(context, () async {
|
|
|
|
Map? temp = await NavigatorUtil.goMapChoicePointPage(context) ;
|
|
|
|
Map? temp = await NavigatorUtil.goMapChoicePointPage(context);
|
|
|
|
if (temp != null) {
|
|
|
|
mapAddress = temp as Map<String, dynamic>?;
|
|
|
|
setState(() {
|
|
...
|
...
|
@@ -1032,8 +1134,8 @@ class _StoreBaseInfoPageSimState extends State<StoreBaseInfoPageSim> { |
|
|
|
morning.end!, SetTimeWidget.dateData);
|
|
|
|
} else if (tag == 2) {
|
|
|
|
//晚市
|
|
|
|
data =
|
|
|
|
Utils.getPickerData(noon.end!, SetTimeWidget.dateData);
|
|
|
|
data = Utils.getPickerData(
|
|
|
|
noon.end!, SetTimeWidget.dateData);
|
|
|
|
}
|
|
|
|
|
|
|
|
SetTimeWidget().showTimeSelector(context, data, start,
|
|
...
|
...
|
@@ -1170,8 +1272,8 @@ class _StoreBaseInfoPageSimState extends State<StoreBaseInfoPageSim> { |
|
|
|
morning.start!, SetTimeWidget.dateData);
|
|
|
|
} else if (tag == 1) {
|
|
|
|
//午市
|
|
|
|
data =
|
|
|
|
Utils.getPickerData(noon.start!, SetTimeWidget.dateData);
|
|
|
|
data = Utils.getPickerData(
|
|
|
|
noon.start!, SetTimeWidget.dateData);
|
|
|
|
} else if (tag == 2) {
|
|
|
|
//晚市
|
|
|
|
data = Utils.getPickerData(
|
|
...
|
...
|
@@ -1686,6 +1788,10 @@ class _StoreBaseInfoPageSimState extends State<StoreBaseInfoPageSim> { |
|
|
|
child: TextField(
|
|
|
|
controller: _phoneController,
|
|
|
|
maxLines: 1,
|
|
|
|
inputFormatters: [
|
|
|
|
phoneInputFormatter(),
|
|
|
|
// LengthLimitingTextInputFormatter(14),
|
|
|
|
],
|
|
|
|
// inputFormatters: [
|
|
|
|
// LengthLimitingTextInputFormatter(
|
|
|
|
// 15),
|
|
...
|
...
|
@@ -1726,7 +1832,8 @@ class _StoreBaseInfoPageSimState extends State<StoreBaseInfoPageSim> { |
|
|
|
FocusScope.of(context).requestFocus(
|
|
|
|
FocusNode()); //点击空白处隐藏键盘
|
|
|
|
},
|
|
|
|
keyboardType: TextInputType.text,
|
|
|
|
keyboardType:
|
|
|
|
TextInputType.numberWithOptions(),
|
|
|
|
),
|
|
|
|
)),
|
|
|
|
HEmptyView(20),
|
|
...
|
...
|
@@ -1764,6 +1871,10 @@ class _StoreBaseInfoPageSimState extends State<StoreBaseInfoPageSim> { |
|
|
|
child: TextField(
|
|
|
|
controller: _phoneController2,
|
|
|
|
maxLines: 1,
|
|
|
|
inputFormatters: [
|
|
|
|
phoneInputFormatter(),
|
|
|
|
// LengthLimitingTextInputFormatter(14),
|
|
|
|
],
|
|
|
|
// inputFormatters: [
|
|
|
|
// LengthLimitingTextInputFormatter(
|
|
|
|
// 15),
|
|
...
|
...
|
@@ -1807,7 +1918,8 @@ class _StoreBaseInfoPageSimState extends State<StoreBaseInfoPageSim> { |
|
|
|
.requestFocus(
|
|
|
|
FocusNode()); //点击空白处隐藏键盘
|
|
|
|
},
|
|
|
|
keyboardType: TextInputType.text,
|
|
|
|
keyboardType: TextInputType
|
|
|
|
.numberWithOptions(),
|
|
|
|
),
|
|
|
|
)),
|
|
|
|
HEmptyView(20),
|
|
...
|
...
|
@@ -1924,9 +2036,10 @@ class _StoreBaseInfoPageSimState extends State<StoreBaseInfoPageSim> { |
|
|
|
Utils.getPickPermission(context,
|
|
|
|
() async {
|
|
|
|
Map? temp = await NavigatorUtil
|
|
|
|
.goMapChoicePointPage(context) ;
|
|
|
|
.goMapChoicePointPage(context);
|
|
|
|
if (temp != null) {
|
|
|
|
mapAddress = temp as Map<String, dynamic>?;
|
|
|
|
mapAddress =
|
|
|
|
temp as Map<String, dynamic>?;
|
|
|
|
setState(() {
|
|
|
|
// storeMapAddress = address['address'];
|
|
|
|
// // createStoreModel.storeInfo?.address = storeAddress;
|
|
...
|
...
|
@@ -2034,9 +2147,10 @@ class _StoreBaseInfoPageSimState extends State<StoreBaseInfoPageSim> { |
|
|
|
.toString(),
|
|
|
|
lat: mapAddress![
|
|
|
|
'lat']
|
|
|
|
.toString()) ;
|
|
|
|
.toString());
|
|
|
|
if (temp != null) {
|
|
|
|
mapAddress = temp as Map<String, dynamic>?;
|
|
|
|
mapAddress = temp as Map<
|
|
|
|
String, dynamic>?;
|
|
|
|
|
|
|
|
setState(() {
|
|
|
|
// storeMapAddress = address['address'];
|
...
|
...
|
|