Exemplo n.º 1
0
        public ActionResult SaveBindMobile(string phone, string code)
        {
            try
            {
                if (string.IsNullOrWhiteSpace(phone) || !new Regex("^1[0-9]{10}$").Match(phone).Success)
                {
                    throw new MyException("手机号码格式错误");
                }
                CheckBindTradePasswordCode(code, phone);


                bool result = WeiXinAccountService.WXBindingMobilePhone(WeiXinUser.AccountID, phone);
                if (!result)
                {
                    throw new MyException("绑定失败");
                }

                RemoveTradePasswordCooike();
                WeiXinUser.MobilePhone         = phone;
                Session["SmartSystem_WX_Info"] = WeiXinUser;

                return(Json(MyResult.Success()));
            }
            catch (MyException ex)
            {
                return(Json(MyResult.Error(ex.Message)));
            }
            catch (Exception ex)
            {
                ExceptionsServices.AddExceptionToDbAndTxt("WeiXinPageError", "绑定手机号失败", ex, LogFrom.WeiXin);
                return(Json(MyResult.Error("绑定失败")));
            }
        }
Exemplo n.º 2
0
        public JsonResult WeixinBingPhone(string phone, string code)
        {
            JsonResult res    = new JsonResult();
            VerifyCode verify = wxApi.getBingding(phone, code, WeiXinUser.OpenID, WeiXinUser.OpenID);
            string     sUrl   = "";

            if (verify.Status == 1)
            {
                sUrl = "/l/ParkingPayment_ComputeNewParkingFee_moduleid=3%5Ecid=" + CurrLoginWeiXinApiConfig.CompanyID;

                //绑定成功了 再平台上也添加一个用户
                bool result = WeiXinAccountService.WXBindingMobilePhone(WeiXinUser.AccountID, phone);
                WeiXinUser.MobilePhone = phone;
                if (!result)
                {
                    TxtLogServices.WriteTxtLogEx("WXBindError", "用户绑定手机失败:{0}", result);
                }
            }

            var bangding = new { Status = verify.Status, Result = verify.Result, Url = sUrl };

            res.Data = bangding;
            return(res);
        }