Esempio n. 1
0
        /// <summary>
        /// 页面加载
        /// </summary>
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                WxPayHelper wx        = new WxPayHelper();
                string      returnMsg = "<xml> <return_code><![CDATA[{0}]]></return_code> <return_msg><![CDATA[{1}]]></return_msg> </xml>";
                SortedDictionary <string, object> dic = wx.GetReturnData();
                Log4Net.WriteInfoLog("收到微信App支付回调:" + new JavaScriptSerializer().Serialize(dic));

                string sign = dic["sign"].ToString();
                if (dic["return_code"].ToString() == "SUCCESS")
                {
                    string signLocal = wx.MakeSign(dic, ApplicationSettings.Get("WXAPPKEY"));
                    if (sign == signLocal)
                    {
                        decimal amount = Convert.ToDecimal(dic["total_fee"]) / 100M;
                        if (dic["result_code"].ToString() == "SUCCESS")
                        {
                            OnLinePayOrder order = new OnLinePayOrder
                            {
                                OrderID    = dic["out_trade_no"].ToString(),
                                PayAddress = GameRequest.GetUserIP(),
                                Amount     = amount
                            };

                            FacadeManage.aideTreasureFacade.FinishOnLineOrder(order);
                            Response.Write(string.Format(returnMsg, "SUCCESS", "支付成功!"));
                        }
                        else
                        {
                            Response.Write(string.Format(returnMsg, "FAIL", "微信交易失败!"));
                        }
                    }
                    else
                    {
                        Response.Write(string.Format(returnMsg, "FAIL", "签名错误!"));
                    }
                }
                else
                {
                    Response.Write(string.Format(returnMsg, "FAIL", "微信交易失败!"));
                }
            }
        }
Esempio n. 2
0
        public void ProcessRequest(HttpContext context)
        {
            //允许跨站请求域名
            context.Response.AddHeader("Access-Control-Allow-Origin", AppConfig.MoblieInterfaceDomain);
            //接口返回数据格式
            context.Response.ContentType = "application/json";
            //接口请求类型
            string action = GameRequest.GetQueryString("action").ToLower();

            try
            {
                lock (lockobj)
                {
                    System.IO.Stream s   = context.Request.InputStream;
                    StreamReader     sr  = new StreamReader(s, System.Text.ASCIIEncoding.UTF8);
                    string           ret = sr.ReadToEnd();
                    //Log4Net.WriteInfoLog("ret:" + ret);

                    string userid = context.Request.Form["userid"];
                    //string log = context.Request.Form["logtext"];
                    int    platformType = GameRequest.GetInt("platformType", 0);
                    string TypeName     = "";
                    if (platformType == 1)
                    {
                        TypeName = "Android";
                    }
                    else if (platformType == 2)
                    {
                        TypeName = "IOS";
                    }
                    Writelog(ret, userid, TypeName);
                    context.Response.Write("true");
                }
            }
            catch (Exception ex)
            {
                Log4Net.WriteInfoLog("下面一条为接口故障信息", "LogInterface");
                Log4Net.WriteErrorLog(ex, "LogInterface");
                context.Response.Write(ex);
            }
        }
Esempio n. 3
0
        /// <summary>
        /// 页面加载
        /// </summary>
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                SortedDictionary <string, string> sPara = AlipayHelper.GetRequestPost();
                Log4Net.WriteInfoLog("收到支付宝支付回调:" + new JavaScriptSerializer().Serialize(sPara));

                if (sPara.Count > 0)//判断是否有带返回参数
                {
                    bool verifyResult = AlipayHelper.Verify(sPara, Request.Form["notify_id"], Request.Form["sign"], Request.Form["sign_type"]);
                    if (verifyResult)
                    {
                        string outTradeNo  = Request.Form["out_trade_no"];
                        string tradeStatus = Request.Form["trade_status"];

                        if (tradeStatus == "TRADE_SUCCESS" || tradeStatus == "TRADE_FINISHED")
                        {
                            OnLinePayOrder order = new OnLinePayOrder
                            {
                                OrderID    = outTradeNo,
                                PayAddress = GameRequest.GetUserIP(),
                                Amount     = Convert.ToDecimal(Request.Form["total_fee"])
                            };

                            FacadeManage.aideTreasureFacade.FinishOnLineOrder(order);
                        }
                        Response.Write("success");
                    }
                    else
                    {
                        Response.Write("fail");
                    }
                }
                else
                {
                    Response.Write("无通知参数");
                }
            }
        }
