Пример #1
0
 public static object shareToWechat(ShareType type, string title, string description, string linkUrl,
                                    string imageUrl)
 {
     return(new ThunkAction <AppState>((dispatcher, getState) => {
         return ShareApi.FetchImageBytes(imageUrl)
         .Then(imageBytes => {
             var encodeBytes = Convert.ToBase64String(imageBytes);
             if (type == ShareType.friends)
             {
                 WechatPlugin.instance().shareToFriend(title, description, linkUrl, encodeBytes);
             }
             else if (type == ShareType.moments)
             {
                 WechatPlugin.instance().shareToTimeline(title, description, linkUrl, encodeBytes);
             }
         }).Catch(error => {
             if (type == ShareType.friends)
             {
                 WechatPlugin.instance().shareToFriend(title, description, linkUrl, null);
             }
             else if (type == ShareType.moments)
             {
                 WechatPlugin.instance().shareToTimeline(title, description, linkUrl, null);
             }
         });
     }));
 }
Пример #2
0
    private IEnumerator DelayToShare(string readAddr)
    {
        var delay = 0f;

        while (!File.Exists(readAddr) && delay < 10) //delay超过10就不要再等待了
        {
            yield return(new WaitForEndOfFrame());

            delay += Time.deltaTime;
        }
        Debug.Log("Share to Social @" + Time.realtimeSinceStartup);
        _isCapturingScreenShot = false;

        if (Application.platform == RuntimePlatform.WindowsPlayer ||
            Application.platform == RuntimePlatform.WindowsEditor)
        {
            //重命名,转存到桌面
            var desktop = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
            File.Copy(readAddr,
                      Path.Combine(desktop,
                                   "screenshot " + DateTime.Now.ToString("yyyy-M-d h-mm") + ".png"), true);
            //Toast.CreateToast("截图已保存到桌面");
        }

        var title = "雷影忍者";
        var desc  = "史上最佳动作游戏——雷影忍者";

        WechatPlugin.SharePic(readAddr, title, desc, "thumb.png", WechatPlugin.Scene.WxSceneTimeline);
    }
Пример #3
0
        Widget _buildWechatButton(BuildContext context)
        {
            if (!WechatPlugin.instance().inInstalled())
            {
                return(new Container());
            }

            WechatPlugin.instance().context = context;
            return(new CustomButton(
                       onPressed: () => {
                WechatPlugin.instance(code => {
                    CustomDialogUtils.showCustomDialog(
                        child: new CustomLoadingDialog()
                        );
                    this.actionModel.loginByWechatAction(code).Then(() => {
                        CustomDialogUtils.hiddenCustomDialog();
                        if (this.anonymous)
                        {
                            LoginScreen.navigator.pushReplacementNamed(LoginNavigatorRoutes
                                                                       .WechatBindUnity);
                        }
                        else
                        {
                            this.actionModel.mainRouterPop();
                        }
                    })
                    .Catch(_ => CustomDialogUtils.hiddenCustomDialog());
                })
                .login(Guid.NewGuid().ToString());
            },
                       padding: EdgeInsets.zero,
                       child: new Container(
                           height: 48,
                           decoration: new BoxDecoration(
                               CColors.PrimaryBlue,
                               borderRadius: BorderRadius.all(24)
                               ),
                           child: new Row(
                               mainAxisAlignment: MainAxisAlignment.center,
                               children: new List <Widget> {
                new Icon(
                    Icons.WechatIcon,
                    size: 24,
                    color: CColors.White
                    ),
                new Container(width: 8),
                new Text(
                    "使用微信账号登录",
                    maxLines: 1,
                    style: CTextStyle.PLargeWhite
                    )
            }
                               )
                           )
                       ));
        }
Пример #4
0
    public static void Invite(string posStr)
    {
        LastActionIsShare = false;
        LastPos           = posStr;
        if (SystemInfo.deviceType == DeviceType.Desktop)
        {
            //Toast.CreateErrorToast("电脑版不能使用微信分享。在手机上也安装载爱掼蛋吧!");
        }
        var url   = "www.iguandan.com";
        var title = "雷影忍者";
        var desc  = "史上最佳动作游戏——雷影忍者";

        WechatPlugin.ShareWebpage(url, title, desc, "thumb.png", WechatPlugin.Scene.WxSceneSession);
    }
