|
|
|
import 'dart:ui';
|
|
|
|
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
|
|
import 'package:one_key/provider/user_model.dart';
|
|
|
|
import 'package:one_key/widgets/system_app_bar.dart';
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
|
|
|
|
import '../../../provider/customer_provider.dart';
|
|
|
|
import '../../../res/colors.dart';
|
|
|
|
import '../../../route/navigator_util.dart';
|
|
|
|
import '../../../utils/dialog_util.dart';
|
|
|
|
import '../../../utils/event_bus.dart';
|
|
|
|
import '../../../utils/screen_util.dart';
|
|
|
|
import '../../../utils/utils.dart';
|
|
|
|
import '../../../widgets/h_empty_view.dart';
|
|
|
|
import '../../../widgets/round_button.dart';
|
|
|
|
import '../../../widgets/v_empty_view.dart';
|
|
|
|
|
|
|
|
typedef ClickCallback = void Function(dynamic value);
|
|
|
|
|
|
|
|
class WineSettingMsgPage extends StatefulWidget {
|
|
|
|
const WineSettingMsgPage();
|
|
...
|
...
|
@@ -13,28 +27,142 @@ class WineSettingMsgPage extends StatefulWidget { |
|
|
|
}
|
|
|
|
|
|
|
|
class _WineSettingMsgPageState extends State<WineSettingMsgPage> {
|
|
|
|
String contentChangeStart = '尊敬的@var(clientname),您好!您的酒水@var(beveragename)已经在我店存放@var(days)了。点击这里编辑您的短信内容。上面的文字时固定不可编辑的。';
|
|
|
|
TextEditingController controller = TextEditingController();
|
|
|
|
|
|
|
|
|
|
|
|
String contentChangeStart =
|
|
|
|
'尊敬的@var(clientname),您好!您的酒水@var(beveragename)已经在我店存放@var(days)了。';
|
|
|
|
TextEditingController controller = TextEditingController();
|
|
|
|
|
|
|
|
CustomerProvider customerProvider;
|
|
|
|
List<String> couponList = [];
|
|
|
|
bool isUse = false;
|
|
|
|
String youhui = '选择优惠';
|
|
|
|
int couponSelectIndex = 0;
|
|
|
|
|
|
|
|
@override
|
|
|
|
void initState() {
|
|
|
|
super.initState();
|
|
|
|
WidgetsBinding.instance.addPostFrameCallback((_) async {
|
|
|
|
_couponNetworkData();
|
|
|
|
});
|
|
|
|
bus.on('refresh_wine_msg', (arg) {
|
|
|
|
_couponNetworkData();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
void dispose() {
|
|
|
|
super.dispose();
|
|
|
|
bus.off('refresh_wine_msg');
|
|
|
|
}
|
|
|
|
|
|
|
|
///消费券
|
|
|
|
_couponNetworkData({bool isShowLoading = true}) async {
|
|
|
|
// customerMakingProvider.couponSelectIndex = 0;
|
|
|
|
Map<String, String> params = {
|
|
|
|
"uid": Provider.of<UserModel>(context, listen: false).user.openid,
|
|
|
|
'status': '1'
|
|
|
|
};
|
|
|
|
await customerProvider.getCustomerSelectActivityNew(context, params,
|
|
|
|
isShowLoading: isShowLoading);
|
|
|
|
//此人已经新建好券
|
|
|
|
if (customerProvider.couponListSelect.length > 0) {
|
|
|
|
// couponProvider.initCouponSelect(context);
|
|
|
|
couponList = [];
|
|
|
|
for (int i = 0; i < customerProvider.couponListSelect.length; i++) {
|
|
|
|
couponList.add(customerProvider.couponListSelect[i].aname);
|
|
|
|
}
|
|
|
|
customerProvider.notifyListeners();
|
|
|
|
} else {
|
|
|
|
//没有新建的优惠券
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
_buttonChoose(String title, ClickCallback callback) {
|
|
|
|
return InkWell(
|
|
|
|
onTap: () {
|
|
|
|
callback(title);
|
|
|
|
},
|
|
|
|
child: Padding(
|
|
|
|
padding: EdgeInsets.symmetric(
|
|
|
|
horizontal: ScreenUtil().setWidth(20),
|
|
|
|
vertical: ScreenUtil().setWidth(10)),
|
|
|
|
// height: ScreenUtil().setWidth(50),
|
|
|
|
// decoration: BoxDecoration(
|
|
|
|
// // border: Border.all(
|
|
|
|
// // width: ScreenUtil().setWidth(2),
|
|
|
|
// // color: MyColours.color_199095),
|
|
|
|
// borderRadius: BorderRadius.circular(ScreenUtil().setWidth(10))),
|
|
|
|
child: Row(
|
|
|
|
children: [
|
|
|
|
Expanded(
|
|
|
|
child: Text(
|
|
|
|
title,
|
|
|
|
textAlign: TextAlign.right,
|
|
|
|
overflow: TextOverflow.ellipsis,
|
|
|
|
style: TextStyle(
|
|
|
|
color: title == '时间(选填)' ||
|
|
|
|
title == '(选填)' ||
|
|
|
|
title == '选择优惠' ||
|
|
|
|
!isUse
|
|
|
|
? MyColours.color_999999
|
|
|
|
: MyColours.color_438E93,
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
fontSize: ScreenUtil().setWidth(30)),
|
|
|
|
)),
|
|
|
|
HEmptyView(20),
|
|
|
|
Image.asset(
|
|
|
|
// Utils.getImgPath(!customerMakingProvider.isUse
|
|
|
|
// ? 'c_arrow_down_unsel'
|
|
|
|
// : 'c_arrow_down'),
|
|
|
|
Utils.getImgPath(isUse ? 'down_c' : 'quan_down_f'),
|
|
|
|
width: ScreenUtil().setWidth(44),
|
|
|
|
// height: ScreenUtil().setWidth(10),
|
|
|
|
)
|
|
|
|
],
|
|
|
|
)));
|
|
|
|
}
|
|
|
|
|
|
|
|
_insertUrllink(String link) {
|
|
|
|
// *************开始直接插入会报错***********还没有改
|
|
|
|
|
|
|
|
var cursorPos = controller.selection.base.offset; //获取到光标的在字符串的位置
|
|
|
|
|
|
|
|
if (cursorPos < 0) {
|
|
|
|
controller.text += link;
|
|
|
|
} else {
|
|
|
|
String textAfterCursor =
|
|
|
|
controller.text.substring(cursorPos); //把字符串从光标的位置截取,光标后面的
|
|
|
|
|
|
|
|
String textBeforeCursor =
|
|
|
|
controller.text.substring(0, cursorPos); //光标前面的字符串
|
|
|
|
controller.text =
|
|
|
|
textBeforeCursor + link + textAfterCursor; //把想要的插入的内容拼接在光标位置处
|
|
|
|
|
|
|
|
controller.selection =
|
|
|
|
TextSelection.collapsed(offset: controller.text.length);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
customerProvider = Provider.of<CustomerProvider>(context, listen: true);
|
|
|
|
return Scaffold(
|
|
|
|
appBar: SystemAppBar('fff'),
|
|
|
|
body: SingleChildScrollView(child:
|
|
|
|
Column(children: [
|
|
|
|
Container(
|
|
|
|
width: double.infinity,
|
|
|
|
padding: EdgeInsets.all(w(10)),
|
|
|
|
margin: EdgeInsets.symmetric(horizontal: w(16)),
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
border: Border.all(
|
|
|
|
color: MyColours.color_DBDBDB, width: w(1)),
|
|
|
|
borderRadius: BorderRadius.circular(r(8))),
|
|
|
|
child: Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: [
|
|
|
|
|
|
|
|
appBar: SystemAppBar('存酒超期通知短信内容设置'),
|
|
|
|
body: Column(children: [
|
|
|
|
Expanded(
|
|
|
|
child: SingleChildScrollView(
|
|
|
|
child: Column(
|
|
|
|
children: [
|
|
|
|
Container(
|
|
|
|
width: double.infinity,
|
|
|
|
padding: EdgeInsets.all(w(10)),
|
|
|
|
margin: EdgeInsets.symmetric(horizontal: w(16)),
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
border: Border.all(
|
|
|
|
color: MyColours.color_DBDBDB, width: w(1)),
|
|
|
|
borderRadius: BorderRadius.circular(r(8))),
|
|
|
|
child: Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: [
|
|
|
|
Text(
|
|
|
|
contentChangeStart,
|
|
|
|
style: TextStyle(
|
|
...
|
...
|
@@ -42,63 +170,221 @@ class _WineSettingMsgPageState extends State<WineSettingMsgPage> { |
|
|
|
color: MyColours.color_66000000,
|
|
|
|
fontSize: font(14)),
|
|
|
|
),
|
|
|
|
TextField(
|
|
|
|
enabled: true,
|
|
|
|
controller: controller,
|
|
|
|
// textAlign: TextAlign.right,
|
|
|
|
// textAlignVertical: TextAlignVertical.bottom,
|
|
|
|
maxLines: 10,
|
|
|
|
|
|
|
|
// inputFormatters: title == '金额'
|
|
|
|
// ? [
|
|
|
|
// FilteringTextInputFormatter(RegExp("[0-9.]"),
|
|
|
|
// allow: true),
|
|
|
|
// MyNumberTextInputFormatter(digit: 2),
|
|
|
|
// ]
|
|
|
|
// : [],
|
|
|
|
|
|
|
|
// //光标颜色
|
|
|
|
// cursorColor:
|
|
|
|
// widget.isSelect ? Colors.white : MyColours.color_199095,
|
|
|
|
//输入文本的样式
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: ScreenUtil().setSp(28),
|
|
|
|
color: MyColours.color_515151),
|
|
|
|
// focusNode: focusNode,
|
|
|
|
decoration: InputDecoration(
|
|
|
|
border:
|
|
|
|
OutlineInputBorder(borderSide: BorderSide.none),
|
|
|
|
hintText:
|
|
|
|
'以上内容为固定不可编辑,点击这里开始编辑短信内容' ,
|
|
|
|
hintStyle: TextStyle(
|
|
|
|
color: MyColours.color_999999,
|
|
|
|
fontSize: ScreenUtil().setSp(28),
|
|
|
|
TextField(
|
|
|
|
enabled: true,
|
|
|
|
controller: controller,
|
|
|
|
// textAlign: TextAlign.right,
|
|
|
|
// textAlignVertical: TextAlignVertical.bottom,
|
|
|
|
maxLines: 8,
|
|
|
|
|
|
|
|
// inputFormatters: title == '金额'
|
|
|
|
// ? [
|
|
|
|
// FilteringTextInputFormatter(RegExp("[0-9.]"),
|
|
|
|
// allow: true),
|
|
|
|
// MyNumberTextInputFormatter(digit: 2),
|
|
|
|
// ]
|
|
|
|
// : [],
|
|
|
|
|
|
|
|
// //光标颜色
|
|
|
|
// cursorColor:
|
|
|
|
// widget.isSelect ? Colors.white : MyColours.color_199095,
|
|
|
|
//输入文本的样式
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: ScreenUtil().setSp(28),
|
|
|
|
color: MyColours.color_515151),
|
|
|
|
// focusNode: focusNode,
|
|
|
|
decoration: InputDecoration(
|
|
|
|
border:
|
|
|
|
OutlineInputBorder(borderSide: BorderSide.none),
|
|
|
|
hintText: '点击这里编辑您的短信内容。上面的文字是固定不可编辑的。',
|
|
|
|
hintStyle: TextStyle(
|
|
|
|
color: MyColours.color_999999,
|
|
|
|
fontSize: ScreenUtil().setSp(28),
|
|
|
|
),
|
|
|
|
contentPadding: EdgeInsets.zero,
|
|
|
|
),
|
|
|
|
contentPadding: EdgeInsets.zero,
|
|
|
|
onChanged: (value) {
|
|
|
|
//添加的代码:光标一直在文本框后面
|
|
|
|
// controller.value = TextEditingValue(
|
|
|
|
// text: controller.text,
|
|
|
|
// selection:
|
|
|
|
// TextSelection.fromPosition(TextPosition(
|
|
|
|
// affinity: TextAffinity.downstream,
|
|
|
|
// offset: controller.text.length,
|
|
|
|
// )));
|
|
|
|
// setState(() {
|
|
|
|
// _cursorPosition = controller.selection.baseOffset;
|
|
|
|
// });
|
|
|
|
},
|
|
|
|
onEditingComplete: () {
|
|
|
|
FocusScope.of(context)
|
|
|
|
.requestFocus(FocusNode()); //点击空白处隐藏键盘
|
|
|
|
},
|
|
|
|
// keyboardType: inputType,
|
|
|
|
),
|
|
|
|
onChanged: (value) {
|
|
|
|
//添加的代码:光标一直在文本框后面
|
|
|
|
// controller.value = TextEditingValue(
|
|
|
|
// text: controller.text,
|
|
|
|
// selection:
|
|
|
|
// TextSelection.fromPosition(TextPosition(
|
|
|
|
// affinity: TextAffinity.downstream,
|
|
|
|
// offset: controller.text.length,
|
|
|
|
// )));
|
|
|
|
// setState(() {
|
|
|
|
// _cursorPosition = controller.selection.baseOffset;
|
|
|
|
// });
|
|
|
|
},
|
|
|
|
onEditingComplete: () {
|
|
|
|
FocusScope.of(context)
|
|
|
|
.requestFocus(FocusNode()); //点击空白处隐藏键盘
|
|
|
|
},
|
|
|
|
// keyboardType: inputType,
|
|
|
|
)
|
|
|
|
],
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],),),
|
|
|
|
);
|
|
|
|
Container(
|
|
|
|
width: double.infinity,
|
|
|
|
// padding: EdgeInsets.all(w(10)),
|
|
|
|
margin: EdgeInsets.symmetric(horizontal: w(16)),
|
|
|
|
child: Column(
|
|
|
|
children: [
|
|
|
|
VEmptyView(36),
|
|
|
|
InkWell(
|
|
|
|
onTap: () {
|
|
|
|
isUse = !isUse;
|
|
|
|
if (!isUse) {
|
|
|
|
youhui = '选择优惠';
|
|
|
|
}
|
|
|
|
setState(() {});
|
|
|
|
},
|
|
|
|
child: Row(children: [
|
|
|
|
Image.asset(
|
|
|
|
Utils.getImgPath(
|
|
|
|
isUse ? 'f_select' : 'f_select_not'),
|
|
|
|
width: ScreenUtil().setWidth(44)),
|
|
|
|
HEmptyView(15),
|
|
|
|
Text(
|
|
|
|
'在当前位置插入优惠',
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: ScreenUtil().setSp(32),
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
color: MyColours.color_515151),
|
|
|
|
),
|
|
|
|
])),
|
|
|
|
VEmptyView(26),
|
|
|
|
if (isUse)
|
|
|
|
Row(children: [
|
|
|
|
Expanded(
|
|
|
|
child: Container(
|
|
|
|
height: ScreenUtil().setWidth(70),
|
|
|
|
// width: ScreenUtil().setWidth(130),
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
borderRadius: BorderRadius.circular(
|
|
|
|
ScreenUtil().setWidth(10)),
|
|
|
|
color: MyColours.color_DBDBDB),
|
|
|
|
child: _buttonChoose(youhui, (value) {
|
|
|
|
if (isUse) {
|
|
|
|
FocusScope.of(context)
|
|
|
|
.requestFocus(FocusNode()); //隐藏键盘
|
|
|
|
if (couponList == null ||
|
|
|
|
couponList.length == 0) {
|
|
|
|
Utils.showToast('暂无优惠券,请创建新优惠');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
DialogUtil.showSelectCusmanDialog(
|
|
|
|
context, couponList,
|
|
|
|
(value) async {
|
|
|
|
if (value != null) {
|
|
|
|
if (customerProvider
|
|
|
|
.couponListSelect[
|
|
|
|
value.first]
|
|
|
|
.urllink ==
|
|
|
|
null) {
|
|
|
|
//创建链接
|
|
|
|
//创建券的二维码
|
|
|
|
Map<String, String> param = {
|
|
|
|
"sid": Provider.of<UserModel>(
|
|
|
|
context,
|
|
|
|
listen: false)
|
|
|
|
.user
|
|
|
|
.sellerid,
|
|
|
|
"id": customerProvider
|
|
|
|
.couponListSelect[
|
|
|
|
value.first]
|
|
|
|
.id,
|
|
|
|
};
|
|
|
|
dynamic object =
|
|
|
|
await customerProvider
|
|
|
|
.createActivityUrlLink(
|
|
|
|
context, param);
|
|
|
|
if (object is bool) {
|
|
|
|
//
|
|
|
|
|
|
|
|
} else {
|
|
|
|
//成功
|
|
|
|
_insertUrllink(object);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// 直接使用
|
|
|
|
setState(() {
|
|
|
|
couponSelectIndex =
|
|
|
|
value.first;
|
|
|
|
youhui = couponList[
|
|
|
|
couponSelectIndex];
|
|
|
|
});
|
|
|
|
|
|
|
|
_insertUrllink(customerProvider
|
|
|
|
.couponListSelect[
|
|
|
|
value.first]
|
|
|
|
.urllink);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
selecteds:
|
|
|
|
couponSelectIndex == null
|
|
|
|
? []
|
|
|
|
: [couponSelectIndex])
|
|
|
|
.then((value) {});
|
|
|
|
}
|
|
|
|
}))),
|
|
|
|
HEmptyView(30),
|
|
|
|
InkWell(
|
|
|
|
onTap: () async {
|
|
|
|
if (isUse) {
|
|
|
|
// NavigatorUtil.goMarketingRecordsDetailPage(context);
|
|
|
|
bool needRefresh =
|
|
|
|
await NavigatorUtil.goCouponEditPage(
|
|
|
|
context);
|
|
|
|
print(needRefresh);
|
|
|
|
if (needRefresh != null && needRefresh) {
|
|
|
|
//刷新页面数据
|
|
|
|
// _controller.callRefresh();
|
|
|
|
_couponNetworkData();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
child: Text('创建新优惠',
|
|
|
|
style: TextStyle(
|
|
|
|
decoration: TextDecoration.underline,
|
|
|
|
color: isUse
|
|
|
|
? MyColours.color_438E93
|
|
|
|
: MyColours.color_999999,
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
fontSize: ScreenUtil().setSp(28)))),
|
|
|
|
]),
|
|
|
|
],
|
|
|
|
))
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
Container(
|
|
|
|
padding: EdgeInsets.only(
|
|
|
|
left: w(23), right: w(23), top: w(12), bottom: w(25)),
|
|
|
|
child: Row(
|
|
|
|
children: [
|
|
|
|
Expanded(
|
|
|
|
child: RoundButton(
|
|
|
|
text: '保存',
|
|
|
|
gradientStart: MyColours.color_438E93,
|
|
|
|
gradientEnd: MyColours.color_438E93,
|
|
|
|
// borderColor: MyColours.color_999999,
|
|
|
|
radius: r(5),
|
|
|
|
height: w(43),
|
|
|
|
fontSize: 32,
|
|
|
|
|
|
|
|
isBold: true,
|
|
|
|
onPressed: () {
|
|
|
|
//群发短信
|
|
|
|
// _createMarketing();
|
|
|
|
},
|
|
|
|
)),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
)
|
|
|
|
]));
|
|
|
|
}
|
|
|
|
} |
|
|
\ No newline at end of file |
|
|
|
} |
...
|
...
|
|