| | |
| | | /// <param name="nowMonth"></param> |
| | | /// <param name="mac"></param> |
| | | /// <returns></returns> |
| | | public ResponsePack GetSensorHistory(int subnetId,int deviceId,int bigClass,int minClass,int queryType,int loopId,int nowMonth,string mac) |
| | | public ResponsePack GetSensorHistory(int subnetId, int deviceId, int bigClass, int minClass, int queryType, int loopId, int nowMonth, string mac) |
| | | { |
| | | Dictionary<string, object> d = new Dictionary<string, object>(); |
| | | d.Add("SubnetID", subnetId); |
| | |
| | | d.Add("MAC", DB_ResidenceData.residenceData.residenceGatewayMAC); |
| | | d.Add("LocalTimeZone", 8); |
| | | var jsonString = Newtonsoft.Json.JsonConvert.SerializeObject(d); |
| | | return RequestHttps("https://developer.hdlcontrol.com/api/GetSensorPushHistory", jsonString,true); |
| | | return RequestHttps("https://developer.hdlcontrol.com/api/GetSensorPushHistory", jsonString, true); |
| | | |
| | | } |
| | | |
| | |
| | | return result; |
| | | } |
| | | |
| | | #region ■ 通用请求接口_______________________ |
| | | /// <summary> |
| | | /// 根椐用户账号获取注册区域 免登录 // 检测账号是否注册也用这个接口 |
| | | /// </summary> |
| | | /// <param name="account"></param> |
| | | /// <returns></returns> |
| | | public ResponsePackNew GetRegionByAccount(string account) |
| | | { |
| | | var requestJson = HttpUtil.GetSignRequestJson(new RegionByAccountObj() { account = account }); |
| | | return HttpUtil.RequestHttpsPost(NewAPI.API_POST_GetRegionByAccount, requestJson); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 刷新Token |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public bool RefreshToken() |
| | | { |
| | | var requestJson = HttpUtil.GetSignRequestJson(new RefreshTokenObj() |
| | | { |
| | | refreshToken = MainPage.LoginUser.refreshToken, |
| | | }); |
| | | var revertObj = HttpUtil.RequestHttpsPost(NewAPI.API_POST_Login, requestJson); |
| | | if (revertObj.Code.ToUpper() == HttpUtil.SUCCESS_CODE) |
| | | { |
| | | var revertData = Newtonsoft.Json.JsonConvert.DeserializeObject<UserLoginRes>(revertObj.Data.ToString()); |
| | | MainPage.LoginUser.loginTokenString = revertData.headerPrefix + revertData.accessToken; |
| | | MainPage.LoginUser.lastTime = DateTime.Now; |
| | | MainPage.LoginUser.SaveUserInfo(); |
| | | return true; |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | |
| | | #region 注册、登录部分 |
| | | /// <summary> |
| | | /// 获取请求提交的语言参数 |
| | | /// </summary> |
| | | public string GetPostLanguageType() |
| | | { |
| | | return Language.CurrentLanguage == "Chinese" ? LanguageTypeEnum.CHINESE.ToString() : LanguageTypeEnum.ENGLISH.ToString(); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 通用 发送验证码方法 |
| | | /// </summary> |
| | | /// <param name="verifyType">1:注册 2:找回密码 3:登陆 4:绑定</param> |
| | | /// <param name="account">邮箱或者手机号</param> |
| | | /// <param name="isPhone">是否手机</param> |
| | | /// <param name="phoneZoneCode">手机国家区号</param> |
| | | /// <returns></returns> |
| | | public ResponsePackNew VerificationCodeSend(VerifyType verifyType, string account, bool isPhone = false, string phoneZoneCode = "86") |
| | | { |
| | | var requestObj = new VerifyCodeSendObj() |
| | | { |
| | | verifyType = (int)verifyType, |
| | | languageType = GetPostLanguageType() |
| | | }; |
| | | // 是否是手机 |
| | | if (isPhone) |
| | | { |
| | | requestObj.phone = account; |
| | | requestObj.phonePrefix = phoneZoneCode; |
| | | } |
| | | else |
| | | { |
| | | requestObj.mail = account; |
| | | } |
| | | // 超时时间设置为20秒,应该测试海外服务器发送验证码响应时间很久 |
| | | var requestJson = HttpUtil.GetSignRequestJson(requestObj); |
| | | return HttpUtil.RequestHttpsPost(NewAPI.API_POST_Verification_Send, requestJson, "", "", HttpUtil.TIME_OUT_LONG); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 账号登录-使用密码 |
| | | /// </summary> |
| | | public ResponsePack LoginByPassword(string account, string password) |
| | | /// <param name="account">账号</param> |
| | | /// <param name="password">密码</param> |
| | | /// <returns></returns> |
| | | public ResponsePackNew LoginByPassword(string account, string password) |
| | | { |
| | | string jsonString = "{" +
|
| | | "\"Account\":" + "\"" + account + "\"" + "," + |
| | | "\"Password\":" + "\"" + password + "\"" + |
| | | "}"; |
| | | return RequestHttps($"{severAddress}/ZigbeeUsers/Login", jsonString, false); |
| | | var requestJson = HttpUtil.GetSignRequestJson(new LoginObj() |
| | | { |
| | | account = account, |
| | | loginPwd = password |
| | | }); |
| | | return HttpUtil.RequestHttpsPost(NewAPI.API_POST_Login, requestJson); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 验证码登录 |
| | | /// </summary> |
| | | public ResponsePack LoginValidCode(string account,string vCode) |
| | | /// <param name="account">账号</param> |
| | | /// <param name="vCode">验证码</param> |
| | | /// <returns></returns> |
| | | public ResponsePackNew LoginValidCode(string account, string vCode) |
| | | { |
| | | Dictionary<string, object> d = new Dictionary<string, object>(); |
| | | d.Add("Account", account); |
| | | d.Add("Code", vCode); |
| | | d.Add("Language", Language.CurrentLanguage); |
| | | d.Add("AreaCode", "86"); |
| | | var jsonString = Newtonsoft.Json.JsonConvert.SerializeObject(d); |
| | | return RequestHttps($"{severAddress}/ZigbeeUsers/LoginValidCode", jsonString, false); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 手机号码注册 |
| | | /// </summary> |
| | | /// <param name="mobileNumber"></param> |
| | | /// <param name="password"></param> |
| | | /// <param name="language"></param> |
| | | public ResponsePack RegisterPhone(string mobileNumber, string password, string language) |
| | | { |
| | | string jsonString = "{" +
|
| | | "\"Account\":" + "\"" + mobileNumber + "\"" + "," + |
| | | "\"Password\":" + "\"" + password + "\"" + "," + |
| | | "\"Language\":" + "\"" + language + "\"" + |
| | | "\"AreaCode\":" + "\"" + "86" + "\"" + |
| | | "}"; |
| | | return RequestHttps($"{severAddress}/SignIn", jsonString, false); |
| | | } |
| | | |
| | | public ResponsePack GetAreaCode() |
| | | { |
| | | string requestJson = "{}"; |
| | | return RequestHttps($"{severAddress}/ZigbeeUsers/GetAreaCode", requestJson, false); |
| | | var requestJson = HttpUtil.GetSignRequestJson(new LoginObj() |
| | | { |
| | | account = account, |
| | | verifyCode = vCode, |
| | | grantType = "verify" |
| | | }); |
| | | return HttpUtil.RequestHttpsPost(NewAPI.API_POST_Login, requestJson); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 验证短信或者邮箱验证码,之后注册 |
| | | /// </summary> |
| | | /// <param name="account">账号</param> |
| | | /// <param name="account">邮箱或者手机号</param> |
| | | /// <param name="password">密码</param> |
| | | /// <param name="entryPassword">确认密码</param> |
| | | /// <param name="code">验证码</param> |
| | | /// <param name="areaCode"></param> |
| | | /// <param name="isPhone">是否手机</param> |
| | | /// <returns></returns> |
| | | public ResponsePack ValidataCodeAndRegister(string account, string password, string entryPassword, string code, int areaCode) |
| | | public ResponsePackNew ValidataCodeAndRegister(string account, string password, string code, bool isPhone = false) |
| | | { |
| | | //var requestObj = new ValidateSmsCodeObj() { Phone = accout, Code = code }; |
| | | //var requestJson = Newtonsoft.Json.JsonConvert.SerializeObject(requestObj); |
| | | string requestJson = "{" +
|
| | | "\"Account\":" + "\"" + account + "\"" + "," + |
| | | "\"Password\":" + "\"" + password + "\"" + "," + |
| | | "\"EnterPassword\":" + "\"" + entryPassword + "\"" + "," + |
| | | "\"Language\":" + "\"" + Language.CurrentLanguage.ToLower() + "\"" + "," + |
| | | "\"Code\":" + "\"" + code + "\"" + "," + |
| | | "\"RegisterSoruce\":" + 0 + "," + |
| | | "\"AreaCode\":" + 86 + |
| | | "}"; |
| | | return RequestHttps($"{severAddress}/ZigbeeUsers/ValidataCodeAndRegisterAccount", requestJson, false); |
| | | var requestObj = new RegisterObj() { loginPwd = password, verifyCode = code, memberName = account }; |
| | | if (isPhone) |
| | | { |
| | | requestObj.memberPhone = account; |
| | | } |
| | | else |
| | | { |
| | | requestObj.memberEmail = account; |
| | | } |
| | | var requestJson = HttpUtil.GetSignRequestJson(requestObj); |
| | | return HttpUtil.RequestHttpsPost(NewAPI.API_POST_Member_Register, requestJson); |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// 获取注册验证码 |
| | | /// 忘记密码,重置密码 |
| | | /// </summary> |
| | | public ResponsePack GetRegisterVerCode(string account) |
| | | /// <param name="account">邮箱或者手机号</param> |
| | | /// <param name="password">新密码</param> |
| | | /// <param name="vCode">验证码</param> |
| | | /// <param name="isPhone">是否手机账号</param> |
| | | /// <returns></returns> |
| | | public ResponsePackNew ForgetPassword(string account, string password, string vCode, bool isPhone) |
| | | { |
| | | string jsonString = "{" +
|
| | | "\"Account\":" + "\"" + account + "\"" + "," + |
| | | "\"Company\":" + MainPage.Company + "," + |
| | | "\"Language\":" + "\"" + Language.CurrentLanguage.ToLower() + "\"" + "," + |
| | | "\"AreaCode\":" + 86 + |
| | | "}"; |
| | | return RequestHttps($"{severAddress}/ZigbeeUsers/RegisterSendVerCode", jsonString, false); |
| | | |
| | | var requestObj = new ForgetPwdObj() { verifyCode = vCode, loginPwd = password }; |
| | | if (isPhone) |
| | | { |
| | | //手机忘记密码 |
| | | requestObj.memberPhone = account; |
| | | } |
| | | else |
| | | { |
| | | //邮箱忘记密码 |
| | | requestObj.memberEmail = account; |
| | | } |
| | | var requestJson = HttpUtil.GetSignRequestJson(requestObj); |
| | | return HttpUtil.RequestHttpsPost(NewAPI.API_POST_Member_ForgetPwd, requestJson); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | /// <summary> |
| | |
| | | |
| | | string jsonString = "{" +
|
| | | "\"Account\":" + "\"" + account + "\"" + "," + |
| | | "\"AreaCode\":" + "86" + |
| | | "\"AreaCode\":" + "86" + |
| | | "}"; |
| | | return RequestHttps($"{severAddress}/ZigbeeUsers/LoginSendVerCode", jsonString, false); |
| | | } |
| | |
| | | return RequestHttps($"{severAddress}/ZigbeeUsers/ValidatorCode", jsonString, false); |
| | | } |
| | | |
| | | |
| | | |
| | | /// <summary> |
| | | /// 重设密码 |
| | | /// </summary> |
| | |
| | | var requestJson = Newtonsoft.Json.JsonConvert.SerializeObject(d); |
| | | var revertObj = RequestHttps($"{severAddress}/ZigbeeUsers/GetAccountInfo", requestJson, true); |
| | | |
| | | if (revertObj.StateCode.ToUpper() == "SUCCESS") |
| | | if (revertObj.StateCode.ToUpper() == HttpUtil.SUCCESS_CODE) |
| | | { |
| | | var dataStr = JObject.FromObject(revertObj.ResponseData); |
| | | //"DistributedMark": "96439601-fd26-4768-8440-1d9dfa32c109", < !--帐号Id-- > |
| | |
| | | fs.Flush(); |
| | | MainPage.LoginUser.headImagePagePath = filePath; |
| | | } |
| | | } catch (Exception ex) |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | MainPage.Log($"download headImage error : {ex.Message}"); |
| | | } |
| | |
| | | "\"HomeType\":" + "\"" + "1" + "\"" + "," + |
| | | "\"LoginAccessToken\":" + "\"" + MainPage.LoginUser.loginTokenString + "\"" + |
| | | "}"; |
| | | var responsePack = RequestHttps($"{severAddress}/App/GetHomePager", jsonString,false); |
| | | var responsePack = RequestHttps($"{severAddress}/App/GetHomePager", jsonString, false); |
| | | |
| | | if (responsePack.StateCode.ToUpper() == "SUCCESS") |
| | | if (responsePack.StateCode.ToUpper() == HttpUtil.SUCCESS_CODE) |
| | | { |
| | | var dataStr = JObject.FromObject(responsePack.ResponseData); |
| | | //没有住宅 |
| | |
| | | /// <param name="nickName"></param> |
| | | /// <param name="subAccountGuid"></param> |
| | | /// <returns></returns> |
| | | public ResponsePack EditSubAccountNickName(string nickName,string subAccountGuid) |
| | | public ResponsePack EditSubAccountNickName(string nickName, string subAccountGuid) |
| | | { |
| | | Dictionary<string, object> d = new Dictionary<string, object>(); |
| | | d.Add("SubAccountGuid", subAccountGuid); |
| | |
| | | /// 获取住宅下子账号的共享数据 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public ResponsePack GetShareData(string memberId,string hId) |
| | | public ResponsePack GetShareData(string memberId, string hId) |
| | | { |
| | | Dictionary<string, object> d = new Dictionary<string, object>(); |
| | | d.Add("DistributedMark", memberId); |
| | |
| | | /// <param name="subAccount"></param> |
| | | /// <param name="nickName"></param> |
| | | /// <returns></returns> |
| | | public ResponsePack BindResidenceMemberAccount(string subAccount,string nickName) |
| | | public ResponsePack BindResidenceMemberAccount(string subAccount, string nickName) |
| | | { |
| | | Dictionary<string, object> d = new Dictionary<string, object>(); |
| | | d.Add("SubAccount", subAccount); |
| | |
| | | } |
| | | System.Threading.Thread.Sleep(1000); |
| | | } |
| | | Shared.Application.RunOnMainThread(() => { |
| | | Shared.Application.RunOnMainThread(() => |
| | | { |
| | | try |
| | | { |
| | | HDL_ON.UI.HomePage.LoadEvent_RefreshAir(); |
| | |
| | | /// 请求Mqtt数据 |
| | | /// </summary> |
| | | /// <param name="dataStringJson">请求的参数.</param> |
| | | public ResponsePack RequestMqttInfo( string dataStringJson) |
| | | public ResponsePack RequestMqttInfo(string dataStringJson) |
| | | { |
| | | ResponsePack revertObj = null; |
| | | |
| | |
| | | /// <summary> |
| | | /// 获取住宅备份列表 |
| | | /// </summary> |
| | | public Dictionary<int,string> GetRegionLastBackupId() |
| | | public Dictionary<int, string> GetRegionLastBackupId() |
| | | { |
| | | //Dialog dialog = new Dialog(); |
| | | //dialog.Show(); |
| | |
| | | d.Add("LevelID", DB_ResidenceData.residenceData.residecenInfo.RegionID);// 199200); |
| | | var requestJson = Newtonsoft.Json.JsonConvert.SerializeObject(d); |
| | | var revertObj = RequestHttps("https://developer.hdlcontrol.com/api/GetUserFolder", requestJson, true); |
| | | if(revertObj == null || revertObj.ResponseData == null) |
| | | if (revertObj == null || revertObj.ResponseData == null) |
| | | { |
| | | return new Dictionary<int, string>(); |
| | | } |