StuDetailVC.m 48 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237
  1. /**
  2. 个人页面跳转进来两种情况,一是从tabbar直接过来,不用返回;另一种是从侧栏进来,要返回回去的
  3. */
  4. #import "StuDetailVC.h"
  5. #import "CLCell.h"
  6. #import "Tools.h"
  7. #import "DES3Util.h"
  8. //#import <SMS_SDK/SMSSDK.h>
  9. //#import <ShareSDK/ShareSDK.h>
  10. #import "ThirdLoginBindYunGuanVC.h"
  11. #import "ShowBindVC.h"
  12. //#import <TOCropViewController.h>
  13. @interface StuDetailVC ()<UITableViewDataSource,UITableViewDelegate,UIAlertViewDelegate,UITextFieldDelegate,QMUIAlbumViewControllerDelegate,QMUIImagePickerViewControllerDelegate,QMUIImagePreviewViewDelegate>
  14. {
  15. UITableView *myTableView;
  16. UITextField *psw1;
  17. UITextField *psw2;
  18. NSArray *titles;
  19. NSArray *images;
  20. NSArray *details;
  21. NSString *SubmitNumType;
  22. NSString *bindTel;
  23. }
  24. @property (nonatomic, readwrite, strong) QMUIImagePreviewViewController *imagePreviewViewController;
  25. @end
  26. @implementation StuDetailVC
  27. - (void)viewDidLoad
  28. {
  29. [super viewDidLoad];
  30. [self setTitle:@"个人中心"];
  31. self.navigationController.navigationBar.translucent = NO;
  32. [self.view setBackgroundColor:[UIColor whiteColor]];
  33. // if (_tag == 1)
  34. // {
  35. // UIBarButtonItem* backBbi = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"question_pre_checked_icon.png"] style:UIBarButtonItemStylePlain target:self action:@selector(dismissNav)];
  36. // [backBbi setTintColor:defGreen];
  37. // self.navigationController.navigationBar.translucent = NO;
  38. // [self.navigationItem setLeftBarButtonItem:backBbi];
  39. // }
  40. // if (_tag == 2) {
  41. // [self configNavigationBar];
  42. // }
  43. [self configNavigationBar];
  44. defUser.userNickName = defUser.userDict[@"nickName"];
  45. [self myInit];
  46. }
  47. -(void)viewWillAppear:(BOOL)animated
  48. {
  49. [super viewWillAppear:animated];
  50. if ([defUser.userDict[@"id"] length] < 1)
  51. {
  52. defUser.userNickName = @"";
  53. defUser.userSex = @"";
  54. }
  55. }
  56. -(void)myInit
  57. {
  58. [self loadModels];
  59. myTableView = [[UITableView alloc] initWithFrame:kFrame style:UITableViewStyleGrouped];
  60. myTableView.height -= kNavOffSet;
  61. [self.view addSubview:myTableView];
  62. [myTableView setDelegate:self];
  63. [myTableView setDataSource:self];
  64. UIView* v = [[UIView alloc] initWithFrame:kFrame];
  65. v.height = 100;
  66. [myTableView setTableFooterView:v];
  67. }
  68. -(void)dismissNav
  69. {
  70. self.tag = 0;
  71. [self.view endEditing:YES];
  72. [self.navigationController dismissViewControllerAnimated:NO completion:nil];
  73. }
  74. - (void)didReceiveMemoryWarning
  75. {
  76. [super didReceiveMemoryWarning];
  77. }
  78. #pragma mark -
  79. -(void)loadModels
  80. {
  81. // titles = @[@[@"头像",@"昵称",@"手机号码"],@[@"姓名",@"性别",@"年龄",@"车型",@"报名时间"],@[@"修改密码"]];
  82. // images = @[@[@"center_img01.png",@"center_img02.png",@"center_img03.png"],@[@"center_img04.png",@"center_img05.png",@"center_img06.png",@"center_img07.png",@"center_img08.png"],@[@"center_img09.png"]];
  83. NSUserDefaults * ud = [NSUserDefaults standardUserDefaults];
  84. NSDictionary *udDic = [ud objectForKey:@"jiaPeiLoginTest"];
  85. if ([udDic[@"loginType"] isEqualToString:@"1"]){
  86. //由计时平台账号登录
  87. titles = @[@[@"头像",@"昵称"],
  88. @[@"姓名",@"性别",@"年龄",@"车型",@"报名时间"],
  89. @[/*@"QQ绑定",@"微信绑定"*/],
  90. @[@"修改登录密码"/*,@"设置支付密码"*/],
  91. @[@"注销账号"]];
  92. images = @[@[@"center_img01.png",@"center_img02.png"],
  93. @[@"center_img04.png",@"center_img05.png",@"center_img06.png",@"center_img07.png",@"center_img08.png"],
  94. @[/*@"center_img11.png",@"center_img12.png"*/],
  95. @[@"center_img09.png"/*,@"center_img10.png"*/],
  96. @[@"center_img03.png"]];//@"center_img03.png" 手机绑定
  97. }else{
  98. //第三方或者手机号登录
  99. titles = @[@[@"头像",@"昵称"],
  100. @[@"姓名",@"性别",@"年龄",@"车型",@"报名时间"],
  101. @[@"学员账号"],
  102. @[@"修改登录密码",@"设置支付密码"]];
  103. images = @[@[@"center_img01.png",@"center_img02.png"],
  104. @[@"center_img04.png",@"center_img05.png",@"center_img06.png",@"center_img07.png",@"center_img08.png"],
  105. @[@"center_img03.png"],
  106. @[@"center_img09.png",@"center_img10.png"]];
  107. }
  108. }
  109. -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
  110. {
  111. return titles.count;
  112. }
  113. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  114. {
  115. return [titles[section] count];
  116. }
  117. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  118. {
  119. CLCell *cell = [CLCell cellForTableView:tableView Style:UITableViewCellStyleValue1];
  120. [cell.textLabel setTextColor:contentTextColor];
  121. [cell.detailTextLabel setTextColor:kTitleColor];
  122. [cell.detailTextLabel setText:@""];
  123. [cell setAccessoryType:UITableViewCellAccessoryDisclosureIndicator];
  124. UIImage* img = [UIImage imageNamed:[images objAtPath:indexPath]];
  125. [cell.imageView setImage:img];
  126. [cell.textLabel setText: [titles objAtPath:indexPath]];
  127. cell.headerImg.hidden = YES;
  128. if ( 0 == indexPath.section) {
  129. switch (indexPath.row) {
  130. case 0:
  131. {
  132. cell.headerImg.hidden = NO;
  133. NSString *str = defUser.userDict[@"photo"];
  134. if (str && ![str hasPrefix:@"http"]){
  135. str = [imgPreFix stringByAppendingString:str];
  136. }
  137. if (str == nil) {
  138. str = @"";
  139. }
  140. [cell.headerImg sd_setImageWithURL:[NSURL URLWithString:str] placeholderImage:[UIImage imageWithColor:[UIColor whiteColor]]];
  141. }
  142. break;
  143. case 1:
  144. [cell.detailTextLabel setText:defUser.userNickName];
  145. break;
  146. default:
  147. break;
  148. }
  149. } else if ( 1 == indexPath.section) {
  150. [cell setAccessoryType:UITableViewCellAccessoryNone];
  151. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  152. switch (indexPath.row) {
  153. case 0:
  154. [cell.detailTextLabel setText:defUser.userName];
  155. break;
  156. case 1:
  157. {
  158. [cell.detailTextLabel setText: [defUser.userSex integerValue] == 2 ? @"女" : @"男"];
  159. }
  160. break;
  161. case 2:
  162. [cell.detailTextLabel setText:defUser.userAge];
  163. break;
  164. case 3:
  165. [cell.detailTextLabel setText:[defUser.userDict objectForKey:@"carType"]];
  166. break;
  167. case 4:
  168. {
  169. NSString *dateString = [defUser.userDict objectForKey:@"crDate"];
  170. if (dateString.length > 10) {
  171. dateString = [dateString substringToIndex:10];
  172. }
  173. [cell.detailTextLabel setText:dateString];
  174. }
  175. break;
  176. default:
  177. break;
  178. }
  179. } else if ( 2 == indexPath.section) {
  180. if ([titles[indexPath.section][indexPath.row] isEqualToString:@"手机绑定"]) {
  181. NSString *telString = @"";
  182. if ([defUser.userDict[@"telphone"] length] > 10) {
  183. telString = defUser.userDict[@"telphone"];
  184. [cell setAccessoryType:UITableViewCellAccessoryNone];
  185. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  186. telString = [telString stringByReplacingCharactersInRange:NSMakeRange(3, 4) withString:@"****"];
  187. [cell.detailTextLabel setText:telString];
  188. }else{
  189. [cell.detailTextLabel setText:@"暂未绑定"];
  190. }
  191. }else if ([titles[indexPath.section][indexPath.row] isEqualToString:@"QQ绑定"]){
  192. NSArray * array = defUser.userDict[@"loginBindInfos"];
  193. [cell.detailTextLabel setText:@"暂未绑定"];
  194. for (NSDictionary * dic in array) {
  195. if ([dic[@"type"] integerValue]== 3) {
  196. [cell setAccessoryType:UITableViewCellAccessoryNone];
  197. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  198. [cell.detailTextLabel setText:@"已绑定"];
  199. }
  200. }
  201. }else if ([titles[indexPath.section][indexPath.row] isEqualToString:@"微信绑定"]){
  202. NSArray * array = defUser.userDict[@"loginBindInfos"];
  203. [cell.detailTextLabel setText:@"暂未绑定"];
  204. for (NSDictionary * dic in array) {
  205. if ([dic[@"type"] integerValue]== 2) {
  206. [cell setAccessoryType:UITableViewCellAccessoryNone];
  207. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  208. [cell.detailTextLabel setText:@"已绑定"];
  209. }
  210. }
  211. }else if ([titles[indexPath.section][indexPath.row] isEqualToString:@"学员账号"]){
  212. if ([defUser.userDict[@"outId"] length] > 0) {
  213. [cell setAccessoryType:UITableViewCellAccessoryNone];
  214. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  215. [cell.detailTextLabel setText:@"已绑定"];
  216. }else{
  217. [cell.detailTextLabel setText:@"暂未绑定"];
  218. }
  219. }
  220. } else if ( 3 == indexPath.section) {
  221. switch (indexPath.row) {
  222. case 1:
  223. {
  224. if ([defUser.userDict[@"payPwd"] length] > 0) {
  225. [cell.textLabel setText:@"修改支付密码"];
  226. }
  227. }
  228. break;
  229. default:
  230. break;
  231. }
  232. } else {
  233. [cell.detailTextLabel setText:@"删除数据,永久注销"];
  234. }
  235. return cell;
  236. }
  237. - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
  238. return [[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, 10)];
  239. }
  240. - (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section {
  241. return [[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, 10)];
  242. }
  243. - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
  244. return (section == 0)? 0.1 : ([titles[section] count] == 0)? 0.1 : 10;
  245. }
  246. - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
  247. return ([titles[section] count] == 0)? 0.1 : 10;
  248. }
  249. -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
  250. {
  251. if (!myDelegate.isLogin)
  252. {
  253. ShowMsg(@"请登录后再操作!");
  254. [self userLoginAction];
  255. return;
  256. }
  257. [tableView deselectRowAtIndexPath:indexPath animated:YES];
  258. if (0 == indexPath.section && 0 == indexPath.row) {
  259. [self showInputHeadImg];
  260. return;
  261. }
  262. if (0 == indexPath.section && 1 == indexPath.row) {
  263. [self showInputNickName];
  264. return;
  265. }
  266. //绑定账号相关
  267. if (2 == indexPath.section) {
  268. if ([titles[indexPath.section][indexPath.row] isEqualToString: @"QQ绑定"]) {
  269. NSArray * array = defUser.userDict[@"loginBindInfos"];
  270. for (NSDictionary * dic in array) {
  271. if ([dic[@"type"] integerValue]== 3) {
  272. return;
  273. }
  274. }
  275. //QQ登录验证
  276. [self QQLoginAction];
  277. } else if ([titles[indexPath.section][indexPath.row] isEqualToString: @"微信绑定"]){
  278. NSArray * array = defUser.userDict[@"loginBindInfos"];
  279. for (NSDictionary * dic in array) {
  280. if ([dic[@"type"] integerValue]== 2) {
  281. return;
  282. }
  283. }
  284. //登录微信验证
  285. [self WetchatLoginAction];
  286. } else if ([titles[indexPath.section][indexPath.row] isEqualToString: @"手机绑定"]){
  287. // NSString *telString = @"";
  288. // if ([defUser.userDict[@"telphone"] isKindOfClass:[NSString class]]) {
  289. // telString = defUser.userDict[@"telphone"];
  290. // }
  291. //
  292. // if (telString.length > 10) {
  293. // return;
  294. // }else{
  295. // //NSLog(@"----><>%@",defUser.userDict);
  296. // if ([defUser.userDict[@"outId"] length] < 1) {
  297. // ShowMsg(@"该账号无法绑定手机");
  298. // return;
  299. // }
  300. // [self bindAction];
  301. // }
  302. ShowMsg(@"暂未开放。。。");
  303. } else if ([titles[indexPath.section][indexPath.row] isEqualToString: @"学员账号"]){
  304. if ([defUser.userDict[@"outId"] length] > 0) {
  305. ShowBindVC *vc = [[ShowBindVC alloc]init];
  306. vc.type = 0;
  307. vc.labNum = defUser.userDict[@"loginCode"];
  308. [self navPushHideTabbarToVC:vc];
  309. return;
  310. }
  311. ThirdLoginBindYunGuanVC *vc = [[ThirdLoginBindYunGuanVC alloc] init];
  312. vc.block = ^(){
  313. [myTableView reloadData];
  314. };
  315. [self navPushHideTabbarToVC:vc];
  316. }
  317. return;
  318. }
  319. if (3 == indexPath.section && 0 == indexPath.row) {
  320. //修改登录密码
  321. // if ([defUser.userDict[@"outId"] length] > 0) {
  322. // [self fixKey];
  323. // }else{
  324. // ShowMsg(@"未绑定学员账号,无需修改登录密码");
  325. // }
  326. [self fixKey];//2018/5/4
  327. return;
  328. }
  329. if (3 == indexPath.section && 1 == indexPath.row) {
  330. if ([defUser.userDict[@"outId"] length] > 0) {
  331. if ([defUser.userDict[@"payPwd"] length] > 0) {
  332. //NSLog(@"修改支付密码");
  333. [self fixPayKey];
  334. }else{
  335. //NSLog(@"设置支付密码");
  336. [self setPayPassword];
  337. }
  338. }else{
  339. ShowMsg(@"未绑定学员账号,无需支付操作");
  340. }
  341. // NSString *telString = @"";
  342. // if ([defUser.userDict[@"telphone"] isKindOfClass:[NSString class]]) {
  343. // telString = defUser.userDict[@"telphone"];
  344. // }
  345. //
  346. // if (telString.length > 10) {
  347. // if ([[defUser.userDict[@"accountInfo"] objectForKey:@"pwd"] length] > 0) {
  348. // //NSLog(@"修改支付密码");
  349. // [self fixPayKey];
  350. // }else{
  351. // //NSLog(@"设置支付密码");
  352. // [self setPayPassword];
  353. // }
  354. // }
  355. }
  356. @weakify(self)
  357. if (4 == indexPath.section) {
  358. [RQ_SHARE_FUNCTION showAlertWithTitle:@"温馨提示" message:@"您即将完全删除用户所有数据!永久注销该账号!请确认是否执行该申请?" alertControllerStyle:UIAlertControllerStyleAlert cancelButtonTitle:@"我再想想" otherButtonTitles:@[@"确认注销"] otherButtonStyles:nil completion:^(NSUInteger selectedOtherButtonIndex) {
  359. if (selectedOtherButtonIndex == 0) {
  360. [MBProgressHUD rq_showProgressHUD:@"注销中"];
  361. RACCommand *zxCommand = [[RACCommand alloc] initWithSignalBlock:^RACSignal *(NSNumber * selected) {
  362. return [self zx];
  363. return [RACSignal empty];
  364. }];
  365. [[zxCommand execute:@1] subscribeNext:^(id _Nullable x) {
  366. @strongify(self)
  367. [self.navigationController popToRootViewControllerAnimated:YES];
  368. [MBProgressHUD rq_hideHUD];
  369. myDelegate.isLogin = NO;
  370. if ([defUser.car_type isEqualToString:@"2"]) {
  371. defUser.car_type = @"C1";
  372. defUser.isZhiGeZheng = @"NO";
  373. myDelegate.subject = @"1";
  374. }
  375. NSString *keyStr = [NSString stringWithFormat:@"zhuxiaozhanghao-%@",defUser.userStuId];
  376. [RQPreferenceSettingHelper setObject:@(YES) forKey:keyStr];
  377. [defUser removeUserInfo];
  378. [self performSelector:@selector(userLoginAction) withObject:nil afterDelay:1];
  379. }];
  380. }
  381. }];
  382. }
  383. }
  384. - (RACSignal *)zx {
  385. return [[[RACSignal createSignal:^RACDisposable *(id<RACSubscriber> subscriber) {
  386. /// 延迟一段时间
  387. [subscriber sendNext:@1];
  388. return [RACDisposable disposableWithBlock:^{
  389. /// 取消任务
  390. }];
  391. }] delay:3] deliverOnMainThread];
  392. }
  393. -(void)userLoginAction{
  394. LoginViewController* vc = [[LoginViewController alloc] init];
  395. vc.modalPresentationStyle = UIModalPresentationFullScreen;
  396. [RQControllerHelper.currentViewController presentViewController:vc animated:YES completion:nil];
  397. }
  398. #pragma mark 修改个人信息
  399. - (void)setNickNameWithString:(NSString *)nick
  400. {
  401. if (![Util connectedToNetWork]) {
  402. showMsgUnconnect();
  403. return;
  404. }
  405. NSMutableArray *arr=[NSMutableArray array];
  406. [arr addPro:@"userId" Value:defUser.userDict[@"id"]];
  407. [arr addPro:@"nickName" Value:nick];
  408. NSString* method = @"updateNickName";
  409. [MBProgressHUD showLoadToView:self.view];
  410. [jiaPeiManager requestAnythingWithURL:method array:arr data:nil completion:^(NSDictionary *root) {
  411. [MBProgressHUD hideHUDForView:self.view];
  412. //NSLog(@"updateNickName--><>%@",root);
  413. if (!root) {
  414. ShowMsg(@"修改失败,请重试!");
  415. return;
  416. }
  417. ShowMsg(root[@"body"]);
  418. if ([root[@"code"] isEqualToString:@"0"]) {
  419. defUser.userNickName = nick;
  420. NSIndexPath *indexPath = [NSIndexPath indexPathForRow:1 inSection:0];
  421. [myTableView reloadRowsAtIndexPaths:[NSArray arrayWithObjects:indexPath,nil] withRowAnimation:UITableViewRowAnimationNone];
  422. [LoginViewController reLoginFromViewController:self finishBlock:nil];
  423. }
  424. }];
  425. }
  426. -(void)InputView:(InputView *)view didGetImage:(UIImage *)image
  427. {
  428. headImg = image;
  429. [self upLoadImg];
  430. }
  431. -(void)InputViewWillPickImage:(InputView *)view
  432. {
  433. // UIImagePickerController *pickerImage = [[UIImagePickerController alloc] init];
  434. // if([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary]) {
  435. // pickerImage.sourceType = view.type;
  436. //// pickerImage.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
  437. // pickerImage.mediaTypes = [UIImagePickerController availableMediaTypesForSourceType:pickerImage.sourceType];
  438. // }
  439. // pickerImage.delegate = self;
  440. // pickerImage.allowsEditing = NO;
  441. // pickerImage.modalPresentationStyle = UIModalPresentationFullScreen;
  442. // [self presentViewController:pickerImage animated:YES completion:nil];
  443. @weakify(self)
  444. [[RACScheduler mainThreadScheduler] schedule:^{
  445. @strongify(self)
  446. if ([QMUIAssetsManager authorizationStatus] == QMUIAssetAuthorizationStatusNotDetermined) {
  447. [QMUIAssetsManager requestAuthorization:^(QMUIAssetAuthorizationStatus status) {
  448. dispatch_async(dispatch_get_main_queue(), ^{
  449. [self presentAlbumViewControllerWithTitle:@"上传照片"];
  450. });
  451. }];
  452. } else {
  453. [self presentAlbumViewControllerWithTitle:@"上传照片"];
  454. }
  455. }];
  456. }
  457. - (void) imagePickerController:(UIImagePickerController *)picker
  458. didFinishPickingMediaWithInfo:(NSDictionary *)info
  459. {
  460. [inputVi cancelAction];
  461. [picker dismissViewControllerAnimated:YES completion:^{
  462. UIImage *originalImage = [info objectForKey:UIImagePickerControllerOriginalImage];
  463. headImg = originalImage;
  464. [self upLoadImg];
  465. }];
  466. }
  467. -(void)upLoadImg
  468. {
  469. // if (!headImg) {
  470. // return;
  471. // }
  472. //
  473. // TOCropViewController *cropController = [[TOCropViewController alloc] initWithCroppingStyle:TOCropViewCroppingStyleCircular image:headImg];
  474. // __weak TOCropViewController *weakCropC = cropController;
  475. // cropController.onDidCropToCircleImage = ^(UIImage * _Nonnull image, CGRect cropRect, NSInteger angle) {
  476. // [weakCropC dismissViewControllerAnimated:YES completion:nil];
  477. // headImg = image;
  478. // [self uploadHeadImage:image];
  479. // };
  480. // cropController.modalPresentationStyle = UIModalPresentationFullScreen;
  481. // [self presentViewController:cropController animated:NO completion:nil];
  482. }
  483. - (void)uploadHeadImage:(UIImage*)image
  484. {
  485. if (![Util connectedToNetWork]) {
  486. showMsgUnconnect();
  487. return;
  488. }
  489. NSData * data;
  490. if (UIImageJPEGRepresentation(image, .5))
  491. {
  492. //图片质量 压缩成多少
  493. data = UIImageJPEGRepresentation(image, .5);
  494. }
  495. else
  496. {
  497. data = UIImagePNGRepresentation(image);
  498. }
  499. NSArray *dataArray = [NSArray arrayWithObject:data];
  500. [MBProgressHUD showLoadToView:self.view];
  501. [jiaPeiManager requestAnythingWithURL:@"uploadUserImg" array:dataArray data:data completion:^(NSDictionary *root) {
  502. if (!root) {
  503. [MBProgressHUD hideHUDForView:self.view];
  504. ShowMsg(@"上传失败");
  505. return;
  506. }
  507. if (![root[@"code"] isEqualToString:@"0"]) {
  508. [MBProgressHUD hideHUDForView:self.view];
  509. ShowMsg(root[@"body"]);
  510. return;
  511. }
  512. NSMutableArray *arr = [NSMutableArray array];
  513. [arr addPro:@"userId" Value:defUser.userDict[@"id"]];
  514. [arr addPro:@"photo" Value:root[@"body"]];
  515. [jiaPeiManager requestAnythingWithURL:@"uploadHeadImg" array:arr data:nil completion:^(NSDictionary *root) {
  516. [MBProgressHUD hideHUDForView:self.view];
  517. if (!root) {
  518. ShowMsg(@"保存失败");
  519. return;
  520. }
  521. ShowMsg(root[@"body"]);
  522. if (![root[@"code"] isEqualToString:@"0"]) {
  523. return;
  524. }
  525. //上传头像后 在获取下最新信息
  526. [self upDateUserInfo];
  527. }];
  528. }];
  529. }
  530. -(void)showInputHeadImg
  531. {
  532. InputView* vi = [[InputView alloc] initWithTitle:@"请选择头像"];
  533. [vi setDelegate:self];
  534. [vi show];
  535. inputVi = vi;
  536. }
  537. //更新表
  538. -(void)upDateUserInfo
  539. {
  540. [LoginViewController reLoginFromViewController:self finishBlock:^{
  541. [myTableView reloadData];
  542. }];
  543. }
  544. -(void)showInputSex//no use now
  545. {
  546. UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"请选择性别" message:nil preferredStyle:UIAlertControllerStyleAlert];
  547. [alert addAction:[UIAlertAction actionWithTitle:@"女" style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {
  548. defUser.userSex = @"女";
  549. NSIndexPath *indexPath=[NSIndexPath indexPathForRow:1 inSection:1];
  550. [myTableView reloadRowsAtIndexPaths:[NSArray arrayWithObjects:indexPath,nil] withRowAnimation:UITableViewRowAnimationNone];
  551. }]];
  552. [alert addAction:[UIAlertAction actionWithTitle:@"男" style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {
  553. defUser.userSex = @"男";
  554. NSIndexPath *indexPath=[NSIndexPath indexPathForRow:1 inSection:1];
  555. [myTableView reloadRowsAtIndexPaths:[NSArray arrayWithObjects:indexPath,nil] withRowAnimation:UITableViewRowAnimationNone];
  556. }]];
  557. [self presentViewController:alert animated:true completion:nil];
  558. }
  559. -(void)showInputNickName
  560. {
  561. //alert的又一种用法
  562. UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"请输入昵称" message:nil preferredStyle:UIAlertControllerStyleAlert];
  563. [alert addTextFieldWithConfigurationHandler:^(UITextField * textField) {
  564. textField.placeholder = @"请输入昵称";
  565. }];
  566. [alert addAction:[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil]];
  567. [alert addAction:[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {
  568. NSString* text = [[alert.textFields firstObject] text];
  569. [self setNickNameWithString:text];
  570. }]];
  571. [self presentViewController:alert animated:true completion:nil];
  572. }
  573. #pragma mark 绑定qq 微信
  574. - (void)bindThirdPartyWithType:(NSString *)BindType OpenId:(NSString *)openId
  575. {
  576. if (![Util connectedToNetWork]) {
  577. showMsgUnconnect();
  578. return;
  579. }
  580. NSMutableArray *arr=[NSMutableArray array];
  581. [arr addPro:@"userId" Value:defUser.userDict[@"id"]];
  582. [arr addPro:@"type" Value:BindType];
  583. [arr addPro:@"account" Value:@""];//获取不到 先不传
  584. [arr addPro:@"openId" Value:openId];
  585. NSString* method = @"bindThirdParty";
  586. [MBProgressHUD showLoadToView:self.view];
  587. [jiaPeiManager requestAnythingWithURL:method array:arr data:nil completion:^(NSDictionary * root) {
  588. [MBProgressHUD hideHUDForView:self.view];
  589. if ([root[@"code"] isEqualToString:@"1"]) {
  590. ShowMsg(root[@"body"]);
  591. return;
  592. }
  593. //绑定成功,更新ui
  594. ShowMsgSuc();
  595. [self upDateUserInfo];
  596. }];
  597. }
  598. - (void)WetchatLoginAction
  599. {
  600. // [ShareSDK cancelAuthorize:SSDKPlatformTypeWechat result:^(NSError *error) {
  601. //
  602. // }]; //这儿就是取消授权
  603. // [ShareSDK getUserInfo: SSDKPlatformTypeWechat
  604. // onStateChanged:^(SSDKResponseState state, SSDKUser *user, NSError *error)
  605. // {
  606. // if (state == SSDKResponseStateSuccess)
  607. // {
  608. //
  609. // //绑定接口
  610. // [self bindThirdPartyWithType:@"2" OpenId:user.uid];
  611. // }else{
  612. // ShowMsg(@"微信登录验证失败");
  613. // }
  614. // }];
  615. }
  616. - (void)QQLoginAction
  617. {
  618. // [ShareSDK cancelAuthorize:SSDKPlatformTypeQQ result:^(NSError *error) {
  619. //
  620. // }];//这儿就是取消授权
  621. // [ShareSDK getUserInfo: SSDKPlatformTypeQQ
  622. // onStateChanged:^(SSDKResponseState state, SSDKUser *user, NSError *error)
  623. // {
  624. // if (state == SSDKResponseStateSuccess)
  625. // {
  626. // //绑定接口
  627. // [self bindThirdPartyWithType:@"3" OpenId:user.uid];
  628. // }else{
  629. // ShowMsg(@"QQ登录验证失败");
  630. // }
  631. // }];
  632. }
  633. #pragma mark 绑定手机号
  634. - (void)bindAction {
  635. // UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"绑定手机" message:@"请确认手机号码,以获取验证码" preferredStyle:UIAlertControllerStyleAlert];
  636. // [alert addTextFieldWithConfigurationHandler:^(UITextField * textField) {
  637. // textField.placeholder = @"请输入手机号码";
  638. //
  639. // NSString *telStr = defUser.userTel;
  640. // if ([telStr length] > 0) {
  641. // textField.text = telStr;
  642. // }
  643. // }];
  644. // [alert addAction:[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil]];
  645. // [alert addAction:[UIAlertAction actionWithTitle:@"下一步" style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {
  646. //
  647. // bindTel = [[alert.textFields firstObject] text];
  648. // if (![Tools isMobileNumber:bindTel]) {
  649. // ShowMsg(@"请核对电话号码");
  650. // [self presentViewController:alert animated:true completion:nil];
  651. // return;
  652. // }
  653. // //调获取验证码接口
  654. // SubmitNumType = @"3";
  655. // [RQ_SHARE_FUNCTION checkMobPolicyOnResult:^(BOOL success) {
  656. // [SMSSDK getVerificationCodeByMethod:SMSGetCodeMethodSMS phoneNumber:bindTel zone:@"86" template:nil result:^(NSError *error) {
  657. // if (error) {
  658. // if (error.code == 477) {
  659. // ShowMsg(@"当天验证次数已超上限");
  660. // }else{
  661. // ShowMsg(@"请检查手机号码是否正确");
  662. // }
  663. // [self presentViewController:alert animated:true completion:nil];
  664. // } else {
  665. //
  666. // UIAlertController *subAlert = [UIAlertController alertControllerWithTitle:@"绑定手机" message:nil preferredStyle:UIAlertControllerStyleAlert];
  667. // [subAlert addTextFieldWithConfigurationHandler:^(UITextField * textField) {
  668. // textField.placeholder = @"请输入验证码";
  669. // }];
  670. // [subAlert addAction:[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil]];
  671. // [subAlert addAction:[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {
  672. //
  673. // NSString *subString = [[subAlert.textFields firstObject] text];
  674. // if (subString.length < 1) {
  675. // ShowMsg(@"请输入有效验证码");
  676. // [self presentViewController:subAlert animated:true completion:nil];
  677. // return;
  678. // }
  679. // //调检验验证码的接口
  680. // [self clickToSubmitWithSubNum:subString];
  681. // }]];
  682. // [self presentViewController:subAlert animated:true completion:nil];
  683. // }}];
  684. // }];
  685. // ;
  686. // }]];
  687. // [self presentViewController:alert animated:true completion:nil];
  688. }
  689. //绑定手机号
  690. -(void)bindAccountTel
  691. {
  692. if (![Util connectedToNetWork])
  693. {
  694. showMsgUnconnect();
  695. return;
  696. }
  697. NSMutableArray *arr=[NSMutableArray array];
  698. [arr addPro:@"user" Value:defUser.userDict[@"id"]];
  699. [arr addPro:@"tel" Value:bindTel];
  700. NSString* method = @"bindAccountTel";
  701. [MBProgressHUD showLoadToView:self.view];
  702. [jiaPeiManager requestAnythingWithURL:method array:arr data:nil completion:^(NSDictionary * root) {
  703. [MBProgressHUD hideHUDForView:self.view];
  704. //NSLog(@"用户绑定---->%@---%@",arr,root);
  705. if (!root) {
  706. ShowMsg(@"绑定失败");
  707. return;
  708. }
  709. if (!root || [root[@"code"] isEqualToString:@"1"])
  710. {
  711. ShowMsg(root[@"body"]);
  712. return;
  713. }
  714. ShowMsgSuc();
  715. [self upDateUserInfo];
  716. }];
  717. }
  718. //验证码有效性检验
  719. -(void)clickToSubmitWithSubNum:(NSString *)subNum {
  720. // //验证验证码是否过期
  721. // if (![Util connectedToNetWork]) {
  722. // showMsgUnconnect();
  723. // return;
  724. // }
  725. //
  726. // [MBProgressHUD showLoadToView:self.view];
  727. // [SMSSDK commitVerificationCode:subNum phoneNumber:bindTel zone:@"86" result:^(NSError *error) {
  728. // if (error) {
  729. // //NSLog(@"验证码有误");
  730. // [MBProgressHUD hideHUDForView:self.view];
  731. // ShowMsg(@"验证失败,请重试");
  732. // return;
  733. // }
  734. //
  735. // if ([SubmitNumType isEqualToString:@"3"]) {
  736. // [self bindAccountTel];
  737. // return;
  738. // }
  739. //
  740. // if ([SubmitNumType isEqualToString:@"1"]) {
  741. // //设置支付密码
  742. // UIAlertView *alertKey = [[UIAlertView alloc] initWithTitle:@"设置新密码" message:@"" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确认",nil];
  743. // [alertKey setAlertViewStyle:UIAlertViewStyleLoginAndPasswordInput];
  744. // alertKey.tag = 11;
  745. // psw1 = [alertKey textFieldAtIndex:0];
  746. // psw1.keyboardType = UIKeyboardTypeNumbersAndPunctuation;
  747. // psw1.delegate = self;
  748. // psw2 = [alertKey textFieldAtIndex:1];
  749. // psw2.keyboardType = UIKeyboardTypeNumbersAndPunctuation;
  750. //
  751. // psw1.placeholder = @"请输入新密码";
  752. // psw2.placeholder = @"请确认密码";
  753. // [psw1 setSecureTextEntry:YES];
  754. // [alertKey show];
  755. // }
  756. // }];
  757. //
  758. }
  759. -(BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
  760. {
  761. NSString *newStr = [textField.text stringByReplacingCharactersInRange:range withString:string];
  762. if (newStr.length >6) {
  763. ShowMsg(@"密码不能超过6位数字");
  764. return NO;
  765. }
  766. return YES;
  767. }
  768. #pragma mark 设置支付密码
  769. -(void)setPayPassword
  770. {
  771. // bindTel = defUser.userDict[@"telphone"];
  772. // [RQ_SHARE_FUNCTION checkMobPolicyOnResult:^(BOOL success) {
  773. // //获取验证码
  774. // [SMSSDK getVerificationCodeByMethod:SMSGetCodeMethodSMS phoneNumber:bindTel zone:@"86" template:nil result:^(NSError *error) {
  775. // if (error) {
  776. // if (error.code == 477) {
  777. // ShowMsg(@"当天验证次数已超上限");
  778. // }else{
  779. // ShowMsg(@"请检查手机号码是否正确");
  780. // }
  781. // } else {
  782. // UIAlertController *subAlert = [UIAlertController alertControllerWithTitle:@"设置支付密码" message:[NSString stringWithFormat:@"验证码已发送到您尾号为%@的绑定手机上,请注意查收",[bindTel substringFromIndex:bindTel.length - 4]] preferredStyle:UIAlertControllerStyleAlert];
  783. //
  784. // [subAlert addTextFieldWithConfigurationHandler:^(UITextField * textField) {
  785. // textField.placeholder = @"请输入验证码";
  786. // }];
  787. // [subAlert addAction:[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil]];
  788. // [subAlert addAction:[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {
  789. //
  790. // NSString *subString = [[subAlert.textFields firstObject] text];
  791. // if (subString.length < 1) {
  792. // ShowMsg(@"请输入有效验证码");
  793. // [self presentViewController:subAlert animated:true completion:nil];
  794. // return;
  795. // }
  796. // //检验验证码
  797. // SubmitNumType = @"1";
  798. // [self clickToSubmitWithSubNum:subString];
  799. // }]];
  800. //
  801. // [self presentViewController:subAlert animated:true completion:nil];
  802. // }
  803. // }];
  804. // }];
  805. }
  806. #pragma mark 修改支付密码
  807. -(void)fixPayKey
  808. {
  809. // SubmitNumType = @"1";
  810. // UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"验证原密码" message:nil preferredStyle:UIAlertControllerStyleAlert];
  811. // [alert addTextFieldWithConfigurationHandler:^(UITextField * textField) {
  812. // textField.placeholder = @"请输入原密码";
  813. // }];
  814. //
  815. // [alert addAction:[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {
  816. //
  817. // NSString* text = [[alert.textFields firstObject] text];
  818. //
  819. // if (text.length < 1) {
  820. // ShowMsg(@"请输入原密码");
  821. // [self presentViewController:alert animated:true completion:nil];
  822. // return;
  823. // }
  824. //
  825. // NSString *oldKey = defUser.userDict[@"payPwd"];
  826. // if (![[text md5Encrypt] isEqualToString:oldKey]) {
  827. // ShowMsg(@"原密码错误!");
  828. // [self presentViewController:alert animated:true completion:nil];
  829. // return;
  830. // }
  831. //
  832. // UIAlertView *alertKey = [[UIAlertView alloc] initWithTitle:@"设置新密码" message:@"" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确认",nil];
  833. // [alertKey setAlertViewStyle:UIAlertViewStyleLoginAndPasswordInput];
  834. // alertKey.tag = 11;
  835. // psw1 = [alertKey textFieldAtIndex:0];
  836. // psw1.keyboardType = UIKeyboardTypeNumbersAndPunctuation;
  837. // psw1.delegate = self;
  838. // psw2 = [alertKey textFieldAtIndex:1];
  839. // psw2.keyboardType = UIKeyboardTypeNumbersAndPunctuation;
  840. //
  841. // psw1.placeholder = @"请输入新密码";
  842. // psw2.placeholder = @"请确认密码";
  843. //
  844. // [psw1 setSecureTextEntry:YES];
  845. //
  846. // [alertKey show];
  847. //
  848. // }]];
  849. //
  850. // [alert addAction:[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleDefault handler:nil]];
  851. //
  852. // [alert addAction:[UIAlertAction actionWithTitle:@"忘记密码" style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {
  853. // //找回密码
  854. // UIAlertController *alertFind = [UIAlertController alertControllerWithTitle:@"找回支付密码" message:@"请填写账户绑定手机号码" preferredStyle:UIAlertControllerStyleAlert];
  855. // [alertFind addTextFieldWithConfigurationHandler:^(UITextField * phoneNumField) {
  856. // phoneNumField.placeholder = @"请输入手机号码";
  857. // }];
  858. // [alertFind addAction:[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil]];
  859. // [alertFind addAction:[UIAlertAction actionWithTitle:@"下一步" style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {
  860. //
  861. // bindTel = [[alertFind.textFields firstObject] text];
  862. // if (![bindTel isEqualToString:defUser.userDict[@"telphone"]]) {
  863. // ShowMsg(@"填写号码与绑定号码不匹配,请重试");
  864. // [self presentViewController:alertFind animated:true completion:nil];
  865. // return;
  866. // }
  867. //
  868. // [RQ_SHARE_FUNCTION checkMobPolicyOnResult:^(BOOL success) {
  869. // //获取验证码
  870. // [SMSSDK getVerificationCodeByMethod:SMSGetCodeMethodSMS phoneNumber:bindTel zone:@"86" template:nil result:^(NSError *error) {
  871. // if (error) {
  872. // //下发验证码失败
  873. // if (error.code == 477) {
  874. // ShowMsg(@"当天验证次数已超上限");
  875. // }else{
  876. // ShowMsg(@"请检查手机号码是否正确");
  877. // }
  878. // [self presentViewController:alertFind animated:true completion:nil];
  879. // } else {
  880. // //下发验证码后的操作
  881. // UIAlertController *subAlert = [UIAlertController alertControllerWithTitle:@"找回支付密码" message:nil preferredStyle:UIAlertControllerStyleAlert];
  882. // [subAlert addTextFieldWithConfigurationHandler:^(UITextField * textField) {
  883. // textField.placeholder = @"请输入验证码";
  884. // textField.keyboardType = UIKeyboardTypeNumberPad;
  885. // }];
  886. // [subAlert addAction:[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil]];
  887. // [subAlert addAction:[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {
  888. //
  889. // NSString *subString = [[subAlert.textFields firstObject] text];
  890. // if (subString.length < 1) {
  891. // ShowMsg(@"请输入有效验证码");
  892. // [self presentViewController:subAlert animated:true completion:nil];
  893. // return;
  894. // }
  895. // //调检验验证码的接口
  896. // [self clickToSubmitWithSubNum:subString];
  897. // }]];
  898. // [self presentViewController:subAlert animated:true completion:nil];
  899. // }
  900. // }];
  901. // }];
  902. // }]];//以上是下一步的操作
  903. // [self presentViewController:alertFind animated:true completion:nil];
  904. // }]];
  905. // [self presentViewController:alert animated:true completion:nil];
  906. }
  907. #pragma mark 修改登录密码
  908. -(void)fixKey
  909. {
  910. SubmitNumType = @"-1";
  911. UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"验证原密码" message:@"如果忘了原密码,请重新登录即可利用找回密码设置新密码" preferredStyle:UIAlertControllerStyleAlert];
  912. [alert addTextFieldWithConfigurationHandler:^(UITextField * textField) {
  913. textField.placeholder = @"请输入原密码";
  914. textField.keyboardType = UIKeyboardTypeNumbersAndPunctuation;
  915. }];
  916. [alert addAction:[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil]];
  917. // [alert addAction:[UIAlertAction actionWithTitle:@"忘记密码" style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {
  918. //
  919. // [Message_SMS_VC goSMSFormVC:self phoneNumber:phoneNumber loginCode:userText.text canEditNum:NO];
  920. // }]];
  921. [alert addAction:[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {
  922. NSString* text = [[alert.textFields firstObject] text];
  923. NSUserDefaults *ud = [NSUserDefaults standardUserDefaults];
  924. NSString *key = [ud objectForKey:@"password"];
  925. if (![text isEqualToString:key]) {
  926. ShowMsg(@"原密码错误!");
  927. return;
  928. }
  929. UIAlertView *alertKey = [[UIAlertView alloc] initWithTitle:@"修改密码" message:@"" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确认修改",nil];
  930. [alertKey setAlertViewStyle:UIAlertViewStyleLoginAndPasswordInput];
  931. alertKey.tag = 11;
  932. psw1 = [alertKey textFieldAtIndex:0];
  933. psw2 = [alertKey textFieldAtIndex:1];
  934. psw1.placeholder = @"请输入新密码";
  935. psw2.placeholder = @"请确认密码";
  936. [psw1 setSecureTextEntry:YES];
  937. [alertKey show];
  938. }]];
  939. [self presentViewController:alert animated:true completion:nil];
  940. }
  941. -(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
  942. {
  943. if (alertView.tag == 11) {
  944. if (buttonIndex == 1)
  945. {
  946. if ([SubmitNumType isEqualToString:@"-1"]) {
  947. [self submit];
  948. }else{
  949. [self bindAccountZfmm];
  950. }
  951. }
  952. }
  953. }
  954. //设置登录密码 成功后重新登录
  955. -(void)submit
  956. {
  957. if (![psw1.text isEqualToString:psw2.text])
  958. {
  959. UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"提示" message:@"密码不一致,请您核查" delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
  960. [alert show];
  961. return;
  962. }
  963. NSUserDefaults *ud = [NSUserDefaults standardUserDefaults];
  964. // NSString *nameString = [ud objectForKey:@"identifyNum"];
  965. NSMutableArray *arr=[NSMutableArray array];
  966. [arr addPro:@"loginCode" Value:defUser.userDict[@"loginCode"]];
  967. [arr addPro:@"pwd" Value:psw1.text];
  968. [arr addPro:@"dqbh" Value:defUser.userDict[@"city"]];
  969. NSString* method = @"savePwdN";
  970. [MBProgressHUD showLoadToView:self.view];
  971. [jiaPeiManager requestAnythingWithURL:method array:arr data:nil completion:^(NSDictionary * root) {
  972. [MBProgressHUD hideHUDForView:self.view];
  973. //NSLog(@"密码返回数据->%@",root);
  974. if (!root)
  975. {
  976. ShowMsgFailed();
  977. return;
  978. }
  979. if ( 1 == [root[@"code"] integerValue]) {
  980. ShowMsg(root[@"body"]);
  981. return;
  982. }
  983. ShowMsg(@"修改成功,请重新登录!");
  984. //这里要做的事 到登录页面 改变登录状态 清除原来的密码信息
  985. [ud setObject:@"" forKey:@"password"];
  986. //异步储存 防止信息未存储 强制立即将数据写入磁盘
  987. [ud synchronize];
  988. myDelegate.isLogin = NO;
  989. if ([defUser.car_type isEqualToString:@"2"]) {
  990. defUser.car_type = @"C1";
  991. defUser.isZhiGeZheng = @"NO";
  992. myDelegate.subject = @"1";
  993. }
  994. [defUser removeUserInfo];
  995. [self userLoginAction];
  996. }];
  997. }
  998. //设置支付密码
  999. -(void)bindAccountZfmm
  1000. {
  1001. psw1.delegate = nil;
  1002. if (![psw1.text isEqualToString:psw2.text])
  1003. {
  1004. UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"提示" message:@"密码不一致,请您核查" delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
  1005. [alert show];
  1006. return;
  1007. }
  1008. NSMutableArray *arr =[NSMutableArray array];
  1009. [arr addPro:@"user" Value:defUser.userDict[@"id"]];
  1010. [arr addPro:@"pwd" Value:[psw1.text md5Encrypt]];
  1011. NSString* method = @"bindAccountZfmm";
  1012. [MBProgressHUD showLoadToView:self.view];
  1013. [jiaPeiManager requestAnythingWithURL:method array:arr data:nil completion:^(NSDictionary * root) {
  1014. [MBProgressHUD hideHUDForView:self.view];
  1015. //NSLog(@"支付密码返回数据--->%@--->%@",arr,root);
  1016. if (!root)
  1017. {
  1018. ShowMsgFailed();
  1019. return;
  1020. }
  1021. if ( 1 == [root[@"code"] integerValue]) {
  1022. ShowMsg(root[@"body"]);
  1023. return;
  1024. }
  1025. ShowMsgSuc();
  1026. [self upDateUserInfo];
  1027. }];
  1028. }
  1029. #pragma mark - <QMUIAlbumViewControllerDelegate>
  1030. - (QMUIImagePickerViewController *)imagePickerViewControllerForAlbumViewController:(QMUIAlbumViewController *)albumViewController {
  1031. QMUIImagePickerViewController *imagePickerViewController = [[QMUIImagePickerViewController alloc] init];
  1032. imagePickerViewController.imagePickerViewControllerDelegate = self;
  1033. imagePickerViewController.maximumSelectImageCount = 1;
  1034. return imagePickerViewController;
  1035. }
  1036. #pragma mark - <QMUIImagePickerViewControllerDelegate>
  1037. - (void)imagePickerViewController:(QMUIImagePickerViewController *)imagePickerViewController didFinishPickingImageWithImagesAssetArray:(NSMutableArray<QMUIAsset *> *)imagesAssetArray {
  1038. // 储存最近选择了图片的相册,方便下次直接进入该相册
  1039. [QMUIImagePickerHelper updateLastestAlbumWithAssetsGroup:imagePickerViewController.assetsGroup ablumContentType:QMUIAlbumContentTypeOnlyPhoto userIdentify:nil];
  1040. [self sendImageWithImagesAssetArray:imagesAssetArray];
  1041. }
  1042. #pragma mark - <QMUIImagePickerPreviewViewControllerDelegate>
  1043. - (void)imagePickerPreviewViewController:(QMUIImagePickerPreviewViewController *)imagePickerPreviewViewController didCheckImageAtIndex:(NSInteger)index {
  1044. [self updateImageCountLabelForPreviewView:imagePickerPreviewViewController];
  1045. }
  1046. - (void)imagePickerPreviewViewController:(QMUIImagePickerPreviewViewController *)imagePickerPreviewViewController didUncheckImageAtIndex:(NSInteger)index {
  1047. [self updateImageCountLabelForPreviewView:imagePickerPreviewViewController];
  1048. }
  1049. // 更新选中的图片数量
  1050. - (void)updateImageCountLabelForPreviewView:(QMUIImagePickerPreviewViewController *)imagePickerPreviewViewController {
  1051. // QDMultipleImagePickerPreviewViewController *customImagePickerPreviewViewController = (QDMultipleImagePickerPreviewViewController *)imagePickerPreviewViewController;
  1052. // NSUInteger selectedCount = [imagePickerPreviewViewController.selectedImageAssetArray count];
  1053. // if (selectedCount > 0) {
  1054. // customImagePickerPreviewViewController.imageCountLabel.text = [[NSString alloc] initWithFormat:@"%@", @(selectedCount)];
  1055. // customImagePickerPreviewViewController.imageCountLabel.hidden = NO;
  1056. // [QMUIImagePickerHelper springAnimationOfImageSelectedCountChangeWithCountLabel:customImagePickerPreviewViewController.imageCountLabel];
  1057. // } else {
  1058. // customImagePickerPreviewViewController.imageCountLabel.hidden = YES;
  1059. // }
  1060. }
  1061. - (void)presentAlbumViewControllerWithTitle:(NSString *)title {
  1062. // 创建一个 QMUIAlbumViewController 实例用于呈现相簿列表
  1063. QMUIAlbumViewController *albumViewController = [[QMUIAlbumViewController alloc] init];
  1064. albumViewController.albumViewControllerDelegate = self;
  1065. albumViewController.contentType = QMUIAlbumContentTypeOnlyPhoto;
  1066. albumViewController.title = title;
  1067. RQBaseNavigationController *navigationController = [[RQBaseNavigationController alloc] initWithRootViewController:albumViewController];
  1068. // 获取最近发送图片时使用过的相簿,如果有则直接进入该相簿
  1069. [albumViewController pickLastAlbumGroupDirectlyIfCan];
  1070. [self presentPanModal:navigationController];
  1071. }
  1072. - (void)sendImageWithImagesAssetArray:(NSMutableArray<QMUIAsset *> *)imagesAssetArray {
  1073. __weak __typeof(self)weakSelf = self;
  1074. for (QMUIAsset *asset in imagesAssetArray) {
  1075. [QMUIImagePickerHelper requestImageAssetIfNeeded:asset completion:^(QMUIAssetDownloadStatus downloadStatus, NSError *error) {
  1076. if (downloadStatus == QMUIAssetDownloadStatusDownloading) {
  1077. // [weakSelf startLoadingWithText:@"从 iCloud 加载中"];
  1078. } else if (downloadStatus == QMUIAssetDownloadStatusSucceed) {
  1079. [weakSelf sendImageWithImagesAssetIfDownloadStatusSucceed:asset];
  1080. } else {
  1081. // [weakSelf showTipLabelWithText:@"iCloud 下载错误,请重新选图"];
  1082. }
  1083. }];
  1084. }
  1085. }
  1086. - (void)sendImageWithImagesAssetIfDownloadStatusSucceed:(QMUIAsset *)imagesAsset {
  1087. @weakify(self)
  1088. CGFloat photoWidth = (RQ_SCREEN_WIDTH - (16.f * 4) - 90.f - (8.f * 3)) / 4.f;
  1089. NSMutableArray <QMUIAsset *>*arr = @[imagesAsset].mutableCopy;
  1090. if ([QMUIImagePickerHelper imageAssetsDownloaded:arr]) {
  1091. [[[arr.rac_sequence.signal deliverOnMainThread] distinctUntilChanged] subscribeNext:^(QMUIAsset * _Nullable asset) {
  1092. @strongify(self)
  1093. UIImage *image = asset.originImage;
  1094. headImg = image;
  1095. [self uploadHeadImage:image];
  1096. }];
  1097. }
  1098. }
  1099. @end