Commit c86d23a6999f91d37704b2928e30add398253717

Authored by wdn127929
1 parent f338a308

个人优惠券分享

@@ -18,6 +18,7 @@ import 'package:one_key/widgets/system_app_bar.dart'; @@ -18,6 +18,7 @@ import 'package:one_key/widgets/system_app_bar.dart';
18 import 'package:one_key/widgets/v_empty_view.dart'; 18 import 'package:one_key/widgets/v_empty_view.dart';
19 import 'package:provider/provider.dart'; 19 import 'package:provider/provider.dart';
20 20
  21 +import '../../provider/base_info_provider.dart';
21 import '../../utils/screen_util.dart'; 22 import '../../utils/screen_util.dart';
22 import '../../widgets/page_exception.dart'; 23 import '../../widgets/page_exception.dart';
23 24
@@ -40,6 +41,7 @@ class _CouponDetailPageState extends State<CouponDetailPage> { @@ -40,6 +41,7 @@ class _CouponDetailPageState extends State<CouponDetailPage> {
40 final heightCell = ScreenUtil().setWidth(80); 41 final heightCell = ScreenUtil().setWidth(80);
41 CouponProvider couponProvider; 42 CouponProvider couponProvider;
42 PageState pageState = PageState.Loading; 43 PageState pageState = PageState.Loading;
  44 + String managerName = '';
43 45
44 @override 46 @override
45 void initState() { 47 void initState() {
@@ -48,6 +50,7 @@ class _CouponDetailPageState extends State<CouponDetailPage> { @@ -48,6 +50,7 @@ class _CouponDetailPageState extends State<CouponDetailPage> {
48 WidgetsBinding.instance.addPostFrameCallback((_) { 50 WidgetsBinding.instance.addPostFrameCallback((_) {
49 // if (widget.idstr != null && widget.idstr != 'null') { 51 // if (widget.idstr != null && widget.idstr != 'null') {
50 _getActivityById(); 52 _getActivityById();
  53 + _getCustomerActivityBaseinfo();
51 // } else { 54 // } else {
52 // couponProvider.couponSunModel = widget.couponSunModel; 55 // couponProvider.couponSunModel = widget.couponSunModel;
53 // pageState = PageState.Success; 56 // pageState = PageState.Success;
@@ -56,6 +59,21 @@ class _CouponDetailPageState extends State<CouponDetailPage> { @@ -56,6 +59,21 @@ class _CouponDetailPageState extends State<CouponDetailPage> {
56 }); 59 });
57 } 60 }
58 61
  62 + _getCustomerActivityBaseinfo() async {
  63 + BaseIndoProvider _baseIndoProvider =
  64 + Provider.of<BaseIndoProvider>(context, listen: false);
  65 + Map<String, String> params = {
  66 + 'sellerid': Provider.of<UserModel>(context, listen: false).user.sellerid,
  67 + "uid": Provider.of<UserModel>(context, listen: false).user.openid,
  68 + };
  69 +
  70 + bool success =
  71 + await _baseIndoProvider.getCustomerActivityBaseinfo(context, params);
  72 + if (success) {
  73 + managerName = _baseIndoProvider.baseInfoSunModel.name;
  74 + }
  75 + }
  76 +
59 _getActivityById() async { 77 _getActivityById() async {
60 pageState = PageState.Loading; 78 pageState = PageState.Loading;
61 bool success = await couponProvider 79 bool success = await couponProvider
@@ -216,21 +234,28 @@ class _CouponDetailPageState extends State<CouponDetailPage> { @@ -216,21 +234,28 @@ class _CouponDetailPageState extends State<CouponDetailPage> {
216 }, 234 },
217 rightImgName: couponProvider != null && 235 rightImgName: couponProvider != null &&
218 couponProvider.couponSunModel != null && 236 couponProvider.couponSunModel != null &&
219 - couponProvider.couponSunModel.isType == '1' &&  
220 - couponProvider.couponSunModel.isExamine == '1' && 237 + // couponProvider.couponSunModel.isType == '1' &&
  238 + // couponProvider.couponSunModel.isExamine == '1' &&
221 couponProvider.couponSunModel.status == '1' 239 couponProvider.couponSunModel.status == '1'
222 ? 'share.png' 240 ? 'share.png'
223 : null, 241 : null,
224 onTapRight: () { 242 onTapRight: () {
  243 + // if (couponProvider.couponSunModel.isType == '1' &&
  244 + // couponProvider.couponSunModel.isExamine == '1' &&
  245 + // couponProvider.couponSunModel.status == '1') {
225 if (couponProvider.couponSunModel.isType == '1' && 246 if (couponProvider.couponSunModel.isType == '1' &&
226 - couponProvider.couponSunModel.isExamine == '1' &&  
227 couponProvider.couponSunModel.status == '1') { 247 couponProvider.couponSunModel.status == '1') {
228 - //店铺可核销券 248 + //店铺券
229 Utils.goShareBuyCouponToWeChat( 249 Utils.goShareBuyCouponToWeChat(
230 context, 250 context,
231 widget.idstr, 251 widget.idstr,
232 couponProvider.couponSunModel.use, 252 couponProvider.couponSunModel.use,
233 couponProvider.couponSunModel); 253 couponProvider.couponSunModel);
  254 + } else if (couponProvider.couponSunModel.isType == '2' &&
  255 + couponProvider.couponSunModel.status == '1') {
  256 + // 我的优惠券
  257 + Utils.goShareBuyCouponToWeChatMy(context, widget.idstr,
  258 + managerName, couponProvider.couponSunModel);
234 } 259 }
235 }, 260 },
236 ), 261 ),
@@ -442,7 +467,8 @@ class _CouponDetailPageState extends State<CouponDetailPage> { @@ -442,7 +467,8 @@ class _CouponDetailPageState extends State<CouponDetailPage> {
442 _item( 467 _item(
443 '发放总量限制', 468 '发放总量限制',
444 couponProvider 469 couponProvider
445 - .couponSunModel.grantNum??''), 470 + .couponSunModel.grantNum ??
  471 + ''),
446 // _select( 472 // _select(
447 // '谁可以发放', 473 // '谁可以发放',
448 // '查看', 474 // '查看',
@@ -644,7 +644,9 @@ var handleCouponDetailPageHandler = new Handler( @@ -644,7 +644,9 @@ var handleCouponDetailPageHandler = new Handler(
644 FluroConvertUtils.fluroCnParamsDecode(params["couponSunModel"].first))); 644 FluroConvertUtils.fluroCnParamsDecode(params["couponSunModel"].first)));
645 } 645 }
646 646
647 - return CouponDetailPage(couponSunModel: couponSunModel, idstr: idStr); 647 + return ChangeNotifierProvider<BaseIndoProvider>(
  648 + create: (_) => BaseIndoProvider(),
  649 + child: CouponDetailPage(couponSunModel: couponSunModel, idstr: idStr));
648 }); 650 });
649 651
650 ///个人资料页面 652 ///个人资料页面
@@ -1731,6 +1731,60 @@ class Utils { @@ -1731,6 +1731,60 @@ class Utils {
1731 } 1731 }
1732 1732
1733 //跳转到优惠券购买页面 1733 //跳转到优惠券购买页面
  1734 + static goShareBuyCouponToWeChatMy(BuildContext context, String couponid,
  1735 + String managerName, CouponSunModel couponSunModel) async {
  1736 + String _webPageUrl = "http://colorcun.com/";
  1737 + // String _thumbnail =
  1738 + // "https://xt04.colorcun.com/h5/index.html#/?id=163854&hasInvitation=1";
  1739 + // String _thumbnail =
  1740 + // "https://qn.colorcun.com/reserve/images/%E5%BE%AE%E4%BF%A1%E5%9B%BE%E7%89%87_201911151148572.jpg";
  1741 + // String sellerImage =
  1742 + // Provider.of<UserModel>(context, listen: false).user.sellerimage;
  1743 +
  1744 + String _thumbnail = 'https://nosqn.colorcun.com/share_money.png';
  1745 + String _title = "${managerName}给您赠送${couponSunModel.aname},点击查看详情";
  1746 +
  1747 + String _userName = "gh_487873d353b3";
  1748 + String _path =
  1749 + "pack-activity/pack/buyCoupon?id=$couponid&name=${Provider.of<UserModel>(context, listen: false).user.sellername}&sid=${Provider.of<UserModel>(context, listen: false).user.sellerid}&types=2";
  1750 + // if (Provider.of<UserModel>(context, listen: false).user.sellerid == '677') {
  1751 + // //京厨九跳转新的邀请函地址
  1752 + // _path =
  1753 + // "pages/customer/index?id=$rid&hasInvitation=1&hasSellerShare=1&uid=$uid";
  1754 + // }
  1755 + String _description = "进入查看包间详情,转发同行好友,还可一键导航到饭店";
  1756 + // Uint8List source = await testComporessList(context, _thumbnail);
  1757 +
  1758 + //跳转小程序
  1759 + var model = new WeChatShareMiniProgramModel(
  1760 + webPageUrl: _webPageUrl,
  1761 + userName: _userName,
  1762 + title: _title,
  1763 + path: _path,
  1764 + // description: 'hhh',
  1765 + // miniProgramType: , //体验版
  1766 + miniProgramType: Constant.wxMiniProgramType, //正式版
  1767 + // miniProgramType: //开发版
  1768 + // thumbnail: WeChatImage.binary(source)
  1769 + thumbnail: WeChatImage.network(_thumbnail),
  1770 + // hdImagePath: WeChatImage.network(_thumbnail), thumbnail: null,
  1771 + // thumbnail: WeChatImage.binary(image)
  1772 + );
  1773 + //分享链接
  1774 + // var model = WeChatShareWebPageModel(
  1775 + // // 'https://xt04.colorcun.com/h5/index.html#/?id=$rid&hasInvitation=1',
  1776 + // 'https://xt04.colorcun.com/h5/index.html?id=$rid&hasInvitation=1&hasSellerShare=1',
  1777 + // title: _title,
  1778 + // description: _description,
  1779 + // thumbnail: WeChatImage.network(_thumbnail),
  1780 + // scene: WeChatScene.SESSION,
  1781 + // );
  1782 +
  1783 + bool isSuccess = await shareToWeChat(model);
  1784 + return isSuccess;
  1785 + }
  1786 +
  1787 + //跳转到优惠券购买页面
1734 static goShareBuyCouponToWeChat(BuildContext context, String couponid, 1788 static goShareBuyCouponToWeChat(BuildContext context, String couponid,
1735 CouponUse use, CouponSunModel couponSunModel) async { 1789 CouponUse use, CouponSunModel couponSunModel) async {
1736 String _webPageUrl = "http://colorcun.com/"; 1790 String _webPageUrl = "http://colorcun.com/";