/// <summary> /// 验证登录 /// </summary> /// <returns></returns> public ResponseBase <object> ValidateLogin(string userName, string password) { var response = new ResponseBase <object>(); try { var client = new HttpClient(); var requestJson = JsonConvert.SerializeObject(new { Account = userName, Password = TripleDes.EncryptDES(password, "50yc_czm", "12345678") }); var result = client.PostAsync(YCDomain + "/api/app/v2/member/signin", new StringContent(requestJson, System.Text.Encoding.UTF8, "application/json")).Result; var responseJson = result.Content.ReadAsStringAsync().Result; var apiResponse = (JObject)JsonConvert.DeserializeObject(responseJson); response.IsSuccess = apiResponse.GetValue("code").Value <string>().Equals("0000"); response.OperationDesc = apiResponse.GetValue("msg").Value <string>(); response.Result = apiResponse.GetValue("result"); } catch (Exception ex) { response.IsSuccess = false; response.OperationDesc = ex.ToString(); WriteLogException(ex); // 记录日志信息 } return(response); }
/// <summary> /// 注册 /// </summary> /// <param name="token"></param> /// <param name="model"></param> /// <returns></returns> public ResponseBase <string> ValidateRegister(string mobile, string smsCode, string password) { var response = new ResponseBase <string>(); try { var client = new HttpClient(); var requestJson = JsonConvert.SerializeObject(new { mobile = mobile, smsCode = smsCode, password = TripleDes.EncryptDES(password, "50yc_czm", "12345678") }); var result = client.PostAsync(YCDomain + "/api/app/v2/member/register", new StringContent(requestJson, System.Text.Encoding.UTF8, "application/json")).Result; var responseJson = result.Content.ReadAsStringAsync().Result; var apiResponse = (JObject)JsonConvert.DeserializeObject(responseJson); response.IsSuccess = apiResponse.GetValue("code").Value <string>().Equals("0000"); response.OperationDesc = apiResponse.GetValue("msg").Value <string>(); if (response.IsSuccess) { response.Result = apiResponse.GetValue("result").Value <string>("memberNo"); } } catch (Exception ex) { response.IsSuccess = false; response.OperationDesc = "请求错误"; WriteLogException(ex); // 记录日志信息 } return(response); }