Пример #5
0
        Widget _buildWeChatButton(BuildContext context)
        {
            if (!WechatPlugin.instance().isInstalled())
            {
                return(new Container());
            }

            WechatPlugin.instance().context = context;
            return(new CustomButton(
                       onPressed: () => {
                WechatPlugin.instance(code => {
                    CustomDialogUtils.showCustomDialog(child: new CustomLoadingDialog());
                    this.widget.actionModel.loginByWechatAction(arg: code);
                })
                .login(Guid.NewGuid().ToString());
            },
                       padding: EdgeInsets.zero,
                       child: new Container(
                           height: 48,
                           decoration: new BoxDecoration(
                               color: CColors.PrimaryBlue,
                               borderRadius: BorderRadius.all(24)
                               ),
                           child: new Row(
                               mainAxisAlignment: MainAxisAlignment.center,
                               children: new List <Widget> {
                new Icon(
                    icon: Icons.WechatIcon,
                    size: 24,
                    color: CColors.White
                    ),
                new Container(width: 8),
                new Text(
                    "使用微信账号登录",
                    maxLines: 1,
                    style: CTextStyle.PLargeWhite
                    )
            }
                               )
                           )
                       ));
        }
Пример #6
0
        List <Widget> _buildShareItems()
        {
            var shareItems = new List <Widget>();

            if (WechatPlugin.instance().inInstalled())
            {
                shareItems.Add(
                    _buildShareItem(
                        Icons.WechatIcon,
                        "微信好友",
                        CColors.White,
                        CColors.WechatGreen,
                        () => this.onPressed(ShareType.friends)
                        )
                    );
                shareItems.Add(
                    _buildShareItem(
                        Icons.WechatMoment,
                        "朋友圈",
                        CColors.White,
                        CColors.WechatGreen,
                        () => this.onPressed(ShareType.moments)
                        )
                    );
            }

            shareItems.Add(
                _buildShareItem(
                    Icons.insert_link,
                    "复制链接",
                    CColors.White,
                    CColors.PrimaryBlue,
                    () => this.onPressed(ShareType.clipBoard)
                    )
                );
            return(shareItems);
        }
        Widget _buildEventBottom(IEvent eventObj, EventType eventType, EventStatus eventStatus,
                                 bool isLoggedIn, BuildContext context)
        {
            if (!WechatPlugin.instance().isInstalled() || eventType == EventType.offline)
            {
                return(new Container());
            }

            return(new Container(
                       height: 56 + CCommonUtils.getSafeAreaBottomPadding(context: context),
                       padding: EdgeInsets.only(16, 8, 16, 8 + CCommonUtils.getSafeAreaBottomPadding(context: context)),
                       decoration: new BoxDecoration(
                           color: CColors.White,
                           border: new Border(new BorderSide(color: CColors.Separator))
                           ),
                       child: new CustomButton(
                           onPressed: () => {
                CustomDialogUtils.showCustomDialog(
                    barrierColor: Color.fromRGBO(0, 0, 0, 0.5f),
                    child: new CustomAlertDialog(
                        "即将前往微信小程序开始观看",
                        null,
                        new List <Widget> {
                    new CustomButton(
                        child: new Text(
                            "稍后再说",
                            style: new TextStyle(
                                height: 1.33f,
                                fontSize: 16,
                                fontFamily: "Roboto-Regular",
                                color: new Color(0xFF959595)
                                ),
                            textAlign: TextAlign.center
                            ),
                        onPressed: CustomDialogUtils.hiddenCustomDialog
                        ),
                    new CustomButton(
                        child: new Text(
                            "立即前往",
                            style: CTextStyle.PLargeBlue,
                            textAlign: TextAlign.center
                            ),
                        onPressed: () => {
                        CustomDialogUtils.hiddenCustomDialog();
                        WechatPlugin.instance().context = this.context;
                        WechatPlugin.instance().currentEventId = eventObj.id;
                        var path = CStringUtils.CreateMiniPath(id: eventObj.id,
                                                               title: eventObj.title);
                        if (path.isNotEmpty())
                        {
                            WechatPlugin.instance().toOpenMiNi(path);
                        }
                    }
                        )
                }
                        )
                    );
            },
                           padding: EdgeInsets.zero,
                           child: new Container(
                               decoration: new BoxDecoration(
                                   color: CColors.PrimaryBlue,
                                   borderRadius: BorderRadius.all(4)
                                   ),
                               child: new Row(
                                   mainAxisAlignment: MainAxisAlignment.center,
                                   children: new List <Widget> {
                new Text(
                    "进入微信小程序",
                    style: CTextStyle.PLargeMediumWhite.merge(new TextStyle(height: 1))
                    )
            }
                                   )
                               )
                           )
                       ));
        }
