ZigbeeApp/GateWay.Droid/Assets/Language.ini
@@ -237,7 +237,6 @@ 231=接近感应 232=接近感应功能设置置失败 233=获取接近感应功能失败 234=方悦新风小模块 235=按住面板模式(Mode)和风速(Fan)按键{0}绿色指示灯亮起。则配网成功 ;三按键面板入网操作指示 236=绿色指示灯闪烁 @@ -310,6 +309,8 @@ 303=温度来源 304=湿度来源 305=PM2.5来源 307=不能创建自动化常开模式 308=不能取消自动化常开模式 @@ -1583,8 +1584,8 @@ 15872=无法识别的设备 15873=拍照 15874=从相册中选择 15875=出现未知错误 15876=请输入手势 15875=抱歉,程序出现错误 15876=请输入手势a 15877=请再次输入手势 15878=更改手势,请输入手势 15879=确认手势错误,请重新设置 @@ -1800,6 +1801,12 @@ 16091=常开模式手动开启 16092=常开模式手动取消 16093=常开模式启用{0}小时 16094=您的权限已经变更,请重新登陆 16095=我已阅读并同意 16096=隐私权政策 16097=和 16098=服务条款 16099=请先阅读并同意《隐私权政策》和《服务条款》 ;★★★★下面这些是接口的返回信息翻译,从18000开始★★★★ 18004=指定网关已经被绑定 @@ -1924,6 +1931,7 @@ 30035=简约2路窗帘面板 30036=方悦/2路窗帘面板-Z 30037=S-one 30038=方悦新风小模块 ;★★★★下面这些是设备所属种类的翻译名字,从40000开始★★★★ 40000=遮阳 @@ -1984,6 +1992,7 @@ 50035=Zigbee简约2路面板 50036=Zigbee方悦2路窗帘面板 50037=Zigbee智能门锁 50038=新风控制小模块 ;★★★★下面这些是模块ID的设备类型名字,从60000开始.注:它并不需要再R.cs文件中定义★★★★ 60000=传感器 @@ -1997,6 +2006,7 @@ 60008=转换器 60009=空调模块 60010=智能门锁 60011=新风模块 ;//★★★★下面这些是添加新设备界面那里显示的名字,从70000开始★★★★ 70000=2按键面板 ZigbeeApp/GateWay.Droid/Assets/Phone/Item/Check1.png
ZigbeeApp/GateWay.Droid/Assets/Phone/Item/Check1Selected.png
ZigbeeApp/GateWay.Droid/GateWay.Droid.csproj
@@ -2090,6 +2090,12 @@ <ItemGroup> <AndroidAsset Include="Assets\Phone\Logo\2.png" /> </ItemGroup> <ItemGroup> <AndroidAsset Include="Assets\Phone\Item\Check1.png" /> </ItemGroup> <ItemGroup> <AndroidAsset Include="Assets\Phone\Item\Check1Selected.png" /> </ItemGroup> <Import Project="..\Shared\Shared.projitems" Label="Shared" Condition="Exists('..\Shared\Shared.projitems')" /> <Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.CSharp.targets" /> <Import Project="..\packages\Xamarin.Android.Support.Annotations.26.0.2\build\MonoAndroid80\Xamarin.Android.Support.Annotations.targets" Condition="Exists('..\packages\Xamarin.Android.Support.Annotations.26.0.2\build\MonoAndroid80\Xamarin.Android.Support.Annotations.targets')" /> ZigbeeApp/GateWay.Droid/Properties/AndroidManifest.xml
@@ -1,5 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.hdl.home" android:versionCode="2020041301" android:installLocation="auto" android:versionName="1.0.20041301"> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.hdl.home" android:versionCode="2020041501" android:installLocation="auto" android:versionName="1.0.20041501"> <uses-sdk android:minSdkVersion="23" android:targetSdkVersion="26" /> <permission android:name="com.hdl.home.permission.JPUSH_MESSAGE" android:protectionLevel="signature" /> <uses-permission android:name="android.permission.WAKE_LOCK" /> ZigbeeApp/GateWay.Droid/Resources/Resource.designer.cs
Diff too large ZigbeeApp/Home.Ios/Home.IOS.csproj
@@ -531,6 +531,7 @@ <BundleResource Include="Resources\Phone\Item\Point.png" /> <BundleResource Include="Resources\Phone\Item\Search.png" /> <BundleResource Include="Resources\Phone\Item\SwitchSelected.png" /> <BundleResource Include="Resources\Phone\Item\Check1.png" /> <BundleResource Include="Resources\Phone\Item\NextSelected.png" /> <BundleResource Include="Resources\Phone\Item\SafetyShortcut_itemSelected.png" /> <BundleResource Include="Resources\Phone\Item\Timer.png" /> @@ -576,6 +577,7 @@ <BundleResource Include="Resources\Phone\Item\MinusSign2Selected.png" /> <BundleResource Include="Resources\Phone\Item\CollectionSelected1.png" /> <BundleResource Include="Resources\Phone\Item\SceneMsgIcon.png" /> <BundleResource Include="Resources\Phone\Item\Check1Selected.png" /> <BundleResource Include="Resources\Phone\Item\FailIcon.png" /> <BundleResource Include="Resources\Phone\Item\Message.png" /> <BundleResource Include="Resources\Phone\Item\FixedPosition.png" /> ZigbeeApp/Home.Ios/Resources/Language.ini
@@ -237,7 +237,6 @@ 231=接近感应 232=接近感应功能设置置失败 233=获取接近感应功能失败 234=方悦新风小模块 235=按住面板模式(Mode)和风速(Fan)按键{0}绿色指示灯亮起。则配网成功 ;三按键面板入网操作指示 236=绿色指示灯闪烁 @@ -310,6 +309,8 @@ 303=温度来源 304=湿度来源 305=PM2.5来源 307=不能创建自动化常开模式 308=不能取消自动化常开模式 @@ -1583,8 +1584,8 @@ 15872=无法识别的设备 15873=拍照 15874=从相册中选择 15875=出现未知错误 15876=请输入手势 15875=抱歉,程序出现错误 15876=请输入手势a 15877=请再次输入手势 15878=更改手势,请输入手势 15879=确认手势错误,请重新设置 @@ -1800,6 +1801,12 @@ 16091=常开模式手动开启 16092=常开模式手动取消 16093=常开模式启用{0}小时 16094=您的权限已经变更,请重新登陆 16095=我已阅读并同意 16096=隐私权政策 16097=和 16098=服务条款 16099=请先阅读并同意《隐私权政策》和《服务条款》 ;★★★★下面这些是接口的返回信息翻译,从18000开始★★★★ 18004=指定网关已经被绑定 @@ -1924,6 +1931,7 @@ 30035=简约2路窗帘面板 30036=方悦/2路窗帘面板-Z 30037=S-one 30038=方悦新风小模块 ;★★★★下面这些是设备所属种类的翻译名字,从40000开始★★★★ 40000=遮阳 @@ -1984,6 +1992,7 @@ 50035=Zigbee简约2路面板 50036=Zigbee方悦2路窗帘面板 50037=Zigbee智能门锁 50038=新风控制小模块 ;★★★★下面这些是模块ID的设备类型名字,从60000开始.注:它并不需要再R.cs文件中定义★★★★ 60000=传感器 @@ -1997,6 +2006,7 @@ 60008=转换器 60009=空调模块 60010=智能门锁 60011=新风模块 ;//★★★★下面这些是添加新设备界面那里显示的名字,从70000开始★★★★ 70000=2按键面板 ZigbeeApp/Home.Ios/Resources/Phone/Item/Check1.png
ZigbeeApp/Home.Ios/Resources/Phone/Item/Check1Selected.png
ZigbeeApp/Shared/Common/CommonPage.cs
@@ -57,7 +57,7 @@ /// <summary> /// 版本号 /// </summary> public static string CodeIDString = "1.0.20041301"; public static string CodeIDString = "1.0.20041501"; /// <summary> /// 注册来源(0:HDL On 1:Zigbee) /// </summary> @@ -374,30 +374,30 @@ } } } } /// <summary> /// 登出 /// </summary> public void SingOut() { try { Application.RunOnMainThread(() => { //设定一个时间 Config.Instance.LoginDateTime = new DateTime(1970, 1, 1); Config.Instance.Save(); CommonPage.Instance.RemoveAll(); CommonPage.Instance.Show(); var login = new Phone.Login.AccountLogin(); CommonPage.Instance.AddChidren(login); login.Show(); }); } catch { } } /// <summary> /// 登出 /// </summary> public void SingOut() { try { Application.RunOnMainThread(() => { //设定一个时间 Config.Instance.LoginDateTime = new DateTime(1970, 1, 1); Config.Instance.Save(); CommonPage.Instance.RemoveAll(); CommonPage.Instance.Show(); var login = new Phone.Login.AccountLogin(); CommonPage.Instance.AddChidren(login); login.Show(); }); } catch { } } /// <summary> /// 退出登录时调用,清除推送数据 /// </summary> ZigbeeApp/Shared/Common/Device.cs
@@ -1003,15 +1003,8 @@ //继电器,掉光器都叫回路 return Language.StringByID(R.MyInternationalizationString.uDeviceCircuit) + epointNo; } //获取设备类型 var deviceInfoType = this.GetMyDeviceEnumInfo(new List<CommonDevice>() { device }); if (device.Type == DeviceType.Thermostat) { //新风面板中的Thermostat叫温度传感器 if (deviceInfoType.ConcreteType == DeviceConcreteType.ButtonPanel_FangyueFreshAir) { return Language.StringByID(R.MyInternationalizationString.TemperatureSensor); } //空调都叫室内机 return Language.StringByID(R.MyInternationalizationString.uIndoorUnit) + epointNo; } @@ -1025,7 +1018,10 @@ //新风面板湿度传感器 return Language.StringByID(R.MyInternationalizationString.HumiditySensor); } else if (device.Type == DeviceType.OnOffSwitch) //获取设备类型 var deviceInfoType = this.GetMyDeviceEnumInfo(new List<CommonDevice>() { device }); if (device.Type == DeviceType.OnOffSwitch) { //面板的干接点叫按键 if (deviceInfoType.BeloneType == DeviceBeloneType.A按键面板) @@ -1036,6 +1032,19 @@ else { return Language.StringByID(R.MyInternationalizationString.uDeviceBelongId16) + epointNo; } } else if (device.Type == DeviceType.TemperatureSensor) { if (deviceInfoType.ConcreteType == DeviceConcreteType.ButtonPanel_FangyueFreshAir) { //新风面板中的Thermostat为温度传感器 return Language.StringByID(R.MyInternationalizationString.TemperatureSensor); } else if (deviceInfoType.BeloneType == DeviceBeloneType.A按键面板) { //面板的温度探头叫 面板名字+温度 return Language.StringByID(deviceInfoType.DefultNameId) + Language.StringByID(R.MyInternationalizationString.uTemperature); } } //其他情况,使用它的默认名称 @@ -2599,7 +2608,7 @@ //=========★★继电器类(2300-2499)★★========= this.dicDeviceModelIdEnum["MPR0310-ZB.10"] = "2300-2300-60001";//3路继电器小模块 this.dicDeviceModelIdEnum["MFA01-ZB1.0"] = "2310-2300-60001";//方悦新风小模块 this.dicDeviceModelIdEnum["MFA01-ZB.10"] = "2310-2300-60011";//方悦新风小模块 //=========★★调光器类(2500-2799)★★========= this.dicDeviceModelIdEnum["MPD0101-ZB.10"] = "2500-2500-60007";//1路调光器小模块 ZigbeeApp/Shared/DLL/Android/Shared.Droid.HDLWidget.dllBinary files differ
ZigbeeApp/Shared/DLL/Android/Shared.Droid.dllBinary files differ
ZigbeeApp/Shared/DLL/IOS/Shared.IOS.dllBinary files differ
ZigbeeApp/Shared/Phone/Category/AddOrEditorSceneForm.cs
@@ -159,8 +159,8 @@ //场景图片 this.btnScenePic = new ImageView(); btnScenePic.Y = Application.GetRealHeight(46); btnScenePic.Width = Application.GetMinRealAverage(887); btnScenePic.Height = Application.GetMinRealAverage(444); btnScenePic.Width = this.GetPictrueRealSize(887); btnScenePic.Height = this.GetPictrueRealSize(444); btnScenePic.Radius = (uint)Application.GetRealHeight(17); btnScenePic.Gravity = Gravity.CenterHorizontal; if (this.editorScene == null) ZigbeeApp/Shared/Phone/Category/SelectLocalSceneImageForm.cs
@@ -29,6 +29,8 @@ { //初始化中部信息 this.InitMiddleFrame(); //设置头部信息 base.SetTitleText(Language.StringByID(R.MyInternationalizationString.LocalPicture)); } /// <summary> ZigbeeApp/Shared/Phone/Device/CommonForm/RoomView.cs
@@ -137,8 +137,9 @@ TextSize = 14, TextAlignment = TextAlignment.CenterLeft }; if (string.IsNullOrEmpty(room.TemperatrueDevice) == false) if (LocalDevice.Current.GetDevice(room.TemperatrueDevice) != null) { //这个设备要存在本地才行 temperatureText.Text = room.Temperatrue == 0 ? "0.0℃" : room.Temperatrue.ToString() + "℃"; } roomTemperatureBackground.AddChidren(temperatureText); @@ -162,8 +163,9 @@ TextSize = 14, TextAlignment = TextAlignment.CenterLeft }; if (string.IsNullOrEmpty(room.HumidityDevice) == false) if (LocalDevice.Current.GetDevice(room.HumidityDevice) != null) { //这个设备要存在本地才行 humidityText.Text = room.Humidity == 0 ? "0.0%" : room.Humidity.ToString() + "%"; } roomTemperatureBackground.AddChidren(humidityText); ZigbeeApp/Shared/Phone/Device/Logic/AddLogicPage.cs
@@ -27,7 +27,7 @@ var middle = new FrameLayout { Y = view.topRowLayout.Bottom, Height = Application.GetRealHeight(1920 - 184), Height = Application.GetRealHeight(Method.H - 184), BackgroundColor = ZigbeeColor.Current.LogicMiddleBackgroundColor, }; this.AddChidren(middle); ZigbeeApp/Shared/Phone/Device/Logic/AddScenePage.cs
@@ -28,7 +28,7 @@ public VerticalScrolViewLayout middle = new VerticalScrolViewLayout { Width = Application.GetRealWidth(1080), Height = Application.GetRealHeight(1920 - 260 - 200 - 184), Height = Application.GetRealHeight(Method.H - 260 - 200 - 184), BackgroundColor = ZigbeeColor.Current.LogicMiddleBackgroundColor, }; ZigbeeApp/Shared/Phone/Device/Logic/CurrentDeviceState.cs
@@ -492,7 +492,8 @@ } break; case DeviceType.DoorLock: { { flMain.RemoveFromParent(); var memberList = new MemberList(); UserView.HomePage.Instance.AddChidren(memberList); ZigbeeApp/Shared/Phone/Device/Logic/CustomText.cs
@@ -22,7 +22,7 @@ var middle = new FrameLayout { Y = view.topRowLayout.Bottom, Height = Application.GetRealHeight(1920 - 184), Height = Application.GetRealHeight(Method.H - 184), BackgroundColor = ZigbeeColor.Current.LogicMiddleBackgroundColor, }; this.AddChidren(middle); ZigbeeApp/Shared/Phone/Device/Logic/Cycle.cs
@@ -31,7 +31,7 @@ var middle = new FrameLayout { Y = view.topRowLayout.Bottom, Height = Application.GetRealHeight(1920 - 184), Height = Application.GetRealHeight(Method.H - 184), BackgroundColor = ZigbeeColor.Current.LogicMiddleBackgroundColor, }; this.AddChidren(middle); ZigbeeApp/Shared/Phone/Device/Logic/DelayTime.cs
@@ -31,7 +31,7 @@ var middle = new FrameLayout { Y = view.topRowLayout.Bottom, Height = Application.GetRealHeight(1920 - 184), Height = Application.GetRealHeight(Method.H - 184), BackgroundColor = ZigbeeColor.Current.LogicMiddleBackgroundColor, }; this.AddChidren(middle); ZigbeeApp/Shared/Phone/Device/Logic/DeviceTarget.cs
@@ -35,7 +35,7 @@ var middle = new FrameLayout { Y = view.topRowLayout.Bottom, Height = Application.GetRealHeight(1920 - 184), Height = Application.GetRealHeight(Method.H - 184), BackgroundColor = ZigbeeColor.Current.LogicMiddleBackgroundColor, }; this.AddChidren(middle); ZigbeeApp/Shared/Phone/Device/Logic/DoorLockLogic/AddCondition.cs
@@ -26,7 +26,7 @@ middle = new VerticalRefreshLayout { Y = view.topRowLayout.Bottom, Height = Application.GetRealHeight(1920 - 184), Height = Application.GetRealHeight(Method.H - 184), BackgroundColor = ZigbeeColor.Current.LogicMiddleBackgroundColor, }; this.AddChidren(middle); ZigbeeApp/Shared/Phone/Device/Logic/DoorLockLogic/LockLogicCommunalPage.cs
@@ -41,7 +41,7 @@ var middle = new VerticalScrolViewLayout { Y = view.topRowLayout.Bottom, Height = Application.GetRealHeight(1920 - 184 - 180), Height = Application.GetRealHeight(Method.H - 184 - 180), BackgroundColor = ZigbeeColor.Current.LogicMiddleBackgroundColor, }; this.AddChidren(middle); ZigbeeApp/Shared/Phone/Device/Logic/DoorLockLogic/LockLogicList.cs
@@ -48,7 +48,7 @@ middle = new VerticalRefreshLayout { Y = view.topRowLayout.Bottom, Height = Application.GetRealHeight(1920 - 184), Height = Application.GetRealHeight(Method.H - 184), BackgroundColor = ZigbeeColor.Current.LogicMiddleBackgroundColor, }; this.AddChidren(middle); ZigbeeApp/Shared/Phone/Device/Logic/EverymonthPage.cs
@@ -30,7 +30,7 @@ var middle = new FrameLayout { Y = view.topRowLayout.Bottom, Height = Application.GetRealHeight(1920 - 184), Height = Application.GetRealHeight(Method.H - 184), BackgroundColor = ZigbeeColor.Current.LogicMiddleBackgroundColor, }; this.AddChidren(middle); ZigbeeApp/Shared/Phone/Device/Logic/EveryyearPage.cs
@@ -77,7 +77,7 @@ var middle = new VerticalScrolViewLayout(); middle.Y = titlerl.Bottom; middle.Height = Application.GetRealHeight(1920 - 220 - 180); middle.Height = Application.GetRealHeight(Method.H - 220 - 180); middle.BackgroundColor = ZigbeeColor.Current.LogicBackgroundColor; this.AddChidren(middle); ZigbeeApp/Shared/Phone/Device/Logic/IgnoreTime.cs
@@ -29,7 +29,7 @@ var middle = new VerticalScrolViewLayout { Y = view.topRowLayout.Bottom, Height = Application.GetRealHeight(1920 - 184 - 260), Height = Application.GetRealHeight(Method.H - 184 - 260), BackgroundColor = ZigbeeColor.Current.LogicMiddleBackgroundColor, }; this.AddChidren(middle); ZigbeeApp/Shared/Phone/Device/Logic/LogicCommunalPage.cs
@@ -43,7 +43,7 @@ var middle = new VerticalScrolViewLayout { Y = view.topRowLayout.Bottom, Height = Application.GetRealHeight(1920 - 184-180), Height = Application.GetRealHeight(Method.H - 184-180), BackgroundColor = ZigbeeColor.Current.LogicMiddleBackgroundColor, }; this.AddChidren(middle); ZigbeeApp/Shared/Phone/Device/Logic/LogicView/CompleteView.cs
@@ -11,7 +11,7 @@ { Width = Application.GetRealWidth(1080), Height = Application.GetRealHeight(140 + 320 + 70), Y = Application.GetRealHeight(1920 - 530), Y = Application.GetRealHeight(Method.H - 530), BackgroundColor = ZigbeeColor.Current.LogicBackgroundColor, // Radius = (uint)Application.GetRealHeight(60), }; ZigbeeApp/Shared/Phone/Device/Logic/MemberList.cs
@@ -33,7 +33,7 @@ middle = new VerticalRefreshLayout { Y = view.topRowLayout.Bottom, Height = Application.GetRealHeight(1920 - 184), Height = Application.GetRealHeight(Method.H - 184), BackgroundColor = ZigbeeColor.Current.LogicMiddleBackgroundColor, }; this.AddChidren(middle); ZigbeeApp/Shared/Phone/Device/Logic/Method.cs
@@ -83,6 +83,16 @@ { //过滤掉不支持的设备 continue; } if (device.Type == DeviceType.DoorLock) { var myInfo = LocalDevice.Current.GetMyDeviceEnumInfo(new List<CommonDevice>() { device }); if (myInfo.ConcreteType == DeviceConcreteType.IntelligentLocks_Sone) { //暂时不支持S-one门锁; //过滤掉不支持S-one门锁设备; continue; } } deviceUIlist.Add(device); } @@ -835,6 +845,9 @@ deviceTarget.Show(str1, str2); } /// <summary> /// 界面高度 /// </summary> public static int H = 1922; } } ZigbeeApp/Shared/Phone/Device/Logic/OneLogic.cs
@@ -53,7 +53,7 @@ var middle = new VerticalScrolViewLayout { Y = view.topRowLayout.Bottom, Height = Application.GetRealHeight(1920 - 184 - 180), Height = Application.GetRealHeight(Method.H - 184 - 180), BackgroundColor = ZigbeeColor.Current.LogicMiddleBackgroundColor, }; this.AddChidren(middle); ZigbeeApp/Shared/Phone/Device/Logic/OneTimePoint.cs
@@ -31,7 +31,7 @@ var middle = new FrameLayout { Y = view.topRowLayout.Bottom, Height = Application.GetRealHeight(1920 - 184 - 260), Height = Application.GetRealHeight(Method.H - 184 - 260), BackgroundColor = ZigbeeColor.Current.LogicMiddleBackgroundColor, }; this.AddChidren(middle); ZigbeeApp/Shared/Phone/Device/Logic/RoomAndDeviceView.cs
@@ -52,7 +52,7 @@ { X = Application.GetRealWidth(58), Y = Application.GetRealHeight(184 + 200 + 280 + 40), Height = Application.GetRealHeight(1920 - 40 - 184 - 280 - 200), Height = Application.GetRealHeight(Method.H - 40 - 184 - 280 - 200), BackgroundColor = ZigbeeColor.Current.LogicBackgroundColor, }; ZigbeeApp/Shared/Phone/Device/Logic/SecurityMode.cs
@@ -30,7 +30,7 @@ var middle = new FrameLayout(); middle.Y = view.topRowLayout.Bottom; middle.Height = Application.GetRealHeight(1920 - 184); middle.Height = Application.GetRealHeight(Method.H - 184); middle.BackgroundColor = ZigbeeColor.Current.LogicMiddleBackgroundColor; this.AddChidren(middle); ZigbeeApp/Shared/Phone/Device/Logic/SkipView.cs
@@ -345,6 +345,9 @@ /// 加载自动化列表界面 /// </summary> /// <param name="refresview">Refresview.</param> static RowLayout selectedRow = new RowLayout() { Tag="0"};//记录左滑状态 private static async void Automationview(VerticalRefreshLayout refresview, bool no) { refresview.RemoveAll(); @@ -363,8 +366,8 @@ var noIconBtn = new Button { Y = Application.GetRealHeight(294 - 55), Width = Application.GetMinRealAverage(756), Height = Application.GetMinRealAverage(434), Width = Application.GetMinRealAverage(757), Height = Application.GetMinRealAverage(435), UnSelectedImagePath = "Item/NoFunction.png", X = Application.GetRealWidth(104), }; @@ -417,17 +420,27 @@ LineColor = ZigbeeColor.Current.LogicBackgroundColor, BackgroundColor = ZigbeeColor.Current.LogicBackgroundColor, SubViewWidth = Application.GetRealWidth(184),//改变编辑控件宽度多少; Tag = i.ToString(), }; fLayout.AddChidren(logicRowlayout); //左滑菜单事件 logicRowlayout.OpenMenuAction += () => { if (selectedRow.Tag.ToString() != logicRowlayout.Tag.ToString()) { //保留左滑只有一个; selectedRow.HideMenu();// } selectedRow = logicRowlayout; }; if (i == 1) { //实现android显示逻辑列表的圆角; fLayout.SetCornerWithSameRadius(Application.GetRealHeight(58), HDLUtils.RectCornerTopLeft); logicRowlayout.SetCornerWithSameRadius(Application.GetRealHeight(58), HDLUtils.RectCornerTopLeft); i = 2; } i++; var logicnameBtn = new Button { Height = Application.GetRealHeight(58), @@ -750,77 +763,45 @@ } return false;//表示添加失败; } ///<summary> /// s-one门锁是否存在自动化的方法(true为存在) /// </summary> public static async System.Threading.Tasks.Task<bool> Exist(int valueInt = 2) { bool exist = false; var Idlist = await Send.GetLogicId(valueInt); if (Idlist.Count != 0) { } ///<summary> /// s-one门锁是否存在自动化的方法; /// 注意(参数2;3):valueInt=3是删除设置失效时间自动化;valueInt=2判断是否存在自动化; /// 返回值:0不存在;1存在;2删除成功;3删除失败; /// </summary> public static async System.Threading.Tasks.Task<int> Exist(int valueInt = 2) { int exist = 0; var Idlist = await Send.GetLogicId(valueInt); if (Idlist.Count != 0) { if (valueInt == 3) { for (int i = 0; i < Idlist.Count; i++) { //valueInt=3一条特殊的自动化(用来设置失效时间) Send.DelLogic(Idlist[i]); } } exist = true; { for (int i = 0; i < Idlist.Count; i++) { //valueInt=3一条特殊的自动化(用来设置失效时间) var d=await Send.DelLogic(Idlist[i]); if (d != 0) { //删除成功 exist = 2; } else { //删除失败 exist = 3; } return exist; } } exist = 1; } return exist; } ///<summary> /// s-one门锁确认取消(使满足条件所有逻辑失能一次)发送的方法 /// </summary> public static async void LockCloseLogic(CommonDevice common) { //读取系统当前时间:时-分 int h = int.Parse(DateTime.Now.ToString("HH")); int m = int.Parse(DateTime.Now.ToString("mm")); //转化为多少分钟; int s = h * 60 + m; var logicList = new List<Common.Logic>(); logicList.Clear(); var Idlist = await Send.GetLogicId(2); if (Idlist.Count != 0) { //先去读取网关看是否存在数据; var list = await Send.ReadList(Idlist.Count, 2); for (int j = 0; j < list.Count; j++) { var logic = list[j]; foreach (var conditions in logic.Conditions) { var linkType = conditions["Type"]; if (linkType == "5") { int startMin = int.Parse(conditions["StartMin"]); int startHour = int.Parse(conditions["StartHour"]); int stopMin = int.Parse(conditions["StopMin"]); int stopHour = int.Parse(conditions["StopHour"]); int s1 = startMin + startHour * 60;//开始时间值 int s2 = stopMin + stopHour * 60;//结束时间值 if (s >= s1 && s <= s2) { //查找系统时间值是否属于这个范围; logicList.Add(logic); } } } } } foreach (var logic in logicList) { logic.IsEnable = 3;//改变逻辑使能状态; //用foreach发送命令; Send.AddModifyLogic(logic); } } } } ZigbeeApp/Shared/Phone/Device/Logic/TemplatePage.cs
@@ -47,7 +47,7 @@ var middle = new VerticalScrolViewLayout { Y = view.topRowLayout.Bottom, Height = Application.GetRealHeight(1920 - 184 - 180), Height = Application.GetRealHeight(Method.H - 184 - 180), BackgroundColor = ZigbeeColor.Current.LogicMiddleBackgroundColor, }; this.AddChidren(middle); ZigbeeApp/Shared/Phone/Device/Logic/TimePage.cs
@@ -33,11 +33,10 @@ var middle = new FrameLayout { Y = view.topRowLayout.Bottom, Height = Application.GetRealHeight(1920 - 184 - 260), Height = Application.GetRealHeight(Method.H - 184 - 260), BackgroundColor = ZigbeeColor.Current.LogicMiddleBackgroundColor, }; this.AddChidren(middle); //保存 SaveView saveView = new SaveView(); saveView.frameLayout.Y = middle.Bottom; ZigbeeApp/Shared/Phone/Device/Logic/TimePoint.cs
@@ -80,7 +80,7 @@ var middle = new FrameLayout { Y = view.topRowLayout.Bottom, Height = Application.GetRealHeight(1920 - 184 - 260), Height = Application.GetRealHeight(Method.H - 184 - 260), BackgroundColor = ZigbeeColor.Current.LogicMiddleBackgroundColor, }; this.AddChidren(middle); ZigbeeApp/Shared/Phone/Device/Logic/WeekPage.cs
@@ -24,7 +24,7 @@ var middle = new VerticalScrolViewLayout { Y = view.topRowLayout.Bottom, Height = Application.GetRealHeight(1920 - 184-260), Height = Application.GetRealHeight(Method.H - 184-260), BackgroundColor = ZigbeeColor.Current.LogicMiddleBackgroundColor, }; this.AddChidren(middle); ZigbeeApp/Shared/Phone/Login/AccountLogin.cs
@@ -133,7 +133,7 @@ { Width = LayoutParams.MatchParent, Height = Application.GetRealHeight(CommonPage.AppRealHeight), BackgroundColor =ZigbeeColor.Current.GXCBackgroundColor BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor }; AddChidren(midFrameLayout); #endregion @@ -173,774 +173,9 @@ Gravity = Gravity.CenterHorizontal, TextID = R.MyInternationalizationString.AppName, TextColor = ZigbeeColor.Current.GXCTextWhiteColor, TextSize=16 TextSize = 16 }; midFrameLayout.AddChidren(logoName); phoneEmailForm = new PhoneEmailForm(); phoneEmailForm.Init(midFrameLayout); //错误提示Btn loginErrorBtn = new Button() { X = Application.GetRealWidth(242), Y = Application.GetRealHeight(740), Width = Application.GetRealWidth(700), Height = Application.GetRealHeight(58), TextColor = ZigbeeColor.Current.GXCTextRed, TextAlignment = TextAlignment.CenterLeft, TextSize=CommonFormResouce.TextSize, IsBold=true }; midFrameLayout.AddChidren(loginErrorBtn); accountPwdFL = new FrameLayout() { Y = Application.GetRealHeight(801), Height = Application.GetRealHeight(553), Width = Application.GetRealWidth(942), Gravity = Gravity.CenterHorizontal, BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor, Radius = (uint)Application.GetRealHeight(17) }; midFrameLayout.AddChidren(accountPwdFL); AddPhoneOrEmailFL(accountPwdFL, "Phone"); forgotPasswordBtn = new Button() { X = Application.GetRealWidth(CommonPage.AppRealWidth - 115 - 250), Y = Application.GetRealHeight(1198), Width = Application.GetRealWidth(250), Height = Application.GetRealHeight(58), TextID = R.MyInternationalizationString.ForgotPWD_1, TextSize = CommonFormResouce.loginTextSize, TextColor = Shared.Common.ZigbeeColor.Current.GXCTextGrayColor, TextAlignment = TextAlignment.CenterRight }; midFrameLayout.AddChidren(forgotPasswordBtn); loginBtn = new Button() { Y = Application.GetRealHeight(1293), Width = Application.GetRealWidth(688), Height = Application.GetRealHeight(127), Gravity = Gravity.CenterHorizontal, TextID = R.MyInternationalizationString.Login, TextSize = 16, TextColor = ZigbeeColor.Current.GXCTextGrayColor, SelectedTextColor = ZigbeeColor.Current.GXCTextWhiteColor, SelectedBackgroundColor = ZigbeeColor.Current.GXCButtonBlackSelectedColor, BackgroundColor = ZigbeeColor.Current.GXCButtonUnSelectedColor, Radius = (uint)Application.GetRealHeight(127 / 2), Enable = false, IsBold=true }; midFrameLayout.AddChidren(loginBtn); loginByCodeBtn = new Button() { X=Application.GetRealWidth(98), Y = Application.GetRealHeight(1466), Width = Application.GetRealWidth(300), Height = Application.GetRealHeight(49), TextID = R.MyInternationalizationString.LoginByCode, TextColor = ZigbeeColor.Current.GXCTextGrayColor, TextAlignment = TextAlignment.CenterLeft, TextSize = CommonFormResouce.loginTextSize }; midFrameLayout.AddChidren(loginByCodeBtn); registerBtn = new Button() { X = Application.GetRealWidth(738), Y = Application.GetRealHeight(1466), Width = Application.GetRealWidth(244), Height = Application.GetRealHeight(49), TextID = R.MyInternationalizationString.Register, TextColor = ZigbeeColor.Current.GXCTextGrayColor, TextAlignment = TextAlignment.CenterRight, TextSize = CommonFormResouce.loginTextSize }; midFrameLayout.AddChidren(registerBtn); wechatBtn = new Button { X = Application.GetRealWidth(395), Y = Application.GetRealHeight(1737), Width = Application.GetMinRealAverage(115), Height = Application.GetMinRealAverage(115), UnSelectedImagePath = "Account/Wechat.png", Gravity=Gravity.CenterHorizontal }; midFrameLayout.AddChidren(wechatBtn); qqBtn = new Button { X = Application.GetRealWidth(567), Y = Application.GetRealHeight(1737), Width = Application.GetMinRealAverage(115), Height = Application.GetMinRealAverage(115), UnSelectedImagePath = "Account/QQ.png" }; //midFrameLayout.AddChidren(qqBtn); #endregion BindEvent(); if (account.Contains("@") == true) { SelectPhoneOrEmail_MouseUpEvent(phoneEmailForm.SelectedEmail, null); } } #endregion #region ◆ 绑定事件_________________________ /// <summary> /// 绑定按钮事件 /// </summary> private void BindEvent() { //选择手机邮箱 phoneEmailForm.SelectedPhone.MouseUpEventHandler += SelectPhoneOrEmail_MouseUpEvent; phoneEmailForm.SelectedEmail.MouseUpEventHandler += SelectPhoneOrEmail_MouseUpEvent; //登录事件 loginBtn.MouseUpEventHandler += LoginBtnEvent; //短信登录 loginByCodeBtn.MouseUpEventHandler += LoginByCode; //注册事件 registerBtn.MouseUpEventHandler += Register; //忘记密码 forgotPasswordBtn.MouseUpEventHandler += ForgetPWD_MouseUpEvent; wechatBtn.MouseUpEventHandler += LoginByWechat; qqBtn.MouseUpEventHandler += LoginByQQ; } #endregion #region ◆ 登录____________________________ /// <summary> /// 登录事件 /// </summary> /// <param name="sender">Sender.</param> /// <param name="mouseEventArgs">The ${ParameterType} instance containing the event data.</param> private void LoginBtnEvent(object sender,MouseEventArgs mouseEventArgs) { if (phoneEmailForm.SelectedPhone.IsSelected) { Login(phoneRow.AccountET.Text.Trim(), phonePwdRow.PasswrodET.Text.Trim()); } else { Login(emailRow.AccountET.Text.Trim(), emailPwdRow.PasswrodET.Text.Trim()); } } /// <summary> /// 登录 /// </summary> /// <param name="accountStr">Account.</param> /// <param name="passwordStr">Password.</param> private void Login(string accountStr, string passwordStr) { //Application.RunOnMainThread( () => //{ Action action = async () => { try { if(CheckAccount(accountStr)==false) { return; } CommonPage.Loading.Start(Language.StringByID(R.MyInternationalizationString.Logining)); var requestObj = new SendDataToServer.LoginObj { Account = accountStr, Password = passwordStr, Source = CommonPage.Source, Company = CommonPage.Company }; var requestJson = Newtonsoft.Json.JsonConvert.SerializeObject(requestObj); var revertObj = await CommonPage.Instance.RequestHttpsZigbeeAsync("ZigbeeUsers/Login", System.Text.Encoding.UTF8.GetBytes(requestJson)); if (revertObj == null) { CommonPage.Instance.FailureToServer(); CommonPage.Loading.Hide(); return; } var stateCodeStr = revertObj.StateCode.ToUpper(); //Error 不能直接从服务器取,只能根据状态码逐一判断 if (stateCodeStr == "SUCCESS") { if (revertObj.ResponseData == null) { return; } HomePage.Instance.ShowLoginLoadView(); new System.Threading.Thread(async () => { //存储数据 var responseDataObj = Newtonsoft.Json.JsonConvert.DeserializeObject<Shared.Common.ResponseEntity.UserLoginRes>(revertObj.ResponseData.ToString()); var revertData = responseDataObj; Config.ReFresh(); //标记上一次是不是同一个账号登陆 UserCenter.UserCenterResourse.ResidenceOption.TheSameLoginAccount = Config.Instance.Guid == revertData.Guid; Config.Instance.Account = revertData.Account; Config.Instance.Password = passwordStr; Config.Instance.MD5PWD = revertData.MD5PWD; Config.Instance.Guid = revertData.Guid; Config.Instance.LoginDateTime = DateTime.Now; Config.Instance.LoginToken = revertData.Token; if (Config.Instance.AccountList.Find((obj) => obj == revertData.Account) == null) { Config.Instance.AccountList.Add(revertData.Account); } Config.Instance.Save(); var resultRegID = await Shared.Common.CommonPage.Instance.PushRegID(); var homes = await House.GetHomeLists(); //刷新个人中心的内存及线程 await UserCenter.UserCenterLogic.InitUserCenterMenmoryAndThread(); //启动ZigBee ZigBee.Common.Application.Init(); UserCenter.HdlRoomLogic.Current.InitAllRoom(); Application.RunOnMainThread(() => { CommonPage.Loading.Hide(); this.RemoveFromParent(); CommonPage.Instance.RemoveViewByTag("Login"); UserPage.Instance.Fresh(); }); }) { IsBackground = true }.Start(); } else if (stateCodeStr == "NOTVERIFY") { CommonPage.Loading.Hide(); //未激活 loginErrorBtn.TextID = R.MyInternationalizationString.NOTVERIFY; } else if (stateCodeStr == "NOTENABLE") { CommonPage.Loading.Hide(); //该用户属于调试账号,并未启用 loginErrorBtn.TextID = R.MyInternationalizationString.NOTENABLE; } else if (stateCodeStr == "USERNAMEORPWDERROR") { CommonPage.Loading.Hide(); //账号或密码错误 loginErrorBtn.TextID = R.MyInternationalizationString.USERNAMEORPWDERROR; } else if (stateCodeStr == "ACCOUNTNOEXISTS") { CommonPage.Loading.Hide(); //账号不存在 loginErrorBtn.TextID = R.MyInternationalizationString.ACCOUNTNOEXISTS; } else if (stateCodeStr == "YOUDATANOISLOCALREGION") { CommonPage.Loading.Hide(); //不在本区域,需要重定向区域后再次请求登录 if (revertObj.ResponseData == null) { return; } var responseDataObj = Newtonsoft.Json.JsonConvert.DeserializeObject<Shared.Common.ResponseEntity.UserLoginLocalRegionRes>(revertObj.ResponseData.ToString()); CommonPage.RequestHttpsHost = responseDataObj.RegionServer; //再次登录 Login(accountStr, passwordStr); } else { loginErrorBtn.TextID = R.MyInternationalizationString.RequestServerFailed; } } catch (Exception ex) { System.Console.WriteLine($"登录失败--{ex.Message}"); CommonPage.Loading.Hide(); CommonPage.Instance.FailureToServer(); } finally { //CommonPage.Loading.Hide(); } //}); }; action(); } /// <summary> /// CheckAccount /// </summary> /// <param name="accountStr"></param> /// <returns></returns> private bool CheckAccount(string accountStr) { if (phoneEmailForm.SelectedEmail.IsSelected) { if (AccountLogic.Instance.CheckEmail(accountStr) == false) { loginErrorBtn.TextID = R.MyInternationalizationString.TheEmailError; return false; } } else { if (AccountLogic.Instance.CheckPhone(accountStr) == false) { loginErrorBtn.TextID = R.MyInternationalizationString.ThePhoneError; return false; } } return true; } /// <summary> /// 通过验证码登录 /// </summary> /// <param name="sender">Sender.</param> /// <param name="mouseEventArgs">The ${ParameterType} instance containing the event data.</param> private void LoginByCode(object sender,MouseEventArgs mouseEventArgs) { //this.RemoveFromParent(); var loginByCodePage = new AccountLoginByCode(); CommonPage.Instance.AddChidren(loginByCodePage); loginByCodePage.Show(); } /// <summary> /// wechat登录 /// </summary> /// <param name="sender"></param> /// <param name="mouseEventArgs"></param> private void LoginByWechat(object sender, MouseEventArgs mouseEventArgs) { #if Android //var alert = new Alert(Language.StringByID(R.MyInternationalizationString.TIP), // Language.StringByID(R.MyInternationalizationString.LoginByWechat), // Language.StringByID(R.MyInternationalizationString.Cancel), // Language.StringByID(R.MyInternationalizationString.Confrim)); //alert.Show(); //alert.ResultEventHandler += (send, e) => //{ //if (e) //{ com.hdl.home.Application.WXLogin(); com.hdl.home.WXEntryActivity.RespAction = (authStr) => { if (authStr == null) { } else { new System.Threading.Thread(async () => { var re = await isBindAuthAsync(authStr); if (re) { Application.RunOnMainThread(() => { //直接登录 HomePage.Instance.ShowLoginLoadView(); }); var resultRegID = await Shared.Common.CommonPage.Instance.PushRegID(); var homes = await House.GetHomeLists(); //刷新个人中心的内存及线程 await UserCenter.UserCenterLogic.InitUserCenterMenmoryAndThread(); //启动ZigBee ZigBee.Common.Application.Init(); UserCenter.HdlRoomLogic.Current.InitAllRoom(); Application.RunOnMainThread(() => { this.RemoveFromParent(); CommonPage.Instance.RemoveViewByTag("Login"); UserPage.Instance.Fresh(); }); } else { var authRes = Newtonsoft.Json.JsonConvert.DeserializeObject<Common.ResponseEntity.AuthUserRes>(authStr); Application.RunOnMainThread(() => { var registerPage = new AccountRegister(); Shared.Common.CommonPage.Instance.AddChidren(registerPage); registerPage.OpenID = authRes.openid; registerPage.Show(); }); } }) { IsBackground = true }.Start(); } }; //} //}; #endif #if iOS Home.IOS.AppDelegate.WXLogin(); Home.IOS.AppDelegate.RespAction = (authStr) => { if (authStr == null) { } else { new System.Threading.Thread(async () => { var re = await isBindAuthAsync(authStr); if (re) { //直接登录 //this.RemoveFromParent(); //UserPage.Instance.Fresh(); var resultRegID = await Shared.Common.CommonPage.Instance.PushRegID(); var homes = await House.GetHomeLists(); //启动ZigBee ZigBee.Common.Application.Init(); //刷新个人中心的内存及线程 await UserCenter.UserCenterLogic.InitUserCenterMenmoryAndThread(); UserCenter.HdlRoomLogic.Current.InitAllRoom(); Application.RunOnMainThread(() => { this.RemoveFromParent(); UserPage.Instance.Fresh(); }); } else { var authRes = Newtonsoft.Json.JsonConvert.DeserializeObject<Common.ResponseEntity.AuthUserRes>(authStr); Application.RunOnMainThread(() => { var registerPage = new AccountRegister(); Shared.Common.CommonPage.Instance.AddChidren(registerPage); registerPage.OpenID = authRes.openid; registerPage.Show(); }); } }) { IsBackground = true }.Start(); } }; #endif } /// <summary> /// qq登录 /// </summary> /// <param name="sender"></param> /// <param name="mouseEventArgs"></param> private void LoginByQQ(object sender, MouseEventArgs mouseEventArgs) { } /// <summary> /// 是否已绑定 /// </summary> /// <param name="authStr"></param> /// <returns></returns> private async System.Threading.Tasks.Task<bool> isBindAuthAsync(string authStr) { var authRes = Newtonsoft.Json.JsonConvert.DeserializeObject<Common.ResponseEntity.AuthUserRes>(authStr); var auth = new SendDataToServer.AuthUser() { AccessToken = authRes.access_token, RefreshToken = authRes.refresh_token, OpenID = authRes.openid }; //获取微信昵称 var strUrl = "https://api.weixin.qq.com/sns/userinfo?access_token=" + authRes.access_token; strUrl += "&openid=" + authRes.openid; var byteData = await Common.CommonPage.Instance.DoRequestZigbeeHttpsInterface(strUrl, null, null, "GET"); if (byteData == null) { return false; } var receipData = System.Text.Encoding.UTF8.GetString(byteData); var nickData = Newtonsoft.Json.JsonConvert.DeserializeObject<UserCenter.NicknameInfo>(receipData); auth.UserName = nickData.nickname; var requestJson = Newtonsoft.Json.JsonConvert.SerializeObject(auth); var revertObj = await CommonPage.Instance.RequestHttpsZigbeeAsync("ZigbeeUsers/InsertOrUpdateAuthUser", System.Text.Encoding.UTF8.GetBytes(requestJson)); if (revertObj == null) { return false; } var stateCodeStr = revertObj.StateCode.ToUpper(); if (stateCodeStr == "SUCCESS") { var responseDataObj = Newtonsoft.Json.JsonConvert.DeserializeObject<Shared.Common.ResponseEntity.UserLoginRes>(revertObj.ResponseData.ToString()); var revertData = responseDataObj; //标记上一次是不是同一个账号登陆 UserCenter.UserCenterResourse.ResidenceOption.TheSameLoginAccount = Config.Instance.Guid == revertData.Guid; Config.Instance.Account = revertData.Account; Config.Instance.MD5PWD = revertData.MD5PWD; Config.Instance.Guid = revertData.Guid; Config.Instance.LoginDateTime = DateTime.Now; if (Config.Instance.AccountList.Find((obj) => obj == revertData.Account) == null) { Config.Instance.AccountList.Add(revertData.Account); } Config.Instance.Save(); return true; } else { return false; } } /// <summary> /// phone/email 选择 /// </summary> /// <param name="sender"></param> /// <param name="mouseEventArgs"></param> private void SelectPhoneOrEmail_MouseUpEvent(object sender, MouseEventArgs mouseEventArgs) { phoneEmailForm.SelectedPhone.IsSelected = phoneEmailForm.SelectedEmail.IsSelected = false; phoneEmailForm.SelectedPhone.IsBold = phoneEmailForm.SelectedEmail.IsBold = false; loginBtn.Enable = loginBtn.IsSelected = false; loginErrorBtn.Text = string.Empty; (sender as Button).IsSelected = (sender as Button).IsBold = true; if((sender as Button).Tag.ToString()=="Phone") { AddPhoneOrEmailFL(accountPwdFL, "Phone"); } else { AddPhoneOrEmailFL(accountPwdFL, "Email"); } } /// <summary> /// AddPhoneOrEmailFL /// </summary> /// <param name="accountPwdFrameLayout"></param> /// <param name="phoneOrEmail"></param> private void AddPhoneOrEmailFL(FrameLayout accountPwdFrameLayout,string phoneOrEmail) { if (phoneOrEmail == "Phone") { if (phoneRow != null) { phoneRow.Visible = true; phonePwdRow.Visible = true; if (emailRow != null) { emailRow.Visible = false; emailPwdRow.Visible = false; } this.Pwd_TextChange(phonePwdRow); return; } phoneRow = new PhoneLoginRowForm(); phoneRow.Init(accountPwdFrameLayout, this, this.oldInputPhone, 29, 29); phoneRow.AccountET.TextChangeEventHandler += Account_TextChange; phonePwdRow = new PwdLoginRowForm(); phonePwdRow.Init(accountPwdFrameLayout, 29, 225); phonePwdRow.PasswrodET.TextChangeEventHandler += (sender, e) => { this.Pwd_TextChange(phonePwdRow); }; } else { if (emailRow != null) { emailRow.Visible = true; emailPwdRow.Visible = true; if (phoneRow != null) { phoneRow.Visible = false; phonePwdRow.Visible = false; } this.Pwd_TextChange(emailPwdRow); return; } emailRow = new EmailLoginRowForm(); emailRow.Init(accountPwdFrameLayout, this.oldInputEmail, 29, 29); emailRow.AccountET.TextChangeEventHandler += Account_TextChange; emailPwdRow = new PwdLoginRowForm(); emailPwdRow.Init(accountPwdFrameLayout, 29, 225); emailPwdRow.PasswrodET.TextChangeEventHandler += (sender, e) => { this.Pwd_TextChange(emailPwdRow); }; } } #endregion #region ◆ 忘记密码________________________ /// <summary> /// 忘记密码 /// </summary> private void ForgetPWD_MouseUpEvent(object sender, MouseEventArgs mouseEventArgs) { var forgot = new AccountForgetPWD(); CommonPage.Instance.AddChidren(forgot); forgot.Show(); } #endregion #region ◆ 注册_____________________________ /// <summary> /// 注册 /// </summary> /// <param name="sender">Sender.</param> /// <param name="mouseEventArgs">The ${ParameterType} instance containing the event data.</param> private void Register(object sender,MouseEventArgs mouseEventArgs) { var registerPage = new AccountRegister(); CommonPage.Instance.AddChidren(registerPage); registerPage.Show(); } #endregion #region ◆ 账号密码监听______________________ /// <summary> /// 账号监听 /// </summary> /// <param name="sender">Sender.</param> /// <param name="mouseEventArgs">The ${ParameterType} instance containing the event data.</param> private void Account_TextChange(object sender,string mouseEventArgs) { loginErrorBtn.Text = string.Empty; } /// <summary> /// 密码监听事件 /// </summary> /// <param name="pwdRow">Sender.</param> private void Pwd_TextChange(PwdLoginRowForm pwdRow) { loginErrorBtn.Text = string.Empty; string pswText = pwdRow.PasswrodET.Text.Trim(); if (1 <= pswText.Length && pswText.Length <= 16 && (phoneRow.AccountET.Text.Trim().Length > 0 || emailRow?.AccountET.Text.Trim().Length>0)) { loginBtn.Enable = loginBtn.IsSelected = true; } else if (pswText.Length > 16) { pwdRow.PasswrodET.Text = pswText.Substring(0, 16); if (phoneRow.AccountET.Text.Trim().Length > 0 || emailRow?.AccountET.Text.Trim().Length > 0) { loginBtn.Enable = loginBtn.IsSelected = true; } } else { loginBtn.Enable = loginBtn.IsSelected = false; } } #endregion #region ■ 变量声明___________________________ /// <summary> /// 手机账号登陆的控件容器 /// </summary> private FrameLayout frameAccLoginPhoneback = null; /// <summary> /// 邮箱账号登陆的控件容器 /// </summary> private FrameLayout frameEmailLoginPhoneback = null; #endregion #region ■ 初始化_____________________________ /// <summary> /// 界面显示 /// </summary> /// <param name="account">登陆账号</param> public void ShowForm(string account = "") { if (Config.Instance.IsLogin == true) { return; } CommonPage.Instance.IsDrawerLockMode = true; this.Tag = "Login"; //界面上部的黑色图片 var btnTopBlackPic = new NormalViewControl(this.Width, Application.GetRealHeight(619), false); btnTopBlackPic.UnSelectedImagePath = "Account/Logo_loginBG.png"; this.AddChidren(btnTopBlackPic); //中间浅白色的背景 var frameMidBack = new FrameLayout(); frameMidBack.Y = btnTopBlackPic.Bottom; frameMidBack.Height = this.Height - btnTopBlackPic.Bottom; frameMidBack.BackgroundColor = ZigbeeColor.Current.GXCGrayBackgroundColor; this.AddChidren(frameMidBack); //HdlHome的图标 var btnLogoIcon = new PicViewControl(184, 184); btnLogoIcon.Y = Application.GetRealHeight(230); btnLogoIcon.UnSelectedImagePath = "Account/Logo_White.png"; btnLogoIcon.Gravity = Gravity.CenterHorizontal; this.AddChidren(btnLogoIcon); //Hdl Home var btnLogoName = new NormalViewControl(300, 69, true); btnLogoName.Y = btnLogoIcon.Bottom; btnLogoName.Gravity = Gravity.CenterHorizontal; btnLogoName.TextID = R.MyInternationalizationString.AppName; btnLogoName.TextColor = ZigbeeColor.Current.GXCTextWhiteColor; btnLogoName.TextSize = 16; this.AddChidren(btnLogoName); //手机号,邮箱的菜单控件 int defultIndex = account.Contains("@") == false ? 1 : 2; var sitchControl = new Controls.PhoneEmailSelectControl(); sitchControl.Y = Application.GetRealHeight(559); this.AddChidren(sitchControl); sitchControl.SelectMenuEvent += (selectIndex) => { //手机号 if (selectIndex == 1) { } //邮箱 else if (selectIndex == 2) { } }; //执行初始化 sitchControl.InitControl(ZigbeeColor.Current.GXCButtonSelectedColor, defultIndex); phoneEmailForm = new PhoneEmailForm(); phoneEmailForm.Init(midFrameLayout); @@ -1051,12 +286,728 @@ }; //midFrameLayout.AddChidren(qqBtn); //添加服务协议控件 //this.AddServiceAgreementControl(phoneEmailBGFL); #endregion BindEvent(); if (account.Contains("@") == true) { SelectPhoneOrEmail_MouseUpEvent(phoneEmailForm.SelectedEmail, null); } } #endregion #region ◆ 绑定事件_________________________ /// <summary> /// 绑定按钮事件 /// </summary> private void BindEvent() { //选择手机邮箱 phoneEmailForm.SelectedPhone.MouseUpEventHandler += SelectPhoneOrEmail_MouseUpEvent; phoneEmailForm.SelectedEmail.MouseUpEventHandler += SelectPhoneOrEmail_MouseUpEvent; //登录事件 loginBtn.MouseUpEventHandler += LoginBtnEvent; //短信登录 loginByCodeBtn.MouseUpEventHandler += LoginByCode; //注册事件 registerBtn.MouseUpEventHandler += Register; //忘记密码 forgotPasswordBtn.MouseUpEventHandler += ForgetPWD_MouseUpEvent; wechatBtn.MouseUpEventHandler += LoginByWechat; qqBtn.MouseUpEventHandler += LoginByQQ; } #endregion #region ◆ 登录____________________________ /// <summary> /// 登录事件 /// </summary> /// <param name="sender">Sender.</param> /// <param name="mouseEventArgs">The ${ParameterType} instance containing the event data.</param> private void LoginBtnEvent(object sender, MouseEventArgs mouseEventArgs) { //检测隐私协议 if (this.CheckPrivacyPolicy() == false) { return; } if (phoneEmailForm.SelectedPhone.IsSelected) { Login(phoneRow.AccountET.Text.Trim(), phonePwdRow.PasswrodET.Text.Trim()); } else { Login(emailRow.AccountET.Text.Trim(), emailPwdRow.PasswrodET.Text.Trim()); } } /// <summary> /// 登录 /// </summary> /// <param name="accountStr">Account.</param> /// <param name="passwordStr">Password.</param> private void Login(string accountStr, string passwordStr) { //Application.RunOnMainThread( () => //{ Action action = async () => { try { if (CheckAccount(accountStr) == false) { return; } CommonPage.Loading.Start(Language.StringByID(R.MyInternationalizationString.Logining)); var requestObj = new SendDataToServer.LoginObj { Account = accountStr, Password = passwordStr, Source = CommonPage.Source, Company = CommonPage.Company }; var requestJson = Newtonsoft.Json.JsonConvert.SerializeObject(requestObj); var revertObj = await CommonPage.Instance.RequestHttpsZigbeeAsync("ZigbeeUsers/Login", System.Text.Encoding.UTF8.GetBytes(requestJson)); if (revertObj == null) { CommonPage.Instance.FailureToServer(); CommonPage.Loading.Hide(); return; } var stateCodeStr = revertObj.StateCode.ToUpper(); //Error 不能直接从服务器取,只能根据状态码逐一判断 if (stateCodeStr == "SUCCESS") { if (revertObj.ResponseData == null) { return; } HomePage.Instance.ShowLoginLoadView(); new System.Threading.Thread(async () => { //存储数据 var responseDataObj = Newtonsoft.Json.JsonConvert.DeserializeObject<Shared.Common.ResponseEntity.UserLoginRes>(revertObj.ResponseData.ToString()); var revertData = responseDataObj; Config.ReFresh(); //标记上一次是不是同一个账号登陆 UserCenter.UserCenterResourse.ResidenceOption.TheSameLoginAccount = Config.Instance.Guid == revertData.Guid; Config.Instance.Account = revertData.Account; Config.Instance.Password = passwordStr; Config.Instance.MD5PWD = revertData.MD5PWD; Config.Instance.Guid = revertData.Guid; Config.Instance.LoginDateTime = DateTime.Now; Config.Instance.LoginToken = revertData.Token; Config.Instance.Save(); var resultRegID = await Shared.Common.CommonPage.Instance.PushRegID(); var homes = await House.GetHomeLists(); //刷新个人中心的内存及线程 await UserCenter.UserCenterLogic.InitUserCenterMenmoryAndThread(); //启动ZigBee ZigBee.Common.Application.Init(); UserCenter.HdlRoomLogic.Current.InitAllRoom(); Application.RunOnMainThread(() => { CommonPage.Loading.Hide(); this.RemoveFromParent(); CommonPage.Instance.RemoveViewByTag("Login"); UserPage.Instance.Fresh(); }); }) { IsBackground = true }.Start(); } else if (stateCodeStr == "NOTVERIFY") { CommonPage.Loading.Hide(); //未激活 loginErrorBtn.TextID = R.MyInternationalizationString.NOTVERIFY; } else if (stateCodeStr == "NOTENABLE") { CommonPage.Loading.Hide(); //该用户属于调试账号,并未启用 loginErrorBtn.TextID = R.MyInternationalizationString.NOTENABLE; } else if (stateCodeStr == "USERNAMEORPWDERROR") { CommonPage.Loading.Hide(); //账号或密码错误 loginErrorBtn.TextID = R.MyInternationalizationString.USERNAMEORPWDERROR; } else if (stateCodeStr == "ACCOUNTNOEXISTS") { CommonPage.Loading.Hide(); //账号不存在 loginErrorBtn.TextID = R.MyInternationalizationString.ACCOUNTNOEXISTS; } else if (stateCodeStr == "YOUDATANOISLOCALREGION") { CommonPage.Loading.Hide(); //不在本区域,需要重定向区域后再次请求登录 if (revertObj.ResponseData == null) { return; } var responseDataObj = Newtonsoft.Json.JsonConvert.DeserializeObject<Shared.Common.ResponseEntity.UserLoginLocalRegionRes>(revertObj.ResponseData.ToString()); CommonPage.RequestHttpsHost = responseDataObj.RegionServer; //再次登录 Login(accountStr, passwordStr); } else { loginErrorBtn.TextID = R.MyInternationalizationString.RequestServerFailed; } } catch (Exception ex) { System.Console.WriteLine($"登录失败--{ex.Message}"); CommonPage.Loading.Hide(); CommonPage.Instance.FailureToServer(); } finally { //CommonPage.Loading.Hide(); } //}); }; action(); } /// <summary> /// CheckAccount /// </summary> /// <param name="accountStr"></param> /// <returns></returns> private bool CheckAccount(string accountStr) { if (phoneEmailForm.SelectedEmail.IsSelected) { if (AccountLogic.Instance.CheckEmail(accountStr) == false) { loginErrorBtn.TextID = R.MyInternationalizationString.TheEmailError; return false; } } else { if (AccountLogic.Instance.CheckPhone(accountStr) == false) { loginErrorBtn.TextID = R.MyInternationalizationString.ThePhoneError; return false; } } return true; } /// <summary> /// 通过验证码登录 /// </summary> /// <param name="sender">Sender.</param> /// <param name="mouseEventArgs">The ${ParameterType} instance containing the event data.</param> private void LoginByCode(object sender, MouseEventArgs mouseEventArgs) { //检测隐私协议 if (this.CheckPrivacyPolicy() == false) { return; } //this.RemoveFromParent(); var loginByCodePage = new AccountLoginByCode(); CommonPage.Instance.AddChidren(loginByCodePage); loginByCodePage.Show(); } /// <summary> /// wechat登录 /// </summary> /// <param name="sender"></param> /// <param name="mouseEventArgs"></param> private void LoginByWechat(object sender, MouseEventArgs mouseEventArgs) { //检测隐私协议 if (this.CheckPrivacyPolicy() == false) { return; } #if Android //var alert = new Alert(Language.StringByID(R.MyInternationalizationString.TIP), // Language.StringByID(R.MyInternationalizationString.LoginByWechat), // Language.StringByID(R.MyInternationalizationString.Cancel), // Language.StringByID(R.MyInternationalizationString.Confrim)); //alert.Show(); //alert.ResultEventHandler += (send, e) => //{ //if (e) //{ com.hdl.home.Application.WXLogin(); com.hdl.home.WXEntryActivity.RespAction = (authStr) => { if (authStr == null) { } else { new System.Threading.Thread(async () => { var re = await isBindAuthAsync(authStr); if (re) { Application.RunOnMainThread(() => { //直接登录 HomePage.Instance.ShowLoginLoadView(); }); var resultRegID = await Shared.Common.CommonPage.Instance.PushRegID(); var homes = await House.GetHomeLists(); //刷新个人中心的内存及线程 await UserCenter.UserCenterLogic.InitUserCenterMenmoryAndThread(); //启动ZigBee ZigBee.Common.Application.Init(); UserCenter.HdlRoomLogic.Current.InitAllRoom(); Application.RunOnMainThread(() => { this.RemoveFromParent(); CommonPage.Instance.RemoveViewByTag("Login"); UserPage.Instance.Fresh(); }); } else { var authRes = Newtonsoft.Json.JsonConvert.DeserializeObject<Common.ResponseEntity.AuthUserRes>(authStr); Application.RunOnMainThread(() => { var registerPage = new AccountRegister(); Shared.Common.CommonPage.Instance.AddChidren(registerPage); registerPage.OpenID = authRes.openid; registerPage.Show(); }); } }) { IsBackground = true }.Start(); } }; //} //}; #endif #if iOS Home.IOS.AppDelegate.WXLogin(); Home.IOS.AppDelegate.RespAction = (authStr) => { if (authStr == null) { } else { new System.Threading.Thread(async () => { var re = await isBindAuthAsync(authStr); if (re) { //直接登录 //this.RemoveFromParent(); //UserPage.Instance.Fresh(); var resultRegID = await Shared.Common.CommonPage.Instance.PushRegID(); var homes = await House.GetHomeLists(); //启动ZigBee ZigBee.Common.Application.Init(); //刷新个人中心的内存及线程 await UserCenter.UserCenterLogic.InitUserCenterMenmoryAndThread(); UserCenter.HdlRoomLogic.Current.InitAllRoom(); Application.RunOnMainThread(() => { this.RemoveFromParent(); UserPage.Instance.Fresh(); }); } else { var authRes = Newtonsoft.Json.JsonConvert.DeserializeObject<Common.ResponseEntity.AuthUserRes>(authStr); Application.RunOnMainThread(() => { var registerPage = new AccountRegister(); Shared.Common.CommonPage.Instance.AddChidren(registerPage); registerPage.OpenID = authRes.openid; registerPage.Show(); }); } }) { IsBackground = true }.Start(); } }; #endif } /// <summary> /// qq登录 /// </summary> /// <param name="sender"></param> /// <param name="mouseEventArgs"></param> private void LoginByQQ(object sender, MouseEventArgs mouseEventArgs) { } /// <summary> /// phone/email 选择 /// </summary> /// <param name="sender"></param> /// <param name="mouseEventArgs"></param> private void SelectPhoneOrEmail_MouseUpEvent(object sender, MouseEventArgs mouseEventArgs) { phoneEmailForm.SelectedPhone.IsSelected = phoneEmailForm.SelectedEmail.IsSelected = false; phoneEmailForm.SelectedPhone.IsBold = phoneEmailForm.SelectedEmail.IsBold = false; loginBtn.Enable = loginBtn.IsSelected = false; loginErrorBtn.Text = string.Empty; (sender as Button).IsSelected = (sender as Button).IsBold = true; if ((sender as Button).Tag.ToString() == "Phone") { AddPhoneOrEmailFL(accountPwdFL, "Phone"); } else { AddPhoneOrEmailFL(accountPwdFL, "Email"); } } /// <summary> /// AddPhoneOrEmailFL /// </summary> /// <param name="accountPwdFrameLayout"></param> /// <param name="phoneOrEmail"></param> private void AddPhoneOrEmailFL(FrameLayout accountPwdFrameLayout, string phoneOrEmail) { if (phoneOrEmail == "Phone") { if (phoneRow != null) { phoneRow.Visible = true; phonePwdRow.Visible = true; if (emailRow != null) { emailRow.Visible = false; emailPwdRow.Visible = false; } this.Pwd_TextChange(phonePwdRow); return; } phoneRow = new PhoneLoginRowForm(); phoneRow.Init(accountPwdFrameLayout, this, this.oldInputPhone, 29, 29); phoneRow.AccountET.TextChangeEventHandler += Account_TextChange; phonePwdRow = new PwdLoginRowForm(); phonePwdRow.Init(accountPwdFrameLayout, 29, 225); phonePwdRow.PasswrodET.TextChangeEventHandler += (sender, e) => { this.Pwd_TextChange(phonePwdRow); }; } else { if (emailRow != null) { emailRow.Visible = true; emailPwdRow.Visible = true; if (phoneRow != null) { phoneRow.Visible = false; phonePwdRow.Visible = false; } this.Pwd_TextChange(emailPwdRow); return; } emailRow = new EmailLoginRowForm(); emailRow.Init(accountPwdFrameLayout, this.oldInputEmail, 29, 29); emailRow.AccountET.TextChangeEventHandler += Account_TextChange; emailPwdRow = new PwdLoginRowForm(); emailPwdRow.Init(accountPwdFrameLayout, 29, 225); emailPwdRow.PasswrodET.TextChangeEventHandler += (sender, e) => { this.Pwd_TextChange(emailPwdRow); }; } } #endregion #region ◆ 忘记密码________________________ /// <summary> /// 忘记密码 /// </summary> private void ForgetPWD_MouseUpEvent(object sender, MouseEventArgs mouseEventArgs) { //检测隐私协议 if (this.CheckPrivacyPolicy() == false) { return; } var forgot = new AccountForgetPWD(); CommonPage.Instance.AddChidren(forgot); forgot.Show(); } #endregion #region ◆ 注册_____________________________ /// <summary> /// 注册 /// </summary> /// <param name="sender">Sender.</param> /// <param name="mouseEventArgs">The ${ParameterType} instance containing the event data.</param> private void Register(object sender, MouseEventArgs mouseEventArgs) { //检测隐私协议 if (this.CheckPrivacyPolicy() == false) { return; } var registerPage = new AccountRegister(); CommonPage.Instance.AddChidren(registerPage); registerPage.Show(); } #endregion #region ◆ 账号密码监听______________________ /// <summary> /// 账号监听 /// </summary> /// <param name="sender">Sender.</param> /// <param name="mouseEventArgs">The ${ParameterType} instance containing the event data.</param> private void Account_TextChange(object sender, string mouseEventArgs) { loginErrorBtn.Text = string.Empty; } /// <summary> /// 密码监听事件 /// </summary> /// <param name="pwdRow">Sender.</param> private void Pwd_TextChange(PwdLoginRowForm pwdRow) { loginErrorBtn.Text = string.Empty; string pswText = pwdRow.PasswrodET.Text.Trim(); if (1 <= pswText.Length && pswText.Length <= 16 && (phoneRow.AccountET.Text.Trim().Length > 0 || emailRow?.AccountET.Text.Trim().Length > 0)) { loginBtn.Enable = loginBtn.IsSelected = true; } else if (pswText.Length > 16) { pwdRow.PasswrodET.Text = pswText.Substring(0, 16); if (phoneRow.AccountET.Text.Trim().Length > 0 || emailRow?.AccountET.Text.Trim().Length > 0) { loginBtn.Enable = loginBtn.IsSelected = true; } } else { loginBtn.Enable = loginBtn.IsSelected = false; } } #endregion #region ■ 变量声明___________________________ /// <summary> /// 错误提示控件 /// </summary> private NormalViewControl btnErrorMsg = null; /// <summary> /// 是否同意隐私协议 /// </summary> private bool isAgreePrivacyPolicy = true; #endregion #region ■ 初始化_____________________________ /// <summary> /// 界面显示 /// </summary> /// <param name="account">登陆账号</param> public void ShowForm(string account = "") { if (Config.Instance.IsLogin == true) { return; } CommonPage.Instance.IsDrawerLockMode = true; this.Tag = "Login"; //界面上部的黑色图片 var btnTopBlackPic = new NormalViewControl(this.Width, Application.GetRealHeight(619), false); btnTopBlackPic.UnSelectedImagePath = "Account/Logo_loginBG.png"; this.AddChidren(btnTopBlackPic); //中间浅白色的背景 var frameMidBack = new FrameLayout(); frameMidBack.Y = btnTopBlackPic.Bottom; frameMidBack.Height = this.Height - btnTopBlackPic.Bottom; frameMidBack.BackgroundColor = ZigbeeColor.Current.GXCGrayBackgroundColor; this.AddChidren(frameMidBack); //HdlHome的图标 var btnLogoIcon = new PicViewControl(184, 184); btnLogoIcon.Y = Application.GetRealHeight(230); btnLogoIcon.UnSelectedImagePath = "Account/Logo_White.png"; btnLogoIcon.Gravity = Gravity.CenterHorizontal; this.AddChidren(btnLogoIcon); //Hdl Home var btnLogoName = new NormalViewControl(300, 69, true); btnLogoName.Y = btnLogoIcon.Bottom; btnLogoName.Gravity = Gravity.CenterHorizontal; btnLogoName.TextID = R.MyInternationalizationString.AppName; btnLogoName.TextColor = ZigbeeColor.Current.GXCTextWhiteColor; btnLogoName.TextAlignment = TextAlignment.Center; btnLogoName.TextSize = 16; this.AddChidren(btnLogoName); //1:手机号 2:邮箱 int selectIndex = account.Contains("@") == false ? 1 : 2; //初始化 手机账号登陆窗口 var frameAccLoginPhoneback = this.InitAccoutLoginWindow(frameMidBack, selectIndex == 1 ? account : string.Empty, 1); //初始化 邮箱账号登陆窗口 var frameEmailLoginPhoneback = this.InitAccoutLoginWindow(frameMidBack, selectIndex == 1 ? string.Empty : account, 2); //初始化 手机账号验证码登陆窗口 var frameAccCodeLoginPhoneback = this.InitCodeLoginWindow(frameMidBack, selectIndex == 1 ? account : string.Empty, 1); //初始化 邮箱账号验证码登陆窗口 var frameEmailCodeLoginPhoneback = this.InitCodeLoginWindow(frameMidBack, selectIndex == 1 ? string.Empty : account, 2); //定义这两个东西,是为了减少判断的代码 var framePhone = frameAccLoginPhoneback; var frameEmail = frameEmailLoginPhoneback; //邮箱,手机号的切换控件 var sitchControl = new Controls.PhoneEmailSelectControl(); sitchControl.Y = Application.GetRealHeight(559); this.AddChidren(sitchControl); sitchControl.SelectMenuEvent += (selectMenu) => { selectIndex = selectMenu; //手机号 if (selectIndex == 1) { framePhone.Visible = true; frameEmail.Visible = false; } //邮箱 else if (selectIndex == 2) { framePhone.Visible = false; frameEmail.Visible = true; } }; //执行初始化 sitchControl.InitControl(ZigbeeColor.Current.GXCButtonSelectedColor, selectIndex); //错误提示控件 this.btnErrorMsg = new NormalViewControl(700, 60, true); btnErrorMsg.Y = frameAccLoginPhoneback.Y - Application.GetRealHeight(60 + 3); btnErrorMsg.X = Application.GetRealWidth(288); btnErrorMsg.TextColor = ZigbeeColor.Current.GXCTextRed; btnErrorMsg.IsBold = true; frameMidBack.AddChidren(btnErrorMsg); //验证码登陆 //1:账号登陆 2:验证码登陆 int codeDiv = 1; var btnLoginByCode = new NormalViewControl(300, 100, true); btnLoginByCode.X = Application.GetRealWidth(98); btnLoginByCode.Y = frameAccLoginPhoneback.Bottom + Application.GetRealHeight(21); btnLoginByCode.TextID = R.MyInternationalizationString.LoginByCode; btnLoginByCode.TextColor = UserCenterColor.Current.TextGrayColor3; btnLoginByCode.TextSize = 12; frameMidBack.AddChidren(btnLoginByCode); btnLoginByCode.ButtonClickEvent += (sender, e) => { if (codeDiv == 1) { //验证码登陆 codeDiv = 2; btnLoginByCode.TextID = R.MyInternationalizationString.LoginByAccountPWD; //账号登陆 //账号登陆的两个东西隐藏 frameAccLoginPhoneback.Visible = false; frameEmailLoginPhoneback.Visible = false; //替换这两个东西 framePhone = frameAccCodeLoginPhoneback; frameEmail = frameEmailCodeLoginPhoneback; } else { //账号登陆 codeDiv = 1; btnLoginByCode.TextID = R.MyInternationalizationString.LoginByCode;//验证码登陆 //验证码登陆的两个东西隐藏 frameAccCodeLoginPhoneback.Visible = false; frameEmailCodeLoginPhoneback.Visible = false; //替换这两个东西 framePhone = frameAccLoginPhoneback; frameEmail = frameEmailLoginPhoneback; } //刷新菜单 sitchControl.SetSelectIndex(1); }; //注册用户 var btnRegister = new NormalViewControl(244, 100, true); btnRegister.Y = btnLoginByCode.Y; btnRegister.X = frameMidBack.Width - Application.GetRealWidth(98 + 244); btnRegister.TextID = R.MyInternationalizationString.Register; btnRegister.TextColor = UserCenterColor.Current.TextGrayColor3; btnRegister.TextSize = 12; btnRegister.TextAlignment = TextAlignment.CenterRight; frameMidBack.AddChidren(btnRegister); btnRegister.ButtonClickEvent += (sender, e) => { var registerPage = new AccountRegister(); CommonPage.Instance.AddChidren(registerPage); registerPage.Show(); }; //微信图标 var btnWebChat = new IconViewControl(115); btnWebChat.Y = frameMidBack.Height - Application.GetRealHeight(69) - btnWebChat.IconSize; btnWebChat.UnSelectedImagePath = "Account/Wechat.png"; btnWebChat.Gravity = Gravity.CenterHorizontal; frameMidBack.AddChidren(btnWebChat); btnWebChat.ButtonClickEvent += (sender, e) => { //微信登陆 this.LoginByWechat(); }; //添加服务协议控件 // this.AddServiceAgreementControl(frameMidBack); } #endregion @@ -1069,13 +1020,20 @@ /// <param name="frameMidBack">中间浅色的背景容器</param> /// <param name="i_account">登陆账号</param> /// <param name="i_div">1:手机号 2:邮箱</param> private void InitAccoutLoginWindow(FrameLayout frameMidBack, string i_account, int i_div) private FrameLayout InitAccoutLoginWindow(FrameLayout frameMidBack, string i_account, int i_div) { //登陆按钮 BottomClickButton btnLogin = null; //账号输入框 TextInputControl txtAccount = null; //密码输入框 TextInputControl txtPsw = null; //容器 var frameBack = new FrameLayout(); frameBack.Height = Application.GetRealHeight(620); frameBack.Y = Application.GetRealHeight(181); frameMidBack.AddChidren(frameBack); frameBack.Visible = false; //白色背景 var frameWhiteBack = new FrameLayout(); frameWhiteBack.Width = Application.GetRealWidth(942); @@ -1099,7 +1057,7 @@ btnAccountIcon.UnSelectedImagePath = "Account/Account.png"; rowAccount.AddChidren(btnAccountIcon); //账号输入框 var txtAccount = new TextInputControl(600, 92, true); txtAccount = new TextInputControl(600, 92, true); txtAccount.X = btnAccountIcon.Right + Application.GetRealWidth(35); txtAccount.Gravity = Gravity.CenterVertical; if (i_div == 1) @@ -1116,11 +1074,42 @@ txtAccount.PlaceholderTextColor = ZigbeeColor.Current.GXCPlaceHolderTextColor; txtAccount.Text = i_account; rowAccount.AddChidren(txtAccount); txtAccount.TextChangeEventHandler += (sender, e) => { //隐藏错误提示 if (this.btnErrorMsg.Visible == true) { this.btnErrorMsg.Visible = false; } if (txtAccount.Text.Trim().Length > 0 && txtPsw.Text.Length > 0) { //能够登陆 if (btnLogin.CanClick == false) { btnLogin.CanClick = true; } return; } //不能点击 if (btnLogin.CanClick == true) { btnLogin.CanClick = false; } }; //底线 var btnAccountLine = new NormalViewControl(rowAccount.Width, 1, false); btnAccountLine.BackgroundColor = ZigbeeColor.Current.GXCGrayLineColor; btnAccountLine.Y = rowAccount.Height - 1; btnAccountLine.Y = rowAccount.Height - 2; rowAccount.AddChidren(btnAccountLine); txtAccount.FoucsChanged += (sender, focusEvent) => { //焦点进入时,底线颜色变更 if (focusEvent.Focus) { btnAccountLine.BackgroundColor = ZigbeeColor.Current.GXCSelectedLineColor; btnAccountLine.Height = 2; } else { btnAccountLine.BackgroundColor = ZigbeeColor.Current.GXCGrayLineColor; btnAccountLine.Height = 1; } }; //密码行 var rowPassword = new FrameLayout(); @@ -1135,19 +1124,889 @@ btnPswIcon.Gravity = Gravity.CenterVertical; btnPswIcon.UnSelectedImagePath = "Account/Password.png"; rowPassword.AddChidren(btnPswIcon); //账号输入框 var txtPsw = new TextInputControl(600, 92, true); //密码输入框 txtPsw = new TextInputControl(600, 92, true); txtPsw.X = txtAccount.X; txtPsw.Gravity = Gravity.CenterVertical; txtPsw.PlaceholderText = Language.StringByID(R.MyInternationalizationString.PleaseInputPWD); txtPsw.PlaceholderTextColor = ZigbeeColor.Current.GXCPlaceHolderTextColor; txtPsw.SecureTextEntry = true; rowPassword.AddChidren(txtPsw); txtPsw.TextChangeEventHandler += (sender, e) => { txtAccount.TextChangeEventHandler(sender, e); }; //隐藏或者显示密码的图标 var btnHiden = new IconViewControl(92); btnHiden.X = rowPassword.Width - Application.GetRealWidth(46) - btnHiden.IconSize; btnHiden.SelectedImagePath = "Account/UnhidePwd.png"; btnHiden.UnSelectedImagePath = "Account/HidePwd.png"; btnHiden.Gravity = Gravity.CenterVertical; rowPassword.AddChidren(btnHiden); btnHiden.ButtonClickEvent += (sender, e) => { txtPsw.SecureTextEntry = !txtPsw.SecureTextEntry; btnHiden.IsSelected = !btnHiden.IsSelected; }; //底线 var btnPswLine = new NormalViewControl(rowPassword.Width, 1, false); btnPswLine.BackgroundColor = ZigbeeColor.Current.GXCGrayLineColor; btnPswLine.Y = rowPassword.Height - 1; btnPswLine.Y = rowPassword.Height - 2; rowPassword.AddChidren(btnPswLine); txtPsw.FoucsChanged += (sender, focusEvent) => { //焦点进入时,底线颜色变更 if (focusEvent.Focus) { btnPswLine.BackgroundColor = ZigbeeColor.Current.GXCSelectedLineColor; btnPswLine.Height = 2; } else { btnPswLine.BackgroundColor = ZigbeeColor.Current.GXCGrayLineColor; btnPswLine.Height = 1; } }; //忘记密码? var btnForgot = new NormalViewControl(250, 90, true); btnForgot.Y = rowPassword.Bottom + Application.GetRealHeight(15); btnForgot.X = frameWhiteBack.Width - Application.GetRealWidth(250 + 35); btnForgot.TextSize = 12; btnForgot.TextColor = UserCenterColor.Current.TextGrayColor3; btnForgot.TextAlignment = TextAlignment.CenterRight; btnForgot.TextID = R.MyInternationalizationString.ForgotPWD_1; frameWhiteBack.AddChidren(btnForgot); btnForgot.ButtonClickEvent += (sender, e) => { var forgot = new AccountForgetPWD(); CommonPage.Instance.AddChidren(forgot); forgot.Show(); }; //登陆按钮 btnLogin = new BottomClickButton(688); btnLogin.Gravity = Gravity.BottomCenter; btnLogin.TextID = R.MyInternationalizationString.Login; btnLogin.oldBackgroundColor = btnLogin.BackgroundColor; frameBack.AddChidren(btnLogin); btnLogin.CanClick = false; btnLogin.ButtonClickEvent += (sender, e) => { //账号密码登陆 this.LoginByAccountAndPsw(txtAccount.Text.Trim(), txtPsw.Text, i_div); }; return frameBack; } #endregion #region ■ 初始化验证码登陆窗口_______________ /// <summary> /// 初始化验证码登陆窗口 /// </summary> /// <param name="frameMidBack">中间浅色的背景容器</param> /// <param name="i_account">登陆账号</param> /// <param name="i_div">1:手机号 2:邮箱</param> private FrameLayout InitCodeLoginWindow(FrameLayout frameMidBack, string i_account, int i_div) { //登陆按钮 BottomClickButton btnLogin = null; //账号输入框 TextInputControl txtAccount = null; //密码输入框 TextInputControl txtVerCode = null; //当前输入的账号(防止发送验证码之后,修改账号) string nowInputAccount = string.Empty; //是否已经发送了验证码 bool hadSendCode = false; //容器 var frameBack = new FrameLayout(); frameBack.Height = Application.GetRealHeight(620); frameBack.Y = Application.GetRealHeight(181); frameMidBack.AddChidren(frameBack); frameBack.Visible = false; //白色背景 var frameWhiteBack = new FrameLayout(); frameWhiteBack.Width = Application.GetRealWidth(942); frameWhiteBack.Height = Application.GetRealHeight(553); frameWhiteBack.BackgroundColor = UserCenterColor.Current.White; frameWhiteBack.Radius = (uint)Application.GetRealHeight(17); frameWhiteBack.Gravity = Gravity.CenterHorizontal; frameBack.AddChidren(frameWhiteBack); //账号行 var rowAccount = new FrameLayout(); rowAccount.Y = Application.GetRealHeight(29); rowAccount.Width = Application.GetRealWidth(884); rowAccount.Height = Application.GetRealHeight(138); rowAccount.Gravity = Gravity.CenterHorizontal; frameWhiteBack.AddChidren(rowAccount); if (i_div == 2) { //账号图标 var btnAccountIcon = new IconViewControl(92); btnAccountIcon.X = Application.GetRealWidth(69); btnAccountIcon.Gravity = Gravity.CenterVertical; btnAccountIcon.UnSelectedImagePath = "Account/Account.png"; rowAccount.AddChidren(btnAccountIcon); } else { //地区码 var btnArea = new NormalViewControl(139, 60, true); btnArea.TextColor = UserCenterColor.Current.TextGrayColor1; btnArea.TextAlignment = TextAlignment.CenterRight; btnArea.Text = "+86"; btnArea.Gravity = Gravity.CenterVertical; rowAccount.AddChidren(btnArea); } //账号输入框 txtAccount = new TextInputControl(600, 92, true); txtAccount.X = Application.GetRealWidth(193); txtAccount.Gravity = Gravity.CenterVertical; if (i_div == 1) { //手机号 txtAccount.IsNumberKeyboardType = true; txtAccount.PlaceholderText = Language.StringByID(R.MyInternationalizationString.PleaseInputPhoneNum); } else { //邮箱 txtAccount.PlaceholderText = Language.StringByID(R.MyInternationalizationString.PleaseInputEmail); } txtAccount.PlaceholderTextColor = ZigbeeColor.Current.GXCPlaceHolderTextColor; txtAccount.Text = i_account; rowAccount.AddChidren(txtAccount); txtAccount.TextChangeEventHandler += (sender, e) => { //隐藏错误提示 if (this.btnErrorMsg.Visible == true) { this.btnErrorMsg.Visible = false; } //必须要发送成功才行 if (hadSendCode = true && txtAccount.Text.Trim().Length > 0 && txtVerCode.Text.Length > 0) { //能够登陆 if (btnLogin.CanClick == false) { btnLogin.CanClick = true; } return; } //不能点击 if (btnLogin.CanClick == true) { btnLogin.CanClick = false; } }; //底线 var btnAccountLine = new NormalViewControl(rowAccount.Width, 1, false); btnAccountLine.BackgroundColor = ZigbeeColor.Current.GXCGrayLineColor; btnAccountLine.Y = rowAccount.Height - 2; rowAccount.AddChidren(btnAccountLine); txtAccount.FoucsChanged += (sender, focusEvent) => { //焦点进入时,底线颜色变更 if (focusEvent.Focus) { btnAccountLine.BackgroundColor = ZigbeeColor.Current.GXCSelectedLineColor; btnAccountLine.Height = 2; } else { btnAccountLine.BackgroundColor = ZigbeeColor.Current.GXCGrayLineColor; btnAccountLine.Height = 1; } }; //验证码行 var rowVerCode = new FrameLayout(); rowVerCode.Y = rowAccount.Bottom + Application.GetRealHeight(58); rowVerCode.Width = rowAccount.Width; rowVerCode.Height = rowAccount.Height; rowVerCode.Gravity = Gravity.CenterHorizontal; frameWhiteBack.AddChidren(rowVerCode); //账号图标 var btnCodeIcon = new IconViewControl(92); btnCodeIcon.X = Application.GetRealWidth(69); btnCodeIcon.Gravity = Gravity.CenterVertical; btnCodeIcon.UnSelectedImagePath = "Account/Code.png"; rowVerCode.AddChidren(btnCodeIcon); //验证码输入框 txtVerCode = new TextInputControl(350, 92, true); txtVerCode.X = btnCodeIcon.Right + Application.GetRealWidth(35); txtVerCode.Gravity = Gravity.CenterVertical; txtVerCode.PlaceholderText = Language.StringByID(R.MyInternationalizationString.PleaseInputVerificationCode); txtVerCode.PlaceholderTextColor = ZigbeeColor.Current.GXCPlaceHolderTextColor; txtVerCode.SecureTextEntry = true; rowVerCode.AddChidren(txtVerCode); txtVerCode.TextChangeEventHandler += (sender, e) => { txtAccount.TextChangeEventHandler(sender, e); }; //竖线 var btnLine2 = new NormalViewControl(1, Application.GetRealHeight(66), false); btnLine2.X = Application.GetRealWidth(611); btnLine2.Gravity = Gravity.CenterVertical; btnLine2.BackgroundColor = ZigbeeColor.Current.GXCLineColor; rowVerCode.AddChidren(btnLine2); //获取验证码 var btnSendCode = new NormalViewControl(250, 70, true); btnSendCode.X = btnLine2.Right + Application.GetRealWidth(36); btnSendCode.Gravity = Gravity.CenterVertical; btnSendCode.TextID = R.MyInternationalizationString.SendVerificationCode; btnSendCode.TextColor = UserCenterColor.Current.TextGrayColor3; btnSendCode.TextAlignment = TextAlignment.Center; btnSendCode.IsBold = true; rowVerCode.AddChidren(btnSendCode); btnSendCode.ButtonClickEvent += async (sender, e) => { //检测输入的账号 nowInputAccount = txtAccount.Text.Trim(); if (this.CheckInputAccount("86", nowInputAccount, i_div) == false) { return; } //发送验证码 hadSendCode = await this.SendVerCode(btnSendCode, nowInputAccount, i_div); }; //底线 var btnCodeLine = new NormalViewControl(rowVerCode.Width, 1, false); btnCodeLine.BackgroundColor = ZigbeeColor.Current.GXCGrayLineColor; btnCodeLine.Y = rowVerCode.Height - 2; rowVerCode.AddChidren(btnCodeLine); txtVerCode.FoucsChanged += (sender, focusEvent) => { //焦点进入时,底线颜色变更 if (focusEvent.Focus) { btnCodeLine.BackgroundColor = ZigbeeColor.Current.GXCSelectedLineColor; btnCodeLine.Height = 2; } else { btnCodeLine.BackgroundColor = ZigbeeColor.Current.GXCGrayLineColor; btnCodeLine.Height = 1; } }; //忘记密码? var btnForgot = new NormalViewControl(250, 90, true); btnForgot.Y = rowVerCode.Bottom + Application.GetRealHeight(15); btnForgot.X = frameWhiteBack.Width - Application.GetRealWidth(250 + 35); btnForgot.TextSize = 12; btnForgot.TextColor = UserCenterColor.Current.TextGrayColor3; btnForgot.TextAlignment = TextAlignment.CenterRight; btnForgot.TextID = R.MyInternationalizationString.ForgotPWD_1; frameWhiteBack.AddChidren(btnForgot); btnForgot.ButtonClickEvent += (sender, e) => { var forgot = new AccountForgetPWD(); CommonPage.Instance.AddChidren(forgot); forgot.Show(); }; //登陆按钮 btnLogin = new BottomClickButton(688); btnLogin.Gravity = Gravity.BottomCenter; btnLogin.TextID = R.MyInternationalizationString.Login; btnLogin.oldBackgroundColor = btnLogin.BackgroundColor; frameBack.AddChidren(btnLogin); btnLogin.CanClick = false; btnLogin.ButtonClickEvent += (sender, e) => { //验证码登陆 this.LoginByVerCode(nowInputAccount, txtVerCode.Text.Trim(), i_div); }; return frameBack; } #endregion #region ■ 服务协议___________________________ /// <summary> /// 添加服务协议控件 /// </summary> /// <param name="frameBack"></param> private void AddServiceAgreementControl(FrameLayout frameBack) { var frameRow = new FrameLayout(); frameRow.Height = Application.GetMinRealAverage(110); frameRow.Y = Application.GetRealHeight(959); frameRow.Gravity = Gravity.CenterHorizontal; //字体总宽度 int fontWidth = 0; int btnWidth = 0; #if Android //特殊的误差值 int speceilValue = Application.GetRealWidth(20); #endif #if iOS //特殊的误差值 int speceilValue = Application.GetRealWidth(10); #endif //我已阅读并同意 var btnMsg1 = new NormalViewControl(100, 90, true); btnMsg1.Gravity = Gravity.CenterVertical; btnMsg1.Y = Application.GetRealHeight(968); btnMsg1.TextSize = 12; btnMsg1.TextColor = UserCenterColor.Current.TextGrayColor1; btnMsg1.TextID = R.MyInternationalizationString.uMyHadReadAndAgree; //计算真实宽度 btnWidth = btnMsg1.GetRealWidthByText(); btnMsg1.Width = btnWidth; fontWidth += btnWidth; //《隐私权政策》 var btnMsg2 = new NormalViewControl(100, 90, true); btnMsg2.Gravity = Gravity.CenterVertical; btnMsg2.TextSize = 12; btnMsg2.TextColor = 0xFF4A90E2; btnMsg2.Text = "《" + Language.StringByID(R.MyInternationalizationString.uPrivacyPolicy) + "》"; //计算真实宽度 btnWidth = btnMsg2.GetRealWidthByText(); btnMsg2.Width = btnWidth; fontWidth += btnWidth; btnMsg2.ButtonClickEvent += (sender, e) => { var form = new UserCenter.Abount.SLAForm(); this.AddChidren(form); form.InitTopFrameLayout(); form.InitBodyFrameLayout(); form.ShowForm(); }; //和 var btnMsg3 = new NormalViewControl(100, 90, true); btnMsg3.Gravity = Gravity.CenterVertical; btnMsg3.TextSize = 12; btnMsg3.TextColor = UserCenterColor.Current.TextGrayColor1; btnMsg3.TextID = R.MyInternationalizationString.uAnd; //计算真实宽度 btnWidth = btnMsg3.GetRealWidthByText(); btnMsg3.Width = btnWidth; fontWidth += btnWidth; //《服务条款》 var btnMsg4 = new NormalViewControl(100, 90, true); btnMsg4.Gravity = Gravity.CenterVertical; btnMsg4.TextSize = 12; btnMsg4.TextColor = 0xFF4A90E2; btnMsg4.Text = "《" + Language.StringByID(R.MyInternationalizationString.uTermsOfService) + "》"; //计算真实宽度 btnWidth = btnMsg4.GetRealWidthByText(); btnMsg4.Width = btnWidth; fontWidth += btnWidth; btnMsg4.ButtonClickEvent += (sender, e) => { btnMsg2.ButtonClickEvent(null, null); }; //图标 var btnIcon = new IconBigViewControl(42, 42); btnIcon.UnSelectedImagePath = "Item/Check1.png"; btnIcon.SelectedImagePath = "Item/Check1Selected.png"; //计算行控件的宽度 frameRow.Width = fontWidth + Application.GetMinRealAverage(42) + Application.GetRealWidth(23) - speceilValue * 3; frameBack.AddChidren(frameRow); //图标控件初始化 frameRow.AddChidren(btnIcon); btnIcon.InitControl(); btnIcon.X = -btnIcon.XOffset; btnIcon.UseClickStatu = false; btnIcon.ButtonClickEvent += (sender, e) => { btnIcon.IsSelected = !btnIcon.IsSelected; isAgreePrivacyPolicy = btnIcon.IsSelected; }; btnMsg1.X = btnIcon.btnIcon.Width + Application.GetRealWidth(23); frameRow.AddChidren(btnMsg1); btnMsg2.Y = btnMsg1.Y; btnMsg2.X = btnMsg1.Right - speceilValue; frameRow.AddChidren(btnMsg2); btnMsg3.X = btnMsg2.Right - speceilValue; btnMsg3.Y = btnMsg1.Y; frameRow.AddChidren(btnMsg3); btnMsg4.X = btnMsg3.Right - speceilValue; btnMsg4.Y = btnMsg1.Y; frameRow.AddChidren(btnMsg4); } #endregion #region ■ 账号密码登陆_______________________ /// <summary> /// 账号密码登陆 /// </summary> /// <param name="i_account">账号</param> /// <param name="i_psw">密码</param> /// <param name="i_div">1:手机号 2:邮箱</param> private void LoginByAccountAndPsw(string i_account, string i_psw, int i_div) { //检测账号 if (this.CheckInputAccount(string.Empty, i_account, i_div) == false) { return; } //登陆中.... CommonPage.Loading.Start(Language.StringByID(R.MyInternationalizationString.Logining)); HdlThreadLogic.Current.RunThread(async () => { //登陆参数 var pra = new SendDataToServer.LoginObj(); pra.Account = i_account; pra.Password = i_psw; pra.Source = CommonPage.Source; pra.Company = CommonPage.Company; //访问接口 var requestJson = Newtonsoft.Json.JsonConvert.SerializeObject(pra); var result = await CommonPage.Instance.RequestHttpsZigbeeAsync("ZigbeeUsers/Login", System.Text.Encoding.UTF8.GetBytes(requestJson)); //处理登陆成功的数据 this.AdjustLoginSuccessData(result, pra, i_account, i_psw, i_div); }); } /// <summary> /// 检测输入的账号 /// </summary> /// <param name="i_areaCode">地区码</param> /// <param name="i_account">账号</param> /// <param name="i_div">1:手机号 2:邮箱</param> /// <returns></returns> private bool CheckInputAccount(string i_areaCode, string i_account, int i_div) { if (i_div == 1) { //检测手机 if (i_areaCode != string.Empty && AccountLogic.Instance.CheckPhoneWithZone(i_account, i_areaCode) == false) { btnErrorMsg.TextID = R.MyInternationalizationString.ThePhoneError; return false; } //检测手机 if (i_areaCode == string.Empty && AccountLogic.Instance.CheckPhone(i_account) == false) { btnErrorMsg.TextID = R.MyInternationalizationString.ThePhoneError; return false; } } else { //检测邮箱 if (AccountLogic.Instance.CheckEmail(i_account) == false) { btnErrorMsg.TextID = R.MyInternationalizationString.TheEmailError; return false; } } return true; } #endregion #region ■ 微信登陆___________________________ /// <summary> /// 微信登录 /// </summary> private void LoginByWechat() { #if Android com.hdl.home.Application.WXLogin(); com.hdl.home.WXEntryActivity.RespAction = (authStr) => { #endif #if iOS Home.IOS.AppDelegate.WXLogin(); Home.IOS.AppDelegate.RespAction = (authStr) => { #endif if (authStr == null) { return; } HdlThreadLogic.Current.RunThread(async () => { //是否已经绑定 var re = await isBindAuthAsync(authStr); if (re) { Application.RunOnMainThread(() => { //直接登录 HomePage.Instance.ShowLoginLoadView(); }); var resultRegID = await Shared.Common.CommonPage.Instance.PushRegID(); var homes = await House.GetHomeLists(); //刷新个人中心的内存及线程 await UserCenter.UserCenterLogic.InitUserCenterMenmoryAndThread(); //启动ZigBee ZigBee.Common.Application.Init(); Application.RunOnMainThread(() => { this.RemoveFromParent(); CommonPage.Instance.RemoveViewByTag("Login"); UserPage.Instance.Fresh(); }); } else { var authRes = Newtonsoft.Json.JsonConvert.DeserializeObject<Common.ResponseEntity.AuthUserRes>(authStr); Application.RunOnMainThread(() => { var registerPage = new AccountRegister(); CommonPage.Instance.AddChidren(registerPage); registerPage.OpenID = authRes.openid; registerPage.Show(); }); } }); }; } /// <summary> /// 是否已绑定 /// </summary> /// <param name="authStr"></param> /// <returns></returns> private async System.Threading.Tasks.Task<bool> isBindAuthAsync(string authStr) { var authRes = Newtonsoft.Json.JsonConvert.DeserializeObject<Common.ResponseEntity.AuthUserRes>(authStr); var auth = new SendDataToServer.AuthUser() { AccessToken = authRes.access_token, RefreshToken = authRes.refresh_token, OpenID = authRes.openid }; //获取微信昵称 var strUrl = "https://api.weixin.qq.com/sns/userinfo?access_token=" + authRes.access_token; strUrl += "&openid=" + authRes.openid; var byteData = await Common.CommonPage.Instance.DoRequestZigbeeHttpsInterface(strUrl, null, null, "GET"); if (byteData == null) { return false; } var receipData = System.Text.Encoding.UTF8.GetString(byteData); var nickData = Newtonsoft.Json.JsonConvert.DeserializeObject<UserCenter.NicknameInfo>(receipData); auth.UserName = nickData.nickname; var requestJson = Newtonsoft.Json.JsonConvert.SerializeObject(auth); var revertObj = await CommonPage.Instance.RequestHttpsZigbeeAsync("ZigbeeUsers/InsertOrUpdateAuthUser", System.Text.Encoding.UTF8.GetBytes(requestJson)); if (revertObj == null) { return false; } var stateCodeStr = revertObj.StateCode.ToUpper(); if (stateCodeStr == "SUCCESS") { var responseDataObj = Newtonsoft.Json.JsonConvert.DeserializeObject<Shared.Common.ResponseEntity.UserLoginRes>(revertObj.ResponseData.ToString()); var revertData = responseDataObj; //标记上一次是不是同一个账号登陆 UserCenter.UserCenterResourse.ResidenceOption.TheSameLoginAccount = Config.Instance.Guid == revertData.Guid; Config.Instance.Account = revertData.Account; Config.Instance.MD5PWD = revertData.MD5PWD; Config.Instance.Guid = revertData.Guid; Config.Instance.LoginDateTime = DateTime.Now; Config.Instance.Save(); return true; } else { return false; } } #endregion #region ■ 验证码登陆_________________________ /// <summary> /// 验证码登陆 /// </summary> /// <param name="i_account">账号</param> /// <param name="i_verCode">验证码</param> /// <param name="i_div">1:手机号 2:邮箱</param> private async void LoginByVerCode(string i_account, string i_verCode, int i_div) { var pra = new SendDataToServer.LoginValidCodeOBJ() { Account = i_account, Code = i_verCode, Language = CommonPage.ZigBeeLanguage, AreaCode = int.Parse(CommonPage.PhoneZoneStr) }; var result = await CommonFormResouce.LoginByCode(pra); //处理登陆成功的数据 this.AdjustLoginSuccessData(result, pra, i_account, string.Empty, i_div); } /// <summary> /// 发送验证码 /// </summary> /// <param name="btnSendCode">发送按钮</param> /// <param name="account">账号</param> /// <param name="i_div">1:手机号 2:邮箱</param> /// <returns></returns> private async System.Threading.Tasks.Task<bool> SendVerCode(NormalViewControl btnSendCode, string account, int i_div) { //不能再点击 btnSendCode.CanClick = false; int companyInt = 0; if (CommonPage.PhoneZoneStr == "86" || i_div == 2) { companyInt = CommonPage.Company; } else { companyInt = CommonPage.CompanyForINTERNETION; } var reqDtoSignPhone = new SendDataToServer.LoginSendVerCodeObj() { Account = account, Company = companyInt, AreaCode = int.Parse(CommonPage.PhoneZoneStr), Language = CommonPage.ZigBeeLanguage }; var requestRevertObj = await CommonFormResouce.LoginSendVerCode(reqDtoSignPhone); if (requestRevertObj == null) { //请求服务器失败 CommonPage.Instance.FailureToServer(); return false; } var stateCodeStr = requestRevertObj.StateCode.ToUpper(); if (stateCodeStr == "SUCCESS") { //开启发送验证码的倒计时 this.StartSendVerCodeTimeOutThread(btnSendCode); return true; } if (stateCodeStr == "PARAMETEROREMPTY") { //提供的参数错误 btnErrorMsg.TextID = R.MyInternationalizationString.PARAMETEROREMPTY; } else if (stateCodeStr == "ACCOUNTNOEXISTS") { //账号不存在 btnErrorMsg.TextID = R.MyInternationalizationString.ACCOUNTNOEXISTS; } else if (stateCodeStr == "SENDFAIL") { //验证码发送失败 btnErrorMsg.TextID = R.MyInternationalizationString.SENDFAIL; } else { //请求服务器失败 btnErrorMsg.TextID = R.MyInternationalizationString.RequestServerFailed; //写Log IMessageCommon.Current.GetMsgByRequestName("ZigbeeUsers/LoginSendVerCode", requestRevertObj, reqDtoSignPhone); } HdlThreadLogic.Current.RunThread(() => { //发送失败后,5秒之后才能再次发送 int i = 0; while (i <= 5) { i++; System.Threading.Thread.Sleep(1000); } btnSendCode.CanClick = true; }); return false; } /// <summary> /// 开启发送验证码的倒计时 /// </summary> /// <param name="btnSendCode"></param> private void StartSendVerCodeTimeOutThread(NormalViewControl btnSendCode) { HdlThreadLogic.Current.RunThread(() => { //后重发 string strText = Language.StringByID(R.MyInternationalizationString.SendVerificationCodeAgain); int time = 60; while (time > 0 && btnSendCode.Parent != null) { HdlThreadLogic.Current.RunMain(() => { btnSendCode.Text = time + "s" + strText; }); time--; } //倒计时完成之后,可以再次点击 btnSendCode.CanClick = true; btnSendCode.TextID = R.MyInternationalizationString.SendVerificationCode;//获取验证码 }); } #endregion #region ■ 处理登陆成功的数据_________________ /// <summary> /// 处理登陆成功的数据 /// </summary> /// <param name="revertObj">云端返回的数据</param> /// <param name="pra">接口请求参数</param> /// <param name="i_account">账号</param> /// <param name="i_psw">密码,验证码登陆时,设置为 string.Empty</param> /// <param name="i_div">1:手机号 2:邮箱</param> private async void AdjustLoginSuccessData(Common.ResponseEntity.ResponsePack revertObj, object pra, string i_account, string i_psw, int i_div) { if (revertObj == null) { HdlThreadLogic.Current.RunMain(() => { //请求服务器失败 CommonPage.Instance.FailureToServer(); CommonPage.Loading.Hide(); }); return; } var stateCodeStr = revertObj.StateCode.ToUpper(); //Error 不能直接从服务器取,只能根据状态码逐一判断 if (stateCodeStr == "SUCCESS") { HdlThreadLogic.Current.RunMain(() => { //显示启动页 HomePage.Instance.ShowLoginLoadView(); }); //存储数据 var responseDataObj = Newtonsoft.Json.JsonConvert.DeserializeObject<Shared.Common.ResponseEntity.UserLoginRes>(revertObj.ResponseData.ToString()); var revertData = responseDataObj; Config.ReFresh(); //标记上一次是不是同一个账号登陆 UserCenterResourse.ResidenceOption.TheSameLoginAccount = Config.Instance.Guid == revertData.Guid; Config.Instance.Account = revertData.Account; Config.Instance.Password = i_psw; Config.Instance.MD5PWD = revertData.MD5PWD; Config.Instance.Guid = revertData.Guid; Config.Instance.LoginDateTime = DateTime.Now; Config.Instance.LoginToken = revertData.Token; Config.Instance.Save(); var resultRegID = await CommonPage.Instance.PushRegID(); var homes = await House.GetHomeLists(); //刷新个人中心的内存及线程 await UserCenterLogic.InitUserCenterMenmoryAndThread(); //启动ZigBee ZigBee.Common.Application.Init(); HdlThreadLogic.Current.RunMain(() => { CommonPage.Loading.Hide(); this.RemoveFromParent(); CommonPage.Instance.RemoveViewByTag("Login"); UserPage.Instance.Fresh(); }); return; } //关闭转圈的 HdlThreadLogic.Current.RunMain(() => { CommonPage.Loading.Hide(); if (stateCodeStr == "NOTVERIFY") { //未激活 btnErrorMsg.TextID = R.MyInternationalizationString.NOTVERIFY; } else if (stateCodeStr == "NOTENABLE") { //该用户属于调试账号,并未启用 btnErrorMsg.TextID = R.MyInternationalizationString.NOTENABLE; } else if (stateCodeStr == "PARAMETEROREMPTY") { //提供的参数错误 btnErrorMsg.TextID = R.MyInternationalizationString.PARAMETEROREMPTY; } else if (stateCodeStr == "VALIDCODEANDPHONENOEQUAL") { //验证码错误,请重新输入 btnErrorMsg.TextID = R.MyInternationalizationString.VALIDCODEANDPHONENOEQUAL; } else if (stateCodeStr == "USERNAMEORPWDERROR") { //账号或密码错误 btnErrorMsg.TextID = R.MyInternationalizationString.USERNAMEORPWDERROR; } else if (stateCodeStr == "ACCOUNTNOEXISTS") { //账号不存在 btnErrorMsg.TextID = R.MyInternationalizationString.ACCOUNTNOEXISTS; } else if (stateCodeStr == "NORECORD" && i_psw == string.Empty) { //请先获取验证码 btnErrorMsg.TextID = R.MyInternationalizationString.NORECORD; } else if (stateCodeStr == "YOUDATANOISLOCALREGION") { //不在本区域,需要重定向区域后再次请求登录 var responseDataObj = Newtonsoft.Json.JsonConvert.DeserializeObject<Shared.Common.ResponseEntity.UserLoginLocalRegionRes>(revertObj.ResponseData.ToString()); CommonPage.RequestHttpsHost = responseDataObj.RegionServer; if (i_psw != string.Empty) { //再次登录 this.LoginByAccountAndPsw(i_account, i_psw, i_div); } } else { btnErrorMsg.TextID = R.MyInternationalizationString.RequestServerFailed; //写Log if (pra is SendDataToServer.LoginObj) { ((SendDataToServer.LoginObj)pra).Password = "*********"; IMessageCommon.Current.GetMsgByRequestName("ZigbeeUsers/Login", revertObj, pra); } else { IMessageCommon.Current.GetMsgByRequestName("ZigbeeUsers/LoginValidCode", revertObj, pra); } } }); } #endregion #region ■ 一般方法___________________________ /// <summary> /// 检测隐私协议 /// </summary> /// <returns></returns> private bool CheckPrivacyPolicy() { if (isAgreePrivacyPolicy == false) { //请先阅读并同意《隐私权政策》和《服务条款》 var btnMsg = new ShowMsgControl(ShowMsgType.Remind, Language.StringByID(R.MyInternationalizationString.uPleaseReadAndAgreePrivacyPolicyMsg)); btnMsg.Show(); return false; } return true; } #endregion ZigbeeApp/Shared/Phone/Login/AccountLoginByCode.cs
@@ -339,10 +339,6 @@ Config.Instance.MD5PWD = revertData.MD5PWD; Config.Instance.LoginDateTime = DateTime.Now; Config.Instance.LoginToken = revertData.Token; if (Config.Instance.AccountList.Find((obj) => obj == revertData.Account) == null) { Config.Instance.AccountList.Add(revertData.Account); } //需要把登录后返回的md5密码 赋值生成Token 因为用户没有输入密码 Config.Instance.MD5PWD = revertData.MD5PWD; Config.Instance.Save(); @@ -648,10 +644,6 @@ Config.Instance.MD5PWD = revertData.MD5PWD; Config.Instance.Guid = revertData.Guid; Config.Instance.LoginDateTime = DateTime.Now; if (Config.Instance.AccountList.Find((obj) => obj == revertData.Account) == null) { Config.Instance.AccountList.Add(revertData.Account); } Config.Instance.Save(); return true; } ZigbeeApp/Shared/Phone/Login/AccountRegister.cs
@@ -54,7 +54,7 @@ /// <summary> /// 账号 /// </summary> private string account; private string account = string.Empty; /// <summary> /// OpenID /// </summary> @@ -239,7 +239,7 @@ codeRow = new CodeForRegisterRowForm(); codeRow.Init(accountCodeFrameLayout, 29, 530); codeRow.VerificationCodeET.TextChangeEventHandler += Code_TextChange; codeRow.SendCodeBtn.MouseUpEventHandler += SendCode_MouseUpEventAsync; codeRow.SendCodeBtn.ButtonClickEvent += SendCode_MouseUpEventAsync; } #endregion @@ -375,11 +375,16 @@ errorBtn.Text = string.Empty; if ((sender as EditText).Text.Trim().Length > 0) { codeRow.SendCodeBtn.Enable = codeRow.SendCodeBtn.IsSelected = true; if (codeRow.SendCodeBtn.CanClick == false) { codeRow.SendCodeBtn.CanClick = true; codeRow.SendCodeBtn.BackgroundColor = 0xFFFC744B; } } else { codeRow.SendCodeBtn.Enable = codeRow.SendCodeBtn.IsSelected = false; codeRow.SendCodeBtn.CanClick = false; codeRow.SendCodeBtn.BackgroundColor = 0xFFFEBCA9; } account = (sender as EditText).Text.Trim(); } @@ -430,7 +435,7 @@ } CommonPage.Loading.Start(); (sender as Button).Enable = false; (sender as UserCenter.NormalViewControl).CanClick = false; try { int companyInt = 0; @@ -452,7 +457,8 @@ var requestRevertObj = await CommonFormResouce.RegisterSendVerCode(reqDto); if (requestRevertObj == null) { CommonPage.Instance.FailureToServer(); CommonPage.Instance.FailureToServer(); (sender as UserCenter.NormalViewControl).CanClick = true; return; } var stateCodeStr = requestRevertObj.StateCode.ToUpper(); @@ -461,35 +467,32 @@ codeRow.TimeBegin(); var alert = new Alert(Language.StringByID(R.MyInternationalizationString.TIP), Language.StringByID(R.MyInternationalizationString.SendVerificationCodeSuccess), Language.StringByID(R.MyInternationalizationString.Confrim)); alert.Show(); return; } else if (stateCodeStr == "PARAMETEROREMPTY") if (stateCodeStr == "PARAMETEROREMPTY") { //提供的参数错误 errorBtn.TextID = R.MyInternationalizationString.PARAMETEROREMPTY; (sender as Button).Enable = true; } else if (stateCodeStr == "SENDFAIL") { //验证码发送失败 errorBtn.TextID = R.MyInternationalizationString.SENDFAIL; (sender as Button).Enable = true; errorBtn.TextID = R.MyInternationalizationString.SENDFAIL; } else if (stateCodeStr == "EXIST") { //账号存在 errorBtn.TextID = R.MyInternationalizationString.AccountHasBeenRegistered; (sender as Button).Enable = true; errorBtn.TextID = R.MyInternationalizationString.AccountHasBeenRegistered; } else { errorBtn.TextID = R.MyInternationalizationString.RequestServerFailed; (sender as Button).Enable = true; errorBtn.TextID = R.MyInternationalizationString.RequestServerFailed; } } catch { errorBtn.TextID = R.MyInternationalizationString.RequestServerFailed; (sender as Button).Enable = true; } finally { ZigbeeApp/Shared/Phone/Login/AccountRegisterSuccess.cs
@@ -124,8 +124,6 @@ //启动ZigBee ZigBee.Common.Application.Init(); UserCenter.HdlRoomLogic.Current.InitAllRoom(); Application.RunOnMainThread(() => { CommonPage.Loading.Hide(); ZigbeeApp/Shared/Phone/Login/Controls/PhoneEmailSelectControl.cs
@@ -48,12 +48,13 @@ public void InitControl(uint selectBackColor,int selectIndex) { //手机号 this.btnPhone = new NormalViewControl(this.Width / 2 + HdlControlLogic.Current.GetPictrueRealSize(20), HdlControlLogic.Current.GetPictrueRealSize(127), false); this.btnPhone = new NormalViewControl(HdlControlLogic.Current.GetPictrueRealSize(467), HdlControlLogic.Current.GetPictrueRealSize(127), false); btnPhone.X = HdlControlLogic.Current.GetPictrueRealSize(10); btnPhone.SelectedBackgroundColor = selectBackColor; btnPhone.TextID = R.MyInternationalizationString.PhoneNum; btnPhone.TextColor = UserCenterColor.Current.TextGrayColor3; btnPhone.SelectedTextColor = UserCenterColor.Current.White; btnPhone.TextAlignment = TextAlignment.Center; btnPhone.Radius = (uint)HdlControlLogic.Current.GetPictrueRealSize(127) / 2; this.AddChidren(btnPhone); btnPhone.ButtonClickEvent += (sender, e) => @@ -72,11 +73,12 @@ //邮箱 this.btnEmail = new NormalViewControl(this.btnPhone.Width, this.btnPhone.Height, false); btnEmail.X = this.btnPhone.Right - HdlControlLogic.Current.GetPictrueRealSize(40); btnEmail.X = this.Width - this.btnPhone.Width - HdlControlLogic.Current.GetPictrueRealSize(10); btnEmail.SelectedBackgroundColor = selectBackColor; btnEmail.TextID = R.MyInternationalizationString.Email; btnEmail.TextColor = UserCenterColor.Current.TextGrayColor3; btnEmail.SelectedTextColor = UserCenterColor.Current.White; btnEmail.TextAlignment = TextAlignment.Center; btnEmail.Radius = (uint)HdlControlLogic.Current.GetPictrueRealSize(127) / 2; this.AddChidren(btnEmail); btnEmail.ButtonClickEvent += (sender, e) => @@ -93,18 +95,42 @@ } }; //设置选择状态 this.SetSelectIndex(selectIndex); } #endregion #region ■ 设置选择状态_______________________ /// <summary> /// 设置选择状态(1:手机号 2:邮箱) /// </summary> /// <param name="i_index">1:手机号 2:邮箱</param> public void SetSelectIndex(int i_index) { //设置初始值 if (selectIndex == 1) if (i_index == 1) { btnPhone.IsBold = true; btnPhone.IsSelected = true; if (btnEmail.IsSelected == true) { btnEmail.IsBold = false; btnEmail.IsSelected = false; } //调用回调函数 this.SelectMenuEvent?.Invoke(1); } else if (selectIndex == 2) else if (i_index == 2) { btnEmail.IsBold = true; btnEmail.IsSelected = true; if (btnPhone.IsSelected == true) { btnPhone.IsBold = false; btnPhone.IsSelected = false; } //调用回调函数 this.SelectMenuEvent?.Invoke(2); } ZigbeeApp/Shared/Phone/Login/PhoneEmailForm.cs
@@ -1042,7 +1042,7 @@ /// <summary> /// sendCode /// </summary> public Button SendCodeBtn; public NormalViewControl SendCodeBtn; /// <summary> /// VerificationCodeET /// </summary> @@ -1105,20 +1105,15 @@ }; codeFL.AddChidren(VerificationCodeET); SendCodeBtn = new Button() SendCodeBtn = new NormalViewControl(300, 127, true) { X = Application.GetRealWidth(CommonFormResouce.Row_Width - 300), Width = Application.GetRealWidth(300), Height = Application.GetRealHeight(127), Gravity = Gravity.CenterVertical, TextID = R.MyInternationalizationString.SendVerificationCode, TextColor = ZigbeeColor.Current.GXCTextWhiteColor, SelectedTextColor = ZigbeeColor.Current.GXCTextWhiteColor, TextAlignment = TextAlignment.Center, BackgroundColor = ZigbeeColor.Current.GXCButtonDisableColor, SelectedBackgroundColor=ZigbeeColor.Current.GXCButtonSelectedColor, Enable = false, IsSelected = false, BackgroundColor = 0xFFFEBCA9, CanClick = false, Radius=(uint)Application.GetRealHeight(12), IsBold=true, TextSize=CommonFormResouce.TextSize @@ -1158,51 +1153,35 @@ } /// <summary> /// TimeOut /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void TimeOut(object sender, System.Timers.ElapsedEventArgs e) { var span = DateTime.Now - dateBegin; if (span.TotalSeconds <= 61) { Application.RunOnMainThread(() => { SendCodeBtn.Text = Convert.ToInt16(60 - span.TotalSeconds) + "s" + Language.StringByID(R.MyInternationalizationString.SendVerificationCodeAgain); SendCodeBtn.Enable = false; SendCodeBtn.BackgroundColor = ZigbeeColor.Current.GXCClearColor; SendCodeBtn.SelectedBackgroundColor= ZigbeeColor.Current.GXCClearColor; SendCodeBtn.TextColor = ZigbeeColor.Current.GXCTextBlackColor; }); } else { Application.RunOnMainThread(() => { SendCodeBtn.TextID = R.MyInternationalizationString.SendVerificationCode; SendCodeBtn.BackgroundColor = ZigbeeColor.Current.GXCButtonDisableColor; SendCodeBtn.SelectedBackgroundColor = ZigbeeColor.Current.GXCButtonSelectedColor; SendCodeBtn.TextColor = ZigbeeColor.Current.GXCTextWhiteColor; SendCodeBtn.Enable = true; t.Stop(); t.Close(); }); } } /// <summary> /// TimeBegin /// </summary> public void TimeBegin() { t.Interval = 1000; t.AutoReset = true; t.Enabled = true; t.Elapsed += TimeOut; //启动计时器倒计时-60s t.Start(); dateBegin = DateTime.Now; { SendCodeBtn.BackgroundColor = UserCenterColor.Current.White; SendCodeBtn.TextColor = ZigbeeColor.Current.GXCTextBlackColor; HdlThreadLogic.Current.RunThread(() => { //后重发 string txtValue = Language.StringByID(R.MyInternationalizationString.SendVerificationCodeAgain); int timeOut = 60; while (timeOut > 0 && SendCodeBtn.Parent != null) { HdlThreadLogic.Current.RunMain(() => { SendCodeBtn.Text = timeOut + "s" + txtValue; }); timeOut--; System.Threading.Thread.Sleep(1000); } HdlThreadLogic.Current.RunMain(() => { SendCodeBtn.TextID = R.MyInternationalizationString.SendVerificationCode; SendCodeBtn.BackgroundColor = 0xFFFC744B; SendCodeBtn.TextColor = ZigbeeColor.Current.GXCTextWhiteColor; SendCodeBtn.CanClick = true; }); }); } /// <summary> ZigbeeApp/Shared/Phone/MainPage/ListRoomViewFrom.cs
@@ -66,9 +66,6 @@ //初始化中部控件 this.InitBodyFrameLayout(); //设置头部信息 base.SetTitleText(Language.StringByID(R.MyInternationalizationString.RoomList)); //初始化中部信息 this.InitMiddleFrame(); } @@ -79,7 +76,11 @@ private void InitTopFrame() { //初始化头部控件 this.InitTopFrameLayout(); this.InitTopFrameLayout(); //设置头部信息 base.SetTitleText(Language.StringByID(R.MyInternationalizationString.RoomList)); //重置返回按键的事件 var btnBack = this.GetBackButton(); btnBack.ButtonClickEvent = null; ZigbeeApp/Shared/Phone/UserCenter/Abount/AbountForm.cs
@@ -150,23 +150,25 @@ var versionFL = new FrameLayout { Y = Application.GetRealHeight(510), Height = Application.GetRealHeight(300), //Height = Application.GetRealHeight(300), Height = Application.GetRealHeight(300-127-12), BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor }; bodyFrameLayout.AddChidren(versionFL); var SLARow = new DeviceInfoRow(12); SLARow.Init(); SLARow.SetTipTitle(R.MyInternationalizationString.SLA); SLARow.NameText.TextAlignment = TextAlignment.CenterRight; versionFL.AddChidren(SLARow); SLARow.ClickBtn.MouseUpEventHandler += (sender, e) => { var slaForm = new SLAForm(); slaForm.AddForm(); }; //var SLARow = new DeviceInfoRow(12); //SLARow.Init(); //SLARow.SetTipTitle(R.MyInternationalizationString.SLA); //SLARow.NameText.TextAlignment = TextAlignment.CenterRight; //versionFL.AddChidren(SLARow); //SLARow.ClickBtn.MouseUpEventHandler += (sender, e) => //{ // var slaForm = new SLAForm(); // slaForm.AddForm(); //}; updateRow = new DeviceInfoRow(12 + 127 + 12); //updateRow = new DeviceInfoRow(12 + 127 + 12); updateRow = new DeviceInfoRow(12); updateRow.Init(); updateRow.SetTipTitle(R.MyInternationalizationString.UpdateVersion); updateRow.NameText.TextAlignment = TextAlignment.CenterRight; ZigbeeApp/Shared/Phone/UserCenter/Abount/SLAForm.cs
@@ -21,36 +21,31 @@ /// </summary> private void InitMiddleFrame() { bodyFrameLayout.BackgroundColor = ZigbeeColor.Current.GXCGrayBackgroundColor; var title = new Button { X = Application.GetRealWidth(58), Y = Application.GetRealHeight(58), Width = Application.GetRealWidth(600), Height = Application.GetRealHeight(58), TextID = R.MyInternationalizationString.SLA_Title, TextAlignment = TextAlignment.CenterLeft, TextColor = ZigbeeColor.Current.GXCTextBlackColor, TextSize = 14 }; title.IsBold = true; bodyFrameLayout.AddChidren(title); var detail=new Button { X = Application.GetRealWidth(58), Y = Application.GetRealHeight(164), Width = Application.GetRealWidth(942), Height = Application.GetRealHeight(800), Text = Language.StringByID(R.MyInternationalizationString.SLA_Detail).Replace("{\\r\\n}","\r\n\r\n"), TextAlignment = TextAlignment.TopLeft, TextColor = ZigbeeColor.Current.GXCTextColor, IsMoreLines=true, TextSize = 12, }; bodyFrameLayout.AddChidren(detail); //打开进度条 this.ShowProgressBar(); HdlThreadLogic.Current.RunThread(async () => { var strUrl = "https://hdlcontrol.com/%E6%B2%B3%E4%B8%9C%E9%9A%90%E7%A7%81%E6%9D%83%E6%94%BF%E7%AD%9620200331.txt"; var byteData = await Common.CommonPage.Instance.DoRequestZigbeeHttpsInterface(strUrl, null, null, "GET"); if (byteData == null) { this.CloseProgressBar(ShowReLoadMode.YES); return; } this.CloseProgressBar(); var receipData = System.Text.Encoding.UTF8.GetString(byteData); HdlThreadLogic.Current.RunMain(() => { var btnText = new EditTextView(); btnText.Height = bodyFrameLayout.Height; btnText.TextSize = 12; btnText.TextColor = UserCenterColor.Current.TextGrayColor3; btnText.TextAlignment = TextAlignment.TopLeft; btnText.Foucs = false; bodyFrameLayout.AddChidren(btnText); btnText.Text = receipData; }); }); } } } ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlDeviceDoorLockLogic.cs
@@ -78,7 +78,7 @@ if (result == null) { return null; } //如果已经创建了,则不再创建 var myData = Newtonsoft.Json.JsonConvert.DeserializeObject<ZigBee.Device.DoorLock.GetDoorLockDataRes>(result); var myData = Newtonsoft.Json.JsonConvert.DeserializeObject<GetListIdResult>(result); if (myData.PageData.Count > 0) { return myData.PageData[0].Id; @@ -186,6 +186,28 @@ public int OpenLockMode = 9000; } /// <summary> /// 接收云端ID的结果 /// </summary> private class GetListIdResult { /// <summary> /// 云端返回的主键ID /// </summary> public List<GetIdResult> PageData = new List<GetIdResult>(); } /// <summary> /// 接收云端ID的结果 /// </summary> private class GetIdResult { /// <summary> /// 云端返回的主键ID /// </summary> public string Id = string.Empty; } #endregion } } ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlGatewayReceiveLogic.cs
@@ -93,6 +93,32 @@ }); return; } else if (topic == "ZigbeeGateWayToClient/" + Common.Config.Instance.Home.Id + "_" + Common.Config.Instance.Guid + "/PrimaryUserDelYou") { HdlThreadLogic.Current.RunMain(() => { //分享住宅已更改,请联系管理员! string msg = Language.StringByID(R.MyInternationalizationString.uShardResidenceHadDeletePleaseTakeToAdmin); var contr = new ShowMsgControl(ShowMsgType.Tip, msg); contr.Show(); UserCenterLogic.ReLoginAgain(UserCenterResourse.UserInfo.Account, false); }); return; } else if (topic == "ZigbeeGateWayToClient/" + Common.Config.Instance.Guid + "/Push/Update") { HdlThreadLogic.Current.RunMain(() => { //您的权限已经变更,请重新登陆 string msg = Language.StringByID(R.MyInternationalizationString.uYouAccessHadChangedPleaseTakeToAdmin); var contr = new ShowMsgControl(ShowMsgType.Tip, msg); contr.Show(); UserCenterLogic.ReLoginAgain(UserCenterResourse.UserInfo.Account, false); }); return; } else if (UserCenterResourse.UserInfo.AuthorityNo == 3) { if (topic == "ZigbeeGateWayToClient/" + Common.Config.Instance.Guid + "/Push/Deleted" @@ -102,19 +128,6 @@ { //分享数据已经变更,请重新登陆 string msg = Language.StringByID(R.MyInternationalizationString.uShardDataIsChangedPleaseLoginAgain); var contr = new ShowMsgControl(ShowMsgType.Tip, msg); contr.Show(); UserCenterLogic.ReLoginAgain(UserCenterResourse.UserInfo.Account, false); }); return; } else if (topic == "ZigbeeGateWayToClient/" + Common.Config.Instance.Home.Id + "_" + Common.Config.Instance.Guid + "/PrimaryUserDelYou") { HdlThreadLogic.Current.RunMain(() => { //分享住宅已更改,请联系管理员! string msg = Language.StringByID(R.MyInternationalizationString.uShardResidenceHadDeletePleaseTakeToAdmin); var contr = new ShowMsgControl(ShowMsgType.Tip, msg); contr.Show(); @@ -802,19 +815,23 @@ //没有添加监听 return; } lock (this.dicDeviceEvent) //lock (this.dicDeviceEvent) { var list = new List<Action<CommonDevice>>(); foreach (string keys in this.dicDeviceEvent.Keys) try { if (this.dicCommandDiv[keys] != comand) foreach (string keys in this.dicDeviceEvent.Keys) { //命令区分不一致,则不调用回调函数 continue; if (this.dicCommandDiv[keys] != comand) { //命令区分不一致,则不调用回调函数 continue; } //命令区分一致时,则调用回调函数 list.Add(this.dicDeviceEvent[keys]); } //命令区分一致时,则调用回调函数 list.Add(this.dicDeviceEvent[keys]); } catch { return; } //有可能在回调函数中移除了事件,导致报错,所以先收集,再调用 foreach (var action in list) { ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/UserCenterLogic.cs
@@ -883,14 +883,14 @@ //初始化本地的设备信息 Common.LocalDevice.Current.ReFreshByLocal(); //初始化房间(郭雪城那边不做处理,需要这里特殊执行一步) HdlRoomLogic.Current.RefreshAllRoomByLocation(); if (hadNet == true) { //同步云端的网关id,如果本地拥有云端不存在的id,则表示应该被换绑了,直接删除 HdlGatewayLogic.Current.SynchronizeDbGateway(); } //初始化房间(郭雪城那边不做处理,需要这里特殊执行一步) HdlRoomLogic.Current.RefreshAllRoomByLocation(); //刷新APP前一次选择的网关ID(可以反复调用,需要在网关初始化完了之后才能调用) HdlGatewayLogic.Current.RefreshAppOldSelectGatewayId(); ZigbeeApp/Shared/Phone/UserCenter/Device/Bind/BindCommonLayout.cs
@@ -12,7 +12,7 @@ } #region ◆ 变量申明__________________________ public FrameLayout topFrameLayout = new FrameLayout { Height = Application.GetRealHeight(184), BackgroundColor = ZigbeeColor.Current.XMTopFrameLayout }; public FrameLayout midFrameLayout = new FrameLayout { Height = Application.GetRealHeight(1921 - 184), BackgroundColor = ZigbeeColor.Current.XMMidFrameLayout }; public FrameLayout midFrameLayout = new FrameLayout { Height = Application.GetRealHeight(1925 - 184), BackgroundColor = ZigbeeColor.Current.XMMidFrameLayout }; public FrameLayout bottomRadiusFrameLayout = new FrameLayout() { Height = Application.GetRealHeight(100), ZigbeeApp/Shared/Phone/UserCenter/Device/Bind/BindTargetsPage.cs
@@ -359,6 +359,7 @@ { midVerticalRefreshLayout = new VerticalFrameRefreshControl(29) { Height = this.midFrameLayout.Height + 1, }; this.midFrameLayout.AddChidren(midVerticalRefreshLayout); midVerticalRefreshLayout.BeginHeaderRefreshingAction += () => ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceListMainForm.cs
@@ -270,6 +270,8 @@ rowMenu.frameTable.ButtonClickEvent += (sender, e) => { //隐藏菜单 rowMenu.HideMenu(); //强制跳转真实设备界面 if (UserCenterResourse.HideOption.GotoRealDeviceForm == 1) { @@ -378,6 +380,8 @@ rowDevice.frameTable.ButtonClickEvent += (sender, e) => { //隐藏菜单 rowDevice.HideMenu(); //界面跳转,记录当前的正在操作的设备的Mac地址 this.nowActionDeviceMac = device.DeviceAddr; //显示设备功能配置界面 ZigbeeApp/Shared/Phone/UserCenter/Device/Panel/PanelFangyueFreshAirButtonSettionForm.cs
@@ -87,7 +87,27 @@ private void InitMenuRow() { this.listview.RemoveAll(); //添加新风目标 this.AddFreshAirRow(); //PM2.5来源 //this.AddPMRow(); //添加温度来源 //this.AddTemperatureSensorRow(); //添加湿度来源 //this.AddHumiditySourceRow(); //添加新风目标 //this.AddPMRow(); //亮度调节 this.AddLevelRow(); } #endregion #region ■ 新风目标_________________________ /// <summary> /// 新风目标行 /// </summary> private void AddFreshAirRow() { //新风目标 var rowNewWind = new FrameRowControl(listview.rowSpace / 2); listview.AddChidren(rowNewWind); @@ -97,14 +117,107 @@ //右箭头 rowNewWind.AddRightArrow(); var msg = Language.StringByID(R.MyInternationalizationString.nothing); // 回调新风个数 // 回调新风绑定目标 var btnNewWindStatu = rowNewWind.AddMostRightView(msg, 700); rowNewWind.ButtonClickEvent += (sender, e) => { var form = new PanelFangyueFreshAirTargetForm(); form.AddForm(this.deviceObj, string.Empty, 3); //var addDevicePage = new Shared.Phone.UserCenter.DeviceBind.PanelFangyueFreshAirTargetsForm(this.deviceObj, 1); //Shared.Phone.UserView.HomePage.Instance.AddChidren(addDevicePage); //Shared.Phone.UserView.HomePage.Instance.PageIndex += 1; //addDevicePage.Show(); var form = new PanelFangyueFreshAirTargetForm(); form.AddForm(this.deviceObj, string.Empty, 3); }; } #endregion #region ■ PM2.5来源_________________________ /// <summary> /// PM2.5来源行 /// </summary> private void AddPMRow() { //PM2.5 var rowNewWind = new FrameRowControl(listview.rowSpace / 2); listview.AddChidren(rowNewWind); rowNewWind.AddLeftCaption(Language.StringByID(R.MyInternationalizationString.PM25Source), 600); //底线 rowNewWind.AddBottomLine(); //右箭头 rowNewWind.AddRightArrow(); var msg = Language.StringByID(R.MyInternationalizationString.nothing); // 回调PM2.5来源绑定目标 var btnNewWindStatu = rowNewWind.AddMostRightView(msg, 700); rowNewWind.ButtonClickEvent += (sender, e) => { var addDevicePage = new Shared.Phone.UserCenter.DeviceBind.PanelFangyueFreshAirTargetsForm(this.deviceObj, 4); Shared.Phone.UserView.HomePage.Instance.AddChidren(addDevicePage); Shared.Phone.UserView.HomePage.Instance.PageIndex += 1; addDevicePage.Show(); }; } #endregion #region ■ 温度来源_________________________ /// <summary> /// 温度来源行 /// </summary> private void AddTemperatureSensorRow() { //温度来源 var rowNewWind = new FrameRowControl(listview.rowSpace / 2); listview.AddChidren(rowNewWind); rowNewWind.AddLeftCaption(Language.StringByID(R.MyInternationalizationString.TemperatureSource), 600); //底线 rowNewWind.AddBottomLine(); //右箭头 rowNewWind.AddRightArrow(); var msg = Language.StringByID(R.MyInternationalizationString.nothing); // 回调温度来源绑定目标 var btnNewWindStatu = rowNewWind.AddMostRightView(msg, 700); rowNewWind.ButtonClickEvent += (sender, e) => { var addDevicePage = new Shared.Phone.UserCenter.DeviceBind.PanelFangyueFreshAirTargetsForm(this.deviceObj, 2); Shared.Phone.UserView.HomePage.Instance.AddChidren(addDevicePage); Shared.Phone.UserView.HomePage.Instance.PageIndex += 1; addDevicePage.Show(); }; } #endregion #region ■ 湿度来源_________________________ /// <summary> /// 湿度来源行 /// </summary> private void AddHumiditySourceRow() { //湿度 var rowNewWind = new FrameRowControl(listview.rowSpace / 2); listview.AddChidren(rowNewWind); rowNewWind.AddLeftCaption(Language.StringByID(R.MyInternationalizationString.HumiditySource), 600); //底线 rowNewWind.AddBottomLine(); //右箭头 rowNewWind.AddRightArrow(); var msg = Language.StringByID(R.MyInternationalizationString.nothing); // 回调湿度来源绑定目标 var btnNewWindStatu = rowNewWind.AddMostRightView(msg, 700); rowNewWind.ButtonClickEvent += (sender, e) => { var addDevicePage = new Shared.Phone.UserCenter.DeviceBind.PanelFangyueFreshAirTargetsForm(this.deviceObj, 3); Shared.Phone.UserView.HomePage.Instance.AddChidren(addDevicePage); Shared.Phone.UserView.HomePage.Instance.PageIndex += 1; addDevicePage.Show(); }; } #endregion #region ■ 亮度调节_________________________ /// <summary> /// 亮度调节行 /// </summary> private void AddLevelRow() { //亮度调节 var rowLight = new FrameRowControl(listview.rowSpace / 2); listview.AddChidren(rowLight); ZigbeeApp/Shared/Phone/UserCenter/Device/Panel/PanelFangyueFreshAirTargetsForm.cs
New file @@ -0,0 +1,1345 @@ using System; using System.Collections.Generic; using System.Linq.Expressions; using Shared.Common; using Shared.Phone.UserCenter.Safety; using ZigBee.Device; using static ZigBee.Device.BindObj; using static ZigBee.Device.Panel; namespace Shared.Phone.UserCenter.DeviceBind { public class PanelFangyueFreshAirTargetsForm : BindCommonLayout { #region 构造函数 /// <summary> /// 构造函数 /// </summary> /// <param name="device"></param> /// <param name="deviceBindType">1:新风;2:温度传感器;3:湿度传感器</param> public PanelFangyueFreshAirTargetsForm(CommonDevice device, int deviceBindType) { this.curControlDev = device as FreshAir; this.curDeviceBindType = deviceBindType; } #endregion #region 变量申明 /// <summary> /// 当前控制设备 /// </summary> //CommonDevice currentControlDevice; /// <summary> /// 当前新风面板【控制设备】 /// </summary> FreshAir curControlDev; /// <summary> /// 显示被绑定设备或场景的view /// </summary> VerticalFrameRefreshControl midVerticalScrolViewLayout; /// <summary> /// 显示房间的view /// </summary> HorizontalScrolViewLayout btnHorizontalScrolViewLayout; /// <summary> /// 按键配置的目标列表 /// </summary> List<CommonDevice> targetList = new List<CommonDevice>(); /// <summary> /// 面板中已经存在的目标列表 /// </summary> List<CommonDevice> oldTargetList = new List<CommonDevice>(); /// <summary> /// 当前设备绑定类型 /// 1:新风 /// 2:温度传感器 /// 3:湿度传感器 /// 4:PM2.5传感器 /// </summary> int curDeviceBindType = 0; /// <summary> /// 本地房间列表 /// </summary> List<Room> supportRoomList = new List<Room>(); /// <summary> /// 当绑定表变化后的回调 /// </summary> public Action<List<BindListResponseObj>> action; /// <summary> /// 保存完成按钮 /// </summary> Button btnFinifh; /// <summary> /// 楼层文本 /// </summary> Button btnFloorText; /// <summary> /// 楼层列表 /// </summary> Dictionary<string, string> dicFloorList; /// <summary> /// 所有房间中支持被绑定的设备列表 /// </summary> List<CommonDevice> currentPanelSupportBindDeviceList = new List<CommonDevice>(); /// <summary> /// 当前房间中支持被绑定的设备列表 /// </summary> List<CommonDevice> currentRoomSupportBindDeviceList = new List<CommonDevice>(); /// <summary> /// 面板中存在的键值 /// </summary> List<String> panelBindListKey = null; #endregion #region UI设计 /// <summary> /// 目标页显示 /// </summary> public void Show() { #region 标题栏 string titleText = ""; switch (curDeviceBindType) { case 1: titleText = Language.StringByID(R.MyInternationalizationString.BindFreshAirTarget); break; case 2: titleText = Language.StringByID(R.MyInternationalizationString.TemperatureSource); break; case 3: titleText = Language.StringByID(R.MyInternationalizationString.HumiditySource); break; case 4: titleText = Language.StringByID(R.MyInternationalizationString.PM25Source); break; } this.TopFrameLayout(this, titleText); EventHandler<MouseEventArgs> eHandlerBack = (sender, e) => { RemoveFromParent(); }; this.btnTitle.Width = Application.GetRealWidth(1080 - 161 - 200 - 58); this.btnBack.MouseUpEventHandler += eHandlerBack; this.btnBackFrameLayout.MouseUpEventHandler += eHandlerBack; this.MidFrameLayout(this); #endregion //添加楼层UI BindDownFrameLayout(); //标题栏下的UI MidFrameLayoutContent(); //初始化设备数据 InitData(); } /// <summary> /// 添加楼层UI /// </summary> void BindDownFrameLayout() { var btnAddFrameLayout = new FrameLayout { X = Application.GetRealWidth(830), }; this.titleFrameLayout.AddChidren(btnAddFrameLayout); btnFloorText = new Button { Width = Application.GetRealWidth(110), X = Application.GetRealWidth(15), Text = Language.StringByID(R.MyInternationalizationString.FirstFloor), TextColor = Shared.Common.ZigbeeColor.Current.XMBlack, TextSize = 14, IsBold = true, TextAlignment = TextAlignment.CenterRight, }; btnAddFrameLayout.AddChidren(btnFloorText); var btnBindDown = new Button { Height = Application.GetMinReal(69), Width = Application.GetMinReal(69), X = Application.GetRealWidth(200 - 77), UnSelectedImagePath = "BindPic/BindDown.png", Gravity = Gravity.CenterVertical, }; btnAddFrameLayout.AddChidren(btnBindDown); btnBindDown.MouseDownEventHandler += (sender, e) => { SideslipFramelayout(); }; if (Common.Config.Instance.Home.FloorDics.Count == 0) { btnAddFrameLayout.Width = 0; } else { btnAddFrameLayout.Width = Application.GetRealWidth(200); } } /// <summary> /// 中部UI【标题栏下的UI】 /// </summary> async void MidFrameLayoutContent() { var btnMidTopLayout = new FrameLayout { Height = Application.GetRealHeight(389 - 184), }; this.midFrameLayout.AddChidren(btnMidTopLayout); //房间栏 btnHorizontalScrolViewLayout = new HorizontalScrolViewLayout { X = Application.GetRealWidth(58), }; btnMidTopLayout.AddChidren(btnHorizontalScrolViewLayout); //设备栏 midVerticalScrolViewLayout = new VerticalFrameRefreshControl() { Y = btnMidTopLayout.Bottom, Height = Application.GetRealHeight(1145), }; this.midFrameLayout.AddChidren(midVerticalScrolViewLayout); //底部保存栏 var bottomFrameLayout = new FrameLayout() { Width = LayoutParams.MatchParent, Height = Application.GetRealHeight(127), Y = Application.GetRealHeight(1472), }; this.midFrameLayout.AddChidren(bottomFrameLayout); btnFinifh = new Button() { Width = Application.GetRealWidth(907), Gravity = Gravity.CenterHorizontal, Radius = (uint)Application.GetRealHeight(127) / 2, TextID = R.MyInternationalizationString.Save, BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack, TextColor = Shared.Common.ZigbeeColor.Current.XMWhite, IsBold = true, TextSize = 16, }; bottomFrameLayout.AddChidren(btnFinifh); btnFinifh.MouseUpEventHandler += async (sender, e) => { SaveTarget(); }; } /// <summary> /// 面板绑定目标表显示 /// </summary> /// <param name="gateway">Gateway.</param> /// <param name="key">Key.</param> void RefreshRoomList(Room curRoom, ref int index2) { if (supportRoomList.Count == 0) { return; } btnHorizontalScrolViewLayout.RemoveAll(); Button curentOldRoom = null; FrameLayout curentOldRoomFrameLayout = null; int index = 0; var roomTempList = GetSupportRoomList(curRoom); for (int i = 0; i < roomTempList.Count; i++) { var room = roomTempList[i]; //房间 var btnRoomFrameLayout = new FrameLayout { Height = Application.GetMinReal(159), Width = Application.GetMinReal(255), Y = Application.GetRealHeight(23), X = Application.GetRealWidth(5), BackgroundImagePath = "Item/RoomIconBackground.png", BorderWidth = 1, }; btnHorizontalScrolViewLayout.AddChidren(btnRoomFrameLayout); var btnRoom = new Button { Height = Application.GetRealHeight(58), Width = Application.GetRealWidth(127), Y = Application.GetRealHeight(58), X = Application.GetRealWidth(14), Text = room.Name, TextSize = 12, TextColor = Shared.Common.ZigbeeColor.Current.XMGray3, Gravity = Gravity.Center, }; btnRoomFrameLayout.AddChidren(btnRoom); btnRoom.IsSelected = false; if (index == 0) { btnRoomFrameLayout.BackgroundImagePath = "Item/RoomIconBackgroundSelected.png"; btnRoom.TextColor = Shared.Common.ZigbeeColor.Current.XMWhite; curentOldRoom = btnRoom; curentOldRoomFrameLayout = btnRoomFrameLayout; } EventHandler<MouseEventArgs> eHandlerRoom = (sender, e) => { //ChangeRoom(curRoom, room, btnRoom, curentOldRoom, btnRoomFrameLayout, curentOldRoomFrameLayout); if (!btnRoom.IsSelected) { if (curentOldRoom != null) { curentOldRoom.TextColor = Shared.Common.ZigbeeColor.Current.XMGray3; } curentOldRoom = btnRoom; curentOldRoom.TextColor = Shared.Common.ZigbeeColor.Current.XMWhite; } if (btnRoomFrameLayout.BorderWidth == 1) { if (curentOldRoomFrameLayout != null) { curentOldRoomFrameLayout.BorderWidth = 1; curentOldRoomFrameLayout.BorderColor = Shared.Common.ZigbeeColor.Current.XMOrange; curentOldRoomFrameLayout.BackgroundImagePath = "Item/RoomIconBackground.png"; } curentOldRoomFrameLayout = btnRoomFrameLayout; curentOldRoomFrameLayout.BorderWidth = 0; curentOldRoomFrameLayout.BackgroundImagePath = "Item/RoomIconBackgroundSelected.png"; } curRoom = room; curControlDev.RoomId = room.Id; if (curRoom.ListSceneId.Count == 0) { btnFinifh.Enable = false; btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMUnSelect; } else { btnFinifh.Enable = true; btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack; } if (targetList.Count == 0) { btnFinifh.Enable = false; btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMUnSelect; } else { btnFinifh.Enable = true; btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack; } RefreshDeviceList(curRoom); }; btnRoom.MouseUpEventHandler += eHandlerRoom; btnRoomFrameLayout.MouseUpEventHandler += eHandlerRoom; index++; } BindInfo.FinishDisplay(roomTempList, btnFinifh); } /// <summary> /// 按键绑目标表显示 /// </summary> /// <param name="curRoom"></param> void RefreshDeviceList(Room curRoom) { midVerticalScrolViewLayout.RemoveAll(); Button oldDevice = null; int curIndex = 0; currentRoomSupportBindDeviceList = GetCurRoomSupportDeviceList(curRoom); if (currentRoomSupportBindDeviceList.Count == 0) { btnFinifh.Enable = false; btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMUnSelect; return; } foreach (var device in currentRoomSupportBindDeviceList) { #region 绑定表UI显(无数据处理) var rowLayout = new FrameLayout() { Height = Application.GetRealHeight(23 + 127), BackgroundColor = Shared.Common.ZigbeeColor.Current.XMWhite, }; midVerticalScrolViewLayout.AddChidren(rowLayout); var devicePic = new Button() { X = Application.GetMinRealAverage(58), Y = Application.GetMinRealAverage(46), Width = Application.GetMinRealAverage(81), Height = Application.GetMinRealAverage(81), UnSelectedImagePath = device.IconPath, }; rowLayout.AddChidren(devicePic); var btnBindName = new Button() { Width = Application.GetRealWidth(790), X = devicePic.Right + Application.GetRealWidth(20), TextColor = Shared.Common.ZigbeeColor.Current.TextBlack, TextAlignment = TextAlignment.CenterLeft, TextSize = 15, Text = Common.LocalDevice.Current.GetDeviceEpointName(device), }; rowLayout.AddChidren(btnBindName); var btnChoose = new Button() { Width = Application.GetMinReal(60), Height = Application.GetMinReal(60), X = Application.GetRealWidth(861 + 81), Y = Application.GetRealHeight(35), SelectedImagePath = "DoorLock/SelectedIcon.png", Visible = false, }; rowLayout.AddChidren(btnChoose); var line2 = new Button() { Y = rowLayout.Height - 1, X = devicePic.Right + Application.GetRealWidth(20), Width = Application.GetRealWidth(965 - 116), Height = 1, BackgroundColor = Shared.Common.ZigbeeColor.Current.XMRowLine, }; rowLayout.AddChidren(line2); if (curIndex == currentPanelSupportBindDeviceList.Count - 1) { line2.Visible = false; } #endregion string mianKey = device.DeviceAddr + device.DeviceEpoint; if (targetList.Count != 0) { // if(curControlDev!=null) // { // foreach (var bindedSc in curControlDev.bindList) // { // if (bindedSc.BindMacAddr + bindedSc.BindEpoint == mianKey) // { // btnChoose.IsSelected = true; // btnChoose.Visible = true; // oldDevice = btnChoose; // targetList.Add(device); // } // } // } //} //else //{ foreach (var bindedDev in targetList) { if (bindedDev.DeviceAddr + bindedDev.DeviceEpoint == mianKey) { btnChoose.IsSelected = true; btnChoose.Visible = true; oldDevice = btnChoose; } } } EventHandler<MouseEventArgs> hander = (sender, e) => { //ChangeTarget(device, btnChoose, oldDevice); if (curControlDev.bindList.Count != 0) { if (btnChoose.IsSelected) { new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.BindExist), Direction = AMPopTipDirection.None, CloseTime = 1 }.Show(CommonPage.Instance); return; } } if (!btnChoose.IsSelected) { if (oldDevice != null) { oldDevice.IsSelected = false; oldDevice.Visible = false; } oldDevice = btnChoose; oldDevice.IsSelected = true; oldDevice.Visible = true; targetList.Clear(); targetList.Add(device); } if (targetList.Count == 0) { btnFinifh.Enable = false; btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMUnSelect; } else { btnFinifh.Enable = true; btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack; } }; rowLayout.MouseUpEventHandler += hander; devicePic.MouseUpEventHandler += hander; btnBindName.MouseUpEventHandler += hander; btnChoose.MouseUpEventHandler += hander; curIndex++; } if (targetList.Count == 0) { btnFinifh.Enable = false; btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMUnSelect; } else { btnFinifh.Enable = true; btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack; } } /// <summary> /// 楼层选择的侧边栏 /// </summary> void SideslipFramelayout() { var dialog = new Dialog { }; dialog.Show(); var flMain = new FrameLayout { BackgroundColor = 0x00000000 }; dialog.AddChidren(flMain); flMain.MouseUpEventHandler += (sender11, e11) => { dialog.Close(); }; var sidelipFrameLayout = new FrameLayout() { Height = Application.GetMinReal(783), Width = Application.GetMinReal(449), Y = Application.GetRealHeight(161), X = Application.GetRealWidth(596), BackgroundImagePath = "DoorLock/SideslipPic.png", }; flMain.AddChidren(sidelipFrameLayout); var btnSelectFloor = new Button() { Width = Application.GetRealWidth(200), Height = Application.GetRealHeight(58), X = Application.GetRealWidth(81), Y = Application.GetRealHeight(81), TextColor = Shared.Common.ZigbeeColor.Current.XMBlack, TextSize = 14, IsBold = true, TextAlignment = TextAlignment.CenterLeft, TextID = R.MyInternationalizationString.SelectFloor, }; sidelipFrameLayout.AddChidren(btnSelectFloor); var sidelipVerticalScrolViewLayout = new VerticalScrolViewLayout() { Height = Application.GetRealHeight(600), Y = btnSelectFloor.Bottom, }; sidelipFrameLayout.AddChidren(sidelipVerticalScrolViewLayout); Button oldbutton = null; Button oldbuttonText = null; foreach (var floorId in dicFloorList.Keys) { var rowFrameLayout = new RowLayout() { Height = Application.GetRealHeight(150), LineColor = Shared.Common.ZigbeeColor.Current.XMRowLine, X = Application.GetRealWidth(81), }; sidelipVerticalScrolViewLayout.AddChidren(rowFrameLayout); var btnAllMethod = new Button() { Width = Application.GetMinReal(81), Height = Application.GetMinReal(81), Y = Application.GetRealHeight(55), UnSelectedImagePath = "Floor/Floor.png", SelectedImagePath = "Floor/FloorSelected.png", }; rowFrameLayout.AddChidren(btnAllMethod); var btnMethodText = new Button() { Width = Application.GetRealWidth(311), Height = Application.GetRealHeight(58), X = Application.GetRealWidth(92), Y = Application.GetRealHeight(69), TextColor = Shared.Common.ZigbeeColor.Current.XMGray3, TextSize = 14, TextAlignment = TextAlignment.CenterLeft, Text = dicFloorList[floorId], }; rowFrameLayout.AddChidren(btnMethodText); if (curControlDev.currentSelectFloorId == floorId) { btnAllMethod.IsSelected = true; btnAllMethod.IsBold = true; btnMethodText.TextColor = Shared.Common.ZigbeeColor.Current.XMBlack; } EventHandler<MouseEventArgs> hander = (sender, e) => { //ChangeFloor(dialog, floorId, btnMethodText, oldbuttonText, oldbutton); var curFloorId = floorId; curControlDev.currentSelectFloorId = curFloorId; btnFloorText.Text = dicFloorList[curFloorId]; if (curControlDev.currentSelectFloorId == curFloorId) { return; } curControlDev.currentSelectFloorId = curFloorId; btnFloorText.Text = dicFloorList[curFloorId]; //获取楼层中房间列表 supportRoomList = GetFloorRoomList(); if (supportRoomList.Count == 0) { return; } var curRoom = new Room(); if (supportRoomList.Count != 0) { curRoom = supportRoomList[0]; } else { curRoom = new Shared.Common.Room(); supportRoomList.Add(curRoom); } if (!btnMethodText.IsSelected) { if (oldbutton != null) { oldbutton.IsSelected = false; } if (oldbuttonText != null) { oldbuttonText.TextColor = Shared.Common.ZigbeeColor.Current.XMGray3; } oldbutton = btnMethodText; oldbuttonText = btnMethodText; btnMethodText.IsSelected = true; oldbuttonText.TextColor = Shared.Common.ZigbeeColor.Current.XMBlack; oldbuttonText.IsBold = true; } int index = 0; RefreshRoomList(curRoom, ref index); if (targetList.Count == 0) { btnFinifh.Enable = false; btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMUnSelect; } else { btnFinifh.Enable = true; btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack; } dialog.Close(); }; btnAllMethod.MouseUpEventHandler += hander; rowFrameLayout.MouseUpEventHandler += hander; btnMethodText.MouseUpEventHandler += hander; } } #endregion #region 数据处理 /// <summary> /// 初始化设备数据 /// </summary> void InitData() { System.Threading.Tasks.Task.Run(async () => { try { Application.RunOnMainThread(() => { CommonPage.Loading.Start(""); }); //获取楼层 dicFloorList = HdlRoomLogic.Current.GetFloorSortList(); curControlDev.currentSelectFloorId = BindInfo.GetCurrentSelectFloorId(); if (BindInfo.GetCurrentSelectFloorIdName() != null) { btnFloorText.Text = BindInfo.GetCurrentSelectFloorIdName(); } //获取楼层中房间列表 supportRoomList = GetFloorRoomList(); if (supportRoomList.Count == 0) { return; } //获取所有房间中匹配的能绑的目标 currentPanelSupportBindDeviceList = GetAllRoomSupportDeviceList(); //获取面板中存在的绑定目标 var panelBindListRes = await this.curControlDev.GetDeviceBindAsync(); if (panelBindListRes != null && panelBindListRes.getAllBindResponseData != null) { curControlDev.bindList.Clear(); foreach (var bDev in panelBindListRes.getAllBindResponseData.BindList) { curControlDev.bindList.Add(bDev); } } else { Application.RunOnMainThread(() => { CommonPage.Loading.Hide(); midVerticalScrolViewLayout.EndHeaderRefreshing(); new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.GwResponseOvertime), Direction = AMPopTipDirection.None, CloseTime = 1 }.Show(Common.CommonPage.Instance); }); } targetList.Clear(); //选中目标列表 targetList if (currentPanelSupportBindDeviceList.Count != 0 && curControlDev.bindList.Count != 0) { foreach (var bindDev in currentPanelSupportBindDeviceList) { var mainKey = bindDev.DeviceAddr + bindDev.DeviceEpoint; var dev = curControlDev.bindList.Find(obj => (obj != null) && (obj.BindMacAddr + obj.BindEpoint == mainKey)); if (dev != null) { var device = LocalDevice.Current.GetDevice(bindDev.DeviceAddr, bindDev.DeviceEpoint); if (device != null) { //获取设备类型的 var deviceEnumInfo = Common.LocalDevice.Current.GetMyDeviceEnumInfo(new List<CommonDevice>() { device }); //新风面板的新风设备,则不显示 if (deviceEnumInfo.ConcreteType == Common.DeviceConcreteType.ButtonPanel_FangyueFreshAir) { continue; } if (device.Type == DeviceType.FreshAir) { targetList.Add(device); oldTargetList.Add(device); } } } } } } catch { } finally { Application.RunOnMainThread(() => { if (supportRoomList.Count != 0) { Shared.Common.Room curRoom = supportRoomList[0]; int index = 0; RefreshRoomList(curRoom, ref index); RefreshDeviceList(curRoom); if (curRoom.ListDevice.Count == 0 || targetList.Count == 0) { btnFinifh.Enable = false; btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMUnSelect; } else { btnFinifh.Enable = true; btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack; } } CommonPage.Loading.Hide(); }); } }); } /// <summary> /// 切换楼层 /// </summary> /// <param name="dialog"></param> /// <param name="curFloorId"></param> /// <param name="btnMethodText"></param> /// <param name="oldbuttonText"></param> /// <param name="oldbutton"></param> void ChangeFloor(Dialog dialog, string curFloorId, Button btnMethodText, Button oldbuttonText, Button oldbutton) { if (curControlDev.currentSelectFloorId == curFloorId) { return; } curControlDev.currentSelectFloorId = curFloorId; btnFloorText.Text = dicFloorList[curFloorId]; //获取楼层中房间列表 supportRoomList = GetFloorRoomList(); if (supportRoomList.Count == 0) { return; } var curRoom = new Room(); if (supportRoomList.Count != 0) { curRoom = supportRoomList[0]; } else { curRoom = new Shared.Common.Room(); supportRoomList.Add(curRoom); } if (!btnMethodText.IsSelected) { if (oldbutton != null) { oldbutton.IsSelected = false; } if (oldbuttonText != null) { oldbuttonText.TextColor = Shared.Common.ZigbeeColor.Current.XMGray3; } oldbutton = btnMethodText; oldbuttonText = btnMethodText; btnMethodText.IsSelected = true; oldbuttonText.TextColor = Shared.Common.ZigbeeColor.Current.XMBlack; oldbuttonText.IsBold = true; } int index = 0; RefreshRoomList(curRoom, ref index); if (targetList.Count == 0) { btnFinifh.Enable = false; btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMUnSelect; } else { btnFinifh.Enable = true; btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack; } dialog.Close(); } /// <summary> /// 切换房间 /// </summary> /// <param name="curRoom"></param> /// <param name="room"></param> /// <param name="btnRoom"></param> /// <param name="curentOldRoom"></param> /// <param name="btnRoomFrameLayout"></param> /// <param name="curentOldRoomFrameLayout"></param> void ChangeRoom(Room curRoom, Room room, Button btnRoom, Button curentOldRoom, FrameLayout btnRoomFrameLayout, FrameLayout curentOldRoomFrameLayout) { if (!btnRoom.IsSelected) { if (curentOldRoom != null) { curentOldRoom.TextColor = Shared.Common.ZigbeeColor.Current.XMGray3; } curentOldRoom = btnRoom; curentOldRoom.TextColor = Shared.Common.ZigbeeColor.Current.XMWhite; } if (btnRoomFrameLayout.BorderWidth == 1) { if (curentOldRoomFrameLayout != null) { curentOldRoomFrameLayout.BorderWidth = 1; curentOldRoomFrameLayout.BorderColor = Shared.Common.ZigbeeColor.Current.XMOrange; curentOldRoomFrameLayout.BackgroundImagePath = "Item/RoomIconBackground.png"; } curentOldRoomFrameLayout = btnRoomFrameLayout; curentOldRoomFrameLayout.BorderWidth = 0; curentOldRoomFrameLayout.BackgroundImagePath = "Item/RoomIconBackgroundSelected.png"; } curRoom = room; curControlDev.RoomId = room.Id; if (curRoom.ListSceneId.Count == 0) { btnFinifh.Enable = false; btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMUnSelect; } else { btnFinifh.Enable = true; btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack; } if (targetList.Count == 0) { btnFinifh.Enable = false; btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMUnSelect; } else { btnFinifh.Enable = true; btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack; } RefreshDeviceList(curRoom); } /// <summary> /// 切换绑定目标 /// </summary> void ChangeTarget(CommonDevice device, Button btnChoose, Button oldDevice) { if (curControlDev.bindList.Count != 0) { if (btnChoose.IsSelected) { new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.BindExist), Direction = AMPopTipDirection.None, CloseTime = 1 }.Show(CommonPage.Instance); return; } } if (!btnChoose.IsSelected) { if (oldDevice != null) { oldDevice.IsSelected = false; oldDevice.Visible = false; } oldDevice = btnChoose; oldDevice.IsSelected = true; oldDevice.Visible = true; targetList.Clear(); targetList.Add(device); } if (targetList.Count == 0) { btnFinifh.Enable = false; btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMUnSelect; } else { btnFinifh.Enable = true; btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack; } } /// <summary> /// 保存目标 /// </summary> /// <param name="curControlDev"></param> void SaveTarget() { bool isFinish = false; //空目标 if (targetList.Count == 0) { Application.RunOnMainThread(() => { var myTip = new Tip(); myTip.Direction = AMPopTipDirection.None; myTip.CloseTime = 2; myTip.Text = Language.StringByID(R.MyInternationalizationString.BindDeviceTargetIsEmpty); myTip.Show(Common.CommonPage.Instance); }); return; } else { //已经绑定过的目标 if (checkExistDevice()) { Application.RunOnMainThread(() => { var myTip = new Tip(); myTip.Direction = AMPopTipDirection.None; myTip.CloseTime = 2; myTip.Text = Language.StringByID(R.MyInternationalizationString.BindExist); myTip.Show(Common.CommonPage.Instance); }); return; } System.Threading.Tasks.Task.Run(async () => { try { Application.RunOnMainThread(() => { CommonPage.Loading.Start(""); }); //删除已经存在的目标 if (oldTargetList.Count != 0) { foreach (var bd in oldTargetList) { await RemoveTargets(bd); } } //添加新的目标 var addBindeDev = new AddBindData(); addBindeDev.DeviceAddr = curControlDev.DeviceAddr; addBindeDev.Epoint = curControlDev.DeviceEpoint; foreach (var de in targetList) { var addBindInfo = new AddBindListObj(); switch (curDeviceBindType) { case 1: addBindInfo.BindCluster = 514; break; case 2: addBindInfo.BindCluster = 1026; break; case 3: addBindInfo.BindCluster = 1029; break; } addBindInfo.BindType = 0; addBindInfo.BindMacAddr = de.DeviceAddr; addBindInfo.BindEpoint = de.DeviceEpoint; addBindeDev.BindList.Add(addBindInfo); } var dev = new AddedDeviceBindResponseAllData(); dev = await curControlDev.AddDeviceBindAsync(addBindeDev); if (dev.addedDeviceBindResponseData == null) { Application.RunOnMainThread(() => { CommonPage.Loading.Hide(); new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.GwResponseOvertime), Direction = AMPopTipDirection.None, CloseTime = 1 }.Show(CommonPage.Instance); }); btnFinifh.Enable = true; btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack; return; } else { if (dev.addedDeviceBindResponseData.Result == 0) { curControlDev.bindList = dev.addedDeviceBindResponseData.BindList; targetList.Clear(); isFinish = true; if (isFinish) { if (action != null) { action(curControlDev.bindList); } this.RemoveFromParent(); } else { this.RemoveFromParent(); } Application.RunOnMainThread(() => { CommonPage.Loading.Hide(); btnFinifh.Enable = true; btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack; }); } else if (dev.addedDeviceBindResponseData.Result == 1) { Application.RunOnMainThread(() => { CommonPage.Loading.Hide(); new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.BindFailed), Direction = AMPopTipDirection.None, CloseTime = 1 }.Show(CommonPage.Instance); }); btnFinifh.Enable = true; btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack; return; } else { Application.RunOnMainThread(() => { CommonPage.Loading.Hide(); new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.BindUnknownError), Direction = AMPopTipDirection.None, CloseTime = 1 }.Show(CommonPage.Instance); }); btnFinifh.Enable = true; btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack; return; } } } catch { } }); } } /// <summary> /// 删除存在的目标 /// </summary> /// <param name="bindDevice"></param> /// <param name="btnDel"></param> /// <returns></returns> private async System.Threading.Tasks.Task<int> RemoveTargets(CommonDevice delDev) { var delDevice = new DelDeviceBindData(); delDevice.DeviceAddr = curControlDev.DeviceAddr; delDevice.Epoint = curControlDev.DeviceEpoint; var removeDevice = new RemoveBindListObj(); removeDevice.BindType = 0; switch (curDeviceBindType) { case 1: removeDevice.BindCluster = 514; break; case 2: removeDevice.BindCluster = 1026; break; case 3: removeDevice.BindCluster = 1029; break; } removeDevice.BindMacAddr = delDev.DeviceAddr; removeDevice.BindEpoint = delDev.DeviceEpoint; delDevice.RemoveBindList.Add(removeDevice); try { CommonPage.Loading.Start(""); var delResult = new DelDeviceBindResponseAllData(); delResult = await curControlDev.DelDeviceBindAsync(delDevice); if (delResult != null && delResult.delDeviceBindResponseData != null) { if (delResult.delDeviceBindResponseData?.RemoveBindList != null) { foreach (var re in delResult.delDeviceBindResponseData.RemoveBindList) { switch (re.Result) { case 0: return 0; break; case 1: return 1; break; case 2: return 2; break; } } } } } catch { } return -1; } /// <summary> /// 检测目标是否被绑定过 /// </summary> /// <returns></returns> private bool checkExistDevice() { bool exist = false; foreach (var oldDev in oldTargetList) { var key = oldDev.DeviceAddr + oldDev.DeviceEpoint; var result = targetList.Find(obj => (obj != null) && (obj.DeviceAddr + obj.DeviceEpoint == key)); if (result != null) { exist = true; } else { exist = false; } } return exist; } /// <summary> /// 能显示的房间列表 /// </summary> private List<Room> GetSupportRoomList(Room curRoom) { var roomTempList = new List<Room>(); for (int i = 0; i < supportRoomList.Count; i++) { var room = supportRoomList[i]; //如果房间为喜爱[后来改名为常用房间],则不显示 if (room.IsLove == true) { continue; } //如果房间中没有设备,则不显示 if (room.ListDevice.Count == 0) { continue; } roomTempList.Add(room); if (roomTempList.Count != 0) { curRoom = roomTempList[0]; } } return roomTempList; } /// <summary> /// 获取楼层对应的房间列表 /// </summary> /// <returns></returns> private List<Room> GetFloorRoomList() { supportRoomList.Clear(); var supportRoomListTemp = new List<Room>(); var listAllRoom = HdlRoomLogic.Current.GetAllListRooms(); if (Common.Config.Instance.Home.FloorDics.Count == 0) { // 获取没有楼层房间 foreach (var room in listAllRoom) { if (string.IsNullOrEmpty(room.FloorId)) { if (room.IsLove) { continue; } supportRoomListTemp.Add(room); } } } else { // 获取楼层对应对房间 foreach (var room in listAllRoom) { if (room.FloorId == curControlDev.currentSelectFloorId) { if (room.IsLove) { continue; } supportRoomListTemp.Add(room); } } } return supportRoomListTemp; } /// <summary> /// 房间中匹配的支持绑定的所有目标列表 /// </summary> /// <returns></returns> List<CommonDevice> GetAllRoomSupportDeviceList() { currentPanelSupportBindDeviceList.Clear(); List<CommonDevice> currentPanelBindSupportDeviceListTemp = new List<CommonDevice>(); switch (curDeviceBindType) { case 1: foreach (var r in supportRoomList) { if (r.ListDevice.Count == 0) { continue; } foreach (var deviceKeys in r.ListDevice) { var device = LocalDevice.Current.GetDevice(deviceKeys); if (device != null) { ////获取设备类型的 //var deviceEnumInfo = Common.LocalDevice.Current.GetMyDeviceEnumInfo(new List<CommonDevice>() { device }); ////新风面板的新风设备,则不显示 //if (deviceEnumInfo.ConcreteType == Common.DeviceConcreteType.ButtonPanel_FangyueFreshAir) //{ // continue; //} if (device.Type == DeviceType.FreshAir) { currentPanelBindSupportDeviceListTemp.Add(device); } } } } break; case 2: break; case 3: break; case 4: break; } return currentPanelBindSupportDeviceListTemp; } /// <summary> /// 获取当前房间中匹配的支持绑定的设备列表 /// </summary> /// <returns></returns> List<CommonDevice> GetCurRoomSupportDeviceList(Room curRoom) { currentRoomSupportBindDeviceList.Clear(); List<CommonDevice> curRoomDeviceListTemp = new List<CommonDevice>(); switch (curDeviceBindType) { case 1: foreach (var deviceKeys in curRoom.ListDevice) { var device = LocalDevice.Current.GetDevice(deviceKeys); if (device != null) { ////获取设备类型的 //var deviceEnumInfo = Common.LocalDevice.Current.GetMyDeviceEnumInfo(new List<CommonDevice>() { device }); ////新风面板的新风设备,则不显示 //if (deviceEnumInfo.ConcreteType == Common.DeviceConcreteType.ButtonPanel_FangyueFreshAir) //{ // continue; //} if (device.Type == DeviceType.FreshAir) { curRoomDeviceListTemp.Add(device); } } } break; case 2: break; case 3: break; case 4: break; } return curRoomDeviceListTemp; } #endregion } } ZigbeeApp/Shared/Phone/UserCenter/DoorLock/DoorLockCommonInfo.cs
@@ -908,9 +908,9 @@ string msg = Language.StringByID(R.MyInternationalizationString.NomallyModeIsCanceled).Replace("{0}", "\r\n"); var confirm = Language.StringByID(R.MyInternationalizationString.SureCancel); var alert = new ShowDoorLockMsgControl(ShowDoorLockMsgControl.DoorLockMsgType.NomallyOpenMode, msg, confirm); var HaveLogicNormallyOpenMode = await Shared.Phone.Device.Logic.SkipView.Exist(); var resTemp = await Shared.Phone.Device.Logic.SkipView.Exist(); if (HaveLogicNormallyOpenMode) if (resTemp == 1) { //有逻辑设置的弹窗 alert = new ShowDoorLockMsgControl(ShowDoorLockMsgControl.DoorLockMsgType.CancelNomallyOpenModeWithLogic, msg, confirm); @@ -1001,7 +1001,6 @@ { new Tip() { MaxWidth = 150, Text = msg2, Direction = AMPopTipDirection.None, CloseTime = 1 }.Show(CommonPage.Instance); }); Shared.Phone.Device.Logic.SkipView.LockCloseLogic(doorLock); } } action?.Invoke(); ZigbeeApp/Shared/Phone/UserCenter/DoorLock/UserDoorLockPage.cs
@@ -679,7 +679,15 @@ } NormallyOpenModeValue(tempRes); HaveLogicNormallyOpenMode = await Shared.Phone.Device.Logic.SkipView.Exist(); var resTemp = await Shared.Phone.Device.Logic.SkipView.Exist(); if (resTemp == 1) { HaveLogicNormallyOpenMode = true; } else if (resTemp == 0) { HaveLogicNormallyOpenMode = false; } Application.RunOnMainThread(() => { UpdateNomallyOpenStatus(); @@ -1092,9 +1100,14 @@ alertNomallyModeIsTurnOn.Show(); alertNomallyModeIsTurnOn.MsgControlClickEvent += async () => { //默认创建特殊逻辑 DoorLockCommonInfo.NormallyOpenModeInvalidTime = 12; Shared.Phone.Device.Logic.SkipView.LockAddModifyLogic(DoorLockCommonInfo.NormallyOpenModeInvalidTime, doorLock); //默认创建常开模式的特殊逻辑 var res = await Shared.Phone.Device.Logic.SkipView.LockAddModifyLogic(DoorLockCommonInfo.NormallyOpenModeInvalidTime, doorLock); if (!res) { string msg0 = Language.StringByID(R.MyInternationalizationString.AddLogicNormallyModeFailed); this.ShowTipMsg(msg0); return; } }; //点击自动化 @@ -1147,6 +1160,13 @@ //上报“常开模式”已被取消,app默认了“常开模式”被取消 NormallyOpenModeValue(false); UpdateNomallyOpenStatus(); //删除已经失效的“常开模式”的逻辑 var resTemp = await Shared.Phone.Device.Logic.SkipView.Exist(3); if (resTemp == 3) { string msg0 = Language.StringByID(R.MyInternationalizationString.CancelLogicNormallyModeFailed); this.ShowTipMsg(msg0); } } else { @@ -1159,8 +1179,17 @@ { if (IsFromReport) { //上报“常开模式”已被取消,app重新开启“常开模式” //上报“常开模式”已被取消 Application.RunOnMainThread(() => { CommonPage.Loading.Start(""); }); //先删除已失效的“常开模式”的逻辑 var resTemp = await Shared.Phone.Device.Logic.SkipView.Exist(3); if (resTemp == 3) { string msg0 = Language.StringByID(R.MyInternationalizationString.CancelLogicNormallyModeFailed); this.ShowTipMsg(msg0); return; } //app重新开启“常开模式” var result = await doorLock.SetNormallyOpenModeFuncAsync(true); if (result == null || result.defaultControlResponseData == null) { @@ -1183,6 +1212,15 @@ //保持“常开成功” NormallyOpenModeValue(true); UpdateNomallyOpenStatus(); //创建常开模式的特殊逻辑 var resu = await Shared.Phone.Device.Logic.SkipView.LockAddModifyLogic(DoorLockCommonInfo.NormallyOpenModeInvalidTime, doorLock); if (!resu) { string msg0 = Language.StringByID(R.MyInternationalizationString.AddLogicNormallyModeFailed); this.ShowTipMsg(msg0); return; } CommonPage.Loading.Hide(); } } @@ -1200,6 +1238,14 @@ //上报门锁“常开模式”已经取消,现在app确认“常开模式”取消 NormallyOpenModeValue(false); UpdateNomallyOpenStatus(); //删除已经失效的“常开模式”的逻辑 var resTemp = await Shared.Phone.Device.Logic.SkipView.Exist(3); if (resTemp == 3) { string msg0 = Language.StringByID(R.MyInternationalizationString.CancelLogicNormallyModeFailed); this.ShowTipMsg(msg0); } } else { @@ -1222,12 +1268,23 @@ { //添加App开启常开模式的历史记录 HdlDeviceDoorLockLogic.Current.AddDoorHistoryLog(this.doorLock, 9002, string.Empty); //app确认取消“常开模式”成功 NormallyOpenModeValue(false); UpdateNomallyOpenStatus(); string msg2 = Language.StringByID(R.MyInternationalizationString.CloseNormallyOpenModeSuccess); this.ShowTipMsg(msg2); Shared.Phone.Device.Logic.SkipView.LockCloseLogic(doorLock); //删除设置常开模式创建的逻辑 var resTemp = await Shared.Phone.Device.Logic.SkipView.Exist(3); if (resTemp == 3) { string msg0 = Language.StringByID(R.MyInternationalizationString.CancelLogicNormallyModeFailed); this.ShowTipMsg(msg0); } else if (resTemp == 2) { string msg2 = Language.StringByID(R.MyInternationalizationString.CloseNormallyOpenModeSuccess); this.ShowTipMsg(msg2); } } } }; @@ -1244,26 +1301,33 @@ var alertTimeInValidSetting = new ShowDoorLockMsgControl(ShowDoorLockMsgControl.DoorLockMsgType.InValid, msgTimeInValidSetting, timeConfrim); alertTimeInValidSetting.Show(); alertTimeInValidSetting.InvalidTimeAction += (obj) => { Regex rg = new Regex("^[0-9]+$"); if (!rg.IsMatch(obj)) { //必须是数字 string msg0 = Language.StringByID(R.MyInternationalizationString.NormallyOpenModeInvalidTimeTip); this.ShowTipMsg(msg0); alertTimeInValidSetting.InvalidTimeAction += async (obj) => { Regex rg = new Regex("^[0-9]+$"); if (!rg.IsMatch(obj)) { //必须是数字 string msg0 = Language.StringByID(R.MyInternationalizationString.NormallyOpenModeInvalidTimeTip); this.ShowTipMsg(msg0); string msgTimeInValidSetting2 = Language.StringByID(R.MyInternationalizationString.DoorLockOpenAllTheTime); var timeConfrim2 = Language.StringByID(R.MyInternationalizationString.Confrim); var alertTimeInValidSetting2 = new ShowDoorLockMsgControl(ShowDoorLockMsgControl.DoorLockMsgType.InValid, msgTimeInValidSetting2, timeConfrim2); alertTimeInValidSetting2.Show(); return; } //常开模式失效时间设置成功 var temp = int.Parse(obj); DoorLockCommonInfo.NormallyOpenModeInvalidTime = temp; Shared.Phone.Device.Logic.SkipView.LockAddModifyLogic(DoorLockCommonInfo.NormallyOpenModeInvalidTime, doorLock); }; string msgTimeInValidSetting2 = Language.StringByID(R.MyInternationalizationString.DoorLockOpenAllTheTime); var timeConfrim2 = Language.StringByID(R.MyInternationalizationString.Confrim); var alertTimeInValidSetting2 = new ShowDoorLockMsgControl(ShowDoorLockMsgControl.DoorLockMsgType.InValid, msgTimeInValidSetting2, timeConfrim2); alertTimeInValidSetting2.Show(); return; } //常开模式失效时间设置成功 var temp = int.Parse(obj); DoorLockCommonInfo.NormallyOpenModeInvalidTime = temp; //默认创建常开模式的特殊逻辑 var res = await Shared.Phone.Device.Logic.SkipView.LockAddModifyLogic(DoorLockCommonInfo.NormallyOpenModeInvalidTime, doorLock); if (!res) { string msg0 = Language.StringByID(R.MyInternationalizationString.AddLogicNormallyModeFailed); this.ShowTipMsg(msg0); return; } }; } /// <summary> /// 常开模式状态更新 ZigbeeApp/Shared/Phone/UserCenter/HideOption/HideOptionFileContentForm.cs
@@ -62,7 +62,7 @@ btnText.TextAlignment = TextAlignment.TopLeft; btnText.TextColor = UserCenterColor.Current.TextColor1; btnText.Text = textValue; btnText.Foucs = false; btnText.Enable = false; bodyFrameLayout.AddChidren(btnText); } } ZigbeeApp/Shared/Phone/UserCenter/Residence/AddNewRoomForm.cs
@@ -79,8 +79,8 @@ //房间图片 var btnPic = new ImageView(); btnPic.Y = Application.GetRealHeight(60); btnPic.Width = Application.GetMinRealAverage(824); btnPic.Height = Application.GetMinRealAverage(549); btnPic.Width = this.GetPictrueRealSize(824); btnPic.Height = this.GetPictrueRealSize(549); btnPic.Radius = (uint)Application.GetRealHeight(17); btnPic.Gravity = Gravity.CenterHorizontal; btnPic.ImagePath = "RoomIcon/0.jpg"; ZigbeeApp/Shared/Phone/UserCenter/Residence/EditorRoomInforForm.cs
@@ -94,8 +94,8 @@ //房间图片 var btnPic = new ImageView(); btnPic.Y = Application.GetRealHeight(60); btnPic.Width = Application.GetMinRealAverage(824); btnPic.Height = Application.GetMinRealAverage(549); btnPic.Width = this.GetPictrueRealSize(824); btnPic.Height = this.GetPictrueRealSize(549); btnPic.Radius = (uint)Application.GetRealHeight(17); btnPic.Gravity = Gravity.CenterHorizontal; if (this.editorRoom.BackgroundImageType == 0) ZigbeeApp/Shared/Phone/UserCenter/Residence/SelectLocalRoomImageForm.cs
@@ -27,6 +27,9 @@ { //初始化中部信息 this.InitMiddleFrame(); //设置头部信息 base.SetTitleText(Language.StringByID(R.MyInternationalizationString.LocalPicture)); } /// <summary> ZigbeeApp/Shared/Phone/UserView/HomePage.cs
@@ -120,6 +120,7 @@ var accountLogin = new Login.AccountLogin { }; Shared.Common.CommonPage.Instance.AddChidren(accountLogin); accountLogin.Show(); //accountLogin.ShowForm(); } } @@ -177,10 +178,6 @@ Config.Instance.Guid = revertData.Guid; Config.Instance.LoginDateTime = DateTime.Now; Config.Instance.LoginToken = revertData.Token; if (Config.Instance.AccountList.Find((obj) => obj == revertData.Account) == null) { Config.Instance.AccountList.Add(revertData.Account); } isLoginSuccess = 1; var resultRegID = await Shared.Common.CommonPage.Instance.PushRegID(); System.Console.WriteLine($"后台登录成功--{Config.Instance.LoginDateTime}"); ZigbeeApp/Shared/Phone/ZigBee/Common/Config.cs
@@ -135,11 +135,6 @@ /// </summary> public string LoginToken = string.Empty; /// <summary> /// 登录过的帐号信息 /// </summary> public List<string> AccountList = new List<string> { }; public List<string> HomeFilePathList = new List<string> { }; public string HomeId = string.Empty; ZigbeeApp/Shared/Phone/ZigBee/Device/FreshAir.cs
@@ -4,8 +4,11 @@ namespace ZigBee.Device { [System.Serializable] public class FreshAir : CommonDevice public class FreshAir : Panel { /// <summary> /// 该类(新风对象)包含新风设备和新风面板 /// </summary> public FreshAir() { this.Type = DeviceType.FreshAir; ZigbeeApp/Shared/Phone/ZigBee/Device/Panel.cs
@@ -61,7 +61,7 @@ public string RoomId = ""; /// <summary> /// 当前房间ID /// 当前选中的场景ID /// </summary> public string curSelectSceneID = ""; ZigbeeApp/Shared/Phone/ZigBee/Device/ZbGateway.cs
@@ -3313,7 +3313,8 @@ //这里是特殊的主题 if (e.ApplicationMessage.Topic == "/ZigbeeGateWayToClient/" + Config.Instance.ConnEmqClientId + "/Push/NotifySqueeze"//踢人下线 || e.ApplicationMessage.Topic == "/ZigbeeGateWayToClient/" + Config.Instance.Guid + "/Push/Deleted"//分享删除 || e.ApplicationMessage.Topic == "/ZigbeeGateWayToClient/" + Config.Instance.Guid + "/Push/DeletedShareData" || e.ApplicationMessage.Topic == "/ZigbeeGateWayToClient/" + Config.Instance.Guid + "/Push/DeletedShareData"//分享删除 || e.ApplicationMessage.Topic == "/ZigbeeGateWayToClient/" + Config.Instance.Guid + "/Push/Update"//成员权限变更 || e.ApplicationMessage.Topic == "/ZigbeeGateWayToClient/" + Config.Instance.Home.Id + "_" + Config.Instance.Guid + "/PrimaryUserDelYou")//子账号被删除 { mqttRemoteClient_MqttMsgPublishReceived(e); @@ -3351,6 +3352,8 @@ await RemoteMqttClient.SubscribeAsync("/ZigbeeGateWayToClient/" + myGuid + "/Push/DeletedShareData"); //订阅一个子账号被删除的主题 await RemoteMqttClient.SubscribeAsync("/ZigbeeGateWayToClient/" + Config.Instance.Home.Id + "_" + myGuid + "/PrimaryUserDelYou"); //订阅一个成员权限已经变更的主题 await RemoteMqttClient.SubscribeAsync("/ZigbeeGateWayToClient/" + myGuid + "/Push/Update"); } //订阅一个挤下线的主题 await RemoteMqttClient.SubscribeAsync("/ZigbeeGateWayToClient/" + Config.Instance.ConnEmqClientId + "/Push/NotifySqueeze"); ZigbeeApp/Shared/R.cs
@@ -330,11 +330,7 @@ /// </summary> public const int GetPanelProximityFail = 233; /// <summary> /// 镜像ID为2310的设备的默认名字:方悦新风小模块 /// </summary> public const int DeviceModelId2310 = 234; /// <summary> /// 镜像ID为2310的设备的默认名字:方悦新风小模块 /// 按住面板模式 /// </summary> public const int AddFreshAirPanelMsg = 235; /// <summary> @@ -542,7 +538,14 @@ /// PM2.5来源 /// </summary> public const int PM25Source = 305; /// <summary> /// 不能创建自动化常开模式 /// </summary> public const int AddLogicNormallyModeFailed = 307; /// <summary> /// 不能取消自动化常开模式 /// </summary> public const int CancelLogicNormallyModeFailed = 308; public readonly static int cancel = 5097; public readonly static int confrim = 5098; @@ -4752,7 +4755,7 @@ /// </summary> public const int uGetPictrueFromAlbum = 15874; /// <summary> /// 出现未知错误 /// 抱歉,程序出现错误 /// </summary> public const int uUnKnownError = 15875; /// <summary> @@ -5619,7 +5622,30 @@ /// 常开模式启用{0}小时 /// </summary> public const int uNormallyOpenModeOpenSomeTime = 16093; /// <summary> /// 您的权限已经变更,请重新登陆 /// </summary> public const int uYouAccessHadChangedPleaseTakeToAdmin = 16094; /// <summary> /// 我已阅读并同意 /// </summary> public const int uMyHadReadAndAgree = 16095; /// <summary> /// 隐私权政策 /// </summary> public const int uPrivacyPolicy = 16096; /// <summary> /// 和 /// </summary> public const int uAnd = 16097; /// <summary> /// 服务条款 /// </summary> public const int uTermsOfService = 16098; /// <summary> /// 请先阅读并同意《隐私权政策》和《服务条款》 /// </summary> public const int uPleaseReadAndAgreePrivacyPolicyMsg = 16099; //★★★★下面这些是接口的返回信息翻译,从18000开始★★★★ /// <summary> @@ -6005,7 +6031,10 @@ /// 镜像ID为2802的设备的官方名字:S-one /// </summary> public const int uDeviceModelId2802 = 30037; /// <summary> /// 镜像ID为2310的设备的默认名字:方悦新风小模块 /// </summary> public const int DeviceModelId2310 = 30038; //★★★★下面这些是设备所属种类的翻译名字,从40000开始★★★★ /// <summary> ZigbeeApp/Shared/Shared.projitems
@@ -198,6 +198,7 @@ <Compile Include="$(MSBuildThisFileDirectory)Phone\UserCenter\Device\Panel\PanelFangyueFreshAirBackLightSettionForm.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Phone\UserCenter\Device\Panel\PanelFangyueFreshAirButtonSettionForm.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Phone\UserCenter\Device\Panel\PanelFangyueFreshAirTargetForm.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Phone\UserCenter\Device\Panel\PanelFangyueFreshAirTargetsForm.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Phone\UserCenter\Device\Panel\PanelFangyueFunctionSettionForm.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Phone\UserCenter\Device\PirSensor\PirSensorDimmingModeForm.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Phone\UserCenter\Device\PirSensor\PirSensorTargetSelectForm.cs" />