Commit 99cd95d19a5816dcd9e36bb7ce4dd31b2682ac12

Authored by wdn127929
1 parent 292681d6

主厨介绍

... ... @@ -265,14 +265,19 @@ class MarkChefModel {
String introduce;
String chefName;
String image;
String isIntroduce;
String isAbove;
String isImages;
MarkChefModel({
this.style,
this.sellerName,
this.introduce,
this.chefName,
this.image,
});
MarkChefModel(
{this.style,
this.sellerName,
this.introduce,
this.chefName,
this.image,
this.isIntroduce,
this.isAbove,
this.isImages});
MarkChefModel.fromJson(Map<String, dynamic> json) {
style = json['style'];
... ... @@ -280,6 +285,9 @@ class MarkChefModel {
chefName = json['chef_name'];
introduce = json['introduce'];
image = json['image'];
isIntroduce = json['is_introduce'];
isAbove = json['is_above'];
isImages = json['is_images'];
}
Map<String, dynamic> toJson() {
... ... @@ -289,6 +297,9 @@ class MarkChefModel {
data['chef_name'] = this.chefName;
data['introduce'] = this.introduce;
data['image'] = this.image;
data['is_introduce'] = this.isIntroduce;
data['is_above'] = this.isAbove;
data['is_images'] = this.isImages;
return data;
}
}
... ...
... ... @@ -38,9 +38,9 @@ class ChefIntroducePage extends StatefulWidget {
}
class _ChefIntroducePageState extends State<ChefIntroducePage> {
int currIndex = 0; //样式按钮默认选中第一个
// int currIndex = 0; //样式按钮默认选中第一个
String sellername; //店铺名称
// String sellername; //店铺名称
TextEditingController chefIntroduceC = TextEditingController();
FocusNode chefIntroduceNode = FocusNode();
... ... @@ -52,15 +52,18 @@ class _ChefIntroducePageState extends State<ChefIntroducePage> {
UploadImageProvider _uploadImageProvider;
MarketingCenterProvider _marketingCenterProvider;
bool addChefIntroduce = false;
bool addChefImge = false;
bool addAbove = false;
@override
void initState() {
super.initState();
WidgetsBinding.instance.addPostFrameCallback((_) async {
UserModel userModel = Provider.of<UserModel>(context, listen: false);
sellername = userModel.user.sellername;
setState(() {});
// UserModel userModel = Provider.of<UserModel>(context, listen: false);
// sellername = userModel.user.sellername;
// setState(() {});
_getQiniuInfo();
await getSellerTemplateConf();
});
... ... @@ -82,7 +85,7 @@ class _ChefIntroducePageState extends State<ChefIntroducePage> {
bool success =
await _marketingCenterProvider.getSellerTemplateConf(context);
if (success && _marketingCenterProvider.markDataModel.chef != null) {
currIndex = int.parse(_marketingCenterProvider.markDataModel.chef.style);
// currIndex = int.parse(_marketingCenterProvider.markDataModel.chef.style);
_uploadImageProvider.firstImage.qiniuUrl =
_marketingCenterProvider.markDataModel.chef.image ?? null;
... ... @@ -96,6 +99,17 @@ class _ChefIntroducePageState extends State<ChefIntroducePage> {
chefNameC.text = _marketingCenterProvider.markDataModel.chef.chefName;
chefIntroduceC.text =
_marketingCenterProvider.markDataModel.chef.introduce;
addChefIntroduce =
_marketingCenterProvider.markDataModel.chef.isIntroduce == '1'
? true
: false;
addChefImge = _marketingCenterProvider.markDataModel.chef.isImages == '1'
? true
: false;
addAbove = _marketingCenterProvider.markDataModel.chef.isAbove == '1'
? true
: false;
setState(() {});
}
}
... ... @@ -128,8 +142,8 @@ class _ChefIntroducePageState extends State<ChefIntroducePage> {
if (need) {
file = File(compressedFile.absolute.path);
}
UploadImageUtil().startUploadOnly(context,
file, 4, true, _uploadImageProvider);
UploadImageUtil()
.startUploadOnly(context, file, 4, true, _uploadImageProvider);
}
}
... ... @@ -245,203 +259,6 @@ class _ChefIntroducePageState extends State<ChefIntroducePage> {
});
}
///图文合并,图文分开,无文字
Widget _selectBtnWidget() {
return Container(
decoration: BoxDecoration(
border: Border(
bottom:
BorderSide(color: MyColours.color_E7E7E7, width: w(0.5)))),
margin: EdgeInsets.only(left: w(16)),
padding: EdgeInsets.only(top: w(12), bottom: w(12), right: w(16)),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
'附加主厨介绍',
style: TextStyle(
color: MyColours.color_515151,
fontSize: ScreenUtil().setWidth(32)),
),
Container(
height: ScreenUtil().setWidth(74),
decoration: BoxDecoration(
color: Color.fromRGBO(232, 232, 232, 1),
borderRadius: BorderRadius.circular(
r(11),
),
// border: Border.all(
// width: w(1), color: MyColours.color_438E93),
),
child: Row(
// mainAxisAlignment: MainAxisAlignment.spaceEvenly,
// crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
CommonButtonFlat(
content: "无介绍",
state: currIndex == 0 ? 1 : 0,
fontSize: 28,
right: false,
width: w(52),
onPress: () {
if (currIndex == 0) return;
setState(() {
currIndex = 0;
});
},
),
currIndex == 2
? MyDivider(
ScreenUtil().setWidth(4),
ScreenUtil().setWidth(46),
color: MyColours.color_dfdfdf,
)
: SizedBox(),
CommonButtonFlat(
content: "图文合并",
state: currIndex == 1 ? 1 : 0,
fontSize: 28,
width: w(66),
left: false,
right: false,
onPress: () {
if (currIndex == 1) return;
setState(() {
currIndex = 1;
});
},
),
currIndex == 0
? MyDivider(
ScreenUtil().setWidth(4),
ScreenUtil().setWidth(46),
color: MyColours.color_dfdfdf,
)
: SizedBox(),
Container(
child: CommonButtonFlat(
content: "图文分开",
left: false,
state: currIndex == 2 ? 1 : 0,
fontSize: 28,
width: w(66),
onPress: () {
if (currIndex == 2) return;
setState(() {
currIndex = 2;
});
},
)),
],
),
),
],
));
}
Widget _introduceWidget(EdgeInsets edgeInsets,
{double width = double.infinity,
Color textColor = MyColours.color_515151,
Color hintColor = MyColours.color_999999,
BoxDecoration boxDecoration}) {
return Container(
width: width,
alignment: Alignment.centerRight,
padding: edgeInsets,
decoration: boxDecoration,
child: Column(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Text(
'Chief Cook',
style: TextStyle(color: MyColours.color_B39437, fontSize: font(14)),
),
Text(
'知名主厨',
style: TextStyle(color: MyColours.color_B39437, fontSize: font(14)),
),
VEmptyView(16),
// Text(
// '${sellername}',
// style: TextStyle(color: textColor, fontSize: font(14)),
// ),
Container(
width: double.infinity,
alignment: Alignment.topRight,
child: TextField(
textAlign: TextAlign.right,
controller: chefNameC,
focusNode: chefNameNode,
style: TextStyle(
color: textColor,
fontSize: ScreenUtil().setSp(28),
textBaseline: TextBaseline.alphabetic),
textAlignVertical: TextAlignVertical.center,
maxLines: 1,
decoration: InputDecoration(
hintText: "点这里录入主厨姓名",
hintStyle: TextStyle(
color: hintColor,
fontSize: ScreenUtil().setSp(28),
),
contentPadding: EdgeInsets.zero,
border: OutlineInputBorder(borderSide: BorderSide.none),
),
keyboardType: TextInputType.text,
onChanged: (value) {
setState(() {
// currentRemark = value ?? "";
});
}),
),
VEmptyView(32),
Container(
width: double.infinity,
// margin: EdgeInsets.symmetric(horizontal: w(10)),
// padding: EdgeInsets.symmetric(horizontal: w(6)),
decoration: BoxDecoration(
border: Border(
right: BorderSide(
width: w(2), color: MyColours.color_EEAE74))),
child: Container(
width: double.infinity,
padding: EdgeInsets.symmetric(
horizontal: ScreenUtil().setWidth(12),
),
alignment: Alignment.topRight,
child: TextField(
textAlign: TextAlign.right,
controller: chefIntroduceC,
focusNode: chefIntroduceNode,
style: TextStyle(
height: 2,
color: textColor,
fontSize: ScreenUtil().setSp(20),
textBaseline: TextBaseline.alphabetic),
textAlignVertical: TextAlignVertical.center,
maxLines: 7,
decoration: InputDecoration(
hintText: "点这里录入主厨介绍文字",
hintStyle: TextStyle(
color: hintColor,
fontSize: ScreenUtil().setSp(20),
),
contentPadding: EdgeInsets.zero,
border: OutlineInputBorder(borderSide: BorderSide.none),
),
keyboardType: TextInputType.multiline,
textInputAction: TextInputAction.newline,
onChanged: (value) {
setState(() {
// currentRemark = value ?? "";
});
}),
)),
],
),
);
}
Widget _uploadImage({EdgeInsets padding = EdgeInsets.zero}) {
return _uploadImageProvider.firstImage.file != null ||
(_uploadImageProvider.firstImage.qiniuUrl != null &&
... ... @@ -605,61 +422,48 @@ class _ChefIntroducePageState extends State<ChefIntroducePage> {
// );
}
///图文合并
Widget _mergingWidget() {
Color themColor = MyColours.color_0C0F0E;
int colorValue = null;
if (_marketingCenterProvider.markDataModel.home != null &&
_marketingCenterProvider.markDataModel.home.themeColor != null) {
colorValue =
int.parse(_marketingCenterProvider.markDataModel.home.themeColor);
}
if (colorValue != null) {
themColor = Color(colorValue);
}
return Column(
children: [
Stack(
alignment: Alignment.centerRight,
children: [
_uploadImage(
padding: EdgeInsets.only(right: w(160)),
),
Positioned(
child: _introduceWidget(
EdgeInsets.only(
right: w(15), top: w(23), left: w(7), bottom: w(42)),
textColor: MyColours.color_ffffff,
hintColor: MyColours.color_ffffff,
boxDecoration: BoxDecoration(
gradient: LinearGradient(
stops: [0, 1],
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors: [
themColor,
MyColours.color_4D0C0F0E,
],
),
)),
width: w(160),
),
],
),
],
);
}
///图文分开
Widget _separateWidget() {
return Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
_introduceWidget(EdgeInsets.all(w(15)),
boxDecoration: BoxDecoration(color: MyColours.color_ffffff)),
VEmptyView(18),
// _introduceWidget(EdgeInsets.all(w(15)),
// boxDecoration: BoxDecoration(color: MyColours.color_ffffff)),
// VEmptyView(18),
_uploadImage(),
]);
}
Widget _item(String title, {bool select, GestureTapCallback onTap}) {
return InkWell(
onTap: onTap,
child: Container(
decoration: BoxDecoration(
border: Border(
bottom: BorderSide(
color: MyColours.color_E7E7E7, width: w(0.5)))),
margin: EdgeInsets.only(left: w(16)),
padding: EdgeInsets.only(top: w(12), bottom: w(12), right: w(16)),
child: Row(
children: [
Text(
title,
style: TextStyle(
color: MyColours.color_515151,
fontSize: ScreenUtil().setWidth(32)),
),
Spacer(),
Container(
padding:
EdgeInsets.symmetric(horizontal: w(7), vertical: w(4)),
child: Image.asset(
Utils.getImgPath(select ? 'swich_on' : 'swich_off'),
width: w(44),
),
)
],
)));
}
@override
Widget build(BuildContext context) {
_uploadImageProvider =
... ... @@ -682,26 +486,97 @@ class _ChefIntroducePageState extends State<ChefIntroducePage> {
child: SingleChildScrollView(
child: Column(
children: [
_selectBtnWidget(),
// _selectBtnWidget(),
// VEmptyView(24),
// Container(
// alignment: Alignment.centerLeft,
// padding: EdgeInsets.only(left: w(16)),
// height: w(48),
// child: Text(
// '效果预览',
// style: TextStyle(
// fontSize: font(16),
// color: MyColours.color_515151),
// ),
// ),
// VEmptyView(24),
_item('预订安排通知中附加主厨文字介绍', select: addChefIntroduce,
onTap: () {
setState(() {
addChefIntroduce = !addChefIntroduce;
});
}),
VEmptyView(24),
//输入框
Container(
alignment: Alignment.centerLeft,
padding: EdgeInsets.only(left: w(16)),
height: w(48),
child: Text(
'效果预览',
style: TextStyle(
fontSize: font(16),
color: MyColours.color_515151),
),
width: double.infinity,
margin: EdgeInsets.symmetric(
horizontal: ScreenUtil().setWidth(40)),
padding: EdgeInsets.symmetric(
horizontal: ScreenUtil().setWidth(40),
vertical: ScreenUtil().setWidth(20)),
alignment: Alignment.topLeft,
decoration: BoxDecoration(
color: MyColours.color_ffffff,
border: Border.all(
color: MyColours.color_DBDBDB,
width: ScreenUtil().setWidth(2)),
borderRadius: BorderRadius.circular(
ScreenUtil().setWidth(20))),
child: TextField(
controller: chefIntroduceC,
focusNode: chefIntroduceNode,
style: TextStyle(
color: MyColours.color_515151,
fontSize: ScreenUtil().setSp(28),
textBaseline: TextBaseline.alphabetic),
textAlignVertical: TextAlignVertical.center,
maxLines: 5,
maxLength: 100,
decoration: InputDecoration(
hintText: "点击录入餐厅介绍文字信息,最多100个汉字。",
hintStyle: TextStyle(
color: MyColours.color_999999,
fontSize: ScreenUtil().setSp(28),
),
contentPadding: EdgeInsets.zero,
border: OutlineInputBorder(
borderSide: BorderSide.none),
),
keyboardType: TextInputType.text,
onChanged: (value) {
setState(() {
// currentRemark = value ?? "";
});
}),
),
VEmptyView(24),
currIndex == 0
? _noTextWidget()
: currIndex == 1
? _mergingWidget()
: _separateWidget(),
VEmptyView(18),
Padding(
padding: EdgeInsets.symmetric(horizontal: w(20)),
child: MyDivider(
double.infinity,
w(0.5),
color: MyColours.color_DBDBDB,
)),
VEmptyView(24),
// _selectBtnWidget(),
_item('预订安排通知中附加主厨介绍图片', select: addChefImge, onTap: () {
setState(() {
addChefImge = !addChefImge;
});
}),
VEmptyView(24),
_separateWidget(),
VEmptyView(24),
_item('主厨介绍文字显示在图片上', select: addAbove, onTap: () {
setState(() {
addAbove = !addAbove;
});
}),
VEmptyView(24),
],
),
)),
... ... @@ -722,24 +597,19 @@ class _ChefIntroducePageState extends State<ChefIntroducePage> {
FocusScope.of(context)
.requestFocus(FocusNode()); //点击空白处隐藏键盘
if ((currIndex == 1 || currIndex == 2)) {
if (chefNameC.text.trim().length == 0) {
Utils.showToast('请输入主厨姓名!');
return false;
}
if (chefIntroduceC.text.trim().length == 0) {
Utils.showToast('请输入主厨介绍文字!');
return false;
}
if (_uploadImageProvider.firstImage.qiniuUrl == null) {
Utils.showToast('请上传图片!');
return false;
}
if (_uploadImageProvider.firstImage.process < 1) {
Utils.showToast('正在上传图片,请稍等');
return false;
}
if (addChefIntroduce &&
chefIntroduceC.text.trim().length == 0) {
Utils.showToast('请输入主厨介绍文字!');
return false;
}
if (_uploadImageProvider.firstImage.qiniuUrl == null) {
Utils.showToast('请上传图片!');
return false;
}
if (_uploadImageProvider.firstImage.process < 1) {
Utils.showToast('正在上传图片,请稍等');
return false;
}
// List<String> images = [];
... ... @@ -766,11 +636,11 @@ class _ChefIntroducePageState extends State<ChefIntroducePage> {
//接口
Map chefData = {
'style': currIndex.toString(),
'seller_name': sellername,
'chef_name': chefNameC.text,
'introduce': chefIntroduceC.text,
'image': _uploadImageProvider.firstImage.qiniuUrl
'image': _uploadImageProvider.firstImage.qiniuUrl,
'is_introduce': addChefIntroduce ? '1' : '0',
'is_images': addChefImge ? '1' : '0',
'is_above': addAbove ? '1' : '0'
};
Map<String, String> params = {
... ...