public void Page_Load(object sender, EventArgs e) { if (IsForbidden) { return; } PageUtils.CheckRequestParameter("PublishmentSystemId"); _returnUrl = StringUtils.ValueFromUrl(Body.GetQueryString("returnUrl")); if (!IsPostBack) { //base.BreadCrumbConsole(AppManager.CMS.LeftMenu.ID_Site, "绑定微信公众帐号", AppManager.Permission.Platform_Site); #region 确认绑定接口没有问题 if (!IsNet45OrNewer()) { FailMessage("请检查是否安装了.NET Framework 4.5以上版本"); return; } var hostUrl = PageUtils.GetHost(); if (hostUrl.IndexOf(":") >= 0) { var port = hostUrl.Split(new char[] { ':' })[1]; if (port != "80") { FailMessage("请检查站点是否设置为80端口"); return; } } var testUrl = PageUtils.AddProtocolToUrl("/api/mp/url?id=1"); var result = string.Empty; WebClientUtils.Post(testUrl, string.Empty, out result); if (!StringUtils.EqualsIgnoreCase(result, "failed:id=1") && !StringUtils.EqualsIgnoreCase(result, "参数错误")) { FailMessage("绑定微信公众账号需要的api有问题! 详细错误信息:" + result); return; } #endregion var accountInfo = WeiXinManager.GetAccountInfo(PublishmentSystemId); EWxAccountTypeUtils.AddListItems(RblWxAccountType); ControlUtils.SelectListItems(RblWxAccountType, EWxAccountTypeUtils.GetValue(EWxAccountTypeUtils.GetEnumType(accountInfo.AccountType))); TbWhchatId.Text = accountInfo.WeChatId; LtlUrl.Text = PageUtilityWX.API.GetMPUrl(PublishmentSystemId); LtlToken.Text = accountInfo.Token; TbAppId.Text = accountInfo.AppId; TbAppSecret.Text = accountInfo.AppSecret; } }
public static bool IsBinding(AccountInfo accountInfo) { var isBinding = false; var accountType = EWxAccountTypeUtils.GetEnumType(accountInfo.AccountType); if (accountType == EWxAccountType.Subscribe) { isBinding = accountInfo.IsBinding; } else { isBinding = accountInfo.IsBinding && !string.IsNullOrEmpty(accountInfo.AppId) && !string.IsNullOrEmpty(accountInfo.AppSecret); } return(isBinding); }
public override void Submit_OnClick(object sender, EventArgs e) { if (Page.IsPostBack && Page.IsValid) { if (PhStep1.Visible) { PhStep2.Visible = true; PhStep3.Visible = PhStep1.Visible = false; } else if (PhStep2.Visible) { var accountType = EWxAccountTypeUtils.GetEnumType(RblWxAccountType.SelectedValue); if (accountType == EWxAccountType.Subscribe) { var accountInfo = WeiXinManager.GetAccountInfo(PublishmentSystemId); accountInfo.AccountType = RblWxAccountType.SelectedValue; accountInfo.WeChatId = TbWhchatId.Text; try { DataProviderWx.AccountDao.Update(accountInfo); LogUtils.AddAdminLog(Body.AdministratorName, "绑定微信公众帐号", $"站点:{PublishmentSystemInfo.PublishmentSystemName}"); SuccessMessage("绑定微信公众帐号成功!"); AddWaitAndRedirectScript(_returnUrl); } catch (Exception ex) { FailMessage(ex, "绑定微信公众帐号失败!"); } } else { PhStep3.Visible = true; PhStep1.Visible = PhStep2.Visible = false; } } else { var accountInfo = WeiXinManager.GetAccountInfo(PublishmentSystemId); accountInfo.AccountType = RblWxAccountType.SelectedValue; accountInfo.WeChatId = TbWhchatId.Text; accountInfo.AppId = TbAppId.Text; accountInfo.AppSecret = TbAppSecret.Text; try { DataProviderWx.AccountDao.Update(accountInfo); LogUtils.AddAdminLog(Body.AdministratorName, "绑定微信公众帐号", $"站点:{PublishmentSystemInfo.PublishmentSystemName}"); SuccessMessage("绑定微信公众帐号成功!"); AddWaitAndRedirectScript(_returnUrl); } catch (Exception ex) { FailMessage(ex, "绑定微信公众帐号失败!"); } } } }
public void Page_Load(object sender, EventArgs e) { if (IsForbidden) { return; } _menuId = Body.GetQueryInt("menuID"); _parentId = Body.GetQueryInt("parentID"); if (Request.QueryString["Delete"] != null && _menuId > 0) { DataProviderWx.MenuDao.Delete(_menuId); SuccessMessage("菜单删除成功!"); } if (Request.QueryString["Subtract"] != null && _menuId > 0) { DataProviderWx.MenuDao.UpdateTaxisToUp(_parentId, _menuId); SuccessMessage("菜单排序成功!"); } if (!IsPostBack) { BreadCrumb(AppManager.WeiXin.LeftMenu.IdAccounts, AppManager.WeiXin.LeftMenu.Function.IdMenu, string.Empty, AppManager.WeiXin.Permission.WebSite.Menu); var accountInfo = WeiXinManager.GetAccountInfo(PublishmentSystemId); if (EWxAccountTypeUtils.Equals(accountInfo.AccountType, EWxAccountType.Subscribe)) { PageUtils.RedirectToErrorPage(@"您的微信公众账号类型为订阅号(非认证),微信目前不支持订阅号自定义菜单。如果您的公众账号类型不是订阅号,请到账户信息中设置微信绑定账号。"); return; } LtlIFrame.Text = @"<iframe frameborder=""0"" id=""menu"" name=""menu"" width=""100%"" height=""500""></iframe>"; var menuInfoList = DataProviderWx.MenuDao.GetMenuInfoList(PublishmentSystemId, 0); var builder = new StringBuilder(); foreach (var menuInfo in menuInfoList) { var subMenuInfoList = DataProviderWx.MenuDao.GetMenuInfoList(PublishmentSystemId, menuInfo.MenuId); var subBuilder = new StringBuilder(); if (subMenuInfoList.Count < 5) { var addSubUrl = PageMenuAdd.GetRedirectUrl(PublishmentSystemId, menuInfo.MenuId, 0); subBuilder.AppendFormat(@" <dd class=""add""> <a href=""{0}"" target=""menu""><font>新增菜单</font></a> </dd>", addSubUrl); } var i = 0; foreach (var subMenuInfo in subMenuInfoList) { i++; var ddClass = i == subMenuInfoList.Count ? "last" : string.Empty; var editSubUrl = PageMenuAdd.GetRedirectUrl(PublishmentSystemId, subMenuInfo.ParentId, subMenuInfo.MenuId); var deleteSubUrl = GetDeleteRedirectUrl(PublishmentSystemId, subMenuInfo.ParentId, subMenuInfo.MenuId); var subtractSubUrl = GetSubtractRedirectUrl(PublishmentSystemId, subMenuInfo.ParentId, subMenuInfo.MenuId); subBuilder.AppendFormat(@" <dd class=""{0}""> <a href=""{1}"" target=""menu""><font>{2}</font></a> <a href=""{3}"" onclick=""javascript:return confirm('此操作将删除子菜单“{2}”,确认吗?');"" class=""delete""><img src=""images/iphone-btn-delete.png""></a> <a href=""{4}"" style='top:20px;' class=""delete""><img src=""images/iphone-btn-up.png""></a> </dd>", ddClass, editSubUrl, subMenuInfo.MenuName, deleteSubUrl, subtractSubUrl); } var editUrl = PageMenuAdd.GetRedirectUrl(PublishmentSystemId, menuInfo.ParentId, menuInfo.MenuId); var subMenuStyle = _parentId == menuInfo.MenuId ? string.Empty : "display:none"; var deleteUrl = GetDeleteRedirectUrl(PublishmentSystemId, menuInfo.ParentId, menuInfo.MenuId); builder.AppendFormat(@" <li class=""secondMenu""> <a href=""{0}"" class=""mainMenu"" target=""menu""><font>{1}</font></a> <dl class=""subMenus"" style=""{2}""> <span> <img width=""9"" height=""6"" src=""images/iphone-btn-tri.png""> </span> {3} </dl> <a href=""{4}"" onclick=""javascript:return confirm('此操作将删除主菜单“{1}”,确认吗?');"" class=""delete""><img src=""images/iphone-btn-delete.png""></a> </li>", editUrl, menuInfo.MenuName, subMenuStyle, subBuilder, deleteUrl); } if (menuInfoList.Count < 3) { var addUrl = PageMenuAdd.GetRedirectUrl(PublishmentSystemId, 0, 0); builder.AppendFormat(@" <li class=""secondMenu addMain""> <a href=""{0}"" class=""mainMenu"" target=""menu""><font>新增菜单</font></a> </li>", addUrl); } LtlMenu.Text = builder.ToString(); } }