| | |
| | | /// 获取用户信息 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public void GetUserInfo() |
| | | public void GetUserInfo(bool bGetHeadImage = true) |
| | | { |
| | | var requestJson = HttpUtil.GetSignRequestJson(new NullObj()); |
| | | var resultObj = HttpUtil.RequestHttpsPost(NewAPI.API_POST_Member_GetMemberInfo, requestJson); |
| | |
| | | MainPage.LoginUser.userEmailInfo = info.memberEmail; |
| | | MainPage.LoginUser.userMobileInfo = info.memberPhone; |
| | | MainPage.LoginUser.userName = info.memberName; |
| | | |
| | | var headImageBytes = DownHeadImage(); |
| | | if (headImageBytes != null) |
| | | MainPage.LoginUser.areaCode = info.memberPhonePrefix; |
| | | //是否需要获取头像 |
| | | if (bGetHeadImage) |
| | | { |
| | | MainPage.LoginUser.headImagePageBytes = headImageBytes; |
| | | FileStream fs = null; |
| | | try |
| | | var headImageBytes = DownHeadImage(); |
| | | if (headImageBytes != null) |
| | | { |
| | | 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) |
| | | FileStream fs = null; |
| | | try |
| | | { |
| | | fs.Close(); |
| | | 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(); |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |
| | | |
| | | MainPage.LoginUser.SaveUserInfo(); |
| | |
| | | else |
| | | { |
| | | //邮箱 |
| | | requestObj.memberMail = account; |
| | | requestObj.memberEmail = account; |
| | | } |
| | | var requestJson = HttpUtil.GetSignRequestJson(requestObj); |
| | | return HttpUtil.RequestHttpsPost(NewAPI.API_POST_Member_UpdateMemberInfo, requestJson).Code; |
| | | return HttpUtil.RequestHttpsPost(NewAPI.API_POST_Member_BindWithAccount, requestJson).Code; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 解绑手机或者邮箱 |
| | | /// </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 住宅部分 |
| | |
| | | public ResponsePackNew GetResidenceMemberAccount() |
| | | { |
| | | var requestJson = Newtonsoft.Json.JsonConvert.SerializeObject(new HomeIdObj() { homeId = DB_ResidenceData.residenceData.residecenInfo.RegionID }); |
| | | return HttpUtil.RequestHttpsPost(NewAPI.API_POST_Child_FindAll, requestJson, null, DB_ResidenceData.residenceData.residecenInfo.regionUrl); |
| | | var replaceToken = MainPage.LoginUser.loginTokenString; |
| | | //如果当前所分享住宅和为管理员,替换为主人token |
| | | //待处理... |
| | | 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; |
| | | //如果当前所分享住宅和为管理员,替换为主人token |
| | | //待处理... |
| | | return HttpUtil.RequestHttpsPost(NewAPI.API_POST_Child_Delete, requestJson, DB_ResidenceData.residenceData.residecenInfo.regionUrl, replaceToken); |
| | | } |
| | | |
| | | /// <summary> |