Esempio n. 4
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "application/json";
            string action  = GameRequest.GetString("action").ToLower();
            int    version = GameRequest.GetInt("version", 2);

            #region Version 2.0 Router

            if (version == 2)
            {
                try
                {
                    //不需要认证的action
                    string[] unNeedAuthActions = { "agentauth", "gettoken" };

                    string token      = GameRequest.GetString("token");
                    string gameid     = GameRequest.GetString("gameid");
                    string authheader = context.Request.Headers["Authorization"];
                    _ajv = new AjaxJsonValid();
                    _ajv.SetDataItem("apiVersion", 20180316);
                    if (!string.IsNullOrEmpty(gameid))
                    {
                        unNeedAuthActions[1] = "setpassword";
                    }

                    //排除不需要认证后判断认证是否正确
                    if (!unNeedAuthActions.Contains(action))
                    {
                        if (string.IsNullOrEmpty(token) &&
                            (string.IsNullOrEmpty(authheader) || !authheader.Contains("Bearer")))
                        {
                            _ajv.code = (int)ApiCode.VertyParamErrorCode;
                            _ajv.msg  = string.Format(EnumHelper.GetDesc(ApiCode.VertyParamErrorCode), " token 缺失");
                            context.Response.Write(_ajv.SerializeToJson());
                            return;
                        }
                        string         authToken = !string.IsNullOrEmpty(token) ? token : authheader.Replace("Bearer ", "");
                        AgentTokenInfo authInfo  = FacadeManage.aideAgentFacade.VerifyAgentToken(authToken);
                        if (authInfo == null)
                        {
                            _ajv.code = (int)ApiCode.Unauthorized;
                            _ajv.msg  = EnumHelper.GetDesc(ApiCode.Unauthorized);
                            context.Response.Write(_ajv.SerializeToJson());
                            return;
                        }
                        //认证完成后 设置到全局
                        _agentInfo = FacadeManage.aideAgentFacade.GetAgentInfo(authInfo.AgentID, authInfo.UserID);
                    }

                    switch (action)
                    {
                    case "agentauth":     //1.0
                        AgentAuth(GameRequest.GetString("gameid"), GameRequest.GetString("pass"));
                        break;

                    case "getinfo":     //1.1
                        GetAgentInfo();
                        break;

                    case "gettoken":     //1.0
                        Gettoken();
                        break;

                    case "getnicknamebygameid":     //1.2
                        GetNickNameByGameID(GameRequest.GetInt("gameid", 0));
                        break;

                    case "getrecord":     //1.3
                        GetRecord(GameRequest.GetString("type"));
                        break;

                    case "getbelowlist":     //1.4
                        GetBelowList(GameRequest.GetString("type"), GameRequest.GetString("query"));
                        break;

                    case "getawardinfo":     //1.5
                        GetAwardInfo();
                        break;

                    case "presentscore":     //1.6
                        TakeScoreORDiamond(GameRequest.GetInt("gameid", 0), GameRequest.GetString("password"),
                                           GameRequest.GetInt("count", 0), Convert.ToByte(GameRequest.GetInt("type", 0)));
                        break;

                    case "presentdiamondorscore":
                        PresentDiamondOrScore(GameRequest.GetInt("gameid", 0), GameRequest.GetString("password"),
                                              GameRequest.GetInt("count", 0), Convert.ToByte(GameRequest.GetInt("type", 0)));
                        break;

                    case "setpassword":     //1.7
                        SetSafePass(GameRequest.GetString("password"));
                        break;

                    case "updatepassword":     //1.8
                        UpdateSafePass(GameRequest.GetString("oldPassword"), GameRequest.GetString("newPassword"));
                        break;

                    case "updateinfo":     //1.9
                        UpdateAgentInfo(GameRequest.GetString("address"), GameRequest.GetString("phone"),
                                        GameRequest.GetString("qq"));
                        break;

                    case "addagent":     //1.10
                        AddBelowAgent(GameRequest.GetInt("gameid", 0), GameRequest.GetString("agentDomain"),
                                      GameRequest.GetString("compellation"),
                                      "", GameRequest.GetString("phone"),
                                      ""
                                      );
                        break;

                    default:
                        _ajv.code = (int)ApiCode.VertyParamErrorCode;
                        _ajv.msg  = string.Format(EnumHelper.GetDesc(ApiCode.VertyParamErrorCode),
                                                  " action 对应接口不存在");
                        break;
                    }

                    context.Response.Write(_ajv.SerializeToJson());
                }
                catch (Exception ex)
                {
                    Log4Net.WriteInfoLog("下面一条为接口故障信息", "Agent_DataHandler");
                    Log4Net.WriteErrorLog(ex, "Agent_DataHandler");
                    _ajv = new AjaxJsonValid
                    {
                        code = (int)ApiCode.LogicErrorCode,
                        msg  = EnumHelper.GetDesc(ApiCode.LogicErrorCode)
                    };
                    context.Response.Write(_ajv.SerializeToJson());
                }
            }

            #endregion
        }
        /// <summary>
        /// 统一处理入口(主要验证)
        /// </summary>
        /// <param name="context"></param>
        public void ProcessRequest(HttpContext context)
        {
            try
            {
                //允许跨站请求域名
                context.Response.AddHeader("Access-Control-Allow-Origin", AppConfig.MoblieInterfaceDomain);
                //接口返回数据格式
                context.Response.ContentType = "application/json";
                //接口请求类型
                string action = GameRequest.GetQueryString("action").ToLower();

                //获取参数
                _userid = GameRequest.GetQueryInt("userid", 0);
                _device = GameRequest.GetString("device");
                _ajv    = new AjaxJsonValid();
#if !DEBUG //DEBUG情况下不验证
                string time = GameRequest.GetQueryString("time");
                string sign = GameRequest.GetQueryString("sign");

                //签名验证
                _ajv =
                    Fetch.VerifySignData((context.Request.QueryString["userid"] == null ? "" : _userid.ToString()) + AppConfig.MoblieInterfaceKey + time,
                                         sign);
//            Log4Net.WriteInfoLog("signStr:"+(context.Request.QueryString["userid"] == null ? "" : _userid.ToString()) + AppConfig.MoblieInterfaceKey + time + " sign:"+sign);
                if (_ajv.code == (int)ApiCode.VertySignErrorCode)
                {
                    context.Response.Write(_ajv.SerializeToJson());
                    return;
                }
#endif
                //参数验证
                if (context.Request.QueryString["userid"] != null && _userid <= 0)
                {
                    _ajv.code = (int)ApiCode.VertyParamErrorCode;
                    _ajv.msg  = string.Format(EnumHelper.GetDesc(ApiCode.VertyParamErrorCode), " userid 错误");
                    context.Response.Write(_ajv.SerializeToJson());
                    return;
                }
                //获取其他参数
                int configid = GameRequest.GetQueryInt("configid", 0);
                int typeid   = GameRequest.GetQueryInt("typeid", 0);

                switch (action)
                {
                case "webversion":
                    _ajv.SetDataItem("apiVersion", 20171220);
                    _ajv.SetDataItem("webVersion", "V1.1.8");
                    _ajv.SetDataItem("updateAt", "2018/02/03");
                    _ajv.SetValidDataValue(true);
                    break;

                //获取手机端登录数据
                case "getmobilelogindata":
                    _ajv.SetDataItem("apiVersion", 20171017);
                    GetMobileLoginData();
                    break;

                //获取手机端登录后数据
                case "getmobileloginlater":
                    _ajv.SetDataItem("apiVersion", 20171213);
                    GetMobileLoginLater();
                    break;

                //获取充值产品列表
                case "getpayproduct":
                    _ajv.SetDataItem("apiVersion", 20171028);
                    //获取参数
                    int typeId = GameRequest.GetQueryInt("typeid", 0);
                    GetPayProduct(typeId);
                    break;

                //领取推广有效好友奖励
                case "receivespreadaward":
                    //参数验证
                    if (configid <= 0)
                    {
                        _ajv.code = (int)ApiCode.VertyParamErrorCode;
                        _ajv.msg  = string.Format(EnumHelper.GetDesc(ApiCode.VertyParamErrorCode), " configid 错误");
                        context.Response.Write(_ajv.SerializeToJson());
                        return;
                    }
                    ReceiveSpreadAward(configid);
                    break;

                case "getgameintrolist":
                    _ajv.SetDataItem("apiVersion", 20171107);
                    GetGameIntroList();
                    break;

                //钻石充值下单
                case "createpayorder":
                    _ajv.SetDataItem("apiVersion", 20171123);
                    //获取参数
                    string paytype = GameRequest.GetQueryString("paytype");
                    string openid  = GameRequest.GetQueryString("openid");
                    string subtype = GameRequest.GetQueryString("subtype");

                    //参数验证
                    if (configid <= 0 || paytype.Equals(""))
                    {
                        _ajv.code = (int)ApiCode.VertyParamErrorCode;
                        _ajv.msg  = string.Format(EnumHelper.GetDesc(ApiCode.VertyParamErrorCode), "");
                        context.Response.Write(_ajv.SerializeToJson());
                        return;
                    }
                    context.Response.Write(CreatePayOrder(configid, paytype, openid, subtype).SerializeToJson());
                    return;

                //获取排行榜数据
                case "getrankingdata":
                    _ajv.SetDataItem("apiVersion", 20171129);
                    //参数验证
                    if (typeid <= 0 || typeid > 7)
                    {
                        _ajv.code = (int)ApiCode.VertyParamErrorCode;
                        _ajv.msg  = string.Format(EnumHelper.GetDesc(ApiCode.VertyParamErrorCode), " typeid 错误");
                        context.Response.Write(_ajv.SerializeToJson());
                        return;
                    }

                    GetRankingData(typeid);
                    break;

                //获取财富信息
                case "getuserwealth":
                    GetUserWealth();
                    break;

                //获取玩家信息
                case "getuserinfo":
                    _ajv.SetDataItem("apiVersion", 20171208);
                    GetUserInfo();
                    break;

                //领取排行奖励
                case "receiverankingaward":
                    _ajv.SetDataItem("apiVersion", 20171213);
                    //获取参数
                    int dateid = GameRequest.GetQueryInt("dateid", 0);

                    //参数验证
                    if (dateid <= 0 || typeid <= 0)
                    {
                        _ajv.code = (int)ApiCode.VertyParamErrorCode;
                        _ajv.msg  = string.Format(EnumHelper.GetDesc(ApiCode.VertyParamErrorCode), "");
                        context.Response.Write(_ajv.SerializeToJson());
                        return;
                    }
                    ReceiveRankingAward(dateid, typeid);
                    break;

                //获取游戏列表
                case "getgamelist":
                    GetGameList();
                    break;

                //领取注册赠送奖励
                case "receiveregistergrant":
                    _ajv.SetDataItem("apiVersion", 20171213);
                    ReceiveRegisterGrant();
                    break;

                //金币流水记录
                case "recordtreasuretrade":
                    RecordTreasureTrade();
                    break;

                //钻石流水记录
                case "recorddiamondstrade":
                    RecordDiamondsTrade();
                    break;

                //钻石兑换金币
                case "diamondexchgold":
                    _ajv.SetDataItem("apiVersion", 20171213);     //for 响应规范
                    if (configid <= 0 || typeid < 0)
                    {
                        _ajv.code = (int)ApiCode.VertyParamErrorCode;
                        _ajv.msg  = string.Format(EnumHelper.GetDesc(ApiCode.VertyParamErrorCode),
                                                  " configid或typeid 错误");
                        context.Response.Write(_ajv.SerializeToJson());
                        return;
                    }
                    DiamondExchGold(configid, typeid);
                    break;

                case "getpayorderstatus":
                    _ajv.SetDataItem("apiVersion", 20171127);
                    string orderid = GameRequest.GetString("orderid");
                    if (string.IsNullOrEmpty(orderid))
                    {
                        _ajv.code = (int)ApiCode.VertyParamErrorCode;
                        _ajv.msg  = string.Format(EnumHelper.GetDesc(ApiCode.VertyParamErrorCode), " orderid 错误");
                        context.Response.Write(_ajv.SerializeToJson());
                        return;
                    }
                    GetPayOrderStatus(orderid);
                    break;

                case "getquestionandanswerlist":
                    _ajv.SetDataItem("apiVersion", 20180125);
                    GetQuestionAndAnswerList();
                    break;

                default:
                    _ajv.code = (int)ApiCode.VertyParamErrorCode;
                    _ajv.msg  = string.Format(EnumHelper.GetDesc(ApiCode.VertyParamErrorCode), " action 错误");
                    break;
                }

                context.Response.Write(_ajv.SerializeToJson());
            }
            catch (Exception ex)
            {
                Log4Net.WriteInfoLog("下面一条为手机接口故障信息", "MobileInterface");
                Log4Net.WriteErrorLog(ex);
                _ajv = new AjaxJsonValid
                {
                    code = 500,
                    msg  = "手机接口短暂故障,请联系管理员!"
                };
                context.Response.Write(_ajv.SerializeToJson());
            }
            context.Response.End();
        }
