|
|
|
import 'dart:convert';
|
|
|
|
import 'dart:async';
|
|
|
|
import 'dart:convert' as Convert;
|
|
|
|
import 'dart:io';
|
|
|
|
import 'dart:math';
|
|
|
|
import 'dart:typed_data';
|
|
|
|
import 'dart:ui';
|
|
|
|
|
|
|
|
import 'package:call_log/call_log.dart';
|
|
|
|
import 'package:common_utils/common_utils.dart';
|
|
...
|
...
|
@@ -197,9 +199,9 @@ class Utils { |
|
|
|
String stringSignTemp =
|
|
|
|
str + "&key=3F59D13EB7681868B96A50902296BCE6"; //注:key为商户平台设置的密钥key
|
|
|
|
|
|
|
|
var key = utf8.encode('3F59D13EB7681868B96A50902296BCE6');
|
|
|
|
var key = Convert.utf8.encode('3F59D13EB7681868B96A50902296BCE6');
|
|
|
|
var hmacSha256 = Hmac(sha256, key); // HMAC-SHA256
|
|
|
|
var bytes = utf8.encode(stringSignTemp);
|
|
|
|
var bytes = Convert.utf8.encode(stringSignTemp);
|
|
|
|
var digest = hmacSha256.convert(bytes);
|
|
|
|
|
|
|
|
print("HMAC digest as bytes: ${digest.bytes}");
|
|
...
|
...
|
@@ -1066,7 +1068,7 @@ class Utils { |
|
|
|
// for (var value in JsonDecoder().convert(str)) {
|
|
|
|
// list.add(value);
|
|
|
|
// }
|
|
|
|
list = jsonDecode(str);
|
|
|
|
list = Convert.jsonDecode(str);
|
|
|
|
return list;
|
|
|
|
}
|
|
|
|
|
|
...
|
...
|
@@ -1394,7 +1396,7 @@ class Utils { |
|
|
|
// "pack-cookbook/pages/success?rid=$rid&identity=2&hasOnlyShow=1";
|
|
|
|
print(data);
|
|
|
|
String _path =
|
|
|
|
"pack-cookbook/pages/success_new?cookbooklist=${json.encode(data)}&hasSuccess=1&oid=$oid&rid=$rid&identity=1&hasOnlyShow=1&sellerName=${Provider.of<UserModel>(context, listen: false).user.sellername}&sid=${Provider.of<UserModel>(context, listen: false).user.sellerid}&type=2&priceSum=${priceSum}&memberPriceSum=${memberPriceSum}&planPriceSum=${planPriceSum}&remark=${remark}&name=${name}&address=${address}&service=${service}";
|
|
|
|
"pack-cookbook/pages/success_new?cookbooklist=${Convert.json.encode(data)}&hasSuccess=1&oid=$oid&rid=$rid&identity=1&hasOnlyShow=1&sellerName=${Provider.of<UserModel>(context, listen: false).user.sellername}&sid=${Provider.of<UserModel>(context, listen: false).user.sellerid}&type=2&priceSum=${priceSum}&memberPriceSum=${memberPriceSum}&planPriceSum=${planPriceSum}&remark=${remark}&name=${name}&address=${address}&service=${service}";
|
|
|
|
String _description = "OneKey";
|
|
|
|
// Uint8List source = await testComporessList(context, _thumbnail);
|
|
|
|
print(_path);
|
|
...
|
...
|
@@ -2078,6 +2080,85 @@ class Utils { |
|
|
|
bool isSuccess = await shareToWeChat(model);
|
|
|
|
return isSuccess;
|
|
|
|
}
|
|
|
|
static Future<ui.Image> loadImage(var path, bool isUrl) async {
|
|
|
|
ImageStream stream;
|
|
|
|
if (isUrl) {
|
|
|
|
stream = NetworkImage(path).resolve(ImageConfiguration.empty);
|
|
|
|
} else {
|
|
|
|
stream = AssetImage(path, bundle: rootBundle)
|
|
|
|
.resolve(ImageConfiguration.empty);
|
|
|
|
}
|
|
|
|
Completer<ui.Image> completer = Completer<ui.Image>();
|
|
|
|
void listener(ImageInfo frame, bool synchronousCall) {
|
|
|
|
final ui.Image image = frame.image;
|
|
|
|
completer.complete(image);
|
|
|
|
stream.removeListener(ImageStreamListener(listener));
|
|
|
|
}
|
|
|
|
|
|
|
|
stream.addListener(ImageStreamListener(listener));
|
|
|
|
return completer.future;
|
|
|
|
}
|
|
|
|
// static Future<ui.Image> getImage(String asset) async {
|
|
|
|
// ByteData data = await rootBundle.load(asset);
|
|
|
|
// Codec codec = await ui.instantiateImageCodec(data.buffer.asUint8List());
|
|
|
|
// FrameInfo fi = await codec.getNextFrame();
|
|
|
|
// 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 goShareInvicationToWeChat(BuildContext context, String rid, String uid,
|
|
...
|
...
|
@@ -2089,9 +2170,12 @@ class Utils { |
|
|
|
// "https://qn.colorcun.com/reserve/images/%E5%BE%AE%E4%BF%A1%E5%9B%BE%E7%89%87_201911151148572.jpg";
|
|
|
|
String sellerImage =
|
|
|
|
Provider.of<UserModel>(context, listen: false).user.sellerimage;
|
|
|
|
String _thumbnail = sellerImage == null || sellerImage == ''
|
|
|
|
// 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;
|
|
|
|
: sellerImage);
|
|
|
|
String _title =
|
|
|
|
"您预订的${Provider.of<UserModel>(context, listen: false).user.sellername},已经安排,点击查看详情";
|
|
|
|
|
|
...
|
...
|
@@ -2125,46 +2209,46 @@ class Utils { |
|
|
|
// miniProgramType: WXMiniProgramType.RELEASE, //正式版
|
|
|
|
// miniProgramType: //开发版
|
|
|
|
// thumbnail: WeChatImage.binary(source)
|
|
|
|
thumbnail: WeChatImage.network(_thumbnail)
|
|
|
|
// thumbnail: WeChatImage.binary(image)
|
|
|
|
// thumbnail: WeChatImage.network(_thumbnail)
|
|
|
|
thumbnail: WeChatImage.binary(_thumbnail)
|
|
|
|
);
|
|
|
|
|
|
|
|
isSuccess = await shareToWeChat(model);
|
|
|
|
} else {
|
|
|
|
Loading.showLoading(context);
|
|
|
|
// Loading.showLoading(context);
|
|
|
|
|
|
|
|
// // String _path =
|
|
|
|
// // "pages/customer/index.html?id=$rid&hasInvitation=1&hasSellerShare=1&uid=$uid";
|
|
|
|
// String _path =
|
|
|
|
// "pages/customer/index.html?id=$rid&hasInvitation=1&hasSellerShare=1&uid=$uid";
|
|
|
|
String _path =
|
|
|
|
"pages/customer/detail_owner_invitation_new.html?id=$rid&hasInvitation=1&hasSellerShare=1&uid=$uid";
|
|
|
|
if(depositId != null){
|
|
|
|
_path =
|
|
|
|
"pages/customer/detail_owner_invitation_new.html?id=$rid&hasInvitation=1&hasSellerShare=1&uid=$uid&paymentId=$depositId";
|
|
|
|
}
|
|
|
|
FlutterWxwork flutterWxwork = FlutterWxwork();
|
|
|
|
bool isAppInstalled = await flutterWxwork.isAppInstalled();
|
|
|
|
print(isAppInstalled);
|
|
|
|
if (isAppInstalled) {
|
|
|
|
bool registerResult = await flutterWxwork.registerApp(
|
|
|
|
'wwauthbdca186ec4257973000003', 'wwbdca186ec4257973', '1000003');
|
|
|
|
print(registerResult);
|
|
|
|
|
|
|
|
// isSuccess = await flutterWxwork.shareText(text: "dddddddd");
|
|
|
|
dynamic isSuccess = await flutterWxwork.shareMiniProgram(
|
|
|
|
userName: 'gh_487873d353b3@app',
|
|
|
|
path: _path,
|
|
|
|
hdImageData: _thumbnail,
|
|
|
|
title: _title,
|
|
|
|
description: _description,
|
|
|
|
);
|
|
|
|
Loading.hideLoading(context);
|
|
|
|
|
|
|
|
// var isSuccess = await flutterWxwork.shareImage();
|
|
|
|
print(isSuccess);
|
|
|
|
} else {
|
|
|
|
Loading.hideLoading(context);
|
|
|
|
Utils.showToast('未安装企业微信');
|
|
|
|
}
|
|
|
|
// "pages/customer/detail_owner_invitation_new.html?id=$rid&hasInvitation=1&hasSellerShare=1&uid=$uid";
|
|
|
|
// if(depositId != null){
|
|
|
|
// _path =
|
|
|
|
// "pages/customer/detail_owner_invitation_new.html?id=$rid&hasInvitation=1&hasSellerShare=1&uid=$uid&paymentId=$depositId";
|
|
|
|
// }
|
|
|
|
// FlutterWxwork flutterWxwork = FlutterWxwork();
|
|
|
|
// bool isAppInstalled = await flutterWxwork.isAppInstalled();
|
|
|
|
// print(isAppInstalled);
|
|
|
|
// if (isAppInstalled) {
|
|
|
|
// bool registerResult = await flutterWxwork.registerApp(
|
|
|
|
// 'wwauthbdca186ec4257973000003', 'wwbdca186ec4257973', '1000003');
|
|
|
|
// print(registerResult);
|
|
|
|
|
|
|
|
// // isSuccess = await flutterWxwork.shareText(text: "dddddddd");
|
|
|
|
// dynamic isSuccess = await flutterWxwork.shareMiniProgram(
|
|
|
|
// userName: 'gh_487873d353b3@app',
|
|
|
|
// path: _path,
|
|
|
|
// hdImageData: _thumbnail,
|
|
|
|
// title: _title,
|
|
|
|
// description: _description,
|
|
|
|
// );
|
|
|
|
// Loading.hideLoading(context);
|
|
|
|
|
|
|
|
// // var isSuccess = await flutterWxwork.shareImage();
|
|
|
|
// print(isSuccess);
|
|
|
|
// } else {
|
|
|
|
// Loading.hideLoading(context);
|
|
|
|
// Utils.showToast('未安装企业微信');
|
|
|
|
// }
|
|
|
|
}
|
|
|
|
|
|
|
|
return isSuccess;
|
...
|
...
|
|