|
@@ -1,153 +0,0 @@
|
|
-//
|
|
|
|
-// SKMineViewController+baby.m
|
|
|
|
-// Overseas Watch
|
|
|
|
-//
|
|
|
|
-// Created by 刘振兴 on 2024/1/19.
|
|
|
|
-// Copyright © 2024 BaH Cy. All rights reserved.
|
|
|
|
-//
|
|
|
|
-
|
|
|
|
-#import "SKMineViewController+baby.h"
|
|
|
|
-#import "SKBabyListCellViewCell.h"
|
|
|
|
-#import "SKBabyDetailInfoViewController.h"
|
|
|
|
-#import "SKBabyQRCodeViewController.h"
|
|
|
|
-
|
|
|
|
-@implementation SKMineViewController (baby)
|
|
|
|
-
|
|
|
|
-- (UITableViewCell *)babyTableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
|
|
|
|
- static NSString *cellID = @"BabyListCellID";
|
|
|
|
- SKBabyListCellViewCell *cell = (SKBabyListCellViewCell*)[tableView dequeueReusableCellWithIdentifier:cellID forIndexPath:indexPath];
|
|
|
|
- if(cell == nil) {
|
|
|
|
- cell = [[SKBabyListCellViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:cellID];
|
|
|
|
- }
|
|
|
|
- [cell setData:indexPath.row];
|
|
|
|
- cell.mCellCallback = ^(NSInteger rowIndex, NSInteger btnIndex) {
|
|
|
|
- self.seletedBabyIdx = rowIndex;
|
|
|
|
- if (btnIndex == 1) {
|
|
|
|
- [self showAlert:1];
|
|
|
|
- } else if (btnIndex == 2) {
|
|
|
|
- [self showAlert:2];
|
|
|
|
- } else if (btnIndex == 3) {
|
|
|
|
- [self showBind:rowIndex];
|
|
|
|
- } else if (btnIndex == 11) {
|
|
|
|
- [self showBabyDetail:rowIndex];
|
|
|
|
- } else if (btnIndex == 12) {
|
|
|
|
- [self showBabyQRCode:rowIndex];
|
|
|
|
- }
|
|
|
|
- };
|
|
|
|
- return cell;
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-- (void)babyTableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-- (void)deleteWatch:(NSInteger)index {
|
|
|
|
- ChildModel *child = [[DataManager shared] getIndexChild:index];
|
|
|
|
- NSDictionary *param = @{
|
|
|
|
- @"cid":child.cid,
|
|
|
|
- @"deviceId":@(child.device.did),
|
|
|
|
- @"ticket":child.device.ticket,
|
|
|
|
- };
|
|
|
|
-
|
|
|
|
- //@"解绑中..."
|
|
|
|
- [self ShowHUBWithText:NSLocalizedString(@"DB.Remove.Bind.Ing", nil)];
|
|
|
|
-
|
|
|
|
- [ERequest httpRequest:param httpURL:URL_DEVICE_DELETE httpMethod:@"POST" onSuccess:^(NSDictionary *result) {
|
|
|
|
- [self HiddenHUB];
|
|
|
|
- if ([ERequest isSuccessWithResult:result]) {
|
|
|
|
-
|
|
|
|
- //@"解绑成功"
|
|
|
|
- [EasyTextView showSuccessText:NSLocalizedString(@"DB.Remove.Bind.Success", nil)];
|
|
|
|
-
|
|
|
|
- [[DataManager shared] removeDevice:index];
|
|
|
|
-
|
|
|
|
- [self.mTableView reloadData];
|
|
|
|
- } else {
|
|
|
|
- [EasyTextView showErrorText:result[@"message"]];
|
|
|
|
- }
|
|
|
|
- } onFailure:^(NSError *error) {
|
|
|
|
- [self HiddenHUB];
|
|
|
|
- [EasyTextView showErrorText:NSLocalizedString(@"Network.Error", nil)];
|
|
|
|
- }];
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-- (void)deleteChild:(NSInteger)index {
|
|
|
|
- ChildModel *child = [[DataManager shared] getIndexChild:index];
|
|
|
|
- NSString* cid = child.cid;
|
|
|
|
-
|
|
|
|
- [self ShowHUBWithText:NSLocalizedString(@"Cancel.Following...", nil)];//@"取消关注中..."];
|
|
|
|
- [ERequest httpRequest:@{} path:cid httpURL:URL_CHILD_DELETE httpMethod:@"GET" onSuccess:^(NSDictionary *result) {
|
|
|
|
- [self HiddenHUB];
|
|
|
|
- if ([ERequest isSuccessWithResult:result]) {
|
|
|
|
- if([[DataManager shared] getChildCount] - 1 > 0) {
|
|
|
|
- if (index >= 0) {
|
|
|
|
- [[DataManager shared] removeData:index];
|
|
|
|
- }
|
|
|
|
- [self.mTableView reloadData];
|
|
|
|
- [EUtil postInformation:@"RELOAD_CHILDS_DEVICES"];
|
|
|
|
- } else {
|
|
|
|
- [[DataManager shared] logout];
|
|
|
|
- }
|
|
|
|
- } else {
|
|
|
|
- [EasyTextView showErrorText:result[@"message"]];
|
|
|
|
- }
|
|
|
|
- } onFailure:^(NSError *error) {
|
|
|
|
- [self HiddenHUB];
|
|
|
|
- [EasyTextView showErrorText:NSLocalizedString(@"Network.Error", nil)];//@"网络错误"];
|
|
|
|
- }];
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-- (void)showBind:(NSInteger)index {
|
|
|
|
- [MobClick event:@"ClickAddBindAgain"];
|
|
|
|
- ChildModel *child = [[DataManager shared] getIndexChild:index];
|
|
|
|
- [DataManager shared].bindOptions = BO_REBIND;
|
|
|
|
- SKBabyDetailInfoViewController *controller = [[self storyboard] instantiateViewControllerWithIdentifier:@"BabyDetailInfo"];
|
|
|
|
- controller.opType = 3;
|
|
|
|
- controller.childModel = child;
|
|
|
|
- [self pushViewController:controller animated:YES];
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-- (void)showBabyDetail:(NSInteger)index {
|
|
|
|
- ChildModel* model = [[DataManager shared] getIndexChild:index];
|
|
|
|
- if (model.role > ROLE_ADMIN)
|
|
|
|
- return;
|
|
|
|
- ChildModel *child = [[DataManager shared] getIndexChild:index];
|
|
|
|
- SKBabyDetailInfoViewController *controller = [[self storyboard] instantiateViewControllerWithIdentifier:@"BabyDetailInfo"];
|
|
|
|
- controller.opType = 1;
|
|
|
|
- controller.childModel = [child mutableCopy];
|
|
|
|
- [self pushViewController:controller animated:YES];
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-- (void)showBabyQRCode:(NSInteger)index {
|
|
|
|
- [MobClick event:@"ClickBabyQRCode"];
|
|
|
|
- ChildModel *child = [[DataManager shared] getIndexChild:index];
|
|
|
|
- SKBabyQRCodeViewController *controller = [[self storyboard] instantiateViewControllerWithIdentifier:@"BabyQRCodeVC"];
|
|
|
|
- controller.cid = child.cid;
|
|
|
|
- [self pushViewController:controller animated:YES];
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-#pragma mark - popup
|
|
|
|
-- (void)showAlert:(NSInteger)type {
|
|
|
|
- NSString* title;
|
|
|
|
- NSString* content;
|
|
|
|
- if (type == 1) {
|
|
|
|
- title = NSLocalizedString(@"Baby.List.Alert.1", nil);
|
|
|
|
- content = NSLocalizedString(@"Baby.List.Alert.Content.1", nil);
|
|
|
|
- } else {
|
|
|
|
- title = NSLocalizedString(@"Baby.List.Alert.2", nil);
|
|
|
|
- content = NSLocalizedString(@"Baby.List.Alert.Content.2", nil);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- UIAlertController *alert = [UIAlertController alertControllerWithTitle:title message:content preferredStyle:UIAlertControllerStyleAlert];
|
|
|
|
- [alert addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"SK.Cancel", nil) style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
|
|
|
|
- }]];
|
|
|
|
- [alert addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"SK.Confirm", nil) style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action) {
|
|
|
|
- if (type == 1) {
|
|
|
|
- [self deleteWatch:self.seletedBabyIdx];
|
|
|
|
- } else if (type == 2) {
|
|
|
|
- [self deleteChild:self.seletedBabyIdx];
|
|
|
|
- }
|
|
|
|
- }]];
|
|
|
|
- [self presentViewController:alert animated:YES completion:nil];
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-@end
|
|
|