Esempio n. 6
0
        /// <summary>
        /// 页面加载
        /// </summary>
        protected void Page_Load(object sender, EventArgs e)
        {
            if (IsPostBack)
            {
                return;
            }
            if ((Typeid != 81 && Typeid != 82 && Typeid != 83 && Typeid != 84) || Gameid <= 0)
            {
                Response.Redirect("/404.html");
                return;
            }


            string userAgent = Request.UserAgent;
            bool   IsWeiXin  = false;

            if (userAgent.ToLower().Contains("micromessenger"))
            {
                IsWeiXin = true;
            }
            else
            {
                IsWeiXin = false;
            }

            //获取公众号配置
            string appid = AppConfig.GetSetting("WXNATIVEAPPID");


            if (string.IsNullOrEmpty(Wxparam) && IsWeiXin && !string.IsNullOrEmpty(appid))
            {
                string path = Typeid == 82
                    ? $"/Mobile/WxRegister.aspx?t=82&g={Gameid}&gr={Groupid}&r={Roomid}&k={Kindid}&a={Action}&p={Password}"
                    : "/Mobile/WxRegister.aspx?t=81&g=" + Gameid;
                if (Typeid == 83)
                {
                    path = "/Mobile/WxRegister.aspx?t=83&g=" + Gameid;
                }
                else if (Typeid == 84)
                {
                    path = "/Mobile/WxRegister.aspx?t=84&g=" + Gameid;
                }

                string param = $"http://{AppConfig.GetSetting("FrontSiteDomain")}{path}";
                if (!string.IsNullOrEmpty(PlatformType))
                {
                    param += $"&y={PlatformType}";
                    //                    TextLogger.Write($"HAuthorizeUrl:{AppConfig.HAuthorizeURL}?url={Server.UrlEncode(param)}");
                    //                    Response.Redirect($"{AppConfig.HAuthorizeURL}?url={Server.UrlEncode(param)}");
                    //                    return;
                }
                Response.Redirect($"{AppConfig.AuthorizeURL}?url={Server.UrlEncode(param)}");
            }
            else if (!string.IsNullOrEmpty(Wxparam) && IsWeiXin && !string.IsNullOrEmpty(appid))
            {
                WxUser wu = Fetch.GetWxUser(Wxparam);
                if (wu == null)
                {
                    Log4Net.WriteInfoLog("获取不到微信信息,Gameid" + Gameid);
                    Response.Redirect("/404.html");
                    return;
                }
                AccountsInfo info = FacadeManage.aideAccountsFacade.GetAccountsInfoByUserUin(wu.unionid);
                if (info == null)
                {
                    //注册帐号
                    UserInfo user = new UserInfo
                    {
                        NickName   = wu.nickname,
                        Gender     = wu.sex,
                        RegisterIP = GameRequest.GetUserIP(),
                        GameID     = Gameid,
                        UserUin    = wu.unionid
                    };
                    FacadeManage.aideAccountsFacade.RegisterWX(user, Typeid, wu.headimgurl);
                }
                else if (info.SpreaderID == 0 && info.AgentID == 0)
                {
                    AccountsInfo infos = FacadeManage.aideAccountsFacade.GetAccountsInfoByGameID(Gameid);
                    if (infos != null && infos.AgentID > 0)
                    {
                        Message mesg = new Message();
                        mesg = FacadeManage.aideAgentFacade.UserAgentBind(info.UserID, infos.GameID, GameRequest.GetUserIP());
                    }
                }


                string redirect;
                if (PlatformType == "h5")
                {
                    string     wxParam = $"<{wu.openid}>,<{wu.unionid}>,<{wu.nickname}>,<{wu.sex}>,<{wu.headimgurl}>";
                    ConfigInfo webCfg  = Fetch.GetWebSiteConfig();
                    string     w       = Server.UrlEncode(Fetch.AESEncrypt(wxParam, AppConfig.WxH5Key,
                                                                           AppConfig.WxH5Key));
                    string baseUrl = "/h5/";
                    if (Typeid == 82)
                    {
                        switch (Kindid)
                        {
                        case 200:
                            baseUrl += "land";
                            break;

                        case 50:
                            baseUrl += "oxsixx";
                            break;

                        case 122:
                            baseUrl += "baccarat";
                            break;

                        case 33:
                            baseUrl += "sangong";
                            break;

                        case 391:
                            baseUrl += "sparrowgdex";
                            break;

                        case 51:
                            baseUrl += "thirteenzj";
                            break;

                        case 6:
                            baseUrl += "zhajinhua";
                            break;

                        case 302:
                            baseUrl += "bloodWar";
                            break;

                        case 390:
                            baseUrl += "sparrowhz";
                            break;

                        case 57:
                            baseUrl += "oxeight";
                            break;

                        case 56:
                            baseUrl += "fksanzhang";
                            break;

                        case 14:
                            baseUrl += "paiGow";
                            break;

                        case 242:
                            baseUrl += "pushBobbin";
                            break;

                        case 389:
                            baseUrl += "sparrowhz";
                            break;

                        default:
                            baseUrl += "hall";
                            break;
                        }
                    }
                    else
                    {
                        baseUrl += "hall";
                    }
                    redirect = baseUrl + (Typeid == 82
                                   ? $"/?w={w}&r={Roomid}&a={Action}&p={Password}"
                                   : $"/?w={w}");
                }
                else
                {
                    redirect = Typeid == 82
                        ? "/Mobile/RoomLink.aspx?" +
                               $"s=already&g={Gameid}&r={Roomid}&gr={Groupid}&k={Kindid}&a={Action}&p={Password}&y={PlatformType}"
                        : $"/Mobile/ShareLinkNew.aspx?s=already&g={Gameid}&y={PlatformType}";

                    if (Typeid == 83)
                    {
                        redirect = $"/Mobile/AgentShareLink.aspx?s=already&g={Gameid}&y={PlatformType}";
                    }
                    else if (Typeid == 84)
                    {
                        redirect = $"/Mobile/AgentShareLinkLua.aspx?s=already&g={Gameid}";
                    }
                }
                Response.Redirect(redirect);
            }
            else
            {
                //保存IP绑定信息
                string UserIP = GameRequest.GetUserIP();
                int    result = FacadeManage.aideAccountsFacade.UserIPBind(UserIP, Gameid);

                string redirectUrl = "";
                redirectUrl = Typeid == 82
                    ? "/Mobile/RoomLink.aspx?" +
                              $"s=already&g={Gameid}&r={Roomid}&gr={Groupid}&k={Kindid}&a={Action}&p={Password}&y={PlatformType}"
                    : $"/Mobile/ShareLinkNew.aspx?s=already&g={Gameid}&y={PlatformType}";

                if (Typeid == 83)
                {
                    redirectUrl = $"/Mobile/AgentShareLink.aspx?s=already&g={Gameid}";
                }
                else if (Typeid == 84)
                {
                    redirectUrl = $"/Mobile/AgentShareLinkLua.aspx?s=already&g={Gameid}";
                }
                Response.Redirect(redirectUrl);
            }
        }
