SKBabyDetailInfoViewController.m 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629
  1. //
  2. // BabyDetailInfoViewController.m
  3. // Artimenring
  4. //
  5. // Created by YangJianguo on 7/2/15.
  6. // Copyright (c) 2015 BaH Cy. All rights reserved.
  7. //
  8. #import "SKBabyDetailInfoViewController.h"
  9. #import "IQKeyboardManager.h"
  10. #import <UMMobClick/MobClick.h>
  11. #import "BabyDetailInfoHeaderView.h"
  12. #import "SKBabyQRCodeViewController.h"
  13. #import "SKScanImeiViewController.h"
  14. #import "SKRelationViewController.h"
  15. #import "PickerView.h"
  16. typedef NS_ENUM(NSInteger, EControllerType) {
  17. EControllerSexType = 0,
  18. EControllerBirthday = 1,
  19. EControllerGrade = 2,
  20. };
  21. @interface SKBabyDetailInfoViewController ()<UITableViewDataSource, UITableViewDelegate, RelationDelegate> {
  22. PickerView *mTimeView;
  23. UIImage* mSaveHeadImage;
  24. EControllerType controllerType;
  25. NSArray *sexTypeArray;
  26. NSArray *gradeArray;
  27. BabyDetailInfoHeaderView* mHeaderView;
  28. }
  29. @property (nonatomic, weak) IBOutlet UITableView *tableView;
  30. @end
  31. @implementation SKBabyDetailInfoViewController
  32. - (void)viewDidLoad {
  33. [super viewDidLoad];
  34. // Do any additional setup after loading the view.
  35. sexTypeArray = @[NSLocalizedString(@"BDI.Boy", nil), NSLocalizedString(@"BDI.Girl", nil)];
  36. gradeArray = @[NSLocalizedString(@"BDI.Grade.00", nil),NSLocalizedString(@"BDI.Grade.01", nil),NSLocalizedString(@"BDI.Grade.02", nil),NSLocalizedString(@"BDI.Grade.03", nil),NSLocalizedString(@"BDI.Grade.11", nil),NSLocalizedString(@"BDI.Grade.12", nil),NSLocalizedString(@"BDI.Grade.13", nil),NSLocalizedString(@"BDI.Grade.14", nil),NSLocalizedString(@"BDI.Grade.15", nil),NSLocalizedString(@"BDI.Grade.16", nil)];
  37. [self setNavigationBarColor:0];
  38. [self.navigationController setNavigationBarHidden:NO];
  39. [self initTitle];
  40. [self initButton];
  41. }
  42. - (void)viewWillAppear:(BOOL)animated {
  43. [super viewWillAppear:animated];
  44. [IQKeyboardManager sharedManager].enable = NO;
  45. }
  46. - (void)viewWillDisappear:(BOOL)animated {
  47. [super viewWillDisappear:animated];
  48. self.title = @"";
  49. [IQKeyboardManager sharedManager].enable = YES;
  50. }
  51. - (void)initTitle {
  52. if (self.opType == 1) {
  53. self.title = NSLocalizedString(@"BDI.Title", nil);
  54. } else if (self.opType == 2) {
  55. self.title = NSLocalizedString(@"BD.Title.2.1.0", nil);
  56. } else if (self.opType == 3) {
  57. self.title = NSLocalizedString(@"BD.Title.2.1.1", nil);
  58. }
  59. }
  60. - (void)initButton {
  61. if (self.from == 1) {
  62. self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]initWithImage:[UIImage imageNamed:@"Clendar_L"] style: UIBarButtonItemStylePlain target:self action:@selector(onLeftBarAction)];
  63. }
  64. NSString* btnString = self.opType == 1 ? NSLocalizedString(@"STDL.Sure", nil) : NSLocalizedString(@"BD.NextStep", nil);
  65. self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:btnString style:UIBarButtonItemStylePlain target:self action:@selector(sureAction:)];
  66. }
  67. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  68. if (section == 0)
  69. return 0;
  70. else if (section == 1)
  71. return 7;
  72. else if (section == 2)
  73. return self.opType == 1 ? 0 : 1;
  74. else
  75. return 0;
  76. }
  77. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
  78. return 3;
  79. }
  80. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
  81. return 64;
  82. }
  83. - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
  84. if (section == 0)
  85. return 115;
  86. else if (section == 2)
  87. return 1;
  88. else
  89. return 0;
  90. }
  91. - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
  92. @weakify(self);
  93. if (section == 0) {
  94. if (mHeaderView == nil) {
  95. mHeaderView = [EUtil getBundleView:@"BabyDetailInfoHeaderView"];
  96. }
  97. [mHeaderView setData:mSaveHeadImage HeadImageURL:self.childModel.avatar callName:self.childModel.name];
  98. mHeaderView.mXIBViewCallback = ^{
  99. if(self.childModel.role > ROLE_ADMIN) { //非管理员
  100. //@"非管理员不可以修改"
  101. [EasyTextView showInfoText:NSLocalizedString(@"BDI.No.Admin", nil)];
  102. return;
  103. }
  104. [weak_self showImagePickerSheet];
  105. };
  106. return mHeaderView;
  107. } else if (section == 2) {
  108. UIView* view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 1)];
  109. [view setBackgroundColor:[UIColor clearColor]];
  110. return view;
  111. } else {
  112. return nil;
  113. }
  114. }
  115. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  116. static NSString *cellID = @"BabyDetailInfoCell";
  117. UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID forIndexPath:indexPath];
  118. if(cell == nil) {
  119. cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:cellID];
  120. }
  121. cell.accessoryView = nil;
  122. //@"未设置"
  123. NSString *notEdited = NSLocalizedString(@"BDI.No.Set", nil);
  124. if (indexPath.section == 1) {
  125. switch (indexPath.row) {
  126. case 0:
  127. //@"宝贝姓名"
  128. cell.textLabel.text = NSLocalizedString(@"BDI.Baby.Name", nil);
  129. if(self.childModel.name.length == 0)
  130. cell.detailTextLabel.text = notEdited;
  131. else if(self.childModel.name.length > 0)
  132. cell.detailTextLabel.text = self.childModel.name;
  133. if(self.childModel.role <= ROLE_ADMIN)
  134. cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
  135. else
  136. cell.accessoryType = UITableViewCellAccessoryNone;
  137. break;
  138. case 1:
  139. //@"国家码"
  140. cell.textLabel.text = NSLocalizedString(@"BDI.Baby.NationCode", nil);
  141. cell.detailTextLabel.text = [NSString stringWithFormat:@"+%@", self.childModel.areaCode];
  142. if(self.childModel.role <= ROLE_ADMIN)
  143. cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
  144. else
  145. cell.accessoryType = UITableViewCellAccessoryNone;
  146. break;
  147. case 2:
  148. //@"手机号"
  149. cell.textLabel.text = NSLocalizedString(@"BDI.Baby.Phone", nil);
  150. if(self.childModel.phoneNumber.length == 0)
  151. cell.detailTextLabel.text = notEdited;
  152. else if(self.childModel.phoneNumber.length > 0)
  153. cell.detailTextLabel.text = self.childModel.phoneNumber;
  154. if(self.childModel.role <= ROLE_ADMIN)
  155. cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
  156. else
  157. cell.accessoryType = UITableViewCellAccessoryNone;
  158. break;
  159. case 3:
  160. //@"性别"
  161. cell.textLabel.text = NSLocalizedString(@"BDI.Baby.gender", nil);
  162. if(self.childModel.gender < 2) {
  163. cell.detailTextLabel.text = notEdited;
  164. } else {
  165. cell.detailTextLabel.text = [sexTypeArray objectAtIndex:(self.childModel.gender - 2)];
  166. }
  167. if(self.childModel.role <= ROLE_ADMIN)
  168. cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
  169. else
  170. cell.accessoryType = UITableViewCellAccessoryNone;
  171. break;
  172. case 4:
  173. //@"生日"
  174. cell.textLabel.text = NSLocalizedString(@"BDI.Baby.Birthday", nil);
  175. if(self.childModel.birthday.length == 0)
  176. cell.detailTextLabel.text = notEdited;
  177. else {
  178. NSDate* date = [NSDate getDateFromString:@"yyyy-MM-dd" timeString:self.childModel.birthday];
  179. cell.detailTextLabel.text = [date getDateString];
  180. }
  181. if(self.childModel.role <= ROLE_ADMIN)
  182. cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
  183. else
  184. cell.accessoryType = UITableViewCellAccessoryNone;
  185. break;
  186. case 5:
  187. //@"身高"
  188. cell.textLabel.text = NSLocalizedString(@"BDI.Baby.Height", nil);
  189. if(self.childModel.height <= 0)
  190. cell.detailTextLabel.text = notEdited;
  191. else
  192. //@"%@ 厘米"
  193. cell.detailTextLabel.text = [NSString stringWithFormat:NSLocalizedString(@"BDI.Centimeter", nil),self.childModel.height];
  194. if(self.childModel.role <= ROLE_ADMIN)
  195. cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
  196. else
  197. cell.accessoryType = UITableViewCellAccessoryNone;
  198. break;
  199. case 6:
  200. //@"体重"
  201. cell.textLabel.text = NSLocalizedString(@"BDI.Baby.Weight", nil);
  202. if(self.childModel.weight <= 0)
  203. cell.detailTextLabel.text = notEdited;
  204. else
  205. cell.detailTextLabel.text = [NSString stringWithFormat:NSLocalizedString(@"BDI.Kilo", nil),self.childModel.weight];
  206. if(self.childModel.role <= ROLE_ADMIN)
  207. cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
  208. else
  209. cell.accessoryType = UITableViewCellAccessoryNone;
  210. break;
  211. case 7:
  212. //@"年级";
  213. break;
  214. case 8: {
  215. //二维码
  216. cell.textLabel.text = NSLocalizedString(@"BDI.Baby.QRCode", nil);
  217. cell.detailTextLabel.text = @"";
  218. UIImageView* image = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"ic_qr_code"]];
  219. cell.accessoryView = image;
  220. cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
  221. break;
  222. }
  223. default:
  224. break;
  225. }
  226. }
  227. else if (indexPath.section == 2) {
  228. switch (indexPath.row) {
  229. case 0:
  230. //@"称呼"
  231. cell.textLabel.text = NSLocalizedString(@"BDI.Baby.Appellation", nil);
  232. if(self.childModel.appellation.length <= 0)
  233. cell.detailTextLabel.text = notEdited;
  234. else
  235. cell.detailTextLabel.text = self.childModel.appellation;
  236. if(self.childModel.role <= ROLE_ADMIN)
  237. cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
  238. else
  239. cell.accessoryType = UITableViewCellAccessoryNone;
  240. break;
  241. default:
  242. break;
  243. }
  244. }
  245. [cell.textLabel setNeedsLayout];
  246. return cell;
  247. }
  248. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
  249. [self.tableView deselectRowAtIndexPath:indexPath animated:YES];
  250. if(self.childModel.role > ROLE_ADMIN) { //非管理员
  251. //@"非管理员不可以修改"
  252. //[EasyTextView showInfoText:NSLocalizedString(@"BDI.No.Admin", nil)];
  253. } else {
  254. UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
  255. if (indexPath.section == 1) {
  256. switch (indexPath.row) {
  257. case 0:
  258. //@"编辑宝贝姓名";
  259. [self editName];
  260. break;
  261. case 1:
  262. //@"编辑手机号";
  263. [self countryCodeActionEx];
  264. break;
  265. case 2:
  266. //@"编辑手机号";
  267. [self editPhone];
  268. break;
  269. case 3:
  270. //@"性别";
  271. [self editSex:cell.detailTextLabel.text];
  272. break;
  273. case 4:
  274. //@"生日";
  275. [self editBirthday:cell.detailTextLabel.text];
  276. break;
  277. case 5:
  278. //@"身高";
  279. [self editHeight];
  280. break;
  281. case 6:
  282. //@"体重";
  283. [self editWeight];
  284. break;
  285. case 7:
  286. //@"年级";
  287. [self editGrade:cell.detailTextLabel.text];
  288. break;
  289. case 8:
  290. [self showBabyQRCode];
  291. break;
  292. default:
  293. break;
  294. }
  295. } else if (indexPath.section == 2) {
  296. switch (indexPath.row) {
  297. case 0:
  298. [self editRelationName];
  299. break;
  300. }
  301. }
  302. }
  303. }
  304. - (void)createPickerView {
  305. if(mTimeView == nil) {
  306. mTimeView = [PickerView create];
  307. [mTimeView setMType:controllerType == EControllerBirthday ? 0:1];
  308. [mTimeView.mDatePicker setHidden: controllerType != EControllerBirthday];
  309. [mTimeView.mCustomPicker setHidden: controllerType == EControllerBirthday];
  310. if(controllerType == EControllerBirthday) {
  311. [mTimeView.mDatePicker setDatePickerMode:UIDatePickerModeDate];
  312. if (@available(iOS 13.4, *)) {
  313. [mTimeView.mDatePicker setPreferredDatePickerStyle:UIDatePickerStyleWheels];
  314. }
  315. [mTimeView.mDatePicker setMaximumDate:[NSDate date]];
  316. } else {
  317. mTimeView.mCustomPickerArray = [NSArray arrayWithArray:controllerType == EControllerSexType ? sexTypeArray : gradeArray];
  318. }
  319. }
  320. }
  321. - (void)modifyPickerView:(EControllerType)type value:(NSString*)value {
  322. controllerType = type;
  323. [self createPickerView];
  324. NSString* title = @"";
  325. if (controllerType == EControllerSexType) {
  326. title = NSLocalizedString(@"BDI.Baby.gender", nil);
  327. } else if (controllerType == EControllerBirthday) {
  328. title = NSLocalizedString(@"BDI.Baby.Birthday", nil);
  329. } else if (controllerType == EControllerGrade) {
  330. title = NSLocalizedString(@"BDI.Baby.Grade", nil);
  331. }
  332. [mTimeView show:title value:value];
  333. __weak typeof(self) _weakself = self;
  334. mTimeView.mDatePickerBtnClick = ^(NSInteger type, NSDate *date, NSInteger selectIndex) {
  335. mTimeView = nil;
  336. if (type != 0) {
  337. [_weakself onSureAction:date selectIndex:selectIndex];
  338. }
  339. };
  340. }
  341. - (void)onSureAction:(NSDate *)date selectIndex:(NSInteger)selectIndex {
  342. if(controllerType == EControllerSexType) {
  343. self.childModel.gender = selectIndex + 2;
  344. } else if(controllerType == EControllerGrade) {
  345. } else if(controllerType == EControllerBirthday) {
  346. NSString* birthday = [date getFormatString:@"yyyy-MM-dd"];
  347. self.childModel.birthday = birthday;
  348. }
  349. [self.tableView reloadData];
  350. }
  351. - (void)sureAction:(id)sender {
  352. if([self.childModel.name length] == 0) {
  353. //@"名字不能为空"
  354. [EasyTextView showInfoText:NSLocalizedString(@"BDI.Name.Nil", nil)];
  355. return;
  356. }
  357. if(![EUtil checkCharacter:self.childModel.name Min:1*2 Max:5*2]) {
  358. //@"名字不能超过1-5个汉字"
  359. [EasyTextView showInfoText:NSLocalizedString(@"NickName.Length", nil)];
  360. return;
  361. }
  362. if (![self.childModel.phoneNumber isValidateMobile]) {
  363. //@"请输入3~32位数字号码"
  364. [EasyTextView showInfoText:NSLocalizedString(@"Input.Correct.Mobile.Number", nil)];
  365. return;
  366. }
  367. // if(self.childModel.height <= 0) {
  368. // //@"身高不能为空"
  369. // [EasyTextView showInfoText:NSLocalizedString(@"BDI.Height.Nil", nil)];
  370. // return;
  371. // }
  372. if(self.childModel.height != 0 && (self.childModel.height < 10 || self.childModel.height > 300)) {
  373. //"身高超过合理范围"
  374. [EasyTextView showInfoText:NSLocalizedString(@"BDI.Height.Beyond", nil)];
  375. return;
  376. }
  377. //
  378. // if(self.childModel.weight <= 0) {
  379. // //@"体重不能为空"
  380. // [EasyTextView showInfoText:NSLocalizedString(@"BDI.Weight.Nil", nil)];
  381. // return;
  382. // }
  383. if(self.childModel.weight != 0 && (self.childModel.weight < 1 || self.childModel.weight > 300)) {
  384. //@"体重超过合理范围"
  385. [EasyTextView showInfoText:NSLocalizedString(@"BDI.Weight.Beyond", nil)];
  386. return;
  387. }
  388. if([self.childModel.appellation length] == 0) {
  389. [EasyTextView showInfoText:NSLocalizedString(@"FAV.Input.Relation", nil)];
  390. return;
  391. }
  392. if(![EUtil checkCharacter:self.childModel.appellation Min:1*2 Max:5*2]) {
  393. //@"名字不能超过1-5个汉字"
  394. [EasyTextView showInfoText:NSLocalizedString(@"Relation.Length", nil)];
  395. return;
  396. }
  397. if (self.opType == 1 || self.opType == 3) {
  398. [self updateChildRequest];
  399. } else {
  400. [self addChildRequest];
  401. }
  402. }
  403. - (void)addChildRequest {
  404. @weakify(self);
  405. NSMutableDictionary *param = [[NSMutableDictionary alloc] init];
  406. param[@"avatar"] = self.childModel.avatar;
  407. param[@"name"] = self.childModel.name;
  408. param[@"appellation"] = self.childModel.appellation;
  409. param[@"areaCode"] = self.childModel.areaCode;
  410. param[@"phoneNumber"] = self.childModel.phoneNumber;
  411. param[@"birthday"] = self.childModel.birthday;
  412. param[@"gender"] = @(self.childModel.gender);
  413. param[@"height"] = @(self.childModel.height);
  414. param[@"weight"] = @(self.childModel.weight);
  415. [self ShowHUBWithText:NSLocalizedString(@"Request.Adding", nil)];
  416. [ERequest httpRequest:param httpURL:URL_CHILD_ADD httpMethod:@"POST" onSuccess:^(NSDictionary *result) {
  417. [weak_self HiddenHUB];
  418. if([ERequest isSuccessWithResult:result]) {
  419. weak_self.childModel.cid = result[@"data"][@"cid"];
  420. [weak_self showScanQRcode];
  421. } else{
  422. [EasyTextView showErrorText:result[@"message"]];
  423. }
  424. }onFailure:^(NSError *error) {
  425. [weak_self HiddenHUB];
  426. [EasyTextView showErrorText:NSLocalizedString(@"Network.Error", nil)];
  427. }];
  428. }
  429. - (void)updateChildRequest {
  430. @weakify(self);
  431. NSMutableDictionary *param = [[NSMutableDictionary alloc] init];
  432. param[@"cid"] = self.childModel.cid;
  433. param[@"avatar"] = self.childModel.avatar;
  434. param[@"name"] = self.childModel.name;
  435. param[@"appellation"] = self.childModel.appellation;
  436. param[@"areaCode"] = self.childModel.areaCode;
  437. param[@"phoneNumber"] = self.childModel.phoneNumber;
  438. param[@"birthday"] = self.childModel.birthday;
  439. param[@"gender"] = @(self.childModel.gender);
  440. param[@"height"] = @(self.childModel.height);
  441. param[@"weight"] = @(self.childModel.weight);
  442. [self ShowHUBWithText:NSLocalizedString(@"Request.Modifing", nil)];
  443. [ERequest httpRequest:param httpURL:URL_CHILD_UPDATE httpMethod:@"POST" onSuccess:^(NSDictionary *result) {
  444. [weak_self HiddenHUB];
  445. if([ERequest isSuccessWithResult:result]) {
  446. if (weak_self.opType == 1) {
  447. [EasyTextView showSuccessText:NSLocalizedString(@"Request.Modify.Success", nil)];
  448. [EUtil postInformation:@"RELOAD_CHILDS_DEVICES"];
  449. [weak_self popViewControllerWithDelay:0.5];
  450. } else {
  451. [weak_self showScanQRcode];
  452. }
  453. } else{
  454. [EasyTextView showErrorText:result[@"message"]];
  455. }
  456. }onFailure:^(NSError *error) {
  457. [weak_self HiddenHUB];
  458. [EasyTextView showErrorText:NSLocalizedString(@"Network.Error", nil)];
  459. }];
  460. }
  461. - (void)editName {
  462. //@"输入宝贝姓名"
  463. NSString* holder = self.childModel.name.length > 0 ? self.childModel.name : NSLocalizedString(@"NickName.Length", nil);
  464. [self showTextFieldAlertView:NSLocalizedString(@"BDI.Baby.Name", nil) Message:nil PlaceHolder:holder isNumber:NO callback:^(BOOL isOK, NSString *text) {
  465. if (isOK) {
  466. self.childModel.name = text;
  467. [self.tableView reloadData];
  468. }
  469. }];
  470. }
  471. - (void)editRelationName {
  472. //@"输入宝贝姓名"
  473. NSString* holder = self.childModel.appellation.length > 0 ? self.childModel.appellation : NSLocalizedString(@"Relation.Length", nil);
  474. [self showTextFieldAlertView:NSLocalizedString(@"BDI.Baby.Appellation", nil) Message:nil PlaceHolder:holder isNumber:NO callback:^(BOOL isOK, NSString *text) {
  475. if (isOK) {
  476. self.childModel.appellation = text;
  477. [self.tableView reloadData];
  478. }
  479. }];
  480. }
  481. - (void)editPhone {
  482. //@"修改手表号码"; @"请输入3~32位数字号码"
  483. NSString* holder = self.childModel.phoneNumber.length > 0 ? self.childModel.phoneNumber : NSLocalizedString(@"Input.Correct.Mobile.Number", nil);
  484. [self showTextFieldAlertView:NSLocalizedString(@"BD.Baby.PhoneNumber", nil) Message:nil PlaceHolder:holder isNumber:YES callback:^(BOOL isOK, NSString *text) {
  485. if (isOK) {
  486. self.childModel.phoneNumber = text;
  487. [self.tableView reloadData];
  488. }
  489. }];
  490. }
  491. - (void)editSex:(NSString*)defaultVal {
  492. [self modifyPickerView:EControllerSexType value:defaultVal];
  493. }
  494. - (void)editBirthday:(NSString*)defaultVal {
  495. [self modifyPickerView:EControllerBirthday value:self.childModel.birthday];
  496. }
  497. - (void)editHeight {
  498. //@"输入宝贝身高"
  499. [self showTextFieldAlertView:NSLocalizedString(@"BDI.Baby.Height", nil) Message:nil PlaceHolder:[NSString stringWithFormat:NSLocalizedString(@"BDI.Centimeter", nil),self.childModel.height] isNumber:YES callback:^(BOOL isOK, NSString *text) {
  500. if (isOK) {
  501. self.childModel.height = [text intValue];
  502. [self.tableView reloadData];
  503. }
  504. }];
  505. }
  506. - (void)editWeight {
  507. [self showTextFieldAlertView:NSLocalizedString(@"BDI.Baby.Weight", nil) Message:nil PlaceHolder:[NSString stringWithFormat:NSLocalizedString(@"BDI.Kilo", nil),self.childModel.weight] isNumber:YES callback:^(BOOL isOK, NSString *text) {
  508. if (isOK) {
  509. self.childModel.weight = [text intValue];
  510. [self.tableView reloadData];
  511. }
  512. }];
  513. }
  514. - (void)editGrade:(NSString*)defaultVal {
  515. [self modifyPickerView:EControllerGrade value:defaultVal];
  516. }
  517. - (void)onCountryCodeCallback:(NSString*)code {
  518. self.childModel.areaCode = code;
  519. [self.tableView reloadData];
  520. }
  521. - (void)showBabyQRCode {
  522. [MobClick event:@"ClickBabyQRCode"];
  523. SKBabyQRCodeViewController *controller = [[self storyboard] instantiateViewControllerWithIdentifier:@"BabyQRCodeVC"];
  524. controller.cid = self.childModel.cid;
  525. [self pushViewController:controller animated:YES];
  526. }
  527. - (void)showRelation {
  528. SKRelationViewController *controller = [[self storyboard] instantiateViewControllerWithIdentifier:@"RelationVC"];
  529. controller.delegate = self;
  530. [self pushViewController:controller animated:YES];
  531. }
  532. - (void)showScanQRcode {
  533. BOOL isOk = [SystemAuthorization checkCamera:self];
  534. if (isOk) {
  535. SKScanImeiViewController *controller = [[self storyboard] instantiateViewControllerWithIdentifier:@"ScanImeiVC"];
  536. controller.childModel = self.childModel;
  537. controller.from = self.from;
  538. [controller setHidesBottomBarWhenPushed:YES];
  539. [self popAndPushViewController:controller animated:YES];
  540. }
  541. }
  542. - (void)onLeftBarAction {
  543. [[DataManager shared] showSKLoginViewController];
  544. }
  545. - (void)onRelationSelected:(NSInteger)index callname:(NSString *)callname {
  546. self.childModel.appellation = callname;
  547. [self.tableView reloadData];
  548. }
  549. - (void)onImagePickerCallback:(UIImage *)image data:(NSData *)data {
  550. [DataManager uploadResource:RESOURCE_HEADIMAGE fileData:data callback:^(BOOL isOK, NSString * _Nonnull url) {
  551. if (url.length > 0) {
  552. self.childModel.avatar = url;
  553. mSaveHeadImage = image;
  554. [mHeaderView.mHeadImage setImage:image];
  555. }
  556. }];
  557. }
  558. @end