|
...
|
...
|
@@ -154,19 +154,19 @@ class Utils { |
|
|
|
return double.tryParse(s) != null;
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool isNumericReq(String str) {
|
|
|
|
final reg = RegExp(r'^[0-9]+$');
|
|
|
|
static bool isNumericReq(String str) {
|
|
|
|
final reg = RegExp(r'^[0-9]+$');
|
|
|
|
print('$str 是否数字:${reg.hasMatch(str)}');
|
|
|
|
return reg.hasMatch(str);
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool isNumeric1Req(String str) {
|
|
|
|
final reg = RegExp(r'((\d{11})|^((\d{7,8})|(\d{4}|\d{3})-(\d{7,8})|(\d{4}|\d{3})-(\d{7,8})-(\d{4}|\d{3}|\d{2}|\d{1})|(\d{7,8})-(\d{4}|\d{3}|\d{2}|\d{1}))$)');
|
|
|
|
static bool isNumeric1Req(String str) {
|
|
|
|
final reg = RegExp(
|
|
|
|
r'((\d{11})|^((\d{7,8})|(\d{4}|\d{3})-(\d{7,8})|(\d{4}|\d{3})-(\d{7,8})-(\d{4}|\d{3}|\d{2}|\d{1})|(\d{7,8})-(\d{4}|\d{3}|\d{2}|\d{1}))$)');
|
|
|
|
print('$str 是否数字:${reg.hasMatch(str)}');
|
|
|
|
return reg.hasMatch(str);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ^(([^0][0-9]+|0)$)|^(([1-9]+)$)
|
|
|
|
|
|
|
|
// 验证是否为数字
|
|
...
|
...
|
@@ -176,7 +176,7 @@ class Utils { |
|
|
|
return reg.hasMatch(str);
|
|
|
|
}
|
|
|
|
|
|
|
|
// 验证是否为数字
|
|
|
|
// 验证是否为数字
|
|
|
|
static bool isIntegerS(String str) {
|
|
|
|
final reg = RegExp(r'^[0-9]\d*$');
|
|
|
|
print('$str 是否数字:${reg.hasMatch(str)}');
|
|
...
|
...
|
@@ -2080,7 +2080,8 @@ class Utils { |
|
|
|
bool isSuccess = await shareToWeChat(model);
|
|
|
|
return isSuccess;
|
|
|
|
}
|
|
|
|
static Future<ui.Image> loadImage(var path, bool isUrl) async {
|
|
|
|
|
|
|
|
static Future<ui.Image> loadImage(var path, bool isUrl) async {
|
|
|
|
ImageStream stream;
|
|
|
|
if (isUrl) {
|
|
|
|
stream = NetworkImage(path).resolve(ImageConfiguration.empty);
|
|
...
|
...
|
@@ -2105,64 +2106,101 @@ class Utils { |
|
|
|
// return fi.image;
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
static Future< Uint8List> canvas(_thumbnail)async{
|
|
|
|
var pictureRecorder = new ui.PictureRecorder(); // 图片记录仪
|
|
|
|
var canvas = new Canvas(pictureRecorder); //canvas接受一个图片记录仪
|
|
|
|
var images = await loadImage(_thumbnail,true); // 使用方法获取Unit8List格式的图片
|
|
|
|
print(images);
|
|
|
|
Paint _linePaint = new Paint()
|
|
|
|
..color = Colors.blue
|
|
|
|
..style = PaintingStyle.fill
|
|
|
|
..isAntiAlias = true
|
|
|
|
..strokeCap = StrokeCap.round
|
|
|
|
..strokeWidth = 500;
|
|
|
|
|
|
|
|
// 绘制图片
|
|
|
|
canvas.drawImage(images, Offset(0, 0), _linePaint); // 直接画图
|
|
|
|
|
|
|
|
// 绘制圆圈
|
|
|
|
// canvas.drawCircle(
|
|
|
|
// new Offset(
|
|
|
|
// 60,
|
|
|
|
// images.height.toDouble() + 60,
|
|
|
|
// ),
|
|
|
|
// 40.0,
|
|
|
|
// _linePaint);
|
|
|
|
|
|
|
|
// 绘制文字
|
|
|
|
ui.ParagraphBuilder pb = ui.ParagraphBuilder(ui.ParagraphStyle(
|
|
|
|
textAlign: TextAlign.left,
|
|
|
|
fontWeight: FontWeight.w400,
|
|
|
|
fontStyle: FontStyle.normal,
|
|
|
|
|
|
|
|
// :MyColours.color_000000,
|
|
|
|
fontSize: 25.0));
|
|
|
|
pb.pushStyle(ui.TextStyle(color: Colors.black));
|
|
|
|
pb.addText('有一种感动就做只有你懂');
|
|
|
|
pb.addText('一个可以钻钱的app');
|
|
|
|
// 设置文本的宽度约束
|
|
|
|
ParagraphConstraints pc = ui.ParagraphConstraints(width: 500);
|
|
|
|
ui.Paragraph paragraph = pb.build()..layout(pc);
|
|
|
|
canvas.drawParagraph(
|
|
|
|
paragraph, Offset(0, images.height.toDouble() + 20));
|
|
|
|
|
|
|
|
|
|
|
|
//下面的代码是生成图片的关键代码,以上绘制文字和圆圈的代码可以忽略不计
|
|
|
|
var picture = await pictureRecorder.endRecording().toImage(500, 400);//设置生成图片的宽和高
|
|
|
|
var pngImageBytes = await picture.toByteData(format: ui.ImageByteFormat.png);
|
|
|
|
// var imgBytes = Uint8List.view(pngImageBytes.buffer); //这一行和下面这一行都是生成Uint8List格式的图片(原理还不知道)
|
|
|
|
Uint8List pngBytes = pngImageBytes.buffer.asUint8List();
|
|
|
|
print(pngBytes);//pngBytes可以放在Image.memory()中预览
|
|
|
|
// setState(() {
|
|
|
|
// imageMemory = pngBytes;
|
|
|
|
// });
|
|
|
|
return pngBytes;
|
|
|
|
static Future<Uint8List> canvas(
|
|
|
|
context, String _thumbnail, String month, String week) async {
|
|
|
|
var pictureRecorder = new ui.PictureRecorder(); // 图片记录仪
|
|
|
|
var canvas = new Canvas(pictureRecorder); //canvas接受一个图片记录仪
|
|
|
|
var images = await loadImage(_thumbnail, true); // 使用方法获取Unit8List格式的图片
|
|
|
|
print(images);
|
|
|
|
// Paint _linePaint = new Paint()
|
|
|
|
// ..color = Colors.blue
|
|
|
|
// ..style = PaintingStyle.fill
|
|
|
|
// ..isAntiAlias = true
|
|
|
|
// ..strokeCap = StrokeCap.round
|
|
|
|
// ..strokeWidth = 500;
|
|
|
|
// Paint selfPaint = Paint()
|
|
|
|
// ..color = Colors.red
|
|
|
|
// ..style = PaintingStyle.fill
|
|
|
|
// ..isAntiAlias = true
|
|
|
|
// ..strokeCap = StrokeCap.butt
|
|
|
|
// ..strokeWidth = 2;
|
|
|
|
final paint = Paint()
|
|
|
|
..color = Color.fromRGBO(0, 0, 0, 0.8)
|
|
|
|
..style = PaintingStyle.fill;
|
|
|
|
|
|
|
|
canvas.drawRect(Rect.fromLTWH(0, 0, 500, 400), paint);
|
|
|
|
|
|
|
|
canvas.drawImage(images, Offset(0, 0), paint);
|
|
|
|
|
|
|
|
|
|
|
|
// 绘制文字
|
|
|
|
ui.ParagraphBuilder pb2 = ui.ParagraphBuilder(ui.ParagraphStyle(
|
|
|
|
textAlign: TextAlign.center,
|
|
|
|
fontWeight: FontWeight.normal,
|
|
|
|
fontStyle: FontStyle.normal,
|
|
|
|
|
|
|
|
// :MyColours.color_000000,
|
|
|
|
fontSize: 26));
|
|
|
|
pb2.pushStyle(ui.TextStyle(color: MyColours.color_FFEFC5, fontSize: 26));
|
|
|
|
pb2.addText(
|
|
|
|
'${Provider.of<UserModel>(context, listen: false).user.sellername}');
|
|
|
|
|
|
|
|
// 设置文本的宽度约束
|
|
|
|
ParagraphConstraints pc2 = ui.ParagraphConstraints(width: 500);
|
|
|
|
ui.Paragraph paragraph2 = pb2.build()..layout(pc2);
|
|
|
|
canvas.drawParagraph(paragraph2, Offset(10, 40));
|
|
|
|
|
|
|
|
// 绘制文字
|
|
|
|
ui.ParagraphBuilder pb = ui.ParagraphBuilder(ui.ParagraphStyle(
|
|
|
|
textAlign: TextAlign.center,
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
fontStyle: FontStyle.normal,
|
|
|
|
|
|
|
|
// :MyColours.color_000000,
|
|
|
|
fontSize: 48));
|
|
|
|
pb.pushStyle(ui.TextStyle(color: MyColours.color_FFEFC5, fontSize: 48));
|
|
|
|
pb.addText(month);
|
|
|
|
|
|
|
|
// 设置文本的宽度约束
|
|
|
|
ParagraphConstraints pc = ui.ParagraphConstraints(width: 500);
|
|
|
|
ui.Paragraph paragraph = pb.build()..layout(pc);
|
|
|
|
canvas.drawParagraph(paragraph, Offset(10, 150));
|
|
|
|
|
|
|
|
// 绘制文字
|
|
|
|
ui.ParagraphBuilder pb3 = ui.ParagraphBuilder(ui.ParagraphStyle(
|
|
|
|
textAlign: TextAlign.center,
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
fontStyle: FontStyle.normal,
|
|
|
|
|
|
|
|
// :MyColours.color_000000,
|
|
|
|
fontSize: 42));
|
|
|
|
pb3.pushStyle(ui.TextStyle(color: MyColours.color_FFEFC5, fontSize: 42));
|
|
|
|
pb3.addText(week);
|
|
|
|
|
|
|
|
// 设置文本的宽度约束
|
|
|
|
ParagraphConstraints pc3 = ui.ParagraphConstraints(width: 500);
|
|
|
|
ui.Paragraph paragraph3 = pb3.build()..layout(pc3);
|
|
|
|
canvas.drawParagraph(paragraph3, Offset(10, 230));
|
|
|
|
|
|
|
|
//下面的代码是生成图片的关键代码,以上绘制文字和圆圈的代码可以忽略不计
|
|
|
|
var picture =
|
|
|
|
await pictureRecorder.endRecording().toImage(500, 400); //设置生成图片的宽和高
|
|
|
|
var pngImageBytes =
|
|
|
|
await picture.toByteData(format: ui.ImageByteFormat.png);
|
|
|
|
// var imgBytes = Uint8List.view(pngImageBytes.buffer); //这一行和下面这一行都是生成Uint8List格式的图片(原理还不知道)
|
|
|
|
Uint8List pngBytes = pngImageBytes.buffer.asUint8List();
|
|
|
|
print(pngBytes); //pngBytes可以放在Image.memory()中预览
|
|
|
|
// setState(() {
|
|
|
|
// imageMemory = pngBytes;
|
|
|
|
// Uint8List result = await resizeImage(pngBytes); //重置图片尺寸
|
|
|
|
Uint8List result = await testFromFileComporessList(context, pngBytes);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
//分享邀请函
|
|
|
|
static goShareInvicationToWeChat(BuildContext context, String rid, String uid,
|
|
|
|
{bool isWechat = true,String depositId}) async {
|
|
|
|
static goShareInvicationToWeChat(
|
|
|
|
BuildContext context, String rid, String uid, String month, String week,
|
|
|
|
{bool isWechat = true, String depositId}) async {
|
|
|
|
String _webPageUrl = "http://colorcun.com/";
|
|
|
|
// String _thumbnail =
|
|
|
|
// "https://xt04.colorcun.com/h5/index.html#/?id=163854&hasInvitation=1";
|
|
...
|
...
|
@@ -2173,9 +2211,13 @@ class Utils { |
|
|
|
// String _thumbnail = sellerImage == null || sellerImage == ''
|
|
|
|
// ? 'http://nosqn.colorcun.com/reserve/images/3x/%E6%9A%82%E6%97%A0.png'
|
|
|
|
// : sellerImage;
|
|
|
|
Uint8List _thumbnail =await canvas(sellerImage == null || sellerImage == ''
|
|
|
|
? 'http://nosqn.colorcun.com/reserve/images/3x/%E6%9A%82%E6%97%A0.png'
|
|
|
|
: sellerImage);
|
|
|
|
Uint8List _thumbnail = await canvas(
|
|
|
|
context,
|
|
|
|
sellerImage == null || sellerImage == ''
|
|
|
|
? 'http://nosqn.colorcun.com/reserve/images/3x/%E6%9A%82%E6%97%A0.png'
|
|
|
|
: sellerImage,
|
|
|
|
month,
|
|
|
|
week);
|
|
|
|
String _title =
|
|
|
|
"您预订的${Provider.of<UserModel>(context, listen: false).user.sellername},已经安排,点击查看详情";
|
|
|
|
|
|
...
|
...
|
@@ -2193,25 +2235,24 @@ class Utils { |
|
|
|
String _userName = "gh_487873d353b3";
|
|
|
|
// String _path =
|
|
|
|
// "pages/customer/index?id=$rid&hasInvitation=1&hasSellerShare=1&uid=$uid";
|
|
|
|
String _path =
|
|
|
|
String _path =
|
|
|
|
"pages/customer/detail_owner_invitation_new?id=$rid&hasInvitation=1&hasSellerShare=1&uid=$uid";
|
|
|
|
if(depositId != null){
|
|
|
|
_path =
|
|
|
|
"pages/customer/detail_owner_invitation_new?id=$rid&hasInvitation=1&hasSellerShare=1&uid=$uid&paymentId=$depositId";
|
|
|
|
}
|
|
|
|
if (depositId != null) {
|
|
|
|
_path =
|
|
|
|
"pages/customer/detail_owner_invitation_new?id=$rid&hasInvitation=1&hasSellerShare=1&uid=$uid&paymentId=$depositId";
|
|
|
|
}
|
|
|
|
var model = new WeChatShareMiniProgramModel(
|
|
|
|
webPageUrl: _webPageUrl,
|
|
|
|
userName: _userName,
|
|
|
|
title: _title,
|
|
|
|
path: _path,
|
|
|
|
description: _description,
|
|
|
|
miniProgramType: Constant.wxMiniProgramType, //体验版
|
|
|
|
miniProgramType: Constant.wxMiniProgramType, //
|
|
|
|
// miniProgramType: WXMiniProgramType.RELEASE, //正式版
|
|
|
|
// miniProgramType: //开发版
|
|
|
|
// thumbnail: WeChatImage.binary(source)
|
|
|
|
// thumbnail: WeChatImage.network(_thumbnail)
|
|
|
|
thumbnail: WeChatImage.binary(_thumbnail)
|
|
|
|
);
|
|
|
|
thumbnail: WeChatImage.binary(_thumbnail));
|
|
|
|
|
|
|
|
isSuccess = await shareToWeChat(model);
|
|
|
|
} else {
|
|
...
|
...
|
@@ -2419,24 +2460,24 @@ class Utils { |
|
|
|
tempList.removeRange(0, int.parse(hour));
|
|
|
|
|
|
|
|
// if (minute != '45') {
|
|
|
|
Map<String, List<int>> map = tempList[0];
|
|
|
|
Map mapNew = {};
|
|
|
|
// map.map((key, value) {
|
|
|
|
|
|
|
|
// mapNew[key]
|
|
|
|
// });
|
|
|
|
|
|
|
|
List<int> list = [];
|
|
|
|
map.forEach((key, value) {
|
|
|
|
value.forEach((element) {
|
|
|
|
if (int.parse(minute) <= element) {
|
|
|
|
list.add(element);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
mapNew[key] = list;
|
|
|
|
Map<String, List<int>> map = tempList[0];
|
|
|
|
Map mapNew = {};
|
|
|
|
// map.map((key, value) {
|
|
|
|
|
|
|
|
// mapNew[key]
|
|
|
|
// });
|
|
|
|
|
|
|
|
List<int> list = [];
|
|
|
|
map.forEach((key, value) {
|
|
|
|
value.forEach((element) {
|
|
|
|
if (int.parse(minute) <= element) {
|
|
|
|
list.add(element);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
tempList.removeAt(0);
|
|
|
|
tempList.insert(0, mapNew);
|
|
|
|
mapNew[key] = list;
|
|
|
|
});
|
|
|
|
tempList.removeAt(0);
|
|
|
|
tempList.insert(0, mapNew);
|
|
|
|
// }
|
|
|
|
|
|
|
|
// tempList.replaceRange(0, 0, mapNew);
|
...
|
...
|
|