Showing
7 changed files
with
265 additions
and
122 deletions
| @@ -4681,7 +4681,30 @@ class InvicationPageState extends State<InvicationPage> | @@ -4681,7 +4681,30 @@ class InvicationPageState extends State<InvicationPage> | ||
| 4681 | } | 4681 | } |
| 4682 | } | 4682 | } |
| 4683 | }), | 4683 | }), |
| 4684 | - HEmptyView(40), | 4684 | + HEmptyView(20), |
| 4685 | + RoundButton( | ||
| 4686 | + text: '企业微信通知', | ||
| 4687 | + width: ScreenUtil().setWidth(100 * 2), | ||
| 4688 | + height: ScreenUtil().setWidth(96), | ||
| 4689 | + fontSize: 30, | ||
| 4690 | + textColor: MyColours.color_999999, | ||
| 4691 | + gradientStart: MyColours.color_f3f3f3, | ||
| 4692 | + gradientEnd: MyColours.color_f3f3f3, | ||
| 4693 | + radius: ScreenUtil().setWidth(8), | ||
| 4694 | + isBold: false, | ||
| 4695 | + onPressed: () async { | ||
| 4696 | + bool isSuccess = await Utils.goShareInvicationToWeChat( | ||
| 4697 | + context, | ||
| 4698 | + widget.rid, | ||
| 4699 | + Provider.of<UserModel>(context, listen: false).user.openid, | ||
| 4700 | + isWechat: false); | ||
| 4701 | + print(isSuccess); | ||
| 4702 | + if (isSuccess) { | ||
| 4703 | + // _addForward(); | ||
| 4704 | + } | ||
| 4705 | + }, | ||
| 4706 | + ), | ||
| 4707 | + HEmptyView(20), | ||
| 4685 | Expanded( | 4708 | Expanded( |
| 4686 | child: Stack(children: [ | 4709 | child: Stack(children: [ |
| 4687 | Row( | 4710 | Row( |
| @@ -4698,62 +4721,105 @@ class InvicationPageState extends State<InvicationPage> | @@ -4698,62 +4721,105 @@ class InvicationPageState extends State<InvicationPage> | ||
| 4698 | ], | 4721 | ], |
| 4699 | ), | 4722 | ), |
| 4700 | RoundButton( | 4723 | RoundButton( |
| 4701 | - text: '微信通知', | ||
| 4702 | - height: ScreenUtil().setWidth(48 * 2), | ||
| 4703 | - fontSize: 38, | ||
| 4704 | - gradientStart: Colors.transparent, | ||
| 4705 | - gradientEnd: Colors.transparent, | ||
| 4706 | - radius: ScreenUtil().setWidth(16), | ||
| 4707 | - isBold: true, | ||
| 4708 | - onPressed: () async { | ||
| 4709 | - if (_nameNode.hasFocus || | ||
| 4710 | - _phoneNode.hasFocus || | ||
| 4711 | - _cusdemNode.hasFocus) { | ||
| 4712 | - needWechat = true; | ||
| 4713 | - _showConfirmWidget( | ||
| 4714 | - needWechat: true, | ||
| 4715 | - callback: () async { | ||
| 4716 | - if (ObjectUtil.isEmpty( | ||
| 4717 | - _baseIndoProvider.baseInfoSunModel) || | ||
| 4718 | - ObjectUtil.isEmpty( | ||
| 4719 | - _baseIndoProvider.baseInfoSunModel.phone)) { | ||
| 4720 | - // Utils.showToast('请填写经理的联系电话'); | ||
| 4721 | - DialogUtil.cupertinoAlertDialog(context, | ||
| 4722 | - title: "填写个人信息", | ||
| 4723 | - content: "暂未填写您的联系信息,请先前往填写,个人信息将会展示给您的顾客。", | ||
| 4724 | - lTitle: "取消", | ||
| 4725 | - rTitle: "去填写", | ||
| 4726 | - lCallback: () {}, rCallback: () { | ||
| 4727 | - _goBaseInfoPage(); | ||
| 4728 | - }); | 4724 | + text: '微信通知', |
| 4725 | + height: ScreenUtil().setWidth(48 * 2), | ||
| 4726 | + fontSize: 38, | ||
| 4727 | + gradientStart: Colors.transparent, | ||
| 4728 | + gradientEnd: Colors.transparent, | ||
| 4729 | + radius: ScreenUtil().setWidth(16), | ||
| 4730 | + isBold: true, | ||
| 4731 | + onPressed: () async { | ||
| 4732 | + if (_nameNode.hasFocus || | ||
| 4733 | + _phoneNode.hasFocus || | ||
| 4734 | + _cusdemNode.hasFocus) { | ||
| 4735 | + needWechat = true; | ||
| 4736 | + _showConfirmWidget( | ||
| 4737 | + needWechat: true, | ||
| 4738 | + callback: () async { | ||
| 4739 | + if (ObjectUtil.isEmpty( | ||
| 4740 | + _baseIndoProvider.baseInfoSunModel) || | ||
| 4741 | + ObjectUtil.isEmpty(_baseIndoProvider | ||
| 4742 | + .baseInfoSunModel.phone)) { | ||
| 4743 | + // Utils.showToast('请填写经理的联系电话'); | ||
| 4744 | + DialogUtil.cupertinoAlertDialog(context, | ||
| 4745 | + title: "填写个人信息", | ||
| 4746 | + content: | ||
| 4747 | + "暂未填写您的联系信息,请先前往填写,个人信息将会展示给您的顾客。", | ||
| 4748 | + lTitle: "取消", | ||
| 4749 | + rTitle: "去填写", | ||
| 4750 | + lCallback: () {}, rCallback: () { | ||
| 4751 | + _goBaseInfoPage(); | ||
| 4752 | + }); | ||
| 4729 | 4753 | ||
| 4730 | - return; | ||
| 4731 | - } | ||
| 4732 | - if (youhui != '选择优惠') { | ||
| 4733 | - Map<String, String> params = { | ||
| 4734 | - "rid": widget.rid, | ||
| 4735 | - "aid": | ||
| 4736 | - '${couponProvider.couponListSelect[couponSelectIndex].id}' | ||
| 4737 | - }; | ||
| 4738 | - bool isSuc = await couponProvider | ||
| 4739 | - .setActivityAsReserve(context, params); | ||
| 4740 | - if (isSuc) { | ||
| 4741 | - couponProvider.hasModify = true; | ||
| 4742 | - bus.emit("refresh_book_list"); | ||
| 4743 | - bool isSuccess = | ||
| 4744 | - await Utils.goShareInvicationToWeChat( | ||
| 4745 | - context, | ||
| 4746 | - widget.rid, | ||
| 4747 | - Provider.of<UserModel>(context, | ||
| 4748 | - listen: false) | ||
| 4749 | - .user | ||
| 4750 | - .openid); | ||
| 4751 | - print(isSuccess); | ||
| 4752 | - if (isSuccess) { | ||
| 4753 | - _addForward(); | 4754 | + return; |
| 4754 | } | 4755 | } |
| 4755 | - } | ||
| 4756 | - } else { | 4756 | + if (youhui != '选择优惠') { |
| 4757 | + Map<String, String> params = { | ||
| 4758 | + "rid": widget.rid, | ||
| 4759 | + "aid": | ||
| 4760 | + '${couponProvider.couponListSelect[couponSelectIndex].id}' | ||
| 4761 | + }; | ||
| 4762 | + bool isSuc = await couponProvider | ||
| 4763 | + .setActivityAsReserve(context, params); | ||
| 4764 | + if (isSuc) { | ||
| 4765 | + couponProvider.hasModify = true; | ||
| 4766 | + bus.emit("refresh_book_list"); | ||
| 4767 | + bool isSuccess = | ||
| 4768 | + await Utils.goShareInvicationToWeChat( | ||
| 4769 | + context, | ||
| 4770 | + widget.rid, | ||
| 4771 | + Provider.of<UserModel>(context, | ||
| 4772 | + listen: false) | ||
| 4773 | + .user | ||
| 4774 | + .openid, | ||
| 4775 | + ); | ||
| 4776 | + print(isSuccess); | ||
| 4777 | + if (isSuccess) { | ||
| 4778 | + _addForward(); | ||
| 4779 | + } | ||
| 4780 | + } | ||
| 4781 | + } else { | ||
| 4782 | + bool isSuccess = | ||
| 4783 | + await Utils.goShareInvicationToWeChat( | ||
| 4784 | + context, | ||
| 4785 | + widget.rid, | ||
| 4786 | + Provider.of<UserModel>(context, | ||
| 4787 | + listen: false) | ||
| 4788 | + .user | ||
| 4789 | + .openid); | ||
| 4790 | + if (isSuccess) { | ||
| 4791 | + _addForward(); | ||
| 4792 | + } | ||
| 4793 | + } | ||
| 4794 | + }); | ||
| 4795 | + removeOverlay(); | ||
| 4796 | + } else { | ||
| 4797 | + if (ObjectUtil.isEmpty( | ||
| 4798 | + _baseIndoProvider.baseInfoSunModel) || | ||
| 4799 | + ObjectUtil.isEmpty( | ||
| 4800 | + _baseIndoProvider.baseInfoSunModel.phone)) { | ||
| 4801 | + // Utils.showToast('请填写经理的联系电话'); | ||
| 4802 | + DialogUtil.cupertinoAlertDialog(context, | ||
| 4803 | + title: "填写个人信息", | ||
| 4804 | + content: "暂未填写您的联系信息,请先前往填写,个人信息将会展示给您的顾客。", | ||
| 4805 | + lTitle: "取消", | ||
| 4806 | + rTitle: "去填写", | ||
| 4807 | + lCallback: () {}, rCallback: () { | ||
| 4808 | + _goBaseInfoPage(); | ||
| 4809 | + }); | ||
| 4810 | + return; | ||
| 4811 | + } | ||
| 4812 | + if (youhui != '选择优惠') { | ||
| 4813 | + Map<String, String> params = { | ||
| 4814 | + "rid": widget.rid, | ||
| 4815 | + "aid": | ||
| 4816 | + '${couponProvider.couponListSelect[couponSelectIndex].id}' | ||
| 4817 | + }; | ||
| 4818 | + bool isSuc = await couponProvider | ||
| 4819 | + .setActivityAsReserve(context, params); | ||
| 4820 | + if (isSuc) { | ||
| 4821 | + couponProvider.hasModify = true; | ||
| 4822 | + bus.emit("refresh_book_list"); | ||
| 4757 | bool isSuccess = | 4823 | bool isSuccess = |
| 4758 | await Utils.goShareInvicationToWeChat( | 4824 | await Utils.goShareInvicationToWeChat( |
| 4759 | context, | 4825 | context, |
| @@ -4762,64 +4828,26 @@ class InvicationPageState extends State<InvicationPage> | @@ -4762,64 +4828,26 @@ class InvicationPageState extends State<InvicationPage> | ||
| 4762 | listen: false) | 4828 | listen: false) |
| 4763 | .user | 4829 | .user |
| 4764 | .openid); | 4830 | .openid); |
| 4831 | + print(isSuccess); | ||
| 4765 | if (isSuccess) { | 4832 | if (isSuccess) { |
| 4766 | _addForward(); | 4833 | _addForward(); |
| 4767 | } | 4834 | } |
| 4768 | } | 4835 | } |
| 4769 | - }); | ||
| 4770 | - removeOverlay(); | ||
| 4771 | - } else { | ||
| 4772 | - if (ObjectUtil.isEmpty( | ||
| 4773 | - _baseIndoProvider.baseInfoSunModel) || | ||
| 4774 | - ObjectUtil.isEmpty( | ||
| 4775 | - _baseIndoProvider.baseInfoSunModel.phone)) { | ||
| 4776 | - // Utils.showToast('请填写经理的联系电话'); | ||
| 4777 | - DialogUtil.cupertinoAlertDialog(context, | ||
| 4778 | - title: "填写个人信息", | ||
| 4779 | - content: "暂未填写您的联系信息,请先前往填写,个人信息将会展示给您的顾客。", | ||
| 4780 | - lTitle: "取消", | ||
| 4781 | - rTitle: "去填写", | ||
| 4782 | - lCallback: () {}, rCallback: () { | ||
| 4783 | - _goBaseInfoPage(); | ||
| 4784 | - }); | ||
| 4785 | - return; | ||
| 4786 | - } | ||
| 4787 | - if (youhui != '选择优惠') { | ||
| 4788 | - Map<String, String> params = { | ||
| 4789 | - "rid": widget.rid, | ||
| 4790 | - "aid": | ||
| 4791 | - '${couponProvider.couponListSelect[couponSelectIndex].id}' | ||
| 4792 | - }; | ||
| 4793 | - bool isSuc = await couponProvider.setActivityAsReserve( | ||
| 4794 | - context, params); | ||
| 4795 | - if (isSuc) { | ||
| 4796 | - couponProvider.hasModify = true; | ||
| 4797 | - bus.emit("refresh_book_list"); | ||
| 4798 | - bool isSuccess = | ||
| 4799 | - await Utils.goShareInvicationToWeChat( | ||
| 4800 | - context, | ||
| 4801 | - widget.rid, | ||
| 4802 | - Provider.of<UserModel>(context, listen: false) | ||
| 4803 | - .user | ||
| 4804 | - .openid); | ||
| 4805 | - print(isSuccess); | ||
| 4806 | - if (isSuccess) { | ||
| 4807 | - _addForward(); | 4836 | + } else { |
| 4837 | + bool isSuccess = | ||
| 4838 | + await Utils.goShareInvicationToWeChat( | ||
| 4839 | + context, | ||
| 4840 | + widget.rid, | ||
| 4841 | + Provider.of<UserModel>(context, | ||
| 4842 | + listen: false) | ||
| 4843 | + .user | ||
| 4844 | + .openid); | ||
| 4845 | + if (isSuccess) { | ||
| 4846 | + _addForward(); | ||
| 4847 | + } | ||
| 4808 | } | 4848 | } |
| 4809 | } | 4849 | } |
| 4810 | - } else { | ||
| 4811 | - bool isSuccess = await Utils.goShareInvicationToWeChat( | ||
| 4812 | - context, | ||
| 4813 | - widget.rid, | ||
| 4814 | - Provider.of<UserModel>(context, listen: false) | ||
| 4815 | - .user | ||
| 4816 | - .openid); | ||
| 4817 | - if (isSuccess) { | ||
| 4818 | - _addForward(); | ||
| 4819 | - } | ||
| 4820 | - } | ||
| 4821 | - } | ||
| 4822 | - }) | 4850 | + }) |
| 4823 | ])), | 4851 | ])), |
| 4824 | ], | 4852 | ], |
| 4825 | )); | 4853 | )); |
| @@ -2338,6 +2338,22 @@ class TableManagerPageState extends State<TableManagerPage> { | @@ -2338,6 +2338,22 @@ class TableManagerPageState extends State<TableManagerPage> { | ||
| 2338 | }, | 2338 | }, |
| 2339 | ), | 2339 | ), |
| 2340 | HEmptyView(20), | 2340 | HEmptyView(20), |
| 2341 | + RoundButton( | ||
| 2342 | + text: '企业微信通知', | ||
| 2343 | + width: ScreenUtil().setWidth(80 * 2), | ||
| 2344 | + height: ScreenUtil().setWidth(96), | ||
| 2345 | + fontSize: 24, | ||
| 2346 | + textColor: MyColours.color_515151, | ||
| 2347 | + gradientStart: MyColours.color_f3f3f3, | ||
| 2348 | + gradientEnd: MyColours.color_f3f3f3, | ||
| 2349 | + radius: ScreenUtil().setWidth(8), | ||
| 2350 | + isBold: false, | ||
| 2351 | + onPressed: () async { | ||
| 2352 | + JhCommonUtils.debounce( | ||
| 2353 | + () => _wechatReserve(false), 500); | ||
| 2354 | + }, | ||
| 2355 | + ), | ||
| 2356 | + HEmptyView(20), | ||
| 2341 | Expanded( | 2357 | Expanded( |
| 2342 | child: RoundButton( | 2358 | child: RoundButton( |
| 2343 | text: '微信通知', | 2359 | text: '微信通知', |
| @@ -2348,7 +2364,8 @@ class TableManagerPageState extends State<TableManagerPage> { | @@ -2348,7 +2364,8 @@ class TableManagerPageState extends State<TableManagerPage> { | ||
| 2348 | radius: ScreenUtil().setWidth(8), | 2364 | radius: ScreenUtil().setWidth(8), |
| 2349 | isBold: false, | 2365 | isBold: false, |
| 2350 | onPressed: () async { | 2366 | onPressed: () async { |
| 2351 | - JhCommonUtils.debounce(() => _wechatReserve(), 500); | 2367 | + JhCommonUtils.debounce( |
| 2368 | + () => _wechatReserve(true), 500); | ||
| 2352 | }, | 2369 | }, |
| 2353 | )), | 2370 | )), |
| 2354 | ], | 2371 | ], |
| @@ -2359,7 +2376,7 @@ class TableManagerPageState extends State<TableManagerPage> { | @@ -2359,7 +2376,7 @@ class TableManagerPageState extends State<TableManagerPage> { | ||
| 2359 | )); | 2376 | )); |
| 2360 | } | 2377 | } |
| 2361 | 2378 | ||
| 2362 | - _wechatReserve() async { | 2379 | + _wechatReserve(bool isWechat) async { |
| 2363 | bool isShow = true; //是否需要弹窗 “预订失败!” | 2380 | bool isShow = true; //是否需要弹窗 “预订失败!” |
| 2364 | SunReserveInfoModel _model = | 2381 | SunReserveInfoModel _model = |
| 2365 | await tableManagerModel.setReserveInfo(context, (v) { | 2382 | await tableManagerModel.setReserveInfo(context, (v) { |
| @@ -2405,7 +2422,21 @@ class TableManagerPageState extends State<TableManagerPage> { | @@ -2405,7 +2422,21 @@ class TableManagerPageState extends State<TableManagerPage> { | ||
| 2405 | // } | 2422 | // } |
| 2406 | // } | 2423 | // } |
| 2407 | // } else { | 2424 | // } else { |
| 2408 | - NavigatorUtil.goInvicationPage(context, _model.row.id); | 2425 | + // if (isWechat) { |
| 2426 | + NavigatorUtil.goInvicationPage(context, _model.row.id); | ||
| 2427 | + // } else { | ||
| 2428 | + // bool isSuccess = await Utils.goShareInvicationToWeChat( | ||
| 2429 | + // context, | ||
| 2430 | + // _model.row.id, | ||
| 2431 | + // Provider.of<UserModel>(context, listen: false).user.openid, | ||
| 2432 | + // isWechat: false | ||
| 2433 | + // ); | ||
| 2434 | + // print(isSuccess); | ||
| 2435 | + // if (isSuccess) { | ||
| 2436 | + // // _addForward(); | ||
| 2437 | + // } | ||
| 2438 | + // } | ||
| 2439 | + | ||
| 2409 | // bool isSuccess = | 2440 | // bool isSuccess = |
| 2410 | // await Utils.goShareInvicationToWeChat( | 2441 | // await Utils.goShareInvicationToWeChat( |
| 2411 | // context, | 2442 | // context, |
| @@ -7,6 +7,7 @@ | @@ -7,6 +7,7 @@ | ||
| 7 | */ | 7 | */ |
| 8 | 8 | ||
| 9 | import 'package:flutter/material.dart'; | 9 | import 'package:flutter/material.dart'; |
| 10 | +import 'package:flutter_wxwork/flutter_wxwork.dart'; | ||
| 10 | import 'package:one_key/utils/repaint_boundary_utils.dart'; | 11 | import 'package:one_key/utils/repaint_boundary_utils.dart'; |
| 11 | // import 'package:flutter_easyloading/flutter_easyloading.dart'; | 12 | // import 'package:flutter_easyloading/flutter_easyloading.dart'; |
| 12 | import 'package:one_key/utils/utils.dart'; | 13 | import 'package:one_key/utils/utils.dart'; |
| @@ -41,4 +42,27 @@ class ShareHelper { | @@ -41,4 +42,27 @@ class ShareHelper { | ||
| 41 | // wxIsInstalled = await WxSdk.wxIsInstalled(); | 42 | // wxIsInstalled = await WxSdk.wxIsInstalled(); |
| 42 | // } | 43 | // } |
| 43 | 44 | ||
| 45 | +//企业微信分享 | ||
| 46 | + static Future<bool> onShareWxwork(BuildContext context, {boundaryKey}) async { | ||
| 47 | + FlutterWxwork flutterWxwork = FlutterWxwork(); | ||
| 48 | + String ddd = await flutterWxwork.isAppInstalled(); | ||
| 49 | + print(ddd); | ||
| 50 | + | ||
| 51 | + //收回键盘,如果有输入的情况下,先收回键盘,再截图 | ||
| 52 | + FocusScope.of(context).requestFocus(FocusNode()); | ||
| 53 | + | ||
| 54 | + // if (ddd) { | ||
| 55 | + //分享 | ||
| 56 | + // WxSdk.ShareText("sdgsfds",title:"标题"); | ||
| 57 | + //获取截图地址 | ||
| 58 | + String filePath = await RepaintBoundaryUtils().captureImage(boundaryKey); | ||
| 59 | + | ||
| 60 | + print(filePath); | ||
| 61 | + await flutterWxwork.registerApp("wwauthbdca186ec4257973000006", "wwbdca186ec4257973", "1000006"); | ||
| 62 | + await flutterWxwork.shareImagePath(filePath); | ||
| 63 | + // } else { | ||
| 64 | + // //提示未安装微信 | ||
| 65 | + // Utils.showToast("未安装企业微信"); | ||
| 66 | + // } | ||
| 67 | + } | ||
| 44 | } | 68 | } |
| @@ -33,8 +33,11 @@ FlutterMethodChannel *channel; | @@ -33,8 +33,11 @@ FlutterMethodChannel *channel; | ||
| 33 | [WWKApi sendReq:req]; | 33 | [WWKApi sendReq:req]; |
| 34 | authResult = result; | 34 | authResult = result; |
| 35 | } | 35 | } |
| 36 | - else if ([@"shareImage" isEqualToString:call.method]) { | ||
| 37 | - [self shareImage:call result:result]; | 36 | + else if ([@"shareImageNetWork" isEqualToString:call.method]) { |
| 37 | + [self shareImageNetWork:call result:result]; | ||
| 38 | + } | ||
| 39 | + else if([@"shareImagePath" isEqualToString:call.method]) { | ||
| 40 | + [self shareImagePath:call result:result]; | ||
| 38 | } | 41 | } |
| 39 | else if ([@"shareMiniProgram" isEqualToString:call.method]) { | 42 | else if ([@"shareMiniProgram" isEqualToString:call.method]) { |
| 40 | [self shareMiniProgram:call result:result]; | 43 | [self shareMiniProgram:call result:result]; |
| @@ -56,7 +59,7 @@ FlutterMethodChannel *channel; | @@ -56,7 +59,7 @@ FlutterMethodChannel *channel; | ||
| 56 | 59 | ||
| 57 | } | 60 | } |
| 58 | 61 | ||
| 59 | -- (void)shareImage:(FlutterMethodCall *)call result:(FlutterResult)result { | 62 | +- (void)shareImageNetWork:(FlutterMethodCall *)call result:(FlutterResult)result { |
| 60 | [WWKApi registerApp:@"wwauthbdca186ec4257973000006" corpId:@"wwbdca186ec4257973" agentId:@"1000006"]; | 63 | [WWKApi registerApp:@"wwauthbdca186ec4257973000006" corpId:@"wwbdca186ec4257973" agentId:@"1000006"]; |
| 61 | 64 | ||
| 62 | dispatch_queue_t globalQueue = dispatch_get_global_queue(0, 0); | 65 | dispatch_queue_t globalQueue = dispatch_get_global_queue(0, 0); |
| @@ -123,6 +126,46 @@ FlutterMethodChannel *channel; | @@ -123,6 +126,46 @@ FlutterMethodChannel *channel; | ||
| 123 | 126 | ||
| 124 | } | 127 | } |
| 125 | 128 | ||
| 129 | +- (void)shareImagePath:(FlutterMethodCall *)call result:(FlutterResult)result { | ||
| 130 | + // [WWKApi registerApp:@"wwauthbdca186ec4257973000006" corpId:@"wwbdca186ec4257973" agentId:@"1000006"]; | ||
| 131 | + | ||
| 132 | + dispatch_queue_t globalQueue = dispatch_get_global_queue(0, 0); | ||
| 133 | + dispatch_async(globalQueue, ^{ | ||
| 134 | + | ||
| 135 | + NSData *imageData= [NSData dataWithContentsOfFile:call.arguments[@"path"]]; | ||
| 136 | + dispatch_async(dispatch_get_main_queue(), ^{ | ||
| 137 | + WWKSendMessageReq *req = [[WWKSendMessageReq alloc] init]; | ||
| 138 | + WWKMessageImageAttachment *attachment = [[WWKMessageImageAttachment alloc] init]; | ||
| 139 | + // attachment.filename = @"icon.jpg"; | ||
| 140 | + // attachment.path = [[NSBundle mainBundle] pathForResource:@"icon" ofType:@"jpg"]; | ||
| 141 | + // NSURL *imageURL = [NSURL URLWithString:@"http://nosqn.colorcun.com/reserve/images/3x/%E6%9A%82%E6%97%A0.png"]; | ||
| 142 | + // //下载图片 | ||
| 143 | + // NSData *data= [NSData dataWithContentsOfURL:imageURL]; | ||
| 144 | + attachment.filename = @"share_image"; | ||
| 145 | + attachment.data = imageData; | ||
| 146 | + req.attachment = attachment; | ||
| 147 | + [WWKApi sendReq:req]; | ||
| 148 | + authResult = result; | ||
| 149 | + }); | ||
| 150 | + | ||
| 151 | + | ||
| 152 | + | ||
| 153 | + | ||
| 154 | + }); | ||
| 155 | + | ||
| 156 | + // WWKSendMessageReq *req = [[WWKSendMessageReq alloc] init]; | ||
| 157 | + // WWKMessageImageAttachment *attachment = [[WWKMessageImageAttachment alloc] init]; | ||
| 158 | + // attachment.filename = @"icon.jpg"; | ||
| 159 | + // attachment.path = [[NSBundle mainBundle] pathForResource:@"icon" ofType:@"jpg"]; | ||
| 160 | + // // NSURL *imageURL = [NSURL URLWithString:@"http://nosqn.colorcun.com/reserve/images/3x/%E6%9A%82%E6%97%A0.png"]; | ||
| 161 | + // // //下载图片 | ||
| 162 | + // // NSData *data= [NSData dataWithContentsOfURL:imageURL]; | ||
| 163 | + // // attachment.data = data; | ||
| 164 | + // req.attachment = attachment; | ||
| 165 | + // [WWKApi sendReq:req]; | ||
| 166 | + | ||
| 167 | +} | ||
| 168 | + | ||
| 126 | 169 | ||
| 127 | - (void)shareMiniProgram:(FlutterMethodCall *)call result:(FlutterResult)result { | 170 | - (void)shareMiniProgram:(FlutterMethodCall *)call result:(FlutterResult)result { |
| 128 | 171 |
| @@ -19,8 +19,11 @@ class FlutterWxwork { | @@ -19,8 +19,11 @@ class FlutterWxwork { | ||
| 19 | return FlutterWxworkPlatform.instance.isAppInstalled(); | 19 | return FlutterWxworkPlatform.instance.isAppInstalled(); |
| 20 | } | 20 | } |
| 21 | 21 | ||
| 22 | - Future<bool> shareImage(String path) { | ||
| 23 | - return FlutterWxworkPlatform.instance.shareImage(path); | 22 | + Future<bool> shareImageNetWork(String path) { |
| 23 | + return FlutterWxworkPlatform.instance.shareImageNetWork(path); | ||
| 24 | + } | ||
| 25 | +Future<bool> shareImagePath(String path) { | ||
| 26 | + return FlutterWxworkPlatform.instance.shareImagePath(path); | ||
| 24 | } | 27 | } |
| 25 | 28 | ||
| 26 | Future<bool> shareMiniProgram( | 29 | Future<bool> shareMiniProgram( |
| @@ -37,12 +37,22 @@ class MethodChannelFlutterWxwork extends FlutterWxworkPlatform { | @@ -37,12 +37,22 @@ class MethodChannelFlutterWxwork extends FlutterWxworkPlatform { | ||
| 37 | } | 37 | } |
| 38 | 38 | ||
| 39 | @override | 39 | @override |
| 40 | - Future<bool> shareImage(String path) async { | ||
| 41 | - final shareImage = | ||
| 42 | - await methodChannel.invokeMethod<bool>('shareImage', <String, String>{ | 40 | + Future<bool> shareImageNetWork(String path) async { |
| 41 | + final shareImageNetWork = | ||
| 42 | + await methodChannel.invokeMethod<bool>('shareImageNetWork', <String, String>{ | ||
| 43 | 'path': path, | 43 | 'path': path, |
| 44 | }); | 44 | }); |
| 45 | - return shareImage; | 45 | + return shareImageNetWork; |
| 46 | + } | ||
| 47 | + | ||
| 48 | + | ||
| 49 | + @override | ||
| 50 | + Future<bool> shareImagePath(String path) async { | ||
| 51 | + final shareImagePath = | ||
| 52 | + await methodChannel.invokeMethod<bool>('shareImagePath', <String, String>{ | ||
| 53 | + 'path': path, | ||
| 54 | + }); | ||
| 55 | + return shareImagePath; | ||
| 46 | } | 56 | } |
| 47 | 57 | ||
| 48 | @override | 58 | @override |
| @@ -35,8 +35,12 @@ abstract class FlutterWxworkPlatform extends PlatformInterface { | @@ -35,8 +35,12 @@ abstract class FlutterWxworkPlatform extends PlatformInterface { | ||
| 35 | throw UnimplementedError('isAppInstalled() has not been implemented.'); | 35 | throw UnimplementedError('isAppInstalled() has not been implemented.'); |
| 36 | } | 36 | } |
| 37 | 37 | ||
| 38 | - Future<bool> shareImage(String path) { | ||
| 39 | - throw UnimplementedError('shareImage() has not been implemented.'); | 38 | + Future<bool> shareImageNetWork(String path) { |
| 39 | + throw UnimplementedError('shareImageNetWork() has not been implemented.'); | ||
| 40 | + } | ||
| 41 | + | ||
| 42 | + Future<bool> shareImagePath(String path) { | ||
| 43 | + throw UnimplementedError('shareImagePath() has not been implemented.'); | ||
| 40 | } | 44 | } |
| 41 | 45 | ||
| 42 | Future<AuthModel> auth() { | 46 | Future<AuthModel> auth() { |
| @@ -44,7 +48,7 @@ abstract class FlutterWxworkPlatform extends PlatformInterface { | @@ -44,7 +48,7 @@ abstract class FlutterWxworkPlatform extends PlatformInterface { | ||
| 44 | } | 48 | } |
| 45 | 49 | ||
| 46 | Future<bool> shareMiniProgram( | 50 | Future<bool> shareMiniProgram( |
| 47 | - { String userName, //必须是应用关联的小程序,注意要有@app后缀 | 51 | + {String userName, //必须是应用关联的小程序,注意要有@app后缀 |
| 48 | String path, | 52 | String path, |
| 49 | String hdImageData, | 53 | String hdImageData, |
| 50 | String title = "分享标题"}) { | 54 | String title = "分享标题"}) { |
-
Please register or login to post a comment