Commit 88f32d67cfa12231c9844ef03fe2707052388ae0

Authored by wdn127929
1 parent 544d47cb

生成预览and微信分享

... ... @@ -32,6 +32,7 @@ class MenuModel {
order = json['order'];
status = json['status'];
classType = json['class_type'];
// allSum = json['allSum'] ?? 0;
if (json['cookbooklist'] != null) {
cookbooklist = [];
json['cookbooklist'][0].forEach((v) {
... ... @@ -48,6 +49,7 @@ class MenuModel {
order = json['order'];
status = json['status'];
classType = json['class_type'];
allSum = json['allSum'] ?? 0;
if (json['cookbooklist'] != null) {
cookbooklist = [];
json['cookbooklist'].forEach((v) {
... ... @@ -65,6 +67,7 @@ class MenuModel {
data['order'] = this.order;
data['status'] = this.status;
data['class_type'] = this.classType;
data['allSum'] = this.allSum;
if (this.cookbooklist != null) {
data['cookbooklist'] = this.cookbooklist.map((v) => v.toJson()).toList();
}
... ... @@ -104,7 +107,7 @@ class MenuSunModel {
List<MenuModel> cookList;
int amount; //菜品数量
TextEditingController amountC = TextEditingController();
int moreSum = 0; //排菜编辑页展示选中总数
... ... @@ -177,6 +180,43 @@ class MenuSunModel {
}
}
MenuSunModel.fromJson3(Map<String, dynamic> json) {
id = json['id'];
sellerid = json['sellerid'];
mid = json['mid'];
lid = json['lid'];
unit = json['unit'];
name = json['name'];
price = json['price'];
member_price = json['member_price'];
first_name = json['first_name'];
search_code = json['search_code'];
channel = json['channel'];
dishesvideo = json['dishesvideo'];
dishesgif = json['dishesgif'];
status = json['status'];
setup = json['setup'];
give = json['give'];
clear_num = json['clear_num'];
record_num = json['record_num'];
image = json['image'];
is_weigh = json['is_weigh'];
desc = json['desc'];
order_o = json['order_o'];
cdate = json['cdate'];
spec = json['spec'];
isSpec = json['isSpec'];
practice = json['practice'];
amount = 0;
amountC.text = '0';
if (json['cookList'] != null) {
cookList = [];
json['cookList'].forEach((v) {
cookList.add(v);
});
}
}
MenuSunModel.fromJson2(Map<String, dynamic> json) {
id = json['id'];
sellerid = json['sellerid'];
... ...
... ... @@ -52,6 +52,9 @@ class _OrderAdvanceEidtPageState extends State<OrderAdvanceEidtPage> {
TextEditingController planDishC = TextEditingController(); //排菜价
List<MenuSunModel> selectMenu = [];
String planDishName;
String planDishRemark;
@override
void initState() {
super.initState();
... ... @@ -78,17 +81,19 @@ class _OrderAdvanceEidtPageState extends State<OrderAdvanceEidtPage> {
List<SunListPlan> storeList = _planDishProvider.storeListTemp;
storeList.forEach((element) {
MenuSunModel menuSunModel = MenuSunModel();
menuSunModel.id = element.id;
menuSunModel.name = element.pname;
// menuSunModel.price = element.menuPrice;
menuSunModel.price = element.planPrice;
menuSunModel.member_price = element.memberPrice;
menuSunModel.unit = '份';
// menuSunModel.amount = element.amount;
menuSunModel.cookList = element.cookList;
cookList.add(menuSunModel);
if (element.status == '1') {
MenuSunModel menuSunModel = MenuSunModel();
menuSunModel.id = element.id;
menuSunModel.name = element.pname;
// menuSunModel.price = element.menuPrice;
menuSunModel.price = element.planPrice;
menuSunModel.member_price = element.memberPrice;
menuSunModel.unit = '份';
// menuSunModel.amount = element.amount;
menuSunModel.cookList = element.cookList;
cookList.add(menuSunModel);
}
});
menuModelSetMeal.cookbooklist = cookList;
... ... @@ -101,21 +106,24 @@ class _OrderAdvanceEidtPageState extends State<OrderAdvanceEidtPage> {
List<MenuSunModel> cookListPlanDish = [];
List<SunListPlan> mineList = _planDishProvider.mineListTemp;
mineList.forEach((element) {
MenuSunModel menuSunModel = MenuSunModel();
menuSunModel.id = element.id;
menuSunModel.name = element.pname;
menuSunModel.price = element.menuPrice;
menuSunModel.member_price = element.memberPrice;
menuSunModel.unit = '份';
// menuSunModel.amount = element.amount;
menuSunModel.cookList = element.cookList;
cookListPlanDish.add(menuSunModel);
if (element.status == '1') {
MenuSunModel menuSunModel = MenuSunModel();
menuSunModel.id = element.id;
menuSunModel.name = element.pname;
menuSunModel.price = element.menuPrice;
menuSunModel.member_price = element.memberPrice;
menuSunModel.unit = '份';
// menuSunModel.amount = element.amount;
menuSunModel.cookList = element.cookList;
cookListPlanDish.add(menuSunModel);
}
});
menuModelPlanDish.cookbooklist = cookListPlanDish;
_planDishProvider.menuModelForManager
.insert(1, menuModelPlanDish); //添加排菜
_planDishProvider.pageStateMenu = PageState.Success;
setState(() {});
} else {
... ... @@ -124,6 +132,7 @@ class _OrderAdvanceEidtPageState extends State<OrderAdvanceEidtPage> {
} else {
// Utils.showToast('');
}
_planDishProvider.pageStateMenu = PageState.ConnectivityError;
}
}).catchError((e) {
print(e);
... ... @@ -365,7 +374,7 @@ class _OrderAdvanceEidtPageState extends State<OrderAdvanceEidtPage> {
}
//计算价格
_calculatePrice() {
_calculatePrice({String planPrice}) {
priceSum = 0;
memberPriceSum = 0;
_planDishProvider.menuModelForManager.forEach((element) {
... ... @@ -433,7 +442,11 @@ class _OrderAdvanceEidtPageState extends State<OrderAdvanceEidtPage> {
});
}
}
planDishC.text = priceSum.toString();
if (planPrice != null) {
planDishC.text = planPrice;
} else {
planDishC.text = priceSum.toString();
}
});
}
... ... @@ -444,7 +457,7 @@ class _OrderAdvanceEidtPageState extends State<OrderAdvanceEidtPage> {
backgroundColor: MyColours.color_ffffff,
appBar: SystemAppBar('经理排菜'),
body: Consumer<PlanDishProvider>(builder: (context, model, child) {
if (model.pageState == PageState.Success) {
if (model.pageStateMenu == PageState.Success) {
return Column(
children: [
MyDivider(
... ... @@ -1033,14 +1046,22 @@ class _OrderAdvanceEidtPageState extends State<OrderAdvanceEidtPage> {
// Map temp;
// if (menuModel == null) {
Map temp = await NavigatorUtil
.goOrderEditListShowPage(context, object: {
'object': _planDishProvider.menuModelForManager,
}, object1: {
'object1': _planDishProvider.storeList
}, object2: {
'object2': _planDishProvider.mineList
});
FocusScope.of(context)
.requestFocus(FocusNode()); //点击空白处隐藏键盘
Map temp =
await NavigatorUtil.goOrderEditListShowPage(
context,
object: {
'object':
_planDishProvider.menuModelForManager,
},
object1: {
'object1': _planDishProvider.storeList
},
object2: {
'object2': _planDishProvider.mineList
},
planPrice: planDishC.text);
// } else {
// temp =
// await NavigatorUtil.goPlanNewDishPage(
... ... @@ -1055,6 +1076,8 @@ class _OrderAdvanceEidtPageState extends State<OrderAdvanceEidtPage> {
temp['more']; //二级菜单
List<MenuModel> dataLocalShowOne =
temp['one']; //一级菜单
planDishName = temp['name'];
planDishRemark = temp['remark'];
// 刷新页面***************
... ... @@ -1128,7 +1151,7 @@ class _OrderAdvanceEidtPageState extends State<OrderAdvanceEidtPage> {
carSum = carSumTemp;
print((_planDishProvider.storeList));
_calculatePrice();
_calculatePrice(planPrice: temp['planPrice']);
_initMenuModelForManagerData();
setState(() {});
}
... ... @@ -1146,7 +1169,206 @@ class _OrderAdvanceEidtPageState extends State<OrderAdvanceEidtPage> {
textColor: MyColours.color_438E93,
isBold: false,
onPressed: () {
NavigatorUtil.goOrderPreviewPage(context);
FocusScope.of(context)
.requestFocus(FocusNode()); //点击空白处隐藏键盘
List<MenuModel> showList = [];
List<MenuSunModel> dataLocalShowMore = []; //二级菜单
List<MenuModel> dataLocalShowOne = []; //一级菜单
if (_planDishProvider.menuModelForManager != null) {
_planDishProvider.menuModelForManager
.forEach((element) {
if (element.className == '套餐' ||
element.className == '我的排菜') {
// //如果是套餐,则看cooklist有没有选中的
// bool isChange = false; //套餐或者排菜数量是否选中
// if (element.className == '套餐') {
// isChange = _isChange(widget.storeList);
// } else {
// // isChange = _isChange(widget.storeList);
// }
element.cookbooklist.forEach((value) {
if (value.amount > 0) {
// if (!isChange) {
// priceSum += double.parse(value.price) * value.amount;
// memberPriceSum +=
// double.parse(value.member_price) * value.amount;
// }
//选中了该套餐
//把套餐中没有选中的菜品踢出去
MenuSunModel menuSunModel =
MenuSunModel();
List<MenuModel> moreMenu = [];
int moreSum = 0;
//遍历套餐中的菜分类
value.cookList.forEach((cook) {
//遍历套餐中的具体菜品
List<MenuSunModel> cooklistSun = [];
int cookSum = 0;
cook.cookbooklist.forEach((cookSun) {
// 具体菜品
if (cookSun.amount > 0) {
//当前菜品已选择
// moreSum += cookSun.amount;
cookSum += cookSun.amount;
// if (isChange) {
// priceSum += double.parse(cookSun.price) * cookSun.amount;
// memberPriceSum +=
// double.parse(cookSun.member_price) * cookSun.amount;
// }
carSum += cookSun.amount;
cooklistSun.add(cookSun);
}
});
if (cooklistSun.length > 0) {
cook.cookbooklist = cooklistSun;
cook.allSum = cookSum;
moreMenu.add(cook);
value.cookList = moreMenu;
}
});
value.moreSum = value.amount;
value.channel = element.className == '套餐'
? '1'
: '2'; // 1套餐----2排菜
dataLocalShowMore.add(value);
}
});
} else if (element.className == '店内常点') {
// //如果是我的排菜,则看cooklist有没有选中的
// bool hasmMine =
// element.cookbooklist.any(((value) => value.amount > 0));
// if (hasmMine) {
// //套餐中有被选中
// maxIndex++;
// }
} else if (element.className == '临时加菜') {
} else {
//单菜
bool hasmMenu = element.cookbooklist
.any(((value) => value.amount > 0));
if (hasmMenu) {
//单品此类有选中菜品
MenuModel menuModel = MenuModel();
menuModel.className = element.className;
menuModel.classLabel = element.classLabel;
menuModel.classType = element.classType;
menuModel.id = element.id;
menuModel.order = element.order;
menuModel.sellerid = element.sellerid;
menuModel.status = element.status;
menuModel.cookbooklist = [];
List<MenuSunModel> cookbooklist = [];
int allSum = 0;
element.cookbooklist.forEach((value) {
if (value.amount > 0) {
allSum += value.amount;
// priceSum += double.parse(value.price) * value.amount;
// memberPriceSum +=
// double.parse(value.member_price) * value.amount;
carSum += value.amount;
cookbooklist.add(value);
}
});
menuModel.allSum = allSum;
menuModel.cookbooklist.addAll(cookbooklist);
dataLocalShowOne.add(menuModel);
}
}
// planDishC.text = priceSum.toString();
});
}
dataLocalShowMore.forEach((value) {
value.cookList.forEach((newValue) {
if (showList.length == 0) {
showList.add(
MenuModel.fromJson2(newValue.toJson()));
} else {
bool hasC = false;
showList.forEach((show) {
if (show.id == newValue.id) {
hasC = true;
//数据存在相同菜类
newValue.cookbooklist.forEach((newcook) {
bool has = false;
show.cookbooklist.forEach((oldshow) {
if (oldshow.id == newcook.id) {
//同一个菜品
has = true;
oldshow.amount += newcook.amount;
show.allSum += newcook.amount;
}
});
if (!has) {
//旧的里面没有该菜品
show.cookbooklist.add(newcook);
}
});
}
});
if (!hasC) {
showList.add(
MenuModel.fromJson2(newValue.toJson()));
}
}
});
});
print(showList);
dataLocalShowOne.forEach((element) {
if (showList.length == 0) {
showList
.add(MenuModel.fromJson2(element.toJson()));
} else {
bool hasC = false;
showList.forEach((show) {
if (show.id == element.id) {
hasC = true;
//数据存在相同菜类
element.cookbooklist.forEach((newcook) {
bool has = false;
show.cookbooklist.forEach((oldshow) {
if (oldshow.id == newcook.id) {
//同一个菜品
has = true;
oldshow.amount += newcook.amount;
show.allSum += newcook.amount;
}
});
if (!has) {
//旧的里面没有该菜品
show.cookbooklist.add(newcook);
}
});
}
});
if (!hasC) {
showList.add(
MenuModel.fromJson2(element.toJson()));
}
}
});
// double priceSum = 0; //总计
// double memberPriceSum = 0; //会员价
// TextEditingController planDishC =
// TextEditingController(); //排菜价
NavigatorUtil.goOrderPreviewPage(context,
object: {'object': showList},
name: planDishName,
remark: planDishRemark,
priceSum: priceSum.toString(),
memberPriceSum: memberPriceSum.toString(),
planDishText: planDishC.text);
},
),
RoundButton(
... ...
... ... @@ -20,7 +20,9 @@ class OrderEditListShowPage extends StatefulWidget {
final List<SunListPlan> storeList; //套餐元数据
final List<SunListPlan> mineList; //我的排菜元数据
final List<MenuModel> data;
OrderEditListShowPage({Key key, this.data, this.storeList, this.mineList})
final String planPrice;
OrderEditListShowPage(
{Key key, this.data, this.storeList, this.mineList, this.planPrice})
: super(key: key);
@override
... ... @@ -37,6 +39,12 @@ class _OrderEditListShowPageState extends State<OrderEditListShowPage> {
double memberPriceSum = 0; //会员价
TextEditingController planDishC = TextEditingController(); //排菜价
List<SunListPlan> storeListLocal = []; //把amount = 0 的筛选出去
List<SunListPlan> mineListLocal = []; //把amount = 0 的筛选出去
TextEditingController planDishName = TextEditingController(); //排菜名称
TextEditingController planDishRemark = TextEditingController(); //排菜备注
Widget _laduWidget() {
// if (labelIcon[widget
// .cookBookList.labelList[index].icon] is int) {
... ... @@ -167,7 +175,35 @@ class _OrderEditListShowPageState extends State<OrderEditListShowPage> {
// planDishC.text = priceSum.toString();
});
}
if (widget.storeList != null) {
SunListPlan sunListPlanTemp = SunListPlan();
widget.storeList.forEach((sunListPlan) {
sunListPlanTemp = sunListPlan;
sunListPlanTemp.cookList.forEach((menuModel) {
menuModel.cookbooklist.removeWhere((element) => element.amount == 0);
});
sunListPlanTemp.cookList
.removeWhere((element) => element.cookbooklist.length == 0);
print(sunListPlanTemp);
storeListLocal.add(sunListPlanTemp);
});
SunListPlan sunListPlanTempMine = SunListPlan();
widget.mineList.forEach((sunListPlan) {
sunListPlanTempMine = sunListPlan;
sunListPlanTempMine.cookList.forEach((menuModel) {
menuModel.cookbooklist.removeWhere((element) => element.amount == 0);
});
sunListPlanTempMine.cookList
.removeWhere((element) => element.cookbooklist.length == 0);
print(sunListPlanTemp);
mineListLocal.add(sunListPlanTempMine);
});
}
_calculatePrice();
if (widget.planPrice != null) {
planDishC.text = widget.planPrice;
}
print(dataLocalShowMore);
print(dataLocalShowOne);
}
... ... @@ -179,22 +215,24 @@ class _OrderEditListShowPageState extends State<OrderEditListShowPage> {
dataLocalShowMore.forEach((element) {
if (element.channel == '1' || element.channel == '2') {
List<SunListPlan> olddata =
element.channel == '1' ? widget.storeList : widget.mineList;
element.channel == '1' ? storeListLocal : mineListLocal;
olddata.forEach((store) {
if (element.amount > 0) {
if (store.id == element.id) {
bool isChange = false; //套餐数量是否发生变化
//同一个套餐
store.cookList.forEach((storeCook) {
if (store.cookList.length != element.cookList.length) {
if (store.cookList.length > element.cookList.length) {
//删除了整个菜品分类
isChange = true;
}
element.cookList.forEach((cooklist) {
if (cooklist.id == storeCook.id) {
if (cooklist.cookbooklist.length !=
storeCook.cookbooklist.length) {
isChange = true;
}
// if (cooklist.cookbooklist.length !=
// storeCook.cookbooklist.length) {
// isChange = true;
// }
//同一分类
cooklist.cookbooklist.forEach((value1) {
storeCook.cookbooklist.forEach((value2) {
... ... @@ -263,6 +301,7 @@ class _OrderEditListShowPageState extends State<OrderEditListShowPage> {
});
}
});
planDishC.text = priceSum.toString();
}
... ... @@ -313,6 +352,21 @@ class _OrderEditListShowPageState extends State<OrderEditListShowPage> {
// }
// }
// 数组拷贝
List copyWithList(List list) {
List copyList = [];
for (var item in list) {
if (item is Map) {
copyList.add(Map.from(item));
} else if (item is List) {
copyList.add(copyWithList(item));
} else {
copyList.add(item);
}
}
return copyList;
}
@override
Widget build(BuildContext context) {
return KeyboardDismissOnTap(
... ... @@ -351,7 +405,7 @@ class _OrderEditListShowPageState extends State<OrderEditListShowPage> {
Expanded(
child: TextField(
maxLines: 1,
// controller:
controller: planDishName,
// focusNode: _focusNode,
// autofocus: true,
... ... @@ -1435,7 +1489,7 @@ class _OrderEditListShowPageState extends State<OrderEditListShowPage> {
color: MyColours.color_DBDBDB)),
child: TextField(
maxLines: 4,
// controller:
controller: planDishRemark,
// focusNode: _focusNode,
// autofocus: true,
... ... @@ -1642,7 +1696,93 @@ class _OrderEditListShowPageState extends State<OrderEditListShowPage> {
fontSize: 32,
isBold: false,
onPressed: () {
NavigatorUtil.goOrderPreviewPage(context);
FocusScope.of(context)
.requestFocus(FocusNode()); //点击空白处隐藏键盘
List<MenuModel> showList = [];
dataLocalShowMore.forEach((value) {
value.cookList.forEach((newValue) {
if (showList.length == 0) {
showList
.add(MenuModel.fromJson2(newValue.toJson()));
} else {
bool hasC = false;
showList.forEach((show) {
if (show.id == newValue.id) {
hasC = true;
//数据存在相同菜类
newValue.cookbooklist.forEach((newcook) {
bool has = false;
show.cookbooklist.forEach((oldshow) {
if (oldshow.id == newcook.id) {
//同一个菜品
has = true;
oldshow.amount += newcook.amount;
show.allSum += newcook.amount;
}
});
if (!has) {
//旧的里面没有该菜品
show.cookbooklist.add(newcook);
}
});
}
});
if (!hasC) {
showList
.add(MenuModel.fromJson2(newValue.toJson()));
}
}
});
});
print(showList);
dataLocalShowOne.forEach((element) {
if (showList.length == 0) {
showList.add(MenuModel.fromJson2(element.toJson()));
} else {
bool hasC = false;
showList.forEach((show) {
if (show.id == element.id) {
hasC = true;
//数据存在相同菜类
element.cookbooklist.forEach((newcook) {
bool has = false;
show.cookbooklist.forEach((oldshow) {
if (oldshow.id == newcook.id) {
//同一个菜品
has = true;
oldshow.amount += newcook.amount;
show.allSum += newcook.amount;
}
});
if (!has) {
//旧的里面没有该菜品
show.cookbooklist.add(newcook);
}
});
}
});
if (!hasC) {
showList.add(MenuModel.fromJson2(element.toJson()));
}
}
});
// double priceSum = 0; //总计
// double memberPriceSum = 0; //会员价
// TextEditingController planDishC =
// TextEditingController(); //排菜价
NavigatorUtil.goOrderPreviewPage(context,
object: {'object': showList},
name: planDishName.text,
remark: planDishRemark.text,
priceSum: priceSum.toString(),
memberPriceSum: memberPriceSum.toString(),
planDishText: planDishC.text);
},
),
HEmptyView(30),
... ... @@ -1661,6 +1801,9 @@ class _OrderEditListShowPageState extends State<OrderEditListShowPage> {
Map data = {
'more': dataLocalShowMore,
'one': dataLocalShowOne,
'planPrice': planDishC.text,
'name': planDishName.text,
'remark': planDishRemark.text
};
Navigator.of(context).pop(data);
... ...
import 'package:flutter/material.dart';
import 'package:one_key/utils/repaint_boundary_utils.dart';
import 'package:one_key/widgets/system_app_bar.dart';
import 'package:provider/provider.dart';
import '../../../res/colors.dart';
import '../../../utils/screen_util.dart';
... ... @@ -8,12 +10,29 @@ import '../../../widgets/MyDivider.dart';
import '../../../widgets/h_empty_view.dart';
import '../../../widgets/round_button.dart';
import '../../../widgets/v_empty_view.dart';
import '../../models/cookbook_model.dart';
import '../../provider/user_model.dart';
import '../../utils/share_helper.dart';
/**
* 生成的预览页
*/
class OrderPreviewPage extends StatefulWidget {
OrderPreviewPage({Key key}) : super(key: key);
final List<MenuModel> showList;
final String priceSum;
final String memberPriceSum;
final String planDishText;
final String name;
final String remark;
OrderPreviewPage(
{Key key,
this.showList,
this.priceSum,
this.memberPriceSum,
this.planDishText,
this.name,
this.remark})
: super(key: key);
@override
_OrderPreviewPageState createState() => _OrderPreviewPageState();
... ... @@ -21,6 +40,8 @@ class OrderPreviewPage extends StatefulWidget {
class _OrderPreviewPageState extends State<OrderPreviewPage> {
ScrollController controller = ScrollController();
//全局key-截图key
final GlobalKey boundaryKey = GlobalKey();
@override
void initState() {
... ... @@ -52,6 +73,10 @@ class _OrderPreviewPageState extends State<OrderPreviewPage> {
@override
Widget build(BuildContext context) {
String sellername =
Provider.of<UserModel>(context, listen: false).user.sellername;
String sellerAdr =
Provider.of<UserModel>(context, listen: false).user.sellerAddr;
return Scaffold(
backgroundColor: MyColours.color_ffffff,
body: Column(
... ... @@ -59,327 +84,397 @@ class _OrderPreviewPageState extends State<OrderPreviewPage> {
Expanded(
child: SingleChildScrollView(
controller: controller,
child: Column(children: [
Container(
width: double.infinity,
margin: EdgeInsets.zero,
padding: EdgeInsets.only(
left: w(20), right: w(20), top: w(30), bottom: w(15)),
// height: w(200),
// constraints: new BoxConstraints.expand(
// height: w(200),
// ),
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage(Utils.getImgPath('preview_bg')),
fit: BoxFit.cover
child: RepaintBoundary(
key: boundaryKey,
child: Container(
color: Colors.white,
child: Column(children: [
Container(
width: double.infinity,
margin: EdgeInsets.zero,
padding: EdgeInsets.only(
left: w(20),
right: w(20),
top: w(30),
bottom: w(15)),
// height: w(200),
// constraints: new BoxConstraints.expand(
// height: w(200),
// ),
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage(
Utils.getImgPath('preview_bg')),
fit: BoxFit.cover
// centerSlice: new Rect.fromLTRB(270.0, 180.0, 1360.0, 730.0),
)),
// centerSlice: new Rect.fromLTRB(270.0, 180.0, 1360.0, 730.0),
)),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'14号酒庄 贵宾排菜菜单',
style: TextStyle(
fontSize: font(20),
fontWeight: FontWeight.bold,
color: MyColours.color_CFB53B),
),
VEmptyView(26),
Text(
'预定贵宾 | 刘生先生',
style: TextStyle(
fontSize: font(14),
color: MyColours.color_303030),
),
VEmptyView(10),
Text(
'预定时间 | 2022年11月11日 晚餐',
style: TextStyle(
fontSize: font(14),
color: MyColours.color_303030),
),
VEmptyView(10),
Text(
'区域桌台 | 一楼包间 108、一楼包间 108、一楼包间 108、一楼包间 108、一楼包间 108',
style: TextStyle(
fontSize: font(14),
color: MyColours.color_303030),
),
VEmptyView(10),
Text(
'餐厅地址 | 唐山市路北区拥军道88号',
style: TextStyle(
fontSize: font(14),
color: MyColours.color_303030),
),
VEmptyView(10),
Text(
'专属服务 | 张山山 18866668888',
style: TextStyle(
fontSize: font(14),
color: MyColours.color_303030),
),
],
),
),
Container(
width: double.infinity,
// width: w(32),
height: w(48),
padding: EdgeInsets.only(left: w(10), right: w(20)),
decoration: BoxDecoration(
border: Border(
// top: BorderSide(
// width: w(1), color: MyColours.color_DBDBDB),
bottom: BorderSide(
width: w(1),
color: MyColours.color_DBDBDB))),
// constraints: BoxConstraints(minWidth: w(20)),
child: Row(
children: [
Expanded(
child: TextField(
maxLines: 1,
// controller:
// focusNode: _focusNode,
// autofocus: true,
style: TextStyle(
color: MyColours.color_515151,
fontSize: font(16),
fontWeight: FontWeight.bold),
textAlign: TextAlign.left,
// textAlignVertical: TextAlignVertical.center,
decoration: InputDecoration(
// hintText: "请输入排菜名称",
hintText: '朋友小聚888套餐(若无名称不展示本行)',
hintStyle: TextStyle(
color: MyColours.color_999999,
fontSize: font(16),
fontWeight: FontWeight.bold),
// isCollapsed:
// true, //重点,相当于高度包裹的意思,必须设置为true,不然有默认奇妙的最小高度
border: OutlineInputBorder(
borderSide: BorderSide.none),
contentPadding: EdgeInsets.zero,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'${sellername} 贵宾排菜菜单',
style: TextStyle(
fontSize: font(20),
fontWeight: FontWeight.bold,
color: MyColours.color_CFB53B),
),
VEmptyView(26),
Text(
'预定贵宾 | 刘生先生',
style: TextStyle(
fontSize: font(14),
color: MyColours.color_303030),
),
VEmptyView(10),
Text(
'预定时间 | 2022年11月11日 晚餐',
style: TextStyle(
fontSize: font(14),
color: MyColours.color_303030),
),
VEmptyView(10),
Text(
'区域桌台 | 一楼包间 108、一楼包间 108、一楼包间 108、一楼包间 108、一楼包间 108',
style: TextStyle(
fontSize: font(14),
color: MyColours.color_303030),
),
VEmptyView(10),
Text(
'餐厅地址 | ${sellerAdr}',
style: TextStyle(
fontSize: font(14),
color: MyColours.color_303030),
),
VEmptyView(10),
Text(
'专属服务 | 张山山 18866668888',
style: TextStyle(
fontSize: font(14),
color: MyColours.color_303030),
),
],
),
keyboardType: TextInputType.text,
textInputAction: TextInputAction.done,
onChanged: (value) {
// setState(() {});
// _searchSellerLocation();
// customerProvider.searchData(value);
},
onEditingComplete: () {
FocusScope.of(context)
.requestFocus(FocusNode()); //点击空白处隐藏键盘
// contantShowModel.searchData(
// contantShowModel.controller.text);
// _searchSellerLocation();
// _focusNode.unfocus();
},
)),
Text(
'1份',
style: TextStyle(
fontSize: font(14),
color: MyColours.color_515151),
),
],
)),
ListView.builder(
itemCount: 20,
shrinkWrap: true,
controller: controller,
itemBuilder: (context, index) {
return ListView.builder(
itemCount: 2 + 1,
shrinkWrap: true,
controller: controller,
itemBuilder: (context, index) {
if (index == 0) {
return Column(
children: [
//头
Container(
width: double.infinity,
// width: w(32),
height: w(48),
padding: EdgeInsets.only(
left: w(10), right: w(20)),
widget.name != null && widget.name != ''
? Container(
width: double.infinity,
// width: w(32),
// constraints: BoxConstraints(
// minHeight: w(48),
// ),
// height: w(48),
padding: EdgeInsets.only(
left: w(10),
right: w(20),
top: w(10),
bottom: w(10)),
decoration: BoxDecoration(
border: Border(
// top: BorderSide(
// width: w(1), color: MyColours.color_DBDBDB),
bottom: BorderSide(
width: w(1),
color:
MyColours.color_DBDBDB))),
// constraints: BoxConstraints(minWidth: w(20)),
child: Row(
children: [
Expanded(
child: Text(
widget.name,
style: TextStyle(
color: MyColours.color_515151,
fontSize: font(16),
fontWeight: FontWeight.bold),
)
// TextField(
// maxLines: 1,
// // controller:
// // focusNode: _focusNode,
// // autofocus: true,
// style: TextStyle(
// color: MyColours.color_515151,
// fontSize: font(16),
// fontWeight: FontWeight.bold),
// textAlign: TextAlign.left,
// // textAlignVertical: TextAlignVertical.center,
// decoration: InputDecoration(
// // hintText: "请输入排菜名称",
// hintText: '朋友小聚888套餐(若无名称不展示本行)',
// hintStyle: TextStyle(
// color: MyColours.color_999999,
// fontSize: font(16),
// fontWeight: FontWeight.bold),
// // isCollapsed:
// // true, //重点,相当于高度包裹的意思,必须设置为true,不然有默认奇妙的最小高度
// border: OutlineInputBorder(
// borderSide: BorderSide.none),
// contentPadding: EdgeInsets.zero,
// ),
// keyboardType: TextInputType.text,
// textInputAction: TextInputAction.done,
// onChanged: (value) {
// // setState(() {});
// // _searchSellerLocation();
// // customerProvider.searchData(value);
// },
// onEditingComplete: () {
// FocusScope.of(context)
// .requestFocus(FocusNode()); //点击空白处隐藏键盘
// // contantShowModel.searchData(
// // contantShowModel.controller.text);
// // _searchSellerLocation();
// // _focusNode.unfocus();
// },
// )
),
HEmptyView(20),
Text(
'1份',
style: TextStyle(
fontSize: font(14),
color: MyColours.color_515151),
),
],
))
: SizedBox(),
ListView.builder(
itemCount: widget.showList.length,
shrinkWrap: true,
controller: controller,
padding: EdgeInsets.zero,
itemBuilder: (context, index) {
MenuModel menuModel = widget.showList[index];
return ListView.builder(
itemCount:
menuModel.cookbooklist.length + 1,
shrinkWrap: true,
controller: controller,
padding: EdgeInsets.zero,
itemBuilder: (context, index) {
if (index == 0) {
return Column(
children: [
//头
Container(
width: double.infinity,
// width: w(32),
height: w(48),
padding: EdgeInsets.only(
left: w(10),
right: w(20)),
decoration: BoxDecoration(
border: Border(
bottom: BorderSide(
width: w(1),
color: MyColours
.color_DBDBDB))),
// constraints: BoxConstraints(minWidth: w(20)),
child: Row(
mainAxisAlignment:
MainAxisAlignment
.spaceBetween,
children: [
Text(
menuModel.className,
style: TextStyle(
fontSize: font(16),
color: MyColours
.color_515151,
fontWeight:
FontWeight
.bold),
),
Text(
'${menuModel.allSum}道',
style: TextStyle(
fontSize: font(14),
color: MyColours
.color_515151,
),
),
],
))
],
);
}
int indexReal = index - 1;
MenuSunModel menuSunModel =
menuModel.cookbooklist[indexReal];
return Container(
padding: EdgeInsets.symmetric(
horizontal: w(20),
vertical: w(13)),
decoration: BoxDecoration(
border: Border(
bottom: BorderSide(
width: w(1),
color: MyColours
.color_DBDBDB))),
// constraints: BoxConstraints(minWidth: w(20)),
child: Row(
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: [
Text(
'热菜',
// Container(
// constraints: BoxConstraints(
// maxWidth: w(80)),
Expanded(
child: Text(
menuSunModel.name,
maxLines: 10,
overflow: TextOverflow.ellipsis,
style: TextStyle(
fontSize: font(16),
fontSize: font(14),
color:
MyColours.color_515151,
fontWeight:
FontWeight.bold),
),
MyColours.color_515151),
)),
// HEmptyView(8),
// _laduWidget(),
Spacer(),
Text(
'6道',
'${menuSunModel.price}元/${menuSunModel.unit}',
maxLines: 2,
overflow: TextOverflow.ellipsis,
style: TextStyle(
fontSize: font(14),
color: MyColours.color_515151,
),
fontSize: font(12),
color:
MyColours.color_515151),
),
// HEmptyView(108),
// Text(
// '38元/份',
// maxLines: 2,
// overflow: TextOverflow.ellipsis,
// style: TextStyle(
// fontSize: font(10),
// color: MyColours.color_8EBBBE),
// ),
Container(
width: w(79),
alignment:
Alignment.centerRight,
child: Text(
'${menuSunModel.amount}份',
style: TextStyle(
fontSize: font(12),
color: MyColours
.color_515151),
)),
],
))
],
);
}
int indexReal = index - 1;
return Container(
padding: EdgeInsets.symmetric(
horizontal: w(20), vertical: w(13)),
decoration: BoxDecoration(
border: Border(
bottom: BorderSide(
width: w(1),
color: MyColours.color_DBDBDB))),
child: Row(
),
);
});
}),
widget.remark != null && widget.remark != ''
? Container(
width: double.infinity,
padding: EdgeInsets.symmetric(
horizontal: w(15), vertical: w(7)),
margin: EdgeInsets.only(
top: w(7),
bottom: w(13),
left: w(20),
right: w(20)),
decoration: BoxDecoration(
borderRadius:
BorderRadius.circular(r(5)),
border: Border.all(
width: w(1),
color: MyColours.color_DBDBDB)),
child: Text(
"${widget.remark}",
style: TextStyle(
color: MyColours.color_515151,
fontSize: font(12)),
)
// child: TextField(
// maxLines: 4,
// // controller:
// // focusNode: _focusNode,
// // autofocus: true,
// style: TextStyle(
// color: MyColours.color_515151, fontSize: font(12)),
// textAlign: TextAlign.left,
// // textAlignVertical: TextAlignVertical.center,
// decoration: InputDecoration(
// hintText: "请输入整单备注",
// hintStyle: TextStyle(
// color: MyColours.color_999999,
// fontSize: font(12),
// ),
// // isCollapsed:
// // true, //重点,相当于高度包裹的意思,必须设置为true,不然有默认奇妙的最小高度
// border:
// OutlineInputBorder(borderSide: BorderSide.none),
// contentPadding: EdgeInsets.zero,
// ),
// keyboardType: TextInputType.number,
// textInputAction: TextInputAction.done,
// onChanged: (value) {
// // setState(() {});
// // _searchSellerLocation();
// // customerProvider.searchData(value);
// },
// onEditingComplete: () {
// FocusScope.of(context)
// .requestFocus(FocusNode()); //点击空白处隐藏键盘
// // contantShowModel.searchData(
// // contantShowModel.controller.text);
// // _searchSellerLocation();
// // _focusNode.unfocus();
// },
// ),
)
: SizedBox(),
Container(
decoration: BoxDecoration(
border: Border(
top: BorderSide(
width: w(1),
color: MyColours.color_DBDBDB))),
padding: EdgeInsets.symmetric(
horizontal: w(10), vertical: w(15)),
child: Row(
mainAxisAlignment:
MainAxisAlignment.spaceAround,
children: [
Container(
constraints:
BoxConstraints(maxWidth: w(80)),
child: Text(
'山城辣子鸡',
maxLines: 10,
overflow: TextOverflow.ellipsis,
style: TextStyle(
fontSize: font(14),
color: MyColours.color_515151),
)),
HEmptyView(8),
_laduWidget(),
Spacer(),
Text(
'38元/份',
maxLines: 2,
overflow: TextOverflow.ellipsis,
'总计',
style: TextStyle(
fontSize: font(12),
color: MyColours.color_515151),
),
HEmptyView(108),
// Text(
// '38元/份',
// maxLines: 2,
// overflow: TextOverflow.ellipsis,
// style: TextStyle(
// fontSize: font(10),
// color: MyColours.color_8EBBBE),
// ),
Text(
'1份',
'菜单价:${widget.priceSum}元',
style: TextStyle(
fontSize: font(12),
color: MyColours.color_515151),
),
],
),
);
});
}),
Container(
padding: EdgeInsets.symmetric(
horizontal: w(15), vertical: w(7)),
margin: EdgeInsets.only(
top: w(7), bottom: w(13), left: w(20), right: w(20)),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(r(5)),
border: Border.all(
width: w(1), color: MyColours.color_DBDBDB)),
child: TextField(
maxLines: 4,
// controller:
// focusNode: _focusNode,
// autofocus: true,
style: TextStyle(
color: MyColours.color_515151, fontSize: font(12)),
textAlign: TextAlign.left,
// textAlignVertical: TextAlignVertical.center,
decoration: InputDecoration(
hintText: "请输入整单备注",
hintStyle: TextStyle(
color: MyColours.color_999999,
fontSize: font(12),
),
// isCollapsed:
// true, //重点,相当于高度包裹的意思,必须设置为true,不然有默认奇妙的最小高度
border:
OutlineInputBorder(borderSide: BorderSide.none),
contentPadding: EdgeInsets.zero,
),
keyboardType: TextInputType.number,
textInputAction: TextInputAction.done,
onChanged: (value) {
// setState(() {});
// _searchSellerLocation();
// customerProvider.searchData(value);
},
onEditingComplete: () {
FocusScope.of(context)
.requestFocus(FocusNode()); //点击空白处隐藏键盘
// contantShowModel.searchData(
// contantShowModel.controller.text);
// _searchSellerLocation();
// _focusNode.unfocus();
},
),
),
]))),
Container(
decoration: BoxDecoration(
border: Border(
top: BorderSide(
width: w(1), color: MyColours.color_DBDBDB))),
padding: EdgeInsets.symmetric(horizontal: w(10), vertical: w(15)),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
Text(
'总计',
style: TextStyle(
fontSize: font(12), color: MyColours.color_515151),
),
Text(
'菜单价:1164元',
style: TextStyle(
fontSize: font(12), color: MyColours.color_515151),
),
Text(
'会员价:1125元',
style: TextStyle(
fontSize: font(12), color: MyColours.color_515151),
),
Text(
'排菜价:1100元',
style: TextStyle(
fontSize: font(12), color: MyColours.color_515151),
)
])),
Text(
'周到安排技术支持 400-000-9690',
style: TextStyle(fontSize: font(12), color: MyColours.color_999999),
),
Text(
'会员价:${widget.memberPriceSum}元',
style: TextStyle(
fontSize: font(12),
color: MyColours.color_515151),
),
Text(
'排菜价:${widget.planDishText}元',
style: TextStyle(
fontSize: font(12),
color: MyColours.color_515151),
)
])),
Text(
'周到安排技术支持 400-000-9690',
style: TextStyle(
fontSize: font(12),
color: MyColours.color_999999),
),
]))))),
Container(
color: MyColours.color_ffffff,
padding: EdgeInsets.only(
... ... @@ -414,6 +509,8 @@ class _OrderPreviewPageState extends State<OrderPreviewPage> {
fontSize: 36,
isBold: false,
onPressed: () {
ShareHelper.onShareWx(context,
boundaryKey: boundaryKey);
// NavigatorUtil.goOrderPreviewPage(context);
},
),
... ...
... ... @@ -20,6 +20,8 @@ class PlanDishProvider extends ChangeNotifier {
PageState pageStateMine = PageState.Success;
PageState pageStateMy = PageState.Loading;
PageState pageStateMenu = PageState.Loading;
List<MenuModel> menuModel; //菜品数据
List<MenuModel> menuModelForManager = []; //经理点菜菜品数据
... ...
... ... @@ -1249,6 +1249,12 @@ class NavigatorUtil {
static Future<dynamic> goOrderPreviewPage(
BuildContext context, {
replace = false,
Map object,
String priceSum,
String memberPriceSum,
String planDishText,
String name,
String remark,
}) {
// if (invoice != null) {
// return _navigateTo(context,
... ... @@ -1259,14 +1265,19 @@ class NavigatorUtil {
// return _navigateTo(context,
// "${Routes.order_advance_home_page}?tids=$tids&tableidNow=$tableidNow&fromPage=$fromPage&canChoose=$canChoose&object=${FluroConvertUtils.object2string(object)}");
// }
return _navigateTo(context, "${Routes.order_preview_page}",
return _navigateTo(context,
"${Routes.order_preview_page}?object=${FluroConvertUtils.object2string(object)}&priceSum=$priceSum&memberPriceSum=$memberPriceSum&planDishText=$planDishText&name=${Uri.encodeComponent(name)}&remark=${Uri.encodeComponent(remark)}",
replace: replace);
}
///经理排菜-编辑列表展示
static Future<dynamic> goOrderEditListShowPage(BuildContext context,
{replace = false, Map object, Map object1, Map object2}) {
{replace = false,
Map object,
Map object1,
Map object2,
String planPrice}) {
// if (invoice != null) {
// return _navigateTo(context,
// "${Routes.order_advance_home_page}?invoice=${FluroConvertUtils.object2string(invoice)}",
... ... @@ -1274,7 +1285,7 @@ class NavigatorUtil {
// }
if (object != null) {
return _navigateTo(context,
"${Routes.order_edit_list_show_page}?object=${FluroConvertUtils.object2string(object)}&object1=${FluroConvertUtils.object2string(object1)}&object2=${FluroConvertUtils.object2string(object2)}");
"${Routes.order_edit_list_show_page}?object=${FluroConvertUtils.object2string(object)}&object1=${FluroConvertUtils.object2string(object1)}&object2=${FluroConvertUtils.object2string(object2)}&planPrice=$planPrice");
}
return _navigateTo(context, "${Routes.order_edit_list_show_page}",
replace: replace);
... ...
... ... @@ -1986,8 +1986,37 @@ var orderPreviewPageHandle = new Handler(
// res.add(TableList.fromJson(item));
// }
// }
List<MenuModel> res = [];
// String planDishPrice = '';
if (params.keys.contains('object')) {
Map object = FluroConvertUtils.string2map(params["object"].first);
List temp = object['object'];
// planDishPrice = params["planDishPrice"].first;
for (var item in temp) {
// MenuModel menuModel = MenuModel.fromJson2(item);
// res.add(menuModel);
// print(res);
res.add(MenuModel.fromJson2(item));
}
}
String priceSum = params["priceSum"].first;
String memberPriceSum = params["memberPriceSum"].first;
String planDishText = params["planDishText"].first;
String name = params["name"].first;
String remark = params["remark"].first;
return ChangeNotifierProvider<PlanDishProvider>(
create: (_) => PlanDishProvider(), child: OrderPreviewPage());
create: (_) => PlanDishProvider(),
child: OrderPreviewPage(
showList: res,
priceSum: priceSum,
memberPriceSum: memberPriceSum,
planDishText: planDishText,
name: name,
remark: remark));
});
///经理排菜---排菜编辑列表展示
... ... @@ -2029,7 +2058,6 @@ var orderEditListShowPageHandle = new Handler(
List temp = object['object1'];
// SunListPlan plan = SunListPlan();
// plan.
// planDishPrice = params["planDishPrice"].first;
for (var item in temp) {
// MenuModel menuModel = MenuModel.fromJson2(item);
... ... @@ -2054,8 +2082,13 @@ var orderEditListShowPageHandle = new Handler(
}
}
String planPrice = params["planPrice"].first;
return OrderEditListShowPage(
data: res, storeList: storeList, mineList: mineList);
data: res,
storeList: storeList,
mineList: mineList,
planPrice: planPrice);
});
///经理排菜--类型选择
... ...
/*
* @Author: 王长春
* @Date: 2022-03-14 09:24:34
* @LastEditors: 王长春
* @LastEditTime: 2022-03-17 10:01:41
* @Description: 截图工具,生成截图,保存到相册或者保存本地cash文件夹返回文件路径(供分享使用)
*/
import 'dart:io';
import 'dart:typed_data';
import 'dart:async';
import 'dart:ui';
import 'dart:ui' as ui;
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
// import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:image_gallery_saver/image_gallery_saver.dart';
import 'package:one_key/utils/utils.dart';
import 'package:path_provider/path_provider.dart';
import 'package:permission_handler/permission_handler.dart';
class RepaintBoundaryUtils {
//全局key-截图key
// final GlobalKey boundaryKey = GlobalKey();
//生成截图
/// 截屏图片生成图片流ByteData
Future<String> captureImage(boundaryKey) async {
RenderRepaintBoundary boundary =
boundaryKey.currentContext.findRenderObject() as RenderRepaintBoundary;
double dpr = ui.window.devicePixelRatio; // 获取当前设备的像素比
var image = await boundary.toImage(pixelRatio: dpr);
// 将image转化成byte
ByteData byteData = await image.toByteData(format: ImageByteFormat.png);
var filePath = "";
Uint8List pngBytes = byteData.buffer.asUint8List();
// 获取手机存储(getTemporaryDirectory临时存储路径)
Directory applicationDir = await getTemporaryDirectory();
// getApplicationDocumentsDirectory();
// 判断路径是否存在
bool isDirExist = await Directory(applicationDir.path).exists();
if (!isDirExist) Directory(applicationDir.path).create();
// 直接保存,返回的就是保存后的文件
File saveFile = await File(
applicationDir.path + "${DateTime.now().toIso8601String()}.jpg")
.writeAsBytes(pngBytes);
filePath = saveFile.path;
// if (Platform.isAndroid) {
// // 如果是Android 的话,直接使用image_gallery_saver就可以了
// // 图片byte数据转化unit8
// Uint8List images = byteData!.buffer.asUint8List();
// // 调用image_gallery_saver的saveImages方法,返回值就是图片保存后的路径
// String result = await ImageGallerySaver.saveImage(images);
// // 需要去除掉file://开头。生成要使用的file
// File saveFile = new File(result.replaceAll("file://", ""));
// filePath = saveFile.path;
//
//
// } else if (Platform.isIOS) {
// // 图片byte数据转化unit8
//
// }
return filePath;
}
//申请存本地相册权限
Future<bool> getPormiation() async {
if (Platform.isIOS) {
var status = await Permission.photos.status;
if (status.isDenied) {
Map<Permission, PermissionStatus> statuses = await [
Permission.photos,
].request();
// saveImage(globalKey);
}
return status.isGranted;
} else {
var status = await Permission.storage.status;
if (status.isDenied) {
Map<Permission, PermissionStatus> statuses = await [
Permission.storage,
].request();
}
return status.isGranted;
}
}
//保存到相册
void savePhoto(boundaryKey) async {
RenderRepaintBoundary boundary =
boundaryKey.currentContext.findRenderObject() as RenderRepaintBoundary;
double dpr = ui.window.devicePixelRatio; // 获取当前设备的像素比
var image = await boundary.toImage(pixelRatio: dpr);
// 将image转化成byte
ByteData byteData = await image.toByteData(format: ImageByteFormat.png);
//获取保存相册权限,如果没有,则申请改权限
bool permition = await getPormiation();
var status = await Permission.photos.status;
if (permition) {
if (Platform.isIOS) {
if (status.isGranted) {
Uint8List images = byteData.buffer.asUint8List();
final result = await ImageGallerySaver.saveImage(images,
quality: 60, name: "hello");
Utils.showToast("保存成功");
}
if (status.isDenied) {
print("IOS拒绝");
}
} else {
//安卓
if (status.isGranted) {
print("Android已授权");
Uint8List images = byteData.buffer.asUint8List();
final result = await ImageGallerySaver.saveImage(images, quality: 60);
if (result != null) {
Utils.showToast("保存成功");
} else {
print('error');
// toast("保存失败");
}
}
}
} else {
//重新请求--第一次请求权限时,保存方法不会走,需要重新调一次
savePhoto(boundaryKey);
}
}
}
... ...
/*
* @Author: 王长春
* @Date: 2022-03-15 15:17:19
* @LastEditors: 王长春
* @LastEditTime: 2022-03-16 19:15:45
* @Description: 分享工具
*/
import 'package:flutter/material.dart';
import 'package:one_key/utils/repaint_boundary_utils.dart';
// import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:one_key/utils/utils.dart';
import 'package:one_key/utils/wx_sdk.dart';
// import 'package:organization/common/utils/repaintBoundary_utils.dart';
// import 'package:organization/common/utils/wechatSDK.dart';
// import 'package:share_plus/share_plus.dart';
class ShareHelper {
static bool wxIsInstalled = false;
//微信分享截图
static void onShareWx(BuildContext context,{boundaryKey}) async {
wxIsInstalled = await WxSdk.wxIsInstalled();
//收回键盘,如果有输入的情况下,先收回键盘,再截图
FocusScope.of(context).requestFocus(FocusNode());
if (wxIsInstalled) {
//分享
// WxSdk.ShareText("sdgsfds",title:"标题");
//获取截图地址
String filePath = await RepaintBoundaryUtils().captureImage(boundaryKey);
print(filePath);
WxSdk.ShareImage(title: "机构检索", decs: "", file: filePath);
} else {
//提示未安装微信
Utils.showToast("未安装微信");
}
}
// static void checkWx() async {
// wxIsInstalled = await WxSdk.wxIsInstalled();
// }
}
... ...
import 'dart:io';
import 'dart:typed_data';
// import 'check.dart';
import 'package:fluwx/fluwx.dart' as fluwx;
class WxSdk {
// static bool wxIsInstalled;
static Future init() async {
fluwx.registerWxApi(
appId: "这里写你注册的appid",
doOnAndroid: true,
doOnIOS: true,
universalLink: "这里写你注册的universalLink");
}
static Future<bool> wxIsInstalled() async {
return await fluwx.isWeChatInstalled;
}
/**
* 分享图片到微信,
* file=本地路径
* url=网络地址
* asset=内置在app的资源图片
* scene=分享场景,1好友会话,2朋友圈,3收藏
*/
static void ShareImage(
{String title,
String decs,
String file,
String url,
String asset,
int scene = 1}) async {
fluwx.WeChatScene wxScene = fluwx.WeChatScene.SESSION;
if (scene == 2) {
wxScene = fluwx.WeChatScene.TIMELINE;
} else if (scene == 3) {
wxScene = fluwx.WeChatScene.FAVORITE;
}
fluwx.WeChatShareImageModel model;
if (file != null) {
model = fluwx.WeChatShareImageModel(fluwx.WeChatImage.file(File(file)),
title: title, description: decs, scene: wxScene);
} else if (url != null) {
model = fluwx.WeChatShareImageModel(fluwx.WeChatImage.network(url),
title: title, description: decs, scene: wxScene);
} else if (asset != null) {
model = fluwx.WeChatShareImageModel(fluwx.WeChatImage.asset(asset),
title: title, description: decs, scene: wxScene);
} else {
throw Exception("缺少图片资源信息");
}
fluwx.shareToWeChat(model);
}
/**
* 分享文本
* content=分享内容
* scene=分享场景,1好友会话,2朋友圈,3收藏
*/
static void ShareText(String content, {String title, int scene = 1}) {
fluwx.WeChatScene wxScene = fluwx.WeChatScene.SESSION;
if (scene == 2) {
wxScene = fluwx.WeChatScene.TIMELINE;
} else if (scene == 3) {
wxScene = fluwx.WeChatScene.FAVORITE;
}
fluwx.WeChatShareTextModel model =
fluwx.WeChatShareTextModel(content, title: title, scene: wxScene);
fluwx.shareToWeChat(model);
}
/***
* 分享视频
* videoUrl=视频网上地址
* thumbFile=缩略图本地路径
* scene=分享场景,1好友会话,2朋友圈,3收藏
*/
static void ShareVideo(String videoUrl,
{String thumbFile, String title, String desc, int scene = 1}) {
fluwx.WeChatScene wxScene = fluwx.WeChatScene.SESSION;
if (scene == 2) {
wxScene = fluwx.WeChatScene.TIMELINE;
} else if (scene == 3) {
wxScene = fluwx.WeChatScene.FAVORITE;
}
fluwx.WeChatImage image;
if (thumbFile != null) {
image = fluwx.WeChatImage.file(File(thumbFile));
}
var model = fluwx.WeChatShareVideoModel(
videoUrl: videoUrl,
thumbnail: image,
title: title,
description: desc,
scene: wxScene);
fluwx.shareToWeChat(model);
}
/**
* 分享链接
* url=链接
* thumbFile=缩略图本地路径
* scene=分享场景,1好友会话,2朋友圈,3收藏
*/
static bool strNoEmpty(String str) {
if (str == null || str == '') {
return false;
}
return true;
}
static void ShareUrl(String url,
{String thumbFile,
Uint8List thumbBytes,
String title,
String desc,
int scene = 1,
String networkThumb,
String assetThumb}) {
desc = desc ?? "";
title = title ?? "";
if (desc.length > 54) {
desc = desc.substring(0, 54) + "...";
}
if (title.length > 20) {
title = title.substring(0, 20) + "...";
}
fluwx.WeChatScene wxScene = fluwx.WeChatScene.SESSION;
if (scene == 2) {
wxScene = fluwx.WeChatScene.TIMELINE;
} else if (scene == 3) {
wxScene = fluwx.WeChatScene.FAVORITE;
}
fluwx.WeChatImage image;
if (thumbFile != null) {
image = fluwx.WeChatImage.file(File(thumbFile));
} else if (thumbBytes != null) {
image = fluwx.WeChatImage.binary(thumbBytes);
} else if (strNoEmpty(networkThumb)) {
image = fluwx.WeChatImage.network(Uri.encodeFull(networkThumb));
} else if (strNoEmpty(assetThumb)) {
image = fluwx.WeChatImage.asset(assetThumb, suffix: ".png");
}
var model = fluwx.WeChatShareWebPageModel(
url,
thumbnail: image,
title: title,
description: desc,
scene: wxScene,
);
fluwx.shareToWeChat(model);
}
}
... ...
... ... @@ -623,6 +623,13 @@ packages:
url: "https://pub.flutter-io.cn"
source: hosted
version: "4.0.1"
image_gallery_saver:
dependency: "direct main"
description:
name: image_gallery_saver
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.7.1"
image_picker:
dependency: "direct main"
description:
... ...
... ... @@ -177,6 +177,7 @@ dependencies:
flutter_keyboard_visibility: ^5.3.0
#
extended_text_field: ^10.1.1
image_gallery_saver: ^1.7.1
... ...