From f788a1e320b8505435ed66e2456ddb2d0a838f76 Mon Sep 17 00:00:00 2001 From: JLChen <551775569@qq.com> Date: 星期四, 19 十一月 2020 19:58:14 +0800 Subject: [PATCH] 2020-11-19 1.优化绑定和解绑页面。2.修改密码功能实现,UI界面实现,接口实现。 --- HDL_ON/DAL/Server/HttpServerRequest.cs | 271 ++++++++++++++++++++++++++++++++++-------------------- 1 files changed, 171 insertions(+), 100 deletions(-) diff --git a/HDL_ON/DAL/Server/HttpServerRequest.cs b/HDL_ON/DAL/Server/HttpServerRequest.cs index b8f4f5c..b31745f 100644 --- a/HDL_ON/DAL/Server/HttpServerRequest.cs +++ b/HDL_ON/DAL/Server/HttpServerRequest.cs @@ -250,32 +250,15 @@ - - - - /// <summary> - /// 鑾峰彇鐧诲綍楠岃瘉鐮� - /// </summary> - public ResponsePack GetLoginVerCode(string account) - { - - string jsonString = "{" + - "\"Account\":" + "\"" + account + "\"" + "," + - "\"AreaCode\":" + "86" + - "}"; - return RequestHttps($"{severAddress}/ZigbeeUsers/LoginSendVerCode", jsonString, false); - } - ///// <summary> - ///// 鍙戦�侀獙璇佺爜 + ///// 鑾峰彇鐧诲綍楠岃瘉鐮� ///// </summary> - //public ResponsePack SendSms(string account) + //public ResponsePack GetLoginVerCode(string account) //{ + // string jsonString = "{" + // "\"Account\":" + "\"" + account + "\"" + "," + - // "\"Company\":" + MainPage.Company + "," + - // "\"Language\":" + "\"" + Language.CurrentLanguage + "\"" + "," + - // "\"AreaCode\":" + OnAppConfig.Instance.CountryNumber + + // "\"AreaCode\":" + "86" + // "}"; // return RequestHttps($"{severAddress}/ZigbeeUsers/LoginSendVerCode", jsonString, false); //} @@ -283,18 +266,27 @@ /// <summary> /// 楠岃瘉楠岃瘉鐮� /// </summary> - /// <param name="account"></param> - /// <param name="code"></param> + /// <param name="verifyType">楠岃瘉绫诲瀷</param> + /// <param name="account">楠岃瘉璐﹀彿</param> + /// <param name="code">楠岃瘉鐮�</param> + /// <param name="isPhone">鏄惁鎵嬫満</param> + /// <param name="verifySuccessFail">楠岃瘉閫氳繃鍚庯紝楠岃瘉鐮佹槸鍚﹀け鏁�</param> /// <returns></returns> - public ResponsePack ValidatorCode(string account, string code, int countryIndex) + public ResponsePackNew ValidatorCode(VerifyType verifyType, string account, string code, bool isPhone, bool verifySuccessFail = true) { - string jsonString = "{" + - "\"Account\":" + "\"" + account + "\"" + "," + - "\"Code\":" + "\"" + code + "\"" + "," + - "\"Language\":" + "\"" + Language.CurrentLanguage + "\"" + "," + - "\"AreaCode\":" + countryIndex + - "}"; - return RequestHttps($"{severAddress}/ZigbeeUsers/ValidatorCode", jsonString, false); + var requestObj = new VerifyCodeCheckObj() { verifyCode = code, verifyType = (int)verifyType , verifySuccessFail = verifySuccessFail }; + if (isPhone) + { + //鎵嬫満 + requestObj.phone = account; + } + else + { + //閭 + requestObj.mail = account; + } + var requestJson = HttpUtil.GetSignRequestJson(requestObj); + return HttpUtil.RequestHttpsPost(NewAPI.API_POST_Verification_Check, requestJson); } @@ -320,57 +312,111 @@ /// 鑾峰彇鐢ㄦ埛淇℃伅 /// </summary> /// <returns></returns> - public void GetUserInfo() + public void GetUserInfo(bool bGetHeadImage = true) { - Dictionary<string, object> d = new Dictionary<string, object>(); - var requestJson = Newtonsoft.Json.JsonConvert.SerializeObject(d); - var revertObj = RequestHttps($"{severAddress}/ZigbeeUsers/GetAccountInfo", requestJson, true); - - if (revertObj.StateCode.ToUpper() == StateCode.SUCCESS) + var requestJson = HttpUtil.GetSignRequestJson(new NullObj()); + var resultObj = HttpUtil.RequestHttpsPost(NewAPI.API_POST_Member_GetMemberInfo, requestJson); + if (resultObj.Code == StateCode.SUCCESS) { - var dataStr = JObject.FromObject(revertObj.ResponseData); - //"DistributedMark": "96439601-fd26-4768-8440-1d9dfa32c109", < !--甯愬彿Id-- > - MainPage.LoginUser.userEmailInfo = dataStr.GetValue("Email").ToString(); - MainPage.LoginUser.userMobileInfo = dataStr.GetValue("Phone").ToString(); - FileStream fs = null; - try + var info = Newtonsoft.Json.JsonConvert.DeserializeObject<MemberInfoRes>(resultObj.Data.ToString()); + MainPage.LoginUser.userEmailInfo = info.memberEmail; + MainPage.LoginUser.userMobileInfo = info.memberPhone; + MainPage.LoginUser.userName = info.memberName; + MainPage.LoginUser.areaCode = info.memberPhonePrefix; + //鏄惁闇�瑕佽幏鍙栧ご鍍� + if (bGetHeadImage) { - var headImageString = dataStr.GetValue("HeadImage").ToString(); - if (!string.IsNullOrEmpty(headImageString)) + var headImageBytes = DownHeadImage(); + if (headImageBytes != null) { - var jsonString = Newtonsoft.Json.JsonConvert.SerializeObject(headImageString); - var headImageBytes = Newtonsoft.Json.JsonConvert.DeserializeObject<byte[]>(jsonString); MainPage.LoginUser.headImagePageBytes = headImageBytes; - var filePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal) + "/", "headImage.png"); - fs = new FileStream(filePath, FileMode.Create, FileAccess.Write); - fs.Write(headImageBytes, 0, headImageBytes.Length); - fs.Flush(); - MainPage.LoginUser.headImagePagePath = filePath; - } - } - catch (Exception ex) - { - MainPage.Log($"download headImage error : {ex.Message}"); - } - finally - { - if (fs != null) - { - fs.Close(); - } - } - // "GesturePwd": null, < !--鎵嬪娍瀵嗙爜-- > - // "StringPwd": null , < !--瀛楃涓插瘑鐮�-- > - MainPage.LoginUser.userName = dataStr.GetValue("UserName").ToString(); + FileStream fs = null; + try + { + MainPage.LoginUser.headImagePageBytes = headImageBytes; + var filePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal) + "/", "headImage.png"); + fs = new FileStream(filePath, FileMode.Create, FileAccess.Write); + fs.Write(headImageBytes, 0, headImageBytes.Length); + fs.Flush(); + MainPage.LoginUser.headImagePagePath = filePath; + } + catch (Exception ex) + { + MainPage.Log($"download headImage error : {ex.Message}"); + } + finally + { + if (fs != null) + { + fs.Close(); + } + } - Application.RunOnMainThread(() => - { - }); + } + } MainPage.LoginUser.SaveUserInfo(); MainPage.Log("鑾峰彇鐢ㄦ埛淇℃伅鎴愬姛銆�"); } + + // Dictionary<string, object> d = new Dictionary<string, object>(); + //var requestJson = Newtonsoft.Json.JsonConvert.SerializeObject(d); + //var revertObj = RequestHttps($"{severAddress}/ZigbeeUsers/GetAccountInfo", requestJson, true); + + //if (revertObj.StateCode.ToUpper() == StateCode.SUCCESS) + //{ + // var dataStr = JObject.FromObject(revertObj.ResponseData); + // //"DistributedMark": "96439601-fd26-4768-8440-1d9dfa32c109", < !--甯愬彿Id-- > + // MainPage.LoginUser.userEmailInfo = dataStr.GetValue("Email").ToString(); + // MainPage.LoginUser.userMobileInfo = dataStr.GetValue("Phone").ToString(); + // FileStream fs = null; + // try + // { + // var headImageString = dataStr.GetValue("HeadImage").ToString(); + // if (!string.IsNullOrEmpty(headImageString)) + // { + // var jsonString = Newtonsoft.Json.JsonConvert.SerializeObject(headImageString); + // var headImageBytes = Newtonsoft.Json.JsonConvert.DeserializeObject<byte[]>(jsonString); + // MainPage.LoginUser.headImagePageBytes = headImageBytes; + // var filePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal) + "/", "headImage.png"); + // fs = new FileStream(filePath, FileMode.Create, FileAccess.Write); + // fs.Write(headImageBytes, 0, headImageBytes.Length); + // fs.Flush(); + // MainPage.LoginUser.headImagePagePath = filePath; + // } + // } + // catch (Exception ex) + // { + // MainPage.Log($"download headImage error : {ex.Message}"); + // } + // finally + // { + // if (fs != null) + // { + // fs.Close(); + // } + // } + // // "GesturePwd": null, < !--鎵嬪娍瀵嗙爜-- > + // // "StringPwd": null , < !--瀛楃涓插瘑鐮�-- > + // MainPage.LoginUser.userName = dataStr.GetValue("UserName").ToString(); + + // Application.RunOnMainThread(() => + // { + // }); + + // MainPage.LoginUser.SaveUserInfo(); + // MainPage.Log("鑾峰彇鐢ㄦ埛淇℃伅鎴愬姛銆�"); + //} + + } + + /// <summary> + /// 涓嬭浇鐢ㄦ埛澶村儚 + /// </summary> + public byte[] DownHeadImage() + { + return HttpUtil.RequestHttpsDownload(NewAPI.API_POST_Head_Down, null); } /// <summary> @@ -378,14 +424,12 @@ /// </summary> /// <param name="userName"></param> /// <returns></returns> - public ResponsePack EditUserName(string userName) + public ResponsePackNew EditUserName(string userName) { - Dictionary<string, string> d = new Dictionary<string, string>(); - d.Add("UserName", userName); - var requestJson = Newtonsoft.Json.JsonConvert.SerializeObject(d); - var revertObj = RequestHttps($"{severAddress}/ZigbeeUsers/UpdateUserName", requestJson, true); - return revertObj; - + var requestJson = HttpUtil.GetSignRequestJson(new UpdateMemberNameRes() { + memberName = userName + }); + return HttpUtil.RequestHttpsPost(NewAPI.API_POST_Member_UpdateMemberInfo, requestJson); } /// <summary> @@ -398,26 +442,47 @@ FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.Read); byte[] bytes = new byte[fs.Length]; fs.Read(bytes, 0, bytes.Length); - - Dictionary<string, byte[]> d = new Dictionary<string, byte[]>(); - d.Add("HeadImage", bytes); - var requestJson = Newtonsoft.Json.JsonConvert.SerializeObject(d); - - var revertObj = RequestHttps($"{severAddress}/ZigbeeUsers/UpdateHeadImage", requestJson, true); - return revertObj.StateCode; + var revertObj = HttpUtil.RequestHttpsUpload(RestSharp.Method.POST, NewAPI.API_POST_Head_Upload, bytes); + return revertObj.Code; } /// <summary> /// 鏇存敼缁戝畾璐︽埛鐨勯偖绠辨垨鑰呮墜鏈哄彿 + /// 2020-11-16 寰呬慨鏀� /// </summary> /// <param name="account"></param> + /// <param name="code"></param> + /// <param name="isPhone"></param> /// <returns></returns> - public string BindAccount(string account) + public string BindAccount(string account, string code = "", bool isPhone = false) { - string jsonString = "{" + "\"Account\":" + "\"" + account + "\"" + "}"; - var responsePack = RequestHttps($"{severAddress}/ZigbeeUsers/BindAccount", jsonString, true); - return responsePack.StateCode; + var requestObj = new BindWithAccountObj() { verifyCode = code}; + if (isPhone) + { + //鎵嬫満 + requestObj.memberPhone = account; + } + else + { + //閭 + requestObj.memberEmail = account; + } + var requestJson = HttpUtil.GetSignRequestJson(requestObj); + return HttpUtil.RequestHttpsPost(NewAPI.API_POST_Member_BindWithAccount, requestJson).Code; } + + /// <summary> + /// 瑙g粦鎵嬫満鎴栬�呴偖绠� + /// </summary> + /// <param name="isPhone"></param> + /// <returns></returns> + public string UnBindAccount(bool isPhone) + { + var requestObj = new UnBindAccountObj() { unBindLabel = isPhone ? "PHONE": "EMAIL" }; + var requestJson = HttpUtil.GetSignRequestJson(requestObj); + return HttpUtil.RequestHttpsPost(NewAPI.API_POST_Member_UnbindWithAccount, requestJson).Code; + } + #endregion #region 浣忓畢閮ㄥ垎 @@ -575,25 +640,31 @@ /// 鑾峰彇浣忓畢涓嬬殑鎴愬憳璐﹀彿 /// </summary> /// <returns></returns> - public ResponsePack GetResidenceMemberAccount() + public ResponsePackNew GetResidenceMemberAccount() { - Dictionary<string, object> d = new Dictionary<string, object>(); - d.Add("DistributedMark", DB_ResidenceData.residenceData.residecenInfo.RegionID); - string jsonString = Newtonsoft.Json.JsonConvert.SerializeObject(d); - return RequestHttps($"{severAddress}/ZigbeeUsers/GetSubAccountByDistributedMark", jsonString, true); + var requestJson = Newtonsoft.Json.JsonConvert.SerializeObject(new HomeIdObj() { homeId = DB_ResidenceData.residenceData.residecenInfo.RegionID }); + var replaceToken = MainPage.LoginUser.loginTokenString; + //濡傛灉褰撳墠鎵�鍒嗕韩浣忓畢鍜屼负绠$悊鍛橈紝鏇挎崲涓轰富浜簍oken + //寰呭鐞�... + return HttpUtil.RequestHttpsPost(NewAPI.API_POST_Child_FindAll, requestJson, DB_ResidenceData.residenceData.residecenInfo.regionUrl, replaceToken); } /// <summary> /// 鍒犻櫎浣忓畢涓嬬殑鎴愬憳璐﹀彿 /// </summary> /// <returns></returns> - public ResponsePack DeleteResidenceMemberAccount(string memberAccount) + public ResponsePackNew DeleteResidenceMemberAccount(ResidenceMemberInfo subaccount) { - Dictionary<string, object> d = new Dictionary<string, object>(); - d.Add("SubAccount", memberAccount); - d.Add("HouseDistributedMark", DB_ResidenceData.residenceData.residecenInfo.RegionID); - string jsonString = Newtonsoft.Json.JsonConvert.SerializeObject(d); - return RequestHttps($"{severAddress}/ZigbeeUsers/DeletedSubAccount", jsonString, true); + var requestObj = new ChildDeleteObj() + { + childAccountId = subaccount.childAccountId, + homeId = subaccount.homeId + }; + var requestJson = Newtonsoft.Json.JsonConvert.SerializeObject(requestObj); + var replaceToken = MainPage.LoginUser.loginTokenString; + //濡傛灉褰撳墠鎵�鍒嗕韩浣忓畢鍜屼负绠$悊鍛橈紝鏇挎崲涓轰富浜簍oken + //寰呭鐞�... + return HttpUtil.RequestHttpsPost(NewAPI.API_POST_Child_Delete, requestJson, DB_ResidenceData.residenceData.residecenInfo.regionUrl, replaceToken); } /// <summary> -- Gitblit v1.8.0