Commit 9c48bb14c44bcc81140abc85a81b024d191dcd3c

Authored by wdn127929
1 parent fb52e529

企业微信通知 ios ok

... ... @@ -4681,7 +4681,30 @@ class InvicationPageState extends State<InvicationPage>
}
}
}),
HEmptyView(40),
HEmptyView(20),
RoundButton(
text: '企业微信通知',
width: ScreenUtil().setWidth(100 * 2),
height: ScreenUtil().setWidth(96),
fontSize: 30,
textColor: MyColours.color_999999,
gradientStart: MyColours.color_f3f3f3,
gradientEnd: MyColours.color_f3f3f3,
radius: ScreenUtil().setWidth(8),
isBold: false,
onPressed: () async {
bool isSuccess = await Utils.goShareInvicationToWeChat(
context,
widget.rid,
Provider.of<UserModel>(context, listen: false).user.openid,
isWechat: false);
print(isSuccess);
if (isSuccess) {
// _addForward();
}
},
),
HEmptyView(20),
Expanded(
child: Stack(children: [
Row(
... ... @@ -4698,62 +4721,105 @@ class InvicationPageState extends State<InvicationPage>
],
),
RoundButton(
text: '微信通知',
height: ScreenUtil().setWidth(48 * 2),
fontSize: 38,
gradientStart: Colors.transparent,
gradientEnd: Colors.transparent,
radius: ScreenUtil().setWidth(16),
isBold: true,
onPressed: () async {
if (_nameNode.hasFocus ||
_phoneNode.hasFocus ||
_cusdemNode.hasFocus) {
needWechat = true;
_showConfirmWidget(
needWechat: true,
callback: () async {
if (ObjectUtil.isEmpty(
_baseIndoProvider.baseInfoSunModel) ||
ObjectUtil.isEmpty(
_baseIndoProvider.baseInfoSunModel.phone)) {
// Utils.showToast('请填写经理的联系电话');
DialogUtil.cupertinoAlertDialog(context,
title: "填写个人信息",
content: "暂未填写您的联系信息,请先前往填写,个人信息将会展示给您的顾客。",
lTitle: "取消",
rTitle: "去填写",
lCallback: () {}, rCallback: () {
_goBaseInfoPage();
});
text: '微信通知',
height: ScreenUtil().setWidth(48 * 2),
fontSize: 38,
gradientStart: Colors.transparent,
gradientEnd: Colors.transparent,
radius: ScreenUtil().setWidth(16),
isBold: true,
onPressed: () async {
if (_nameNode.hasFocus ||
_phoneNode.hasFocus ||
_cusdemNode.hasFocus) {
needWechat = true;
_showConfirmWidget(
needWechat: true,
callback: () async {
if (ObjectUtil.isEmpty(
_baseIndoProvider.baseInfoSunModel) ||
ObjectUtil.isEmpty(_baseIndoProvider
.baseInfoSunModel.phone)) {
// Utils.showToast('请填写经理的联系电话');
DialogUtil.cupertinoAlertDialog(context,
title: "填写个人信息",
content:
"暂未填写您的联系信息,请先前往填写,个人信息将会展示给您的顾客。",
lTitle: "取消",
rTitle: "去填写",
lCallback: () {}, rCallback: () {
_goBaseInfoPage();
});
return;
}
if (youhui != '选择优惠') {
Map<String, String> params = {
"rid": widget.rid,
"aid":
'${couponProvider.couponListSelect[couponSelectIndex].id}'
};
bool isSuc = await couponProvider
.setActivityAsReserve(context, params);
if (isSuc) {
couponProvider.hasModify = true;
bus.emit("refresh_book_list");
bool isSuccess =
await Utils.goShareInvicationToWeChat(
context,
widget.rid,
Provider.of<UserModel>(context,
listen: false)
.user
.openid);
print(isSuccess);
if (isSuccess) {
_addForward();
return;
}
}
} else {
if (youhui != '选择优惠') {
Map<String, String> params = {
"rid": widget.rid,
"aid":
'${couponProvider.couponListSelect[couponSelectIndex].id}'
};
bool isSuc = await couponProvider
.setActivityAsReserve(context, params);
if (isSuc) {
couponProvider.hasModify = true;
bus.emit("refresh_book_list");
bool isSuccess =
await Utils.goShareInvicationToWeChat(
context,
widget.rid,
Provider.of<UserModel>(context,
listen: false)
.user
.openid,
);
print(isSuccess);
if (isSuccess) {
_addForward();
}
}
} else {
bool isSuccess =
await Utils.goShareInvicationToWeChat(
context,
widget.rid,
Provider.of<UserModel>(context,
listen: false)
.user
.openid);
if (isSuccess) {
_addForward();
}
}
});
removeOverlay();
} else {
if (ObjectUtil.isEmpty(
_baseIndoProvider.baseInfoSunModel) ||
ObjectUtil.isEmpty(
_baseIndoProvider.baseInfoSunModel.phone)) {
// Utils.showToast('请填写经理的联系电话');
DialogUtil.cupertinoAlertDialog(context,
title: "填写个人信息",
content: "暂未填写您的联系信息,请先前往填写,个人信息将会展示给您的顾客。",
lTitle: "取消",
rTitle: "去填写",
lCallback: () {}, rCallback: () {
_goBaseInfoPage();
});
return;
}
if (youhui != '选择优惠') {
Map<String, String> params = {
"rid": widget.rid,
"aid":
'${couponProvider.couponListSelect[couponSelectIndex].id}'
};
bool isSuc = await couponProvider
.setActivityAsReserve(context, params);
if (isSuc) {
couponProvider.hasModify = true;
bus.emit("refresh_book_list");
bool isSuccess =
await Utils.goShareInvicationToWeChat(
context,
... ... @@ -4762,64 +4828,26 @@ class InvicationPageState extends State<InvicationPage>
listen: false)
.user
.openid);
print(isSuccess);
if (isSuccess) {
_addForward();
}
}
});
removeOverlay();
} else {
if (ObjectUtil.isEmpty(
_baseIndoProvider.baseInfoSunModel) ||
ObjectUtil.isEmpty(
_baseIndoProvider.baseInfoSunModel.phone)) {
// Utils.showToast('请填写经理的联系电话');
DialogUtil.cupertinoAlertDialog(context,
title: "填写个人信息",
content: "暂未填写您的联系信息,请先前往填写,个人信息将会展示给您的顾客。",
lTitle: "取消",
rTitle: "去填写",
lCallback: () {}, rCallback: () {
_goBaseInfoPage();
});
return;
}
if (youhui != '选择优惠') {
Map<String, String> params = {
"rid": widget.rid,
"aid":
'${couponProvider.couponListSelect[couponSelectIndex].id}'
};
bool isSuc = await couponProvider.setActivityAsReserve(
context, params);
if (isSuc) {
couponProvider.hasModify = true;
bus.emit("refresh_book_list");
bool isSuccess =
await Utils.goShareInvicationToWeChat(
context,
widget.rid,
Provider.of<UserModel>(context, listen: false)
.user
.openid);
print(isSuccess);
if (isSuccess) {
_addForward();
} else {
bool isSuccess =
await Utils.goShareInvicationToWeChat(
context,
widget.rid,
Provider.of<UserModel>(context,
listen: false)
.user
.openid);
if (isSuccess) {
_addForward();
}
}
}
} else {
bool isSuccess = await Utils.goShareInvicationToWeChat(
context,
widget.rid,
Provider.of<UserModel>(context, listen: false)
.user
.openid);
if (isSuccess) {
_addForward();
}
}
}
})
})
])),
],
));
... ...
... ... @@ -2338,6 +2338,22 @@ class TableManagerPageState extends State<TableManagerPage> {
},
),
HEmptyView(20),
RoundButton(
text: '企业微信通知',
width: ScreenUtil().setWidth(80 * 2),
height: ScreenUtil().setWidth(96),
fontSize: 24,
textColor: MyColours.color_515151,
gradientStart: MyColours.color_f3f3f3,
gradientEnd: MyColours.color_f3f3f3,
radius: ScreenUtil().setWidth(8),
isBold: false,
onPressed: () async {
JhCommonUtils.debounce(
() => _wechatReserve(false), 500);
},
),
HEmptyView(20),
Expanded(
child: RoundButton(
text: '微信通知',
... ... @@ -2348,7 +2364,8 @@ class TableManagerPageState extends State<TableManagerPage> {
radius: ScreenUtil().setWidth(8),
isBold: false,
onPressed: () async {
JhCommonUtils.debounce(() => _wechatReserve(), 500);
JhCommonUtils.debounce(
() => _wechatReserve(true), 500);
},
)),
],
... ... @@ -2359,7 +2376,7 @@ class TableManagerPageState extends State<TableManagerPage> {
));
}
_wechatReserve() async {
_wechatReserve(bool isWechat) async {
bool isShow = true; //是否需要弹窗 “预订失败!”
SunReserveInfoModel _model =
await tableManagerModel.setReserveInfo(context, (v) {
... ... @@ -2405,7 +2422,21 @@ class TableManagerPageState extends State<TableManagerPage> {
// }
// }
// } else {
NavigatorUtil.goInvicationPage(context, _model.row.id);
// if (isWechat) {
NavigatorUtil.goInvicationPage(context, _model.row.id);
// } else {
// bool isSuccess = await Utils.goShareInvicationToWeChat(
// context,
// _model.row.id,
// Provider.of<UserModel>(context, listen: false).user.openid,
// isWechat: false
// );
// print(isSuccess);
// if (isSuccess) {
// // _addForward();
// }
// }
// bool isSuccess =
// await Utils.goShareInvicationToWeChat(
// context,
... ...
... ... @@ -7,6 +7,7 @@
*/
import 'package:flutter/material.dart';
import 'package:flutter_wxwork/flutter_wxwork.dart';
import 'package:one_key/utils/repaint_boundary_utils.dart';
// import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:one_key/utils/utils.dart';
... ... @@ -41,4 +42,27 @@ class ShareHelper {
// wxIsInstalled = await WxSdk.wxIsInstalled();
// }
//企业微信分享
static Future<bool> onShareWxwork(BuildContext context, {boundaryKey}) async {
FlutterWxwork flutterWxwork = FlutterWxwork();
String ddd = await flutterWxwork.isAppInstalled();
print(ddd);
//收回键盘,如果有输入的情况下,先收回键盘,再截图
FocusScope.of(context).requestFocus(FocusNode());
// if (ddd) {
//分享
// WxSdk.ShareText("sdgsfds",title:"标题");
//获取截图地址
String filePath = await RepaintBoundaryUtils().captureImage(boundaryKey);
print(filePath);
await flutterWxwork.registerApp("wwauthbdca186ec4257973000006", "wwbdca186ec4257973", "1000006");
await flutterWxwork.shareImagePath(filePath);
// } else {
// //提示未安装微信
// Utils.showToast("未安装企业微信");
// }
}
}
... ...
... ... @@ -33,8 +33,11 @@ FlutterMethodChannel *channel;
[WWKApi sendReq:req];
authResult = result;
}
else if ([@"shareImage" isEqualToString:call.method]) {
[self shareImage:call result:result];
else if ([@"shareImageNetWork" isEqualToString:call.method]) {
[self shareImageNetWork:call result:result];
}
else if([@"shareImagePath" isEqualToString:call.method]) {
[self shareImagePath:call result:result];
}
else if ([@"shareMiniProgram" isEqualToString:call.method]) {
[self shareMiniProgram:call result:result];
... ... @@ -56,7 +59,7 @@ FlutterMethodChannel *channel;
}
- (void)shareImage:(FlutterMethodCall *)call result:(FlutterResult)result {
- (void)shareImageNetWork:(FlutterMethodCall *)call result:(FlutterResult)result {
[WWKApi registerApp:@"wwauthbdca186ec4257973000006" corpId:@"wwbdca186ec4257973" agentId:@"1000006"];
dispatch_queue_t globalQueue = dispatch_get_global_queue(0, 0);
... ... @@ -123,6 +126,46 @@ FlutterMethodChannel *channel;
}
- (void)shareImagePath:(FlutterMethodCall *)call result:(FlutterResult)result {
// [WWKApi registerApp:@"wwauthbdca186ec4257973000006" corpId:@"wwbdca186ec4257973" agentId:@"1000006"];
dispatch_queue_t globalQueue = dispatch_get_global_queue(0, 0);
dispatch_async(globalQueue, ^{
NSData *imageData= [NSData dataWithContentsOfFile:call.arguments[@"path"]];
dispatch_async(dispatch_get_main_queue(), ^{
WWKSendMessageReq *req = [[WWKSendMessageReq alloc] init];
WWKMessageImageAttachment *attachment = [[WWKMessageImageAttachment alloc] init];
// attachment.filename = @"icon.jpg";
// attachment.path = [[NSBundle mainBundle] pathForResource:@"icon" ofType:@"jpg"];
// NSURL *imageURL = [NSURL URLWithString:@"http://nosqn.colorcun.com/reserve/images/3x/%E6%9A%82%E6%97%A0.png"];
// //下载图片
// NSData *data= [NSData dataWithContentsOfURL:imageURL];
attachment.filename = @"share_image";
attachment.data = imageData;
req.attachment = attachment;
[WWKApi sendReq:req];
authResult = result;
});
});
// WWKSendMessageReq *req = [[WWKSendMessageReq alloc] init];
// WWKMessageImageAttachment *attachment = [[WWKMessageImageAttachment alloc] init];
// attachment.filename = @"icon.jpg";
// attachment.path = [[NSBundle mainBundle] pathForResource:@"icon" ofType:@"jpg"];
// // NSURL *imageURL = [NSURL URLWithString:@"http://nosqn.colorcun.com/reserve/images/3x/%E6%9A%82%E6%97%A0.png"];
// // //下载图片
// // NSData *data= [NSData dataWithContentsOfURL:imageURL];
// // attachment.data = data;
// req.attachment = attachment;
// [WWKApi sendReq:req];
}
- (void)shareMiniProgram:(FlutterMethodCall *)call result:(FlutterResult)result {
... ...
... ... @@ -19,8 +19,11 @@ class FlutterWxwork {
return FlutterWxworkPlatform.instance.isAppInstalled();
}
Future<bool> shareImage(String path) {
return FlutterWxworkPlatform.instance.shareImage(path);
Future<bool> shareImageNetWork(String path) {
return FlutterWxworkPlatform.instance.shareImageNetWork(path);
}
Future<bool> shareImagePath(String path) {
return FlutterWxworkPlatform.instance.shareImagePath(path);
}
Future<bool> shareMiniProgram(
... ...
... ... @@ -37,12 +37,22 @@ class MethodChannelFlutterWxwork extends FlutterWxworkPlatform {
}
@override
Future<bool> shareImage(String path) async {
final shareImage =
await methodChannel.invokeMethod<bool>('shareImage', <String, String>{
Future<bool> shareImageNetWork(String path) async {
final shareImageNetWork =
await methodChannel.invokeMethod<bool>('shareImageNetWork', <String, String>{
'path': path,
});
return shareImage;
return shareImageNetWork;
}
@override
Future<bool> shareImagePath(String path) async {
final shareImagePath =
await methodChannel.invokeMethod<bool>('shareImagePath', <String, String>{
'path': path,
});
return shareImagePath;
}
@override
... ...
... ... @@ -35,8 +35,12 @@ abstract class FlutterWxworkPlatform extends PlatformInterface {
throw UnimplementedError('isAppInstalled() has not been implemented.');
}
Future<bool> shareImage(String path) {
throw UnimplementedError('shareImage() has not been implemented.');
Future<bool> shareImageNetWork(String path) {
throw UnimplementedError('shareImageNetWork() has not been implemented.');
}
Future<bool> shareImagePath(String path) {
throw UnimplementedError('shareImagePath() has not been implemented.');
}
Future<AuthModel> auth() {
... ... @@ -44,7 +48,7 @@ abstract class FlutterWxworkPlatform extends PlatformInterface {
}
Future<bool> shareMiniProgram(
{ String userName, //必须是应用关联的小程序,注意要有@app后缀
{String userName, //必须是应用关联的小程序,注意要有@app后缀
String path,
String hdImageData,
String title = "分享标题"}) {
... ...