Esempio n. 7
0
        /// <summary>
        /// 页面加载(微信授权-网站使用)
        /// </summary>
        protected void Page_Load(object sender, EventArgs e)
        {
            if (IsPostBack)
            {
                return;
            }
            if (AppConfig.Mode == AppConfig.CodeMode.Dev)
            {
                #region 内部测试

                Random rd         = new Random();
                string unionid    = Utility.MD5(rd.Next(1000000, 9999999).ToString());
                string nickname   = "网站" + rd.Next(10000, 99999).ToString();
                string headimgurl =
                    "http://wx.qlogo.cn/mmopen/ajNVdqHZLLAMfyaTEB7juwPCNXBEC5SNBkgUgLuQjeu8bgcsiaEM77Y1F83qb05w0UjGJkVCqqgrs1EWic1Pmn5LjYYKJxSgRwwXz7iaxia6to0/0";
                if (LinkUrl.IndexOf("Card/Index", StringComparison.Ordinal) > 0)
                {
                    unionid = "o9ZMqwltMdZANFwT5P8FAGS2ZDkk";
                }
                string wxParam = $"<{unionid}>,<{unionid}>,<{nickname}>,<{1}>,<{headimgurl}>";
                LinkUrl = LinkUrl + "&w=" + Server.UrlEncode(Fetch.DESEncrypt(wxParam, AppConfig.WxUrlKey));

                Response.Redirect(LinkUrl);

                #endregion
            }
            else if (AppConfig.Mode == AppConfig.CodeMode.Production)
            {
                #region 客户版本

                WxAuthorize jsApiDown = new WxAuthorize(this);
                try
                {
                    jsApiDown.GetOpenidAndAccessToken();
                    jsApiDown.GetUserInfo();

                    string openid     = jsApiDown.Openid;
                    string unionid    = jsApiDown.Unionid;
                    string nickname   = jsApiDown.Nickname;
                    int    sex        = jsApiDown.Sex;
                    string headimgurl = jsApiDown.Headimgurl;


                    if (string.IsNullOrEmpty(LinkUrl))
                    {
                        Response.Write("<span style='color:#FF0000;font-size:20px'>" + "页面加载出错,请重试" + "</span>");
                        return;
                    }
                    string wxParam = $"<{openid}>,<{unionid}>,<{nickname}>,<{sex}>,<{headimgurl}>";

                    Log4Net.WriteInfoLog("网站获取微信参数:" + wxParam);
                    LinkUrl = LinkUrl + "&w=" + Server.UrlEncode(Fetch.DESEncrypt(wxParam, AppConfig.WxUrlKey));

                    Response.Redirect(LinkUrl);
                }
                catch (Exception)
                {
                    Response.Write("<span style='color:#FF0000;font-size:20px'>" + "页面加载出错,请重试" + "</span>");
                }

                #endregion
            }
            else if (AppConfig.Mode == AppConfig.CodeMode.Demo)
            {
                #region 演示版本

                Response.Redirect("http://ry.foxuc.net/JJAuthorize.aspx?url=" + Server.UrlEncode(LinkUrl));

                #endregion
            }
        }
