using Itlead.Architecture.Contract; using Itlead.Architecture.Contract.DataContract; using Newtonsoft.Json; using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.SessionState; namespace Itlead.Architecture.WebUI.tools { /// /// CheckSMS 的摘要说明 /// public class CheckSMS : IHttpHandler, IRequiresSessionState { const string userService = "userService"; public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/json"; ReturnData re = new ReturnData(); try { string phone = context.Request.Params["phone"]; string code = context.Request.Params["phone_code"]; int type = int.Parse(context.Request.Params["type"]); Guid? id = null; if (context.Request.Cookies["user"] != null) { id = new Guid(context.Request.Cookies["user"]["UserId"]); } var s = MyBasicLib.Utilities.ServiceInvoker.Invoke(userService, u => u.CheckPhone(phone, type, id)); re.flag = s; if (!s) { re.msg = "手机号码已存在"; re.flag = false; } if (re.flag) { re = new getPhoneCode().checkSMS(context, phone, code, 6); } } catch (Exception e) { re.flag = false; re.msg = e.Message; } context.Response.Write(JsonConvert.SerializeObject(re)); } public bool IsReusable { get { return false; } } } }