|
|
|
// import 'dart:html';
|
|
|
|
|
|
|
|
// import 'dart:async';
|
|
|
|
// import 'dart:convert';
|
|
|
|
import 'dart:io';
|
|
|
|
|
|
|
|
import 'package:call_log/call_log.dart';
|
|
|
|
import 'package:easy_contact_picker/easy_contact_picker.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter/services.dart';
|
|
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
|
|
import 'package:one_key/provider/coupon_provider.dart';
|
|
|
|
import 'package:one_key/provider/marketing_center_provider.dart';
|
|
|
|
import 'package:one_key/provider/notebook_detail_model.dart';
|
|
|
|
import 'package:one_key/provider/user_model.dart';
|
|
|
|
import 'package:one_key/res/colors.dart';
|
|
|
|
import 'package:one_key/utils/dialog_util.dart';
|
|
|
|
import 'package:one_key/utils/event_bus.dart';
|
|
|
|
import 'package:one_key/utils/misc.dart';
|
|
|
|
import 'package:one_key/utils/utils.dart';
|
|
|
|
import 'package:one_key/widgets/h_empty_view.dart';
|
|
|
|
import 'package:one_key/widgets/round_button.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 '../../models/user_history_entity.dart';
|
|
|
|
import '../../utils/call_log_utils.dart';
|
|
|
|
import '../../utils/common_utils.dart';
|
|
|
|
import '../../utils/screen_util.dart';
|
|
|
|
import '../../widgets/MyDivider.dart';
|
|
|
|
import '../../widgets/special_text/my_extended_text_selection_controls.dart';
|
|
|
|
import 'package:flutter_picker/flutter_picker.dart' as Picker;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 填写预订联系人页面
|
|
|
|
*/
|
|
|
|
class EditReserverPageSim extends StatefulWidget {
|
|
|
|
final String rid;
|
|
|
|
final String name;
|
|
|
|
final String sex;
|
|
|
|
final bool needBtn;
|
|
|
|
final String mid;
|
|
|
|
EditReserverPageSim(this.rid, this.name, this.sex, this.mid,
|
|
|
|
{Key key, this.needBtn})
|
|
|
|
: super(key: key);
|
|
|
|
|
|
|
|
@override
|
|
|
|
_EditReserverPageSimState createState() => _EditReserverPageSimState();
|
|
|
|
}
|
|
|
|
|
|
|
|
class _EditReserverPageSimState extends State<EditReserverPageSim> {
|
|
|
|
NotebookDetailModel detailModel;
|
|
|
|
String nameStr;
|
|
|
|
FocusNode _nameNode = FocusNode();
|
|
|
|
FocusNode _phoneNode = FocusNode();
|
|
|
|
bool showPhoneHistory = false; //显示客户历史记录
|
|
|
|
EasyContactPicker _contactPicker = EasyContactPicker();
|
|
|
|
|
|
|
|
MyTextSelectionControls _myExtendedMaterialTextSelectionControls =
|
|
|
|
MyTextSelectionControls();
|
|
|
|
|
|
|
|
ScrollController _scrollCrl = ScrollController();
|
|
|
|
|
|
|
|
MarketingCenterProvider marketingCenterProvider;
|
|
|
|
|
|
|
|
@override
|
|
|
|
void initState() {
|
|
|
|
super.initState();
|
|
|
|
_myExtendedMaterialTextSelectionControls =
|
|
|
|
MyTextSelectionControls(callback: (value) {
|
|
|
|
// detailModel.phoneController.text = value;
|
|
|
|
detailModel.phoneController.value = TextEditingValue(
|
|
|
|
text: value,
|
|
|
|
selection: TextSelection.fromPosition(TextPosition(
|
|
|
|
affinity: TextAffinity.downstream,
|
|
|
|
offset: value.toString().length)));
|
|
|
|
});
|
|
|
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
|
|
|
if (widget.name != '' &&
|
|
|
|
widget.name != null &&
|
|
|
|
widget.sex != '' &&
|
|
|
|
widget.sex != null) {
|
|
|
|
nameStr = widget.name;
|
|
|
|
for (var item in detailModel.sexList) {
|
|
|
|
item['select'] = false;
|
|
|
|
if (item['code'] == widget.sex) {
|
|
|
|
item['select'] = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
_addNameSuffix(nameStr, _nameSuffix());
|
|
|
|
setState(() {});
|
|
|
|
}
|
|
|
|
getDzSellerConf();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
getDzSellerConf() async {
|
|
|
|
await marketingCenterProvider.getDzSellerConf(context);
|
|
|
|
}
|
|
|
|
|
|
|
|
_openAddressBook() async {
|
|
|
|
if (!(await checkContactPermission())) {
|
|
|
|
PermissionStatus permissionStatus = await contactPermissionStatus();
|
|
|
|
if (permissionStatus == PermissionStatus.permanentlyDenied) {
|
|
|
|
//用户选择不在弹出权限提示框
|
|
|
|
print('never');
|
|
|
|
DialogUtil.openAlertDialog(
|
|
|
|
context, '未获得通讯录权限', "请在手机的权限管理里,将通讯录权限开启", '去设置', 340.0,
|
|
|
|
onTap: () {
|
|
|
|
openSetting();
|
|
|
|
Navigator.pop(context, '');
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
// 申请权限
|
|
|
|
bool canContacts = await requestContactPermission();
|
|
|
|
if (canContacts) {
|
|
|
|
_getContactData();
|
|
|
|
} else {
|
|
|
|
//拒绝通讯录权限 , 苹果拒绝权限后,不再提示权限框,进入此处
|
|
|
|
DialogUtil.openAlertDialog(
|
|
|
|
context, '未获得通讯录权限', "请在手机的权限管理里,将通讯录权限开启。", '去设置', 340.0,
|
|
|
|
onTap: () {
|
|
|
|
openSetting();
|
|
|
|
Navigator.pop(context, '');
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
_getContactData();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//处理在线预订
|
|
|
|
setMessageStatus() {
|
|
|
|
bus.emit("remove_untreated_message", widget.mid);
|
|
|
|
bus.emit("refresh_untreated_num"); //刷新未读消息数目
|
|
|
|
Map<String, String> params = {
|
|
|
|
"sid": Provider.of<UserModel>(context, listen: false).user.sellerid,
|
|
|
|
"id": widget.mid,
|
|
|
|
"status": "is_handle"
|
|
|
|
};
|
|
|
|
detailModel.setMessageStatus(context, params);
|
|
|
|
}
|
|
|
|
|
|
|
|
_getContactData() async {
|
|
|
|
Contact contact = await _contactPicker.selectContactWithNative();
|
|
|
|
setState(() {
|
|
|
|
String fullName =
|
|
|
|
contact.fullName.replaceAll(new RegExp(r"\s+\b|\b\s"), "");
|
|
|
|
String phone =
|
|
|
|
contact.phoneNumber.replaceAll(new RegExp(r"\s+\b|\b\s"), "");
|
|
|
|
if (fullName.compareTo(phone) == 0) {
|
|
|
|
fullName = '';
|
|
|
|
} else {
|
|
|
|
fullName = contact.fullName;
|
|
|
|
}
|
|
|
|
detailModel.phoneController.text =
|
|
|
|
contact.phoneNumber.replaceAll(new RegExp(r"\s+"), "");
|
|
|
|
nameStr = fullName;
|
|
|
|
// _homeEnterModel.nameController.text = fullName + _nameSuffix();
|
|
|
|
_addNameSuffix(fullName, _nameSuffix());
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
_addNameSuffix(String name, String suffix) {
|
|
|
|
if (name == detailModel.nameController.text &&
|
|
|
|
detailModel.nameController.text.endsWith(suffix)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (name != '') {
|
|
|
|
detailModel.nameController.text = name + suffix ?? '';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//姓名后缀
|
|
|
|
_nameSuffix() {
|
|
|
|
for (var item in detailModel.sexList) {
|
|
|
|
if (item['select'] == true) {
|
|
|
|
return item['title'];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Widget _callButton(
|
|
|
|
{GestureTapCallback onPress,
|
|
|
|
content,
|
|
|
|
hasLeftBorder = true,
|
|
|
|
isSelect = false}) {
|
|
|
|
return InkWell(
|
|
|
|
onTap: onPress,
|
|
|
|
child: Container(
|
|
|
|
width: ScreenUtil().setWidth(84),
|
|
|
|
height: ScreenUtil().setHeight(48),
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
color: isSelect ? MyColours.color_199095 : MyColours.color_fefefe,
|
|
|
|
border: Border(
|
|
|
|
bottom: BorderSide(
|
|
|
|
color: MyColours.color_6AB6B9,
|
|
|
|
width: ScreenUtil().setWidth(2)),
|
|
|
|
top: BorderSide(
|
|
|
|
color: MyColours.color_6AB6B9,
|
|
|
|
width: ScreenUtil().setWidth(2)),
|
|
|
|
left: hasLeftBorder
|
|
|
|
? BorderSide(
|
|
|
|
color: MyColours.color_6AB6B9,
|
|
|
|
width: ScreenUtil().setWidth(2))
|
|
|
|
: BorderSide.none,
|
|
|
|
right: BorderSide(
|
|
|
|
color: MyColours.color_6AB6B9,
|
|
|
|
width: ScreenUtil().setWidth(2)))),
|
|
|
|
child: Align(
|
|
|
|
alignment: Alignment.center,
|
|
|
|
child: Text(
|
|
|
|
content,
|
|
|
|
style: TextStyle(
|
|
|
|
color: isSelect ? Colors.white : MyColours.color_353535,
|
|
|
|
fontSize: ScreenUtil().setSp(28)),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
_getCallLog() async {
|
|
|
|
List<Picker.PickerItem<dynamic>> data = [];
|
|
|
|
|
|
|
|
Iterable<CallLogEntry> result = await CallLogUtils.getCallLog(context);
|
|
|
|
if (result != null) {
|
|
|
|
detailModel.userHistorys = [];
|
|
|
|
|
|
|
|
List<CallLogEntry> object = Utils.removeDuplicates(result.toList());
|
|
|
|
|
|
|
|
detailModel.userHistorys = [];
|
|
|
|
showPhoneHistory = false;
|
|
|
|
// setState(() {});
|
|
|
|
|
|
|
|
object.forEach((element) {
|
|
|
|
detailModel.userHistorys.add(UserHistoryEntity(
|
|
|
|
'', '', element.name ?? '', '1', element.number, '', '', ''));
|
|
|
|
|
|
|
|
String title = '';
|
|
|
|
title += ' ${element.number ?? ''}';
|
|
|
|
if (element.name != null && element.name != '') {
|
|
|
|
title += ' ${element.name}';
|
|
|
|
}
|
|
|
|
|
|
|
|
String stateStr = ''; //状态
|
|
|
|
|
|
|
|
if (element.callType.name == 'incoming' ||
|
|
|
|
element.callType.name == 'wifiIncoming' ||
|
|
|
|
element.callType.name == 'answeredExternally') {
|
|
|
|
stateStr = ' 呼入';
|
|
|
|
} else if (element.callType.name == 'outgoing' ||
|
|
|
|
element.callType.name == 'wifiOutgoing' ||
|
|
|
|
element.callType.name == 'voiceMail') {
|
|
|
|
stateStr = ' 呼出';
|
|
|
|
} else if (element.callType.name == 'missed') {
|
|
|
|
stateStr = ' 未接';
|
|
|
|
} else if (element.callType.name == 'rejected') {
|
|
|
|
stateStr = ' 拒接';
|
|
|
|
} else if (element.callType.name == 'blocked') {
|
|
|
|
stateStr = ' 拦截';
|
|
|
|
}
|
|
|
|
|
|
|
|
String sunString =
|
|
|
|
Utils.formatCallLogFromMill(element.timestamp.toString());
|
|
|
|
|
|
|
|
data.add(Picker.PickerItem(
|
|
|
|
text: Row(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
children: [
|
|
|
|
Expanded(
|
|
|
|
child: Row(
|
|
|
|
children: [
|
|
|
|
HEmptyView(30),
|
|
|
|
Text(title ?? '',
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: font(16), color: MyColours.color_515151)),
|
|
|
|
Expanded(
|
|
|
|
child: Text(stateStr ?? '',
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: font(16),
|
|
|
|
color: MyColours.color_26000000))),
|
|
|
|
],
|
|
|
|
)),
|
|
|
|
Container(
|
|
|
|
margin: EdgeInsets.only(right: w(15)),
|
|
|
|
child: Text(sunString ?? '',
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: font(16), color: MyColours.color_515151)))
|
|
|
|
],
|
|
|
|
)));
|
|
|
|
});
|
|
|
|
if (data.length > 0) {
|
|
|
|
//有记录,底部弹窗展示
|
|
|
|
// showPhoneHistory = true;
|
|
|
|
// setState(() {});
|
|
|
|
DialogUtil.showSelectCusmanWidgetDialog(context, data, (value) {
|
|
|
|
if (value != null) {
|
|
|
|
_byValueToReqeust(value[0]);
|
|
|
|
}
|
|
|
|
}, title: '从通话记录选择客人电话', selecteds: [
|
|
|
|
// _getFirSelected(hourAndMinute, data),
|
|
|
|
// _getSecSelected(hourAndMinute)
|
|
|
|
]).then((value) {
|
|
|
|
print(value);
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
Utils.showToast('暂无通话记录!');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
_byValueToReqeust(int index) {
|
|
|
|
setState(() {
|
|
|
|
showPhoneHistory = false;
|
|
|
|
UserHistoryEntity userHistoryEntity = detailModel.userHistorys[index];
|
|
|
|
detailModel.phoneController.text =
|
|
|
|
userHistoryEntity.phone != null ? userHistoryEntity.phone : '';
|
|
|
|
for (var item in detailModel.sexList) {
|
|
|
|
item['select'] = false;
|
|
|
|
if (item['title'] == userHistoryEntity.sexStr) {
|
|
|
|
item['select'] = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((nameStr != null && nameStr != '') &&
|
|
|
|
(userHistoryEntity.rname == '' || userHistoryEntity.rname == null)) {
|
|
|
|
} else {
|
|
|
|
nameStr = userHistoryEntity.rname;
|
|
|
|
}
|
|
|
|
|
|
|
|
_addNameSuffix(userHistoryEntity.rname, _nameSuffix());
|
|
|
|
|
|
|
|
_phoneNode.unfocus();
|
|
|
|
detailModel.userHistorys.clear();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
marketingCenterProvider =
|
|
|
|
Provider.of<MarketingCenterProvider>(context, listen: true);
|
|
|
|
detailModel = Provider.of<NotebookDetailModel>(context, listen: true);
|
|
|
|
return Scaffold(
|
|
|
|
backgroundColor: MyColours.color_ffffff,
|
|
|
|
appBar: SystemAppBar(
|
|
|
|
'录入预订人信息',
|
|
|
|
onTap: () {
|
|
|
|
Navigator.pop(context);
|
|
|
|
},
|
|
|
|
),
|
|
|
|
body: Container(
|
|
|
|
color: MyColours.color_ffffff,
|
|
|
|
// color: Colors.red,
|
|
|
|
child: InkWell(
|
|
|
|
onTap: () {
|
|
|
|
FocusScope.of(context).requestFocus(FocusNode()); //点击空白处隐藏键盘
|
|
|
|
if (showPhoneHistory) {
|
|
|
|
setState(() {
|
|
|
|
showPhoneHistory = false;
|
|
|
|
detailModel.userHistorys.clear();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
},
|
|
|
|
child: Padding(
|
|
|
|
padding: EdgeInsets.symmetric(
|
|
|
|
horizontal: ScreenUtil().setWidth(40)),
|
|
|
|
child: Column(children: [
|
|
|
|
//第一行 顾客姓名
|
|
|
|
|
|
|
|
VEmptyView(40),
|
|
|
|
|
|
|
|
Column(
|
|
|
|
children: [
|
|
|
|
Row(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
|
children: [
|
|
|
|
Expanded(
|
|
|
|
child: Container(
|
|
|
|
height: ScreenUtil().setWidth(60),
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
border: Border(
|
|
|
|
bottom: BorderSide(
|
|
|
|
width: ScreenUtil().setWidth(2),
|
|
|
|
color: MyColours.color_efefef))),
|
|
|
|
child: TextField(
|
|
|
|
maxLines: 1,
|
|
|
|
|
|
|
|
//输入文本的样式
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: ScreenUtil().setSp(30),
|
|
|
|
color: MyColours.color_353535),
|
|
|
|
controller: detailModel.nameController,
|
|
|
|
focusNode: _nameNode,
|
|
|
|
// textAlignVertical: TextAlignVertical.top,
|
|
|
|
decoration: InputDecoration(
|
|
|
|
hintText: "客人姓名",
|
|
|
|
hintStyle: TextStyle(
|
|
|
|
color: MyColours.color_999999,
|
|
|
|
fontSize: ScreenUtil().setSp(30),
|
|
|
|
),
|
|
|
|
// contentPadding:
|
|
|
|
// EdgeInsets.only(bottom: ScreenUtil().setWidth(17)),
|
|
|
|
// border: InputBorder.none,
|
|
|
|
contentPadding: EdgeInsets.zero,
|
|
|
|
border: OutlineInputBorder(
|
|
|
|
borderSide: BorderSide.none),
|
|
|
|
),
|
|
|
|
onChanged: (value) {
|
|
|
|
print('ggg');
|
|
|
|
if (value.endsWith('先生') ||
|
|
|
|
value.endsWith('女士') ||
|
|
|
|
value.endsWith('公司')) {
|
|
|
|
nameStr = value.substring(
|
|
|
|
0, value.length - 2);
|
|
|
|
} else {
|
|
|
|
nameStr = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (detailModel.phoneController.text
|
|
|
|
.length ==
|
|
|
|
0 &&
|
|
|
|
value.length > 0) {
|
|
|
|
if (marketingCenterProvider.nameSwich) {
|
|
|
|
detailModel.userHistorys = [];
|
|
|
|
setState(() {
|
|
|
|
showPhoneHistory = true;
|
|
|
|
});
|
|
|
|
Map<String, String> params = {
|
|
|
|
"keywords": value,
|
|
|
|
"sid": Provider.of<UserModel>(
|
|
|
|
context,
|
|
|
|
listen: false)
|
|
|
|
.user
|
|
|
|
.sellerid,
|
|
|
|
};
|
|
|
|
JhCommonUtils.debounce(() =>
|
|
|
|
detailModel.getUserHistorys(
|
|
|
|
context, params));
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
setState(() {
|
|
|
|
showPhoneHistory = false;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
},
|
|
|
|
onEditingComplete: () {
|
|
|
|
print('fff');
|
|
|
|
_nameNode.unfocus();
|
|
|
|
// _homeEnterModel.nameController.text =
|
|
|
|
// nameStr + _nameSuffix();
|
|
|
|
_addNameSuffix(nameStr, _nameSuffix());
|
|
|
|
},
|
|
|
|
keyboardType: TextInputType.text,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
// HEmptyView(40),
|
|
|
|
Row(
|
|
|
|
children: detailModel.sexList.map((value) {
|
|
|
|
return _callButton(
|
|
|
|
onPress: () {
|
|
|
|
for (var item in detailModel.sexList) {
|
|
|
|
item['select'] = false;
|
|
|
|
if (item['title'] == value['title']) {
|
|
|
|
item['select'] = true;
|
|
|
|
// _homeEnterModel.nameController.text =
|
|
|
|
// nameStr + item['title'];
|
|
|
|
if (nameStr != null &&
|
|
|
|
nameStr != '') {
|
|
|
|
_addNameSuffix(
|
|
|
|
nameStr, item['title']);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
detailModel.notifyListeners();
|
|
|
|
},
|
|
|
|
content: value['title'],
|
|
|
|
hasLeftBorder: value['hasLeftBorder'],
|
|
|
|
isSelect: value['select']);
|
|
|
|
}).toList()),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
// VEmptyView(30),
|
|
|
|
// MyDivider(double.infinity,
|
|
|
|
// ScreenUtil().setWidth(2),
|
|
|
|
// color:
|
|
|
|
// MyColours.color_efefef),
|
|
|
|
//电话
|
|
|
|
VEmptyView(20),
|
|
|
|
|
|
|
|
Row(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
|
children: [
|
|
|
|
Expanded(
|
|
|
|
child: Container(
|
|
|
|
height: ScreenUtil().setWidth(60),
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
// color: Colors.red,
|
|
|
|
border: Border(
|
|
|
|
bottom: BorderSide(
|
|
|
|
width: ScreenUtil().setWidth(2),
|
|
|
|
color:
|
|
|
|
MyColours.color_efefef))),
|
|
|
|
child: TextField(
|
|
|
|
selectionControls:
|
|
|
|
_myExtendedMaterialTextSelectionControls,
|
|
|
|
maxLines: 1,
|
|
|
|
//输入文本的样式
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: ScreenUtil().setSp(30),
|
|
|
|
color: MyColours.color_353535),
|
|
|
|
controller: detailModel.phoneController,
|
|
|
|
focusNode: _phoneNode,
|
|
|
|
// textAlignVertical: TextAlignVertical.top,
|
|
|
|
inputFormatters: <TextInputFormatter>[
|
|
|
|
LengthLimitingTextInputFormatter(
|
|
|
|
11) //限制长度
|
|
|
|
],
|
|
|
|
decoration: InputDecoration(
|
|
|
|
hintText: "电话",
|
|
|
|
hintStyle: TextStyle(
|
|
|
|
color: MyColours.color_999999,
|
|
|
|
fontSize: ScreenUtil().setSp(30),
|
|
|
|
),
|
|
|
|
contentPadding: EdgeInsets.zero,
|
|
|
|
border: OutlineInputBorder(
|
|
|
|
borderSide: BorderSide.none),
|
|
|
|
),
|
|
|
|
onChanged: (value) {
|
|
|
|
if (value.isEmpty ||
|
|
|
|
value.length > 11) {
|
|
|
|
//内容为空,或 超过11位
|
|
|
|
setState(() {
|
|
|
|
detailModel.userHistorys.clear();
|
|
|
|
});
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (value.isEmpty || value.length > 0) {
|
|
|
|
if (marketingCenterProvider
|
|
|
|
.phoneSwich) {
|
|
|
|
detailModel.userHistorys = [];
|
|
|
|
setState(() {
|
|
|
|
showPhoneHistory = true;
|
|
|
|
});
|
|
|
|
Map<String, String> params = {
|
|
|
|
"keywords": value,
|
|
|
|
"sid": Provider.of<UserModel>(
|
|
|
|
context,
|
|
|
|
listen: false)
|
|
|
|
.user
|
|
|
|
.sellerid,
|
|
|
|
};
|
|
|
|
JhCommonUtils.debounce(() =>
|
|
|
|
detailModel.getUserHistorys(
|
|
|
|
context, params));
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
setState(() {
|
|
|
|
showPhoneHistory = false;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
},
|
|
|
|
onEditingComplete: () {
|
|
|
|
_phoneNode.unfocus();
|
|
|
|
},
|
|
|
|
onTap: () {
|
|
|
|
// setState(() {
|
|
|
|
// showPhoneHistory = true;
|
|
|
|
// });
|
|
|
|
// Future.delayed(Duration(milliseconds: 300), () {
|
|
|
|
// _controller.jumpTo(_controller.position.maxScrollExtent);
|
|
|
|
// });
|
|
|
|
},
|
|
|
|
keyboardType:
|
|
|
|
TextInputType.numberWithOptions(
|
|
|
|
decimal: true),
|
|
|
|
)),
|
|
|
|
),
|
|
|
|
// InkWell(
|
|
|
|
// onTap: () {
|
|
|
|
// _openAddressBook();
|
|
|
|
// },
|
|
|
|
// child: Container(
|
|
|
|
// width: ScreenUtil().setWidth(84) * 3,
|
|
|
|
// height: ScreenUtil().setWidth(48),
|
|
|
|
// alignment: Alignment.centerRight,
|
|
|
|
// child: Text('电话簿',
|
|
|
|
// style: TextStyle(
|
|
|
|
// color: MyColours.color_199095,
|
|
|
|
// fontSize: ScreenUtil().setSp(28),
|
|
|
|
// decoration:
|
|
|
|
// TextDecoration.underline)),
|
|
|
|
// ),
|
|
|
|
// ),
|
|
|
|
InkWell(
|
|
|
|
onTap: () async {
|
|
|
|
_openAddressBook();
|
|
|
|
// var result = await CallLogUtil.getCallLog();
|
|
|
|
// print(result);
|
|
|
|
},
|
|
|
|
child: Container(
|
|
|
|
// color: Colors.red,
|
|
|
|
width: ScreenUtil().setWidth(64) * 2,
|
|
|
|
height: ScreenUtil().setWidth(48),
|
|
|
|
alignment: Alignment.centerRight,
|
|
|
|
child: Text('电话簿',
|
|
|
|
style: TextStyle(
|
|
|
|
color: MyColours.color_199095,
|
|
|
|
fontSize: ScreenUtil().setSp(28),
|
|
|
|
decoration:
|
|
|
|
TextDecoration.underline)),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
|
|
|
if (Platform.isAndroid)
|
|
|
|
Row(
|
|
|
|
children: [
|
|
|
|
HEmptyView(20),
|
|
|
|
MyDivider(1.0, ScreenUtil().setWidth(40)),
|
|
|
|
HEmptyView(20),
|
|
|
|
InkWell(
|
|
|
|
onTap: () async {
|
|
|
|
_getCallLog();
|
|
|
|
},
|
|
|
|
child: Container(
|
|
|
|
// color: Colors.red,
|
|
|
|
// width: ScreenUtil().setWidth(64) * 2,
|
|
|
|
height: ScreenUtil().setWidth(48),
|
|
|
|
alignment: Alignment.centerLeft,
|
|
|
|
child: Text('通话记录',
|
|
|
|
style: TextStyle(
|
|
|
|
color: MyColours.color_199095,
|
|
|
|
fontSize:
|
|
|
|
ScreenUtil().setSp(28),
|
|
|
|
decoration:
|
|
|
|
TextDecoration.underline)),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
)
|
|
|
|
],
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
VEmptyView(60),
|
|
|
|
Stack(
|
|
|
|
children: [
|
|
|
|
Padding(
|
|
|
|
padding: EdgeInsets.only(
|
|
|
|
top: ScreenUtil().setWidth(60)),
|
|
|
|
child: Row(
|
|
|
|
mainAxisAlignment:
|
|
|
|
MainAxisAlignment.spaceEvenly,
|
|
|
|
children: [
|
|
|
|
RoundButton(
|
|
|
|
text: '返回',
|
|
|
|
fontSize: 28,
|
|
|
|
isBold: false,
|
|
|
|
height: ScreenUtil().setWidth(70),
|
|
|
|
width: ScreenUtil().setWidth(180),
|
|
|
|
radius: ScreenUtil().setWidth(10),
|
|
|
|
gradientStart: MyColours.color_ffffff,
|
|
|
|
textColor: MyColours.color_333333,
|
|
|
|
borderColor: MyColours.color_199095,
|
|
|
|
gradientEnd: MyColours.color_ffffff,
|
|
|
|
onPressed: () {
|
|
|
|
// setState(() {
|
|
|
|
// nameStr = '';
|
|
|
|
// detailModel.nameController.text = '';
|
|
|
|
// detailModel.phoneController.text = '';
|
|
|
|
// });
|
|
|
|
Navigator.of(context).pop();
|
|
|
|
},
|
|
|
|
),
|
|
|
|
widget.needBtn
|
|
|
|
? RoundButton(
|
|
|
|
text: '保存并发短信',
|
|
|
|
fontSize: 28,
|
|
|
|
isBold: false,
|
|
|
|
height: ScreenUtil().setWidth(70),
|
|
|
|
width: ScreenUtil().setWidth(200),
|
|
|
|
radius: ScreenUtil().setWidth(10),
|
|
|
|
gradientStart: MyColours.color_199095,
|
|
|
|
textColor: MyColours.color_ffffff,
|
|
|
|
borderColor: MyColours.color_199095,
|
|
|
|
gradientEnd: MyColours.color_199095,
|
|
|
|
onPressed: () async {
|
|
|
|
if (nameStr == null ||
|
|
|
|
nameStr.trim().length == 0) {
|
|
|
|
Utils.showToast('请填写客人姓名');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (detailModel.phoneController.text
|
|
|
|
.trim()
|
|
|
|
.length ==
|
|
|
|
0) {
|
|
|
|
Utils.showToast('请填写电话');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (!Utils.isInteger(detailModel
|
|
|
|
.phoneController.text
|
|
|
|
.replaceAll(' ', ''))) {
|
|
|
|
Utils.showToast('手机号错误,请修改正确');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
String sex = '1';
|
|
|
|
for (var item
|
|
|
|
in detailModel.sexList) {
|
|
|
|
if (item['select']) {
|
|
|
|
sex = item['code'];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
bool sucess =
|
|
|
|
await detailModel.upReserveInfo(
|
|
|
|
context, widget.rid,
|
|
|
|
name: nameStr,
|
|
|
|
sex: sex,
|
|
|
|
phone: detailModel
|
|
|
|
.phoneController.text
|
|
|
|
.replaceAll(' ', ''),
|
|
|
|
showLoading: true);
|
|
|
|
if (sucess) {
|
|
|
|
bus.emit(
|
|
|
|
"refresh_tablemanager"); //刷新桌位
|
|
|
|
bus.emit(
|
|
|
|
"refresh_book_list"); //刷新已预订列表
|
|
|
|
bus.emit("refresh_detail");
|
|
|
|
UserModel userModel =
|
|
|
|
Provider.of<UserModel>(
|
|
|
|
context,
|
|
|
|
listen: false);
|
|
|
|
Map<String, String> params = {
|
|
|
|
"rid": widget.rid,
|
|
|
|
"sid": userModel.user.sellerid
|
|
|
|
};
|
|
|
|
CouponProvider couponProvider =
|
|
|
|
Provider.of<CouponProvider>(
|
|
|
|
context,
|
|
|
|
listen: false);
|
|
|
|
bool success =
|
|
|
|
await couponProvider
|
|
|
|
.sendSMSWxSendSms(
|
|
|
|
context, params);
|
|
|
|
print(success);
|
|
|
|
if (success) {
|
|
|
|
Navigator.of(context).pop(
|
|
|
|
detailModel
|
|
|
|
.phoneController.text);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
)
|
|
|
|
: SizedBox(),
|
|
|
|
RoundButton(
|
|
|
|
text: widget.needBtn ? '仅保存' : '保存',
|
|
|
|
fontSize: 28,
|
|
|
|
isBold: false,
|
|
|
|
height: ScreenUtil().setWidth(70),
|
|
|
|
width: ScreenUtil().setWidth(180),
|
|
|
|
radius: ScreenUtil().setWidth(10),
|
|
|
|
gradientStart: widget.needBtn
|
|
|
|
? MyColours.color_ffffff
|
|
|
|
: MyColours.color_199095,
|
|
|
|
gradientEnd: widget.needBtn
|
|
|
|
? MyColours.color_ffffff
|
|
|
|
: MyColours.color_199095,
|
|
|
|
textColor: widget.needBtn
|
|
|
|
? MyColours.color_333333
|
|
|
|
: MyColours.color_ffffff,
|
|
|
|
borderColor: MyColours.color_199095,
|
|
|
|
onPressed: () async {
|
|
|
|
if (nameStr == null ||
|
|
|
|
nameStr.trim().length == 0) {
|
|
|
|
Utils.showToast('请填写客人姓名');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (detailModel.phoneController.text
|
|
|
|
.trim()
|
|
|
|
.length >
|
|
|
|
0) {
|
|
|
|
if (!Utils.isInteger(detailModel
|
|
|
|
.phoneController.text
|
|
|
|
.replaceAll(' ', ''))) {
|
|
|
|
Utils.showToast('手机号错误,请修改正确');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
String sex = '1';
|
|
|
|
for (var item in detailModel.sexList) {
|
|
|
|
if (item['select']) {
|
|
|
|
sex = item['code'];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
bool sucess = await detailModel
|
|
|
|
.upReserveInfo(context, widget.rid,
|
|
|
|
name: nameStr,
|
|
|
|
sex: sex,
|
|
|
|
phone: detailModel
|
|
|
|
.phoneController.text
|
|
|
|
.replaceAll(' ', ''));
|
|
|
|
if (sucess) {
|
|
|
|
if (widget.mid != '' &&
|
|
|
|
widget.mid != null) {
|
|
|
|
setMessageStatus();
|
|
|
|
}
|
|
|
|
EventBus().emit(
|
|
|
|
"refresh_tablemanager"); //刷新桌位
|
|
|
|
bus.emit("refresh_book_list"); //刷新已预订列表
|
|
|
|
bus.emit("refresh_detail");
|
|
|
|
|
|
|
|
Navigator.of(context).pop(
|
|
|
|
detailModel.phoneController.text);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
)
|
|
|
|
],
|
|
|
|
)),
|
|
|
|
Offstage(
|
|
|
|
offstage: !(showPhoneHistory &&
|
|
|
|
detailModel.userHistorys.length > 0),
|
|
|
|
child: Container(
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
borderRadius: BorderRadius.circular(8),
|
|
|
|
border: Border.all(color: Colors.white),
|
|
|
|
color: MyColours.color_ffffff,
|
|
|
|
boxShadow: [
|
|
|
|
BoxShadow(
|
|
|
|
color: MyColours.color_e5e5e5,
|
|
|
|
blurRadius: ScreenUtil().setWidth(20))
|
|
|
|
]),
|
|
|
|
width: ScreenUtil().screenWidth - w(60),
|
|
|
|
// width: ScreenUtil().setWidth(350),
|
|
|
|
constraints: BoxConstraints(maxHeight: w(270)),
|
|
|
|
// width: ScreenUtil().setWidth(440),
|
|
|
|
// height: detailModel.userHistorys.length > 1
|
|
|
|
// ? ScreenUtil().setWidth(260)
|
|
|
|
// : ScreenUtil().setWidth(104),
|
|
|
|
padding: EdgeInsets.symmetric(
|
|
|
|
horizontal: ScreenUtil().setWidth(30)),
|
|
|
|
child: Align(
|
|
|
|
alignment: Alignment.topCenter,
|
|
|
|
child: MediaQuery.removePadding(
|
|
|
|
context: context,
|
|
|
|
removeTop: true,
|
|
|
|
child: Scrollbar(
|
|
|
|
isAlwaysShown: true, //设置滚动条常亮
|
|
|
|
controller:
|
|
|
|
_scrollCrl, //必须设置一个controller
|
|
|
|
|
|
|
|
///添加进度条
|
|
|
|
child: ListView.builder(
|
|
|
|
shrinkWrap: true,
|
|
|
|
controller: _scrollCrl,
|
|
|
|
itemBuilder: (context, index) {
|
|
|
|
return GestureDetector(
|
|
|
|
onTap: () {
|
|
|
|
_byValueToReqeust(index);
|
|
|
|
// setState(() {
|
|
|
|
// showPhoneHistory = false;
|
|
|
|
// UserHistoryEntity
|
|
|
|
// userHistoryEntity =
|
|
|
|
// detailModel
|
|
|
|
// .userHistorys[
|
|
|
|
// index];
|
|
|
|
// if (userHistoryEntity.sex ==
|
|
|
|
// null ||
|
|
|
|
// userHistoryEntity.sex ==
|
|
|
|
// '') {
|
|
|
|
// userHistoryEntity.sex =
|
|
|
|
// '1';
|
|
|
|
// }
|
|
|
|
// detailModel.phoneController
|
|
|
|
// .text =
|
|
|
|
// userHistoryEntity
|
|
|
|
// .phone !=
|
|
|
|
// null
|
|
|
|
// ? userHistoryEntity
|
|
|
|
// .phone
|
|
|
|
// : '';
|
|
|
|
// for (var item in detailModel
|
|
|
|
// .sexList) {
|
|
|
|
// item['select'] = false;
|
|
|
|
// if (item['title'] ==
|
|
|
|
// userHistoryEntity
|
|
|
|
// .sexStr) {
|
|
|
|
// item['select'] = true;
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// // _homeEnterModel.nameController.text =
|
|
|
|
// // _homeEnterModel
|
|
|
|
// // .userHistorys[index].rname +
|
|
|
|
// // _nameSuffix();
|
|
|
|
// _addNameSuffix(
|
|
|
|
// userHistoryEntity.rname,
|
|
|
|
// _nameSuffix());
|
|
|
|
// nameStr =
|
|
|
|
// userHistoryEntity.rname;
|
|
|
|
// _phoneNode.unfocus();
|
|
|
|
// detailModel.userHistorys
|
|
|
|
// .clear();
|
|
|
|
// });
|
|
|
|
},
|
|
|
|
child: Container(
|
|
|
|
width: double.infinity,
|
|
|
|
height: ScreenUtil()
|
|
|
|
.setWidth(102),
|
|
|
|
alignment: Alignment.center,
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
border: Border(
|
|
|
|
bottom: (index !=
|
|
|
|
(detailModel
|
|
|
|
.userHistorys
|
|
|
|
.length -
|
|
|
|
1) &&
|
|
|
|
detailModel
|
|
|
|
.userHistorys
|
|
|
|
.length >
|
|
|
|
1)
|
|
|
|
? BorderSide(
|
|
|
|
color: MyColours
|
|
|
|
.color_e5e5e5,
|
|
|
|
width: ScreenUtil()
|
|
|
|
.setWidth(
|
|
|
|
2))
|
|
|
|
: BorderSide
|
|
|
|
.none)),
|
|
|
|
child: Align(
|
|
|
|
alignment:
|
|
|
|
Alignment.centerLeft,
|
|
|
|
child: Text(
|
|
|
|
(_nameNode.hasFocus
|
|
|
|
? (detailModel
|
|
|
|
.userHistorys[
|
|
|
|
index]
|
|
|
|
.rnameStr ==
|
|
|
|
null
|
|
|
|
? ''
|
|
|
|
: detailModel
|
|
|
|
.userHistorys[
|
|
|
|
index]
|
|
|
|
.rnameStr)
|
|
|
|
: (detailModel
|
|
|
|
.userHistorys[
|
|
|
|
index]
|
|
|
|
.phone ==
|
|
|
|
null
|
|
|
|
? ''
|
|
|
|
: detailModel
|
|
|
|
.userHistorys[
|
|
|
|
index]
|
|
|
|
.phone)) +
|
|
|
|
' ' +
|
|
|
|
(_nameNode.hasFocus
|
|
|
|
? (detailModel
|
|
|
|
.userHistorys[
|
|
|
|
index]
|
|
|
|
.phone ==
|
|
|
|
null
|
|
|
|
? ''
|
|
|
|
: detailModel
|
|
|
|
.userHistorys[
|
|
|
|
index]
|
|
|
|
.phone)
|
|
|
|
: (detailModel
|
|
|
|
.userHistorys[
|
|
|
|
index]
|
|
|
|
.rnameStr ==
|
|
|
|
null
|
|
|
|
? ''
|
|
|
|
: detailModel
|
|
|
|
.userHistorys[
|
|
|
|
index]
|
|
|
|
.rnameStr)) +
|
|
|
|
' ' +
|
|
|
|
detailModel
|
|
|
|
.userHistorys[
|
|
|
|
index]
|
|
|
|
.nickName,
|
|
|
|
style: TextStyle(
|
|
|
|
color: MyColours
|
|
|
|
.color_333333,
|
|
|
|
fontSize:
|
|
|
|
ScreenUtil()
|
|
|
|
.setSp(32)),
|
|
|
|
)),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
},
|
|
|
|
itemExtent:
|
|
|
|
ScreenUtil().setWidth(104),
|
|
|
|
itemCount:
|
|
|
|
detailModel.userHistorys.length,
|
|
|
|
)))),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
])))));
|
|
|
|
}
|
|
|
|
} |
...
|
...
|
|