Пример #8
0
 void Awake()
 {
     _instance = this;
     WechatPlugin.AddShareResultListener(this);
 }
Пример #9
0
        Widget _buildEventBottom(IEvent eventObj, EventType eventType, EventStatus eventStatus,
                                 bool isLoggedIn)
        {
            if (!WechatPlugin.instance().isInstalled() || eventType == EventType.offline)
            {
                return(new Container());
            }

            return(new Container(
                       height: 56 + this._bottomPadding,
                       padding: EdgeInsets.only(16, 8, 16, 8 + this._bottomPadding),
                       decoration: new BoxDecoration(
                           color: CColors.White,
                           border: new Border(new BorderSide(color: CColors.Separator))
                           ),
                       child: new CustomButton(
                           onPressed: () => {
                CustomDialogUtils.showCustomDialog(
                    barrierColor: Color.fromRGBO(0, 0, 0, 0.5f),
                    child: new CustomAlertDialog(
                        "即将前往微信小程序\n开始观看",
                        null,
                        new List <Widget> {
                    new CustomButton(
                        child: new Text(
                            "稍后再说",
                            style: new TextStyle(
                                height: 1.33f,
                                fontSize: 16,
                                fontFamily: "Roboto-Regular",
                                color: new Color(0xFF959595)
                                ),
                            textAlign: TextAlign.center
                            ),
                        onPressed: CustomDialogUtils.hiddenCustomDialog
                        ),
                    new CustomButton(
                        child: new Text(
                            "立即前往",
                            style: CTextStyle.PLargeBlue,
                            textAlign: TextAlign.center
                            ),
                        onPressed: () => {
                        CustomDialogUtils.hiddenCustomDialog();
                        WechatPlugin.instance().context = this.context;
                        WechatPlugin.instance().currentEventId = eventObj.id;
                        var path = CStringUtils.CreateMiniPath(id: eventObj.id,
                                                               title: eventObj.title);
                        if (path.isNotEmpty())
                        {
                            WechatPlugin.instance().toOpenMiNi(path);
                        }
                    }
                        )
                }
                        )
                    );
            },
                           padding: EdgeInsets.zero,
                           child: new Container(
                               decoration: new BoxDecoration(
                                   color: CColors.PrimaryBlue,
                                   borderRadius: BorderRadius.all(4)
                                   ),
                               child: new Row(
                                   mainAxisAlignment: MainAxisAlignment.center,
                                   children: new List <Widget> {
                new Text(
                    "进入微信小程序",
                    style: CTextStyle.PLargeMediumWhite.merge(new TextStyle(height: 1))
                    )
            }
                                   )
                               )
                           )
                       ));

//            var onlineCount = eventObj.onlineMemberCount;
//            var recordWatchCount = eventObj.recordWatchCount;
//            var userIsCheckedIn = eventObj.userIsCheckedIn;
//            var title = "";
//            var subTitle = "";
//            if (eventStatus == EventStatus.live) {
//                title = "正在直播";
//                subTitle = $"{onlineCount}人正在观看";
//            }
//
//            if (eventStatus == EventStatus.past) {
//                title = "回放";
//                subTitle = $"{recordWatchCount}次观看";
//            }
//
//            if (eventStatus == EventStatus.future || eventStatus == EventStatus.countDown) {
//                var begin = eventObj.begin != null ? eventObj.begin : new TimeMap();
//                var startTime = begin.startTime;
//                if (startTime.isNotEmpty()) {
//                    subTitle = DateConvert.GetFutureTimeFromNow(startTime);
//                }
//
//                title = "距离开始还有";
//            }
//
//            var backgroundColor = CColors.PrimaryBlue;
//            var joinInText = "立即加入";
//            var textStyle = CTextStyle.PLargeMediumWhite;
//
//            Widget child = new Text(
//                joinInText,
//                style: textStyle
//            );
//
//            if (this.widget.viewModel.joinEventLoading) {
//                child = new CustomActivityIndicator(
//                    loadingColor: LoadingColor.white
//                );
//            }
//
//            return new Container(
//                height: 64,
//                padding: EdgeInsets.symmetric(horizontal: 16),
//                margin: EdgeInsets.only(bottom: MediaQuery.of(this.context).padding.bottom),
//                decoration: new BoxDecoration(
//                    CColors.White,
//                    border: new Border(new BorderSide(CColors.Separator))
//                ),
//                child: new Row(
//                    mainAxisAlignment: MainAxisAlignment.spaceBetween,
//                    children: new List<Widget> {
//                        new Column(
//                            mainAxisAlignment: MainAxisAlignment.center,
//                            crossAxisAlignment: CrossAxisAlignment.start,
//                            children: new List<Widget> {
//                                new Text(
//                                    title,
//                                    style: CTextStyle.PSmallBody4
//                                ),
//                                new Container(height: 2),
//                                new Text(
//                                    subTitle,
//                                    style: CTextStyle.H5Body
//                                )
//                            }
//                        ),
//                        new CustomButton(
//                            onPressed: () => {
//                                if (this.widget.viewModel.joinEventLoading) {
//                                    return;
//                                }
//
//                                if (!this.widget.viewModel.isLoggedIn) {
//                                    this.widget.actionModel.pushToLogin();
//                                }
//                                else {
//                                    if (!WechatPlugin.instance().isInstalled()) {
//                                        CustomToast.show(new CustomToastItem(this.context, "需要安装微信才能打开小程序",
//                                            gravity: ToastGravity.center));
//                                        return;
//                                    }
//
//                                    CustomDialogUtils.showCustomDialog(
//                                        barrierColor: Color.fromRGBO(0, 0, 0, 0.5f),
//                                        child: new CustomAlertDialog(
//                                            "即将前往微信小程序\n开始观看",
//                                            null,
//                                            new List<Widget> {
//                                                new CustomButton(
//                                                    child: new Text(
//                                                        "稍后再说",
//                                                        style: new TextStyle(
//                                                            height: 1.33f,
//                                                            fontSize: 16,
//                                                            fontFamily: "Roboto-Regular",
//                                                            color: new Color(0xFF959595)
//                                                        ),
//                                                        textAlign: TextAlign.center
//                                                    ),
//                                                    onPressed: () => { CustomDialogUtils.hiddenCustomDialog(); }
//                                                ),
//                                                new CustomButton(
//                                                    child: new Text(
//                                                        "立即前往",
//                                                        style: CTextStyle.PLargeBlue,
//                                                        textAlign: TextAlign.center
//                                                    ),
//                                                    onPressed: () => {
//                                                        CustomDialogUtils.hiddenCustomDialog();
//                                                        WechatPlugin.instance().context = this.context;
//                                                        WechatPlugin.instance().currentEventId = eventObj.id;
//                                                        var path =
//                                                            $"pages/Detail/Detail?id={eventObj.id}&title={eventObj.title}&app=true";
//                                                        WechatPlugin.instance().toOpenMiNi(path);
//                                                    }
//                                                )
//                                            }
//                                        )
//                                    );
//                                }
//                            },
//                            child: new Container(
//                                width: 96,
//                                height: 40,
//                                decoration: new BoxDecoration(
//                                    backgroundColor,
//                                    borderRadius: BorderRadius.all(4)
//                                ),
//                                alignment: Alignment.center,
//                                child: new Row(
//                                    mainAxisAlignment: MainAxisAlignment.center,
//                                    children: new List<Widget> {
//                                        child
//                                    }
//                                )
//                            )
//                        )
//                    }
//                )
//            );
        }