Esempio n. 8
0
        /// <summary>
        /// 页面加载(微信授权-H5使用)
        /// </summary>
        protected void Page_Load(object sender, EventArgs e)
        {
            if (IsPostBack)
            {
                return;
            }

            if (AppConfig.Mode == AppConfig.CodeMode.Dev)
            {
                #region 内部测试

                string unionid    = "59C6CEA7FBAB5A19C3177E1216BBACF6";
                string nickname   = "网站47033";
                string headimgurl =
                    "http://wx.qlogo.cn/mmopen/ajNVdqHZLLAMfyaTEB7juwPCNXBEC5SNBkgUgLuQjeu8bgcsiaEM77Y1F83qb05w0UjGJkVCqqgrs1EWic1Pmn5LjYYKJxSgRwwXz7iaxia6to0/0";

                string wxParam = $"<{unionid}>,<{unionid}>,<{nickname}>,<{1}>,<{headimgurl}>";

                string url = "http://172.16.0.211:6566/develop/majiang/index.html" + "?w=" +
                             Server.UrlEncode(Fetch.AESEncrypt(wxParam, AppConfig.WxH5Key, AppConfig.WxH5Key));

                Response.Redirect(url);

                #endregion
            }
            else if (AppConfig.Mode == AppConfig.CodeMode.Production)
            {
                #region 客户版本

                WxAuthorize jsApiDown = new WxAuthorize(this);
                try
                {
                    jsApiDown.GetOpenidAndAccessToken();
                    jsApiDown.GetUserInfo();

                    string openid     = jsApiDown.Openid;
                    string unionid    = jsApiDown.Unionid;
                    string nickname   = jsApiDown.Nickname;
                    int    sex        = jsApiDown.Sex;
                    string headimgurl = jsApiDown.Headimgurl;


                    string wxParam = $"<{openid}>,<{unionid}>,<{nickname}>,<{sex}>,<{headimgurl}>";
                    Log4Net.WriteInfoLog("H5获取微信参数:" + wxParam);
                    ConfigInfo config = Fetch.GetWebSiteConfig();
                    string     url    = (config != null ? config.Field4 : "/WH/QJ/H5/index.html") + "?w=" +
                                        Server.UrlEncode(Fetch.AESEncrypt(wxParam, AppConfig.WxH5Key,
                                                                          AppConfig.WxH5Key));

                    Response.Redirect(url);
                }
                catch (Exception)
                {
                    Response.Write("<span style='color:#FF0000;font-size:20px'>" + "页面加载出错,请重试" + "</span>");
                }

                #endregion
            }
            else if (AppConfig.Mode == AppConfig.CodeMode.Demo)
            {
                #region 演示版本

                Response.Redirect("http://ry.foxuc.net/JJHAuthorize.aspx?url=" + (LinkUrl.Equals("")? "http://oss.foxuc.net/WH/QJ/H5/index.html" : LinkUrl));

                #endregion
            }
        }