123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133 |
- 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 = "<h3>利亚方舟影楼管理系统微信公众平台授权登录</h3>"
- + " <span>利亚方舟影楼管理软件微信平台为用户提供第三方的公众平台管理、客户互动,模板消息推送等,满足您的需要。</span>"
- + " <h3>点击“微信公众号登录授权”即可完成公众号与平台的邦定</h3>"
- + " <a href=\"" + url + "\"><img style=\"border:hidden;\" src=\"WeiXinAPP/images/icon_button3_1.png\" alt=\"微信公众号登录授权\" /></a>"
- + " <h3>可授权权限集</h3>"
- + " <p>"
- + " <b> 消息管理权限:</b> 帮助公众号接收用户消息,进行人工客服回复或自动回复"
- + " <br /><b> 自定义菜单权限:</b>帮助公众号使用自定义菜单"
- + " <br /><b> 网页服务权限:</b>帮助公众号实现第三方网页服务和活动"
- + " <br /><b> 群发与通知权限:</b>帮助公众号进行群发和模板消息业务通知"
- + " <br /><b> 用户管理权限:</b>帮助公众号获取用户信息,进行用户管理"
- + " </p>";
- }
- else
- {
- this.divInfo.InnerHtml = "<h3>请求错误:不是有效的企业ID</h3>";
- }
- }
- else
- {
- this.divInfo.InnerHtml = "<h3>非法请求!</h3>";
- }
- #if 参考
- if (string.IsNullOrEmpty(strEntId) || string.IsNullOrEmpty(strAppId))
- {
- this.divInfo.InnerHtml = "<h3>非法请求!</h3>";
- }
- 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 = "<h3>利亚方舟影楼管理系统微信公众平台授权登录</h3>"
- + " <span>利亚方舟影楼管理软件微信平台为用户提供第三方的公众平台管理、客户互动,模板消息推送等,满足您的需要。</span>"
- + " <h3>点击“微信公众号登录授权”即可完成公众号与平台的邦定</h3>"
- + " <a href=\"" + url + "\"><img style=\"border:hidden;\" src=\"WeiXinAPP/images/icon_button3_1.png\" alt=\"微信公众号登录授权\" /></a>"
- + " <h3>可授权权限集</h3>"
- + " <p>"
- + " <b> 消息管理权限:</b> 帮助公众号接收用户消息,进行人工客服回复或自动回复"
- + " <br /><b> 自定义菜单权限:</b>帮助公众号使用自定义菜单"
- + " <br /><b> 网页服务权限:</b>帮助公众号实现第三方网页服务和活动"
- + " <br /><b> 群发与通知权限:</b>帮助公众号进行群发和模板消息业务通知"
- + " <br /><b> 用户管理权限:</b>帮助公众号获取用户信息,进行用户管理"
- + " </p>";
- }
- else
- {
- // LYFZ.WXLibrary.CommonHandleClass.WriteLog("请求错误:不是有效的JMG域名", JMGDomainName, Global.LogsDongleDomainList);
- this.divInfo.InnerHtml = "<h3>请求错误:不是有效的JMG域名</h3>";
- }
- }
- catch (Exception ex)
- {
- // LYFZ.WXLibrary.CommonHandleClass.WriteLog("请求错误:" + ex.Message, JMGDomainName, Global.LogsDongleDomainList);
- this.divInfo.InnerHtml = "<h3>请求错误:" + ex.Message + "</h3>";
- }
- }
- #endif
- }
- /// <summary>
- /// 参数校验
- /// </summary>
- /// <param name="strEntId">企业id</param>
- /// <param name="strAppId">app对象id</param>
- /// <param name="strAppType">app对象类型</param>
- /// <param name="strAppWxId">app对象的微信号</param>
- /// <returns>若参数有效返回true,参数无效或空返回false</returns>
- 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;
- }
- }
- }
|