using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace LYFZ.WeixinServers { public partial class Authorize : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { // 企业id; string strEntId = ""; // 公众号或小程序appid; string strAppId = ""; // app类型:公众号或小程序; string strAppType = ""; // app的微信号; string strAppWxId = ""; if (VerifyParam(out strEntId, out strAppId, out strAppType, out strAppWxId)) { // 根据企业id获取企业信息; LoginModel.enterprise model = GlobalCache.GetEnterpriseModel(strEntId); if (model != null) { string authorizeParameter = LYFZ.WinAPI.SDKSecurity.Encode(strAppType + "&" + strAppId + "&" + strEntId); string url = "https://mp.weixin.qq.com/cgi-bin/componentloginpage?component_appid=" + LYFZ.WXLibrary.OpenPlatformConfig.OpenAppID + "&pre_auth_code=" + LYFZ.WXLibrary.OpenPlatformConfig.Pre_auth_code + "&redirect_uri=" + LYFZ.WXLibrary.OpenPlatformConfig.Redirect_uri + "?auth_parameters=" + authorizeParameter; this.divInfo.InnerHtml = "

利亚方舟影楼管理系统微信公众平台授权登录

" + " 利亚方舟影楼管理软件微信平台为用户提供第三方的公众平台管理、客户互动,模板消息推送等,满足您的需要。" + "

点击“微信公众号登录授权”即可完成公众号与平台的邦定

" + " \"微信公众号登录授权\"" + "

可授权权限集

" + "

" + " 消息管理权限: 帮助公众号接收用户消息,进行人工客服回复或自动回复" + "
自定义菜单权限:帮助公众号使用自定义菜单" + "
网页服务权限:帮助公众号实现第三方网页服务和活动" + "
群发与通知权限:帮助公众号进行群发和模板消息业务通知" + "
用户管理权限:帮助公众号获取用户信息,进行用户管理" + "

"; } else { this.divInfo.InnerHtml = "

请求错误:不是有效的企业ID

"; } } else { this.divInfo.InnerHtml = "

非法请求!

"; } #if 参考 if (string.IsNullOrEmpty(strEntId) || string.IsNullOrEmpty(strAppId)) { this.divInfo.InnerHtml = "

非法请求!

"; } else { LYFZ.WeixinServiceDate.Model.Model_CustomerInterfaces cusModel = null; try { // LYFZ.WXLibrary.CommonHandleClass.WriteLog("JMGDomainName: " + JMGDomainName, JMGDomainName, Global.LogsDongleDomainList); cusModel = Global.GetCustomerModel(strEntId); if (cusModel != null && cusModel.ID > 0) { string authorizeParameter = LYFZ.WinAPI.SDKSecurity.Encode("" + strAppId + "&" + strEntId); string url = "https://mp.weixin.qq.com/cgi-bin/componentloginpage?component_appid=" + LYFZ.WXLibrary.OpenPlatformConfig.OpenAppID + "&pre_auth_code=" + LYFZ.WXLibrary.OpenPlatformConfig.Pre_auth_code + "&redirect_uri=" + LYFZ.WXLibrary.OpenPlatformConfig.Redirect_uri + "?authorizeParameter=" + authorizeParameter; this.divInfo.InnerHtml = "

利亚方舟影楼管理系统微信公众平台授权登录

" + " 利亚方舟影楼管理软件微信平台为用户提供第三方的公众平台管理、客户互动,模板消息推送等,满足您的需要。" + "

点击“微信公众号登录授权”即可完成公众号与平台的邦定

" + " \"微信公众号登录授权\"" + "

可授权权限集

" + "

" + " 消息管理权限: 帮助公众号接收用户消息,进行人工客服回复或自动回复" + "
自定义菜单权限:帮助公众号使用自定义菜单" + "
网页服务权限:帮助公众号实现第三方网页服务和活动" + "
群发与通知权限:帮助公众号进行群发和模板消息业务通知" + "
用户管理权限:帮助公众号获取用户信息,进行用户管理" + "

"; } else { // LYFZ.WXLibrary.CommonHandleClass.WriteLog("请求错误:不是有效的JMG域名", JMGDomainName, Global.LogsDongleDomainList); this.divInfo.InnerHtml = "

请求错误:不是有效的JMG域名

"; } } catch (Exception ex) { // LYFZ.WXLibrary.CommonHandleClass.WriteLog("请求错误:" + ex.Message, JMGDomainName, Global.LogsDongleDomainList); this.divInfo.InnerHtml = "

请求错误:" + ex.Message + "

"; } } #endif } /// /// 参数校验 /// /// 企业id /// app对象id /// app对象类型 /// app对象的微信号 /// 若参数有效返回true,参数无效或空返回false public bool VerifyParam(out string strEntId, out string strAppId, out string strAppType, out string strAppWxId) { strEntId = strAppId = strAppType = strAppWxId = ""; if (this.Request.QueryString["ent_id"] != null && this.Request.QueryString["app_id"] != null && this.Request.QueryString["app_type"] != null && this.Request.QueryString["app_wx_id"] != null) { strEntId = this.Request["ent_id"]; strAppId = this.Request["app_id"]; strAppType = this.Request["app_type"]; strAppWxId = this.Request["app_wx_id"]; if (string.IsNullOrEmpty(strEntId) || string.IsNullOrEmpty(strAppId) || string.IsNullOrEmpty(strAppType) || string.IsNullOrEmpty(strAppWxId)) return false; return true; } return false; } } }