1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237 |
- /**
- 个人页面跳转进来两种情况,一是从tabbar直接过来,不用返回;另一种是从侧栏进来,要返回回去的
- */
- #import "StuDetailVC.h"
- #import "CLCell.h"
- #import "Tools.h"
- #import "DES3Util.h"
- //#import <SMS_SDK/SMSSDK.h>
- //#import <ShareSDK/ShareSDK.h>
- #import "ThirdLoginBindYunGuanVC.h"
- #import "ShowBindVC.h"
- //#import <TOCropViewController.h>
- @interface StuDetailVC ()<UITableViewDataSource,UITableViewDelegate,UIAlertViewDelegate,UITextFieldDelegate,QMUIAlbumViewControllerDelegate,QMUIImagePickerViewControllerDelegate,QMUIImagePreviewViewDelegate>
- {
- UITableView *myTableView;
- UITextField *psw1;
- UITextField *psw2;
-
- NSArray *titles;
- NSArray *images;
- NSArray *details;
- NSString *SubmitNumType;
- NSString *bindTel;
- }
- @property (nonatomic, readwrite, strong) QMUIImagePreviewViewController *imagePreviewViewController;
- @end
- @implementation StuDetailVC
- - (void)viewDidLoad
- {
- [super viewDidLoad];
-
- [self setTitle:@"个人中心"];
- self.navigationController.navigationBar.translucent = NO;
- [self.view setBackgroundColor:[UIColor whiteColor]];
-
- // if (_tag == 1)
- // {
- // UIBarButtonItem* backBbi = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"question_pre_checked_icon.png"] style:UIBarButtonItemStylePlain target:self action:@selector(dismissNav)];
- // [backBbi setTintColor:defGreen];
- // self.navigationController.navigationBar.translucent = NO;
- // [self.navigationItem setLeftBarButtonItem:backBbi];
- // }
- // if (_tag == 2) {
- // [self configNavigationBar];
- // }
- [self configNavigationBar];
- defUser.userNickName = defUser.userDict[@"nickName"];
-
- [self myInit];
- }
- -(void)viewWillAppear:(BOOL)animated
- {
- [super viewWillAppear:animated];
- if ([defUser.userDict[@"id"] length] < 1)
- {
- defUser.userNickName = @"";
- defUser.userSex = @"";
- }
- }
- -(void)myInit
- {
- [self loadModels];
-
- myTableView = [[UITableView alloc] initWithFrame:kFrame style:UITableViewStyleGrouped];
- myTableView.height -= kNavOffSet;
- [self.view addSubview:myTableView];
- [myTableView setDelegate:self];
- [myTableView setDataSource:self];
-
- UIView* v = [[UIView alloc] initWithFrame:kFrame];
- v.height = 100;
- [myTableView setTableFooterView:v];
- }
- -(void)dismissNav
- {
- self.tag = 0;
- [self.view endEditing:YES];
- [self.navigationController dismissViewControllerAnimated:NO completion:nil];
- }
- - (void)didReceiveMemoryWarning
- {
- [super didReceiveMemoryWarning];
- }
- #pragma mark -
- -(void)loadModels
- {
- // titles = @[@[@"头像",@"昵称",@"手机号码"],@[@"姓名",@"性别",@"年龄",@"车型",@"报名时间"],@[@"修改密码"]];
- // 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"]];
- NSUserDefaults * ud = [NSUserDefaults standardUserDefaults];
- NSDictionary *udDic = [ud objectForKey:@"jiaPeiLoginTest"];
- if ([udDic[@"loginType"] isEqualToString:@"1"]){
- //由计时平台账号登录
- titles = @[@[@"头像",@"昵称"],
- @[@"姓名",@"性别",@"年龄",@"车型",@"报名时间"],
- @[/*@"QQ绑定",@"微信绑定"*/],
- @[@"修改登录密码"/*,@"设置支付密码"*/],
- @[@"注销账号"]];
- images = @[@[@"center_img01.png",@"center_img02.png"],
- @[@"center_img04.png",@"center_img05.png",@"center_img06.png",@"center_img07.png",@"center_img08.png"],
- @[/*@"center_img11.png",@"center_img12.png"*/],
- @[@"center_img09.png"/*,@"center_img10.png"*/],
- @[@"center_img03.png"]];//@"center_img03.png" 手机绑定
- }else{
- //第三方或者手机号登录
- titles = @[@[@"头像",@"昵称"],
- @[@"姓名",@"性别",@"年龄",@"车型",@"报名时间"],
- @[@"学员账号"],
- @[@"修改登录密码",@"设置支付密码"]];
- images = @[@[@"center_img01.png",@"center_img02.png"],
- @[@"center_img04.png",@"center_img05.png",@"center_img06.png",@"center_img07.png",@"center_img08.png"],
- @[@"center_img03.png"],
- @[@"center_img09.png",@"center_img10.png"]];
- }
-
- }
- -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
- {
- return titles.count;
- }
- - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
- {
- return [titles[section] count];
- }
- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
- {
- CLCell *cell = [CLCell cellForTableView:tableView Style:UITableViewCellStyleValue1];
- [cell.textLabel setTextColor:contentTextColor];
- [cell.detailTextLabel setTextColor:kTitleColor];
- [cell.detailTextLabel setText:@""];
- [cell setAccessoryType:UITableViewCellAccessoryDisclosureIndicator];
-
- UIImage* img = [UIImage imageNamed:[images objAtPath:indexPath]];
- [cell.imageView setImage:img];
- [cell.textLabel setText: [titles objAtPath:indexPath]];
-
- cell.headerImg.hidden = YES;
-
- if ( 0 == indexPath.section) {
- switch (indexPath.row) {
- case 0:
- {
- cell.headerImg.hidden = NO;
- NSString *str = defUser.userDict[@"photo"];
- if (str && ![str hasPrefix:@"http"]){
- str = [imgPreFix stringByAppendingString:str];
- }
- if (str == nil) {
- str = @"";
- }
- [cell.headerImg sd_setImageWithURL:[NSURL URLWithString:str] placeholderImage:[UIImage imageWithColor:[UIColor whiteColor]]];
- }
- break;
- case 1:
- [cell.detailTextLabel setText:defUser.userNickName];
- break;
-
- default:
- break;
- }
- } else if ( 1 == indexPath.section) {
- [cell setAccessoryType:UITableViewCellAccessoryNone];
- cell.selectionStyle = UITableViewCellSelectionStyleNone;
- switch (indexPath.row) {
- case 0:
- [cell.detailTextLabel setText:defUser.userName];
- break;
- case 1:
- {
- [cell.detailTextLabel setText: [defUser.userSex integerValue] == 2 ? @"女" : @"男"];
- }
- break;
- case 2:
- [cell.detailTextLabel setText:defUser.userAge];
- break;
- case 3:
- [cell.detailTextLabel setText:[defUser.userDict objectForKey:@"carType"]];
- break;
- case 4:
- {
- NSString *dateString = [defUser.userDict objectForKey:@"crDate"];
- if (dateString.length > 10) {
- dateString = [dateString substringToIndex:10];
- }
- [cell.detailTextLabel setText:dateString];
- }
- break;
-
- default:
- break;
- }
- } else if ( 2 == indexPath.section) {
- if ([titles[indexPath.section][indexPath.row] isEqualToString:@"手机绑定"]) {
- NSString *telString = @"";
- if ([defUser.userDict[@"telphone"] length] > 10) {
- telString = defUser.userDict[@"telphone"];
- [cell setAccessoryType:UITableViewCellAccessoryNone];
- cell.selectionStyle = UITableViewCellSelectionStyleNone;
- telString = [telString stringByReplacingCharactersInRange:NSMakeRange(3, 4) withString:@"****"];
- [cell.detailTextLabel setText:telString];
- }else{
- [cell.detailTextLabel setText:@"暂未绑定"];
- }
- }else if ([titles[indexPath.section][indexPath.row] isEqualToString:@"QQ绑定"]){
- NSArray * array = defUser.userDict[@"loginBindInfos"];
- [cell.detailTextLabel setText:@"暂未绑定"];
- for (NSDictionary * dic in array) {
- if ([dic[@"type"] integerValue]== 3) {
- [cell setAccessoryType:UITableViewCellAccessoryNone];
- cell.selectionStyle = UITableViewCellSelectionStyleNone;
- [cell.detailTextLabel setText:@"已绑定"];
- }
- }
- }else if ([titles[indexPath.section][indexPath.row] isEqualToString:@"微信绑定"]){
- NSArray * array = defUser.userDict[@"loginBindInfos"];
- [cell.detailTextLabel setText:@"暂未绑定"];
- for (NSDictionary * dic in array) {
- if ([dic[@"type"] integerValue]== 2) {
- [cell setAccessoryType:UITableViewCellAccessoryNone];
- cell.selectionStyle = UITableViewCellSelectionStyleNone;
- [cell.detailTextLabel setText:@"已绑定"];
- }
- }
-
- }else if ([titles[indexPath.section][indexPath.row] isEqualToString:@"学员账号"]){
- if ([defUser.userDict[@"outId"] length] > 0) {
- [cell setAccessoryType:UITableViewCellAccessoryNone];
- cell.selectionStyle = UITableViewCellSelectionStyleNone;
- [cell.detailTextLabel setText:@"已绑定"];
- }else{
- [cell.detailTextLabel setText:@"暂未绑定"];
- }
- }
-
- } else if ( 3 == indexPath.section) {
- switch (indexPath.row) {
- case 1:
- {
- if ([defUser.userDict[@"payPwd"] length] > 0) {
- [cell.textLabel setText:@"修改支付密码"];
- }
- }
- break;
-
- default:
- break;
- }
- } else {
- [cell.detailTextLabel setText:@"删除数据,永久注销"];
- }
- return cell;
- }
- - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
- return [[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, 10)];
- }
- - (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section {
- return [[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, 10)];
- }
- - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
- return (section == 0)? 0.1 : ([titles[section] count] == 0)? 0.1 : 10;
- }
- - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
- return ([titles[section] count] == 0)? 0.1 : 10;
- }
- -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
- {
- if (!myDelegate.isLogin)
- {
- ShowMsg(@"请登录后再操作!");
- [self userLoginAction];
- return;
- }
- [tableView deselectRowAtIndexPath:indexPath animated:YES];
- if (0 == indexPath.section && 0 == indexPath.row) {
- [self showInputHeadImg];
- return;
- }
- if (0 == indexPath.section && 1 == indexPath.row) {
- [self showInputNickName];
- return;
- }
- //绑定账号相关
- if (2 == indexPath.section) {
- if ([titles[indexPath.section][indexPath.row] isEqualToString: @"QQ绑定"]) {
- NSArray * array = defUser.userDict[@"loginBindInfos"];
- for (NSDictionary * dic in array) {
- if ([dic[@"type"] integerValue]== 3) {
- return;
- }
- }
-
- //QQ登录验证
- [self QQLoginAction];
-
- } else if ([titles[indexPath.section][indexPath.row] isEqualToString: @"微信绑定"]){
- NSArray * array = defUser.userDict[@"loginBindInfos"];
- for (NSDictionary * dic in array) {
- if ([dic[@"type"] integerValue]== 2) {
- return;
- }
- }
- //登录微信验证
- [self WetchatLoginAction];
-
- } else if ([titles[indexPath.section][indexPath.row] isEqualToString: @"手机绑定"]){
- // NSString *telString = @"";
- // if ([defUser.userDict[@"telphone"] isKindOfClass:[NSString class]]) {
- // telString = defUser.userDict[@"telphone"];
- // }
- //
- // if (telString.length > 10) {
- // return;
- // }else{
- // //NSLog(@"----><>%@",defUser.userDict);
- // if ([defUser.userDict[@"outId"] length] < 1) {
- // ShowMsg(@"该账号无法绑定手机");
- // return;
- // }
- // [self bindAction];
- // }
- ShowMsg(@"暂未开放。。。");
- } else if ([titles[indexPath.section][indexPath.row] isEqualToString: @"学员账号"]){
- if ([defUser.userDict[@"outId"] length] > 0) {
- ShowBindVC *vc = [[ShowBindVC alloc]init];
- vc.type = 0;
- vc.labNum = defUser.userDict[@"loginCode"];
- [self navPushHideTabbarToVC:vc];
- return;
- }
- ThirdLoginBindYunGuanVC *vc = [[ThirdLoginBindYunGuanVC alloc] init];
- vc.block = ^(){
- [myTableView reloadData];
- };
- [self navPushHideTabbarToVC:vc];
- }
- return;
- }
-
- if (3 == indexPath.section && 0 == indexPath.row) {
- //修改登录密码
- // if ([defUser.userDict[@"outId"] length] > 0) {
- // [self fixKey];
- // }else{
- // ShowMsg(@"未绑定学员账号,无需修改登录密码");
- // }
- [self fixKey];//2018/5/4
-
- return;
- }
- if (3 == indexPath.section && 1 == indexPath.row) {
-
- if ([defUser.userDict[@"outId"] length] > 0) {
- if ([defUser.userDict[@"payPwd"] length] > 0) {
- //NSLog(@"修改支付密码");
- [self fixPayKey];
- }else{
- //NSLog(@"设置支付密码");
- [self setPayPassword];
- }
- }else{
- ShowMsg(@"未绑定学员账号,无需支付操作");
- }
-
- // NSString *telString = @"";
- // if ([defUser.userDict[@"telphone"] isKindOfClass:[NSString class]]) {
- // telString = defUser.userDict[@"telphone"];
- // }
- //
- // if (telString.length > 10) {
- // if ([[defUser.userDict[@"accountInfo"] objectForKey:@"pwd"] length] > 0) {
- // //NSLog(@"修改支付密码");
- // [self fixPayKey];
- // }else{
- // //NSLog(@"设置支付密码");
- // [self setPayPassword];
- // }
- // }
- }
- @weakify(self)
- if (4 == indexPath.section) {
- [RQ_SHARE_FUNCTION showAlertWithTitle:@"温馨提示" message:@"您即将完全删除用户所有数据!永久注销该账号!请确认是否执行该申请?" alertControllerStyle:UIAlertControllerStyleAlert cancelButtonTitle:@"我再想想" otherButtonTitles:@[@"确认注销"] otherButtonStyles:nil completion:^(NSUInteger selectedOtherButtonIndex) {
- if (selectedOtherButtonIndex == 0) {
- [MBProgressHUD rq_showProgressHUD:@"注销中"];
- RACCommand *zxCommand = [[RACCommand alloc] initWithSignalBlock:^RACSignal *(NSNumber * selected) {
- return [self zx];
- return [RACSignal empty];
- }];
-
- [[zxCommand execute:@1] subscribeNext:^(id _Nullable x) {
- @strongify(self)
- [self.navigationController popToRootViewControllerAnimated:YES];
- [MBProgressHUD rq_hideHUD];
- myDelegate.isLogin = NO;
- if ([defUser.car_type isEqualToString:@"2"]) {
- defUser.car_type = @"C1";
- defUser.isZhiGeZheng = @"NO";
- myDelegate.subject = @"1";
- }
- NSString *keyStr = [NSString stringWithFormat:@"zhuxiaozhanghao-%@",defUser.userStuId];
- [RQPreferenceSettingHelper setObject:@(YES) forKey:keyStr];
- [defUser removeUserInfo];
- [self performSelector:@selector(userLoginAction) withObject:nil afterDelay:1];
- }];
- }
- }];
- }
- }
- - (RACSignal *)zx {
- return [[[RACSignal createSignal:^RACDisposable *(id<RACSubscriber> subscriber) {
- /// 延迟一段时间
- [subscriber sendNext:@1];
- return [RACDisposable disposableWithBlock:^{
- /// 取消任务
- }];
- }] delay:3] deliverOnMainThread];
- }
- -(void)userLoginAction{
- LoginViewController* vc = [[LoginViewController alloc] init];
- vc.modalPresentationStyle = UIModalPresentationFullScreen;
- [RQControllerHelper.currentViewController presentViewController:vc animated:YES completion:nil];
- }
- #pragma mark 修改个人信息
- - (void)setNickNameWithString:(NSString *)nick
- {
- if (![Util connectedToNetWork]) {
- showMsgUnconnect();
- return;
- }
-
- NSMutableArray *arr=[NSMutableArray array];
- [arr addPro:@"userId" Value:defUser.userDict[@"id"]];
- [arr addPro:@"nickName" Value:nick];
- NSString* method = @"updateNickName";
- [MBProgressHUD showLoadToView:self.view];
- [jiaPeiManager requestAnythingWithURL:method array:arr data:nil completion:^(NSDictionary *root) {
- [MBProgressHUD hideHUDForView:self.view];
-
- //NSLog(@"updateNickName--><>%@",root);
-
- if (!root) {
- ShowMsg(@"修改失败,请重试!");
- return;
- }
-
- ShowMsg(root[@"body"]);
-
- if ([root[@"code"] isEqualToString:@"0"]) {
-
- defUser.userNickName = nick;
- NSIndexPath *indexPath = [NSIndexPath indexPathForRow:1 inSection:0];
- [myTableView reloadRowsAtIndexPaths:[NSArray arrayWithObjects:indexPath,nil] withRowAnimation:UITableViewRowAnimationNone];
-
- [LoginViewController reLoginFromViewController:self finishBlock:nil];
- }
- }];
- }
- -(void)InputView:(InputView *)view didGetImage:(UIImage *)image
- {
- headImg = image;
- [self upLoadImg];
- }
- -(void)InputViewWillPickImage:(InputView *)view
- {
- // UIImagePickerController *pickerImage = [[UIImagePickerController alloc] init];
- // if([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary]) {
- // pickerImage.sourceType = view.type;
- //// pickerImage.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
- // pickerImage.mediaTypes = [UIImagePickerController availableMediaTypesForSourceType:pickerImage.sourceType];
- // }
- // pickerImage.delegate = self;
- // pickerImage.allowsEditing = NO;
- // pickerImage.modalPresentationStyle = UIModalPresentationFullScreen;
- // [self presentViewController:pickerImage animated:YES completion:nil];
- @weakify(self)
- [[RACScheduler mainThreadScheduler] schedule:^{
- @strongify(self)
- if ([QMUIAssetsManager authorizationStatus] == QMUIAssetAuthorizationStatusNotDetermined) {
- [QMUIAssetsManager requestAuthorization:^(QMUIAssetAuthorizationStatus status) {
- dispatch_async(dispatch_get_main_queue(), ^{
- [self presentAlbumViewControllerWithTitle:@"上传照片"];
- });
- }];
- } else {
- [self presentAlbumViewControllerWithTitle:@"上传照片"];
- }
- }];
- }
- - (void) imagePickerController:(UIImagePickerController *)picker
- didFinishPickingMediaWithInfo:(NSDictionary *)info
- {
- [inputVi cancelAction];
- [picker dismissViewControllerAnimated:YES completion:^{
- UIImage *originalImage = [info objectForKey:UIImagePickerControllerOriginalImage];
- headImg = originalImage;
- [self upLoadImg];
- }];
- }
- -(void)upLoadImg
- {
- // if (!headImg) {
- // return;
- // }
- //
- // TOCropViewController *cropController = [[TOCropViewController alloc] initWithCroppingStyle:TOCropViewCroppingStyleCircular image:headImg];
- // __weak TOCropViewController *weakCropC = cropController;
- // cropController.onDidCropToCircleImage = ^(UIImage * _Nonnull image, CGRect cropRect, NSInteger angle) {
- // [weakCropC dismissViewControllerAnimated:YES completion:nil];
- // headImg = image;
- // [self uploadHeadImage:image];
- // };
- // cropController.modalPresentationStyle = UIModalPresentationFullScreen;
- // [self presentViewController:cropController animated:NO completion:nil];
- }
- - (void)uploadHeadImage:(UIImage*)image
- {
- if (![Util connectedToNetWork]) {
- showMsgUnconnect();
- return;
- }
-
- NSData * data;
- if (UIImageJPEGRepresentation(image, .5))
- {
- //图片质量 压缩成多少
- data = UIImageJPEGRepresentation(image, .5);
- }
- else
- {
- data = UIImagePNGRepresentation(image);
- }
-
- NSArray *dataArray = [NSArray arrayWithObject:data];
- [MBProgressHUD showLoadToView:self.view];
- [jiaPeiManager requestAnythingWithURL:@"uploadUserImg" array:dataArray data:data completion:^(NSDictionary *root) {
-
- if (!root) {
- [MBProgressHUD hideHUDForView:self.view];
- ShowMsg(@"上传失败");
- return;
- }
- if (![root[@"code"] isEqualToString:@"0"]) {
- [MBProgressHUD hideHUDForView:self.view];
- ShowMsg(root[@"body"]);
- return;
- }
-
- NSMutableArray *arr = [NSMutableArray array];
- [arr addPro:@"userId" Value:defUser.userDict[@"id"]];
- [arr addPro:@"photo" Value:root[@"body"]];
- [jiaPeiManager requestAnythingWithURL:@"uploadHeadImg" array:arr data:nil completion:^(NSDictionary *root) {
- [MBProgressHUD hideHUDForView:self.view];
- if (!root) {
- ShowMsg(@"保存失败");
- return;
- }
-
- ShowMsg(root[@"body"]);
- if (![root[@"code"] isEqualToString:@"0"]) {
- return;
- }
-
- //上传头像后 在获取下最新信息
- [self upDateUserInfo];
- }];
- }];
- }
- -(void)showInputHeadImg
- {
- InputView* vi = [[InputView alloc] initWithTitle:@"请选择头像"];
- [vi setDelegate:self];
- [vi show];
- inputVi = vi;
- }
- //更新表
- -(void)upDateUserInfo
- {
- [LoginViewController reLoginFromViewController:self finishBlock:^{
- [myTableView reloadData];
- }];
- }
- -(void)showInputSex//no use now
- {
- UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"请选择性别" message:nil preferredStyle:UIAlertControllerStyleAlert];
-
- [alert addAction:[UIAlertAction actionWithTitle:@"女" style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {
- defUser.userSex = @"女";
- NSIndexPath *indexPath=[NSIndexPath indexPathForRow:1 inSection:1];
- [myTableView reloadRowsAtIndexPaths:[NSArray arrayWithObjects:indexPath,nil] withRowAnimation:UITableViewRowAnimationNone];
- }]];
- [alert addAction:[UIAlertAction actionWithTitle:@"男" style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {
- defUser.userSex = @"男";
- NSIndexPath *indexPath=[NSIndexPath indexPathForRow:1 inSection:1];
- [myTableView reloadRowsAtIndexPaths:[NSArray arrayWithObjects:indexPath,nil] withRowAnimation:UITableViewRowAnimationNone];
- }]];
- [self presentViewController:alert animated:true completion:nil];
- }
- -(void)showInputNickName
- {
- //alert的又一种用法
- UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"请输入昵称" message:nil preferredStyle:UIAlertControllerStyleAlert];
- [alert addTextFieldWithConfigurationHandler:^(UITextField * textField) {
- textField.placeholder = @"请输入昵称";
- }];
-
- [alert addAction:[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil]];
- [alert addAction:[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {
- NSString* text = [[alert.textFields firstObject] text];
- [self setNickNameWithString:text];
- }]];
- [self presentViewController:alert animated:true completion:nil];
- }
- #pragma mark 绑定qq 微信
- - (void)bindThirdPartyWithType:(NSString *)BindType OpenId:(NSString *)openId
- {
-
- if (![Util connectedToNetWork]) {
- showMsgUnconnect();
- return;
- }
-
- NSMutableArray *arr=[NSMutableArray array];
- [arr addPro:@"userId" Value:defUser.userDict[@"id"]];
- [arr addPro:@"type" Value:BindType];
- [arr addPro:@"account" Value:@""];//获取不到 先不传
- [arr addPro:@"openId" Value:openId];
-
- NSString* method = @"bindThirdParty";
- [MBProgressHUD showLoadToView:self.view];
- [jiaPeiManager requestAnythingWithURL:method array:arr data:nil completion:^(NSDictionary * root) {
- [MBProgressHUD hideHUDForView:self.view];
-
- if ([root[@"code"] isEqualToString:@"1"]) {
- ShowMsg(root[@"body"]);
- return;
- }
-
- //绑定成功,更新ui
- ShowMsgSuc();
- [self upDateUserInfo];
- }];
- }
- - (void)WetchatLoginAction
- {
- // [ShareSDK cancelAuthorize:SSDKPlatformTypeWechat result:^(NSError *error) {
- //
- // }]; //这儿就是取消授权
- // [ShareSDK getUserInfo: SSDKPlatformTypeWechat
- // onStateChanged:^(SSDKResponseState state, SSDKUser *user, NSError *error)
- // {
- // if (state == SSDKResponseStateSuccess)
- // {
- //
- // //绑定接口
- // [self bindThirdPartyWithType:@"2" OpenId:user.uid];
- // }else{
- // ShowMsg(@"微信登录验证失败");
- // }
- // }];
- }
- - (void)QQLoginAction
- {
- // [ShareSDK cancelAuthorize:SSDKPlatformTypeQQ result:^(NSError *error) {
- //
- // }];//这儿就是取消授权
- // [ShareSDK getUserInfo: SSDKPlatformTypeQQ
- // onStateChanged:^(SSDKResponseState state, SSDKUser *user, NSError *error)
- // {
- // if (state == SSDKResponseStateSuccess)
- // {
- // //绑定接口
- // [self bindThirdPartyWithType:@"3" OpenId:user.uid];
- // }else{
- // ShowMsg(@"QQ登录验证失败");
- // }
- // }];
-
- }
- #pragma mark 绑定手机号
- - (void)bindAction {
- // UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"绑定手机" message:@"请确认手机号码,以获取验证码" preferredStyle:UIAlertControllerStyleAlert];
- // [alert addTextFieldWithConfigurationHandler:^(UITextField * textField) {
- // textField.placeholder = @"请输入手机号码";
- //
- // NSString *telStr = defUser.userTel;
- // if ([telStr length] > 0) {
- // textField.text = telStr;
- // }
- // }];
- // [alert addAction:[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil]];
- // [alert addAction:[UIAlertAction actionWithTitle:@"下一步" style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {
- //
- // bindTel = [[alert.textFields firstObject] text];
- // if (![Tools isMobileNumber:bindTel]) {
- // ShowMsg(@"请核对电话号码");
- // [self presentViewController:alert animated:true completion:nil];
- // return;
- // }
- // //调获取验证码接口
- // SubmitNumType = @"3";
- // [RQ_SHARE_FUNCTION checkMobPolicyOnResult:^(BOOL success) {
- // [SMSSDK getVerificationCodeByMethod:SMSGetCodeMethodSMS phoneNumber:bindTel zone:@"86" template:nil result:^(NSError *error) {
- // if (error) {
- // if (error.code == 477) {
- // ShowMsg(@"当天验证次数已超上限");
- // }else{
- // ShowMsg(@"请检查手机号码是否正确");
- // }
- // [self presentViewController:alert animated:true completion:nil];
- // } else {
- //
- // UIAlertController *subAlert = [UIAlertController alertControllerWithTitle:@"绑定手机" message:nil preferredStyle:UIAlertControllerStyleAlert];
- // [subAlert addTextFieldWithConfigurationHandler:^(UITextField * textField) {
- // textField.placeholder = @"请输入验证码";
- // }];
- // [subAlert addAction:[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil]];
- // [subAlert addAction:[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {
- //
- // NSString *subString = [[subAlert.textFields firstObject] text];
- // if (subString.length < 1) {
- // ShowMsg(@"请输入有效验证码");
- // [self presentViewController:subAlert animated:true completion:nil];
- // return;
- // }
- // //调检验验证码的接口
- // [self clickToSubmitWithSubNum:subString];
- // }]];
- // [self presentViewController:subAlert animated:true completion:nil];
- // }}];
- // }];
- // ;
- // }]];
- // [self presentViewController:alert animated:true completion:nil];
- }
- //绑定手机号
- -(void)bindAccountTel
- {
- if (![Util connectedToNetWork])
- {
- showMsgUnconnect();
- return;
- }
-
- NSMutableArray *arr=[NSMutableArray array];
- [arr addPro:@"user" Value:defUser.userDict[@"id"]];
- [arr addPro:@"tel" Value:bindTel];
-
- NSString* method = @"bindAccountTel";
- [MBProgressHUD showLoadToView:self.view];
- [jiaPeiManager requestAnythingWithURL:method array:arr data:nil completion:^(NSDictionary * root) {
- [MBProgressHUD hideHUDForView:self.view];
- //NSLog(@"用户绑定---->%@---%@",arr,root);
- if (!root) {
- ShowMsg(@"绑定失败");
- return;
- }
- if (!root || [root[@"code"] isEqualToString:@"1"])
- {
- ShowMsg(root[@"body"]);
- return;
- }
-
- ShowMsgSuc();
- [self upDateUserInfo];
- }];
-
- }
- //验证码有效性检验
- -(void)clickToSubmitWithSubNum:(NSString *)subNum {
- // //验证验证码是否过期
- // if (![Util connectedToNetWork]) {
- // showMsgUnconnect();
- // return;
- // }
- //
- // [MBProgressHUD showLoadToView:self.view];
- // [SMSSDK commitVerificationCode:subNum phoneNumber:bindTel zone:@"86" result:^(NSError *error) {
- // if (error) {
- // //NSLog(@"验证码有误");
- // [MBProgressHUD hideHUDForView:self.view];
- // ShowMsg(@"验证失败,请重试");
- // return;
- // }
- //
- // if ([SubmitNumType isEqualToString:@"3"]) {
- // [self bindAccountTel];
- // return;
- // }
- //
- // if ([SubmitNumType isEqualToString:@"1"]) {
- // //设置支付密码
- // UIAlertView *alertKey = [[UIAlertView alloc] initWithTitle:@"设置新密码" message:@"" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确认",nil];
- // [alertKey setAlertViewStyle:UIAlertViewStyleLoginAndPasswordInput];
- // alertKey.tag = 11;
- // psw1 = [alertKey textFieldAtIndex:0];
- // psw1.keyboardType = UIKeyboardTypeNumbersAndPunctuation;
- // psw1.delegate = self;
- // psw2 = [alertKey textFieldAtIndex:1];
- // psw2.keyboardType = UIKeyboardTypeNumbersAndPunctuation;
- //
- // psw1.placeholder = @"请输入新密码";
- // psw2.placeholder = @"请确认密码";
- // [psw1 setSecureTextEntry:YES];
- // [alertKey show];
- // }
- // }];
- //
- }
- -(BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
- {
- NSString *newStr = [textField.text stringByReplacingCharactersInRange:range withString:string];
- if (newStr.length >6) {
- ShowMsg(@"密码不能超过6位数字");
- return NO;
- }
- return YES;
- }
- #pragma mark 设置支付密码
- -(void)setPayPassword
- {
- // bindTel = defUser.userDict[@"telphone"];
- // [RQ_SHARE_FUNCTION checkMobPolicyOnResult:^(BOOL success) {
- // //获取验证码
- // [SMSSDK getVerificationCodeByMethod:SMSGetCodeMethodSMS phoneNumber:bindTel zone:@"86" template:nil result:^(NSError *error) {
- // if (error) {
- // if (error.code == 477) {
- // ShowMsg(@"当天验证次数已超上限");
- // }else{
- // ShowMsg(@"请检查手机号码是否正确");
- // }
- // } else {
- // UIAlertController *subAlert = [UIAlertController alertControllerWithTitle:@"设置支付密码" message:[NSString stringWithFormat:@"验证码已发送到您尾号为%@的绑定手机上,请注意查收",[bindTel substringFromIndex:bindTel.length - 4]] preferredStyle:UIAlertControllerStyleAlert];
- //
- // [subAlert addTextFieldWithConfigurationHandler:^(UITextField * textField) {
- // textField.placeholder = @"请输入验证码";
- // }];
- // [subAlert addAction:[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil]];
- // [subAlert addAction:[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {
- //
- // NSString *subString = [[subAlert.textFields firstObject] text];
- // if (subString.length < 1) {
- // ShowMsg(@"请输入有效验证码");
- // [self presentViewController:subAlert animated:true completion:nil];
- // return;
- // }
- // //检验验证码
- // SubmitNumType = @"1";
- // [self clickToSubmitWithSubNum:subString];
- // }]];
- //
- // [self presentViewController:subAlert animated:true completion:nil];
- // }
- // }];
- // }];
- }
- #pragma mark 修改支付密码
- -(void)fixPayKey
- {
- // SubmitNumType = @"1";
- // UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"验证原密码" message:nil preferredStyle:UIAlertControllerStyleAlert];
- // [alert addTextFieldWithConfigurationHandler:^(UITextField * textField) {
- // textField.placeholder = @"请输入原密码";
- // }];
- //
- // [alert addAction:[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {
- //
- // NSString* text = [[alert.textFields firstObject] text];
- //
- // if (text.length < 1) {
- // ShowMsg(@"请输入原密码");
- // [self presentViewController:alert animated:true completion:nil];
- // return;
- // }
- //
- // NSString *oldKey = defUser.userDict[@"payPwd"];
- // if (![[text md5Encrypt] isEqualToString:oldKey]) {
- // ShowMsg(@"原密码错误!");
- // [self presentViewController:alert animated:true completion:nil];
- // return;
- // }
- //
- // UIAlertView *alertKey = [[UIAlertView alloc] initWithTitle:@"设置新密码" message:@"" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确认",nil];
- // [alertKey setAlertViewStyle:UIAlertViewStyleLoginAndPasswordInput];
- // alertKey.tag = 11;
- // psw1 = [alertKey textFieldAtIndex:0];
- // psw1.keyboardType = UIKeyboardTypeNumbersAndPunctuation;
- // psw1.delegate = self;
- // psw2 = [alertKey textFieldAtIndex:1];
- // psw2.keyboardType = UIKeyboardTypeNumbersAndPunctuation;
- //
- // psw1.placeholder = @"请输入新密码";
- // psw2.placeholder = @"请确认密码";
- //
- // [psw1 setSecureTextEntry:YES];
- //
- // [alertKey show];
- //
- // }]];
- //
- // [alert addAction:[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleDefault handler:nil]];
- //
- // [alert addAction:[UIAlertAction actionWithTitle:@"忘记密码" style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {
- // //找回密码
- // UIAlertController *alertFind = [UIAlertController alertControllerWithTitle:@"找回支付密码" message:@"请填写账户绑定手机号码" preferredStyle:UIAlertControllerStyleAlert];
- // [alertFind addTextFieldWithConfigurationHandler:^(UITextField * phoneNumField) {
- // phoneNumField.placeholder = @"请输入手机号码";
- // }];
- // [alertFind addAction:[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil]];
- // [alertFind addAction:[UIAlertAction actionWithTitle:@"下一步" style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {
- //
- // bindTel = [[alertFind.textFields firstObject] text];
- // if (![bindTel isEqualToString:defUser.userDict[@"telphone"]]) {
- // ShowMsg(@"填写号码与绑定号码不匹配,请重试");
- // [self presentViewController:alertFind animated:true completion:nil];
- // return;
- // }
- //
- // [RQ_SHARE_FUNCTION checkMobPolicyOnResult:^(BOOL success) {
- // //获取验证码
- // [SMSSDK getVerificationCodeByMethod:SMSGetCodeMethodSMS phoneNumber:bindTel zone:@"86" template:nil result:^(NSError *error) {
- // if (error) {
- // //下发验证码失败
- // if (error.code == 477) {
- // ShowMsg(@"当天验证次数已超上限");
- // }else{
- // ShowMsg(@"请检查手机号码是否正确");
- // }
- // [self presentViewController:alertFind animated:true completion:nil];
- // } else {
- // //下发验证码后的操作
- // UIAlertController *subAlert = [UIAlertController alertControllerWithTitle:@"找回支付密码" message:nil preferredStyle:UIAlertControllerStyleAlert];
- // [subAlert addTextFieldWithConfigurationHandler:^(UITextField * textField) {
- // textField.placeholder = @"请输入验证码";
- // textField.keyboardType = UIKeyboardTypeNumberPad;
- // }];
- // [subAlert addAction:[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil]];
- // [subAlert addAction:[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {
- //
- // NSString *subString = [[subAlert.textFields firstObject] text];
- // if (subString.length < 1) {
- // ShowMsg(@"请输入有效验证码");
- // [self presentViewController:subAlert animated:true completion:nil];
- // return;
- // }
- // //调检验验证码的接口
- // [self clickToSubmitWithSubNum:subString];
- // }]];
- // [self presentViewController:subAlert animated:true completion:nil];
- // }
- // }];
- // }];
- // }]];//以上是下一步的操作
- // [self presentViewController:alertFind animated:true completion:nil];
- // }]];
- // [self presentViewController:alert animated:true completion:nil];
- }
- #pragma mark 修改登录密码
- -(void)fixKey
- {
- SubmitNumType = @"-1";
- UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"验证原密码" message:@"如果忘了原密码,请重新登录即可利用找回密码设置新密码" preferredStyle:UIAlertControllerStyleAlert];
- [alert addTextFieldWithConfigurationHandler:^(UITextField * textField) {
- textField.placeholder = @"请输入原密码";
- textField.keyboardType = UIKeyboardTypeNumbersAndPunctuation;
- }];
-
- [alert addAction:[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil]];
- // [alert addAction:[UIAlertAction actionWithTitle:@"忘记密码" style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {
- //
- // [Message_SMS_VC goSMSFormVC:self phoneNumber:phoneNumber loginCode:userText.text canEditNum:NO];
- // }]];
- [alert addAction:[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {
-
- NSString* text = [[alert.textFields firstObject] text];
-
- NSUserDefaults *ud = [NSUserDefaults standardUserDefaults];
- NSString *key = [ud objectForKey:@"password"];
-
- if (![text isEqualToString:key]) {
- ShowMsg(@"原密码错误!");
- return;
- }
-
- UIAlertView *alertKey = [[UIAlertView alloc] initWithTitle:@"修改密码" message:@"" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确认修改",nil];
- [alertKey setAlertViewStyle:UIAlertViewStyleLoginAndPasswordInput];
- alertKey.tag = 11;
- psw1 = [alertKey textFieldAtIndex:0];
- psw2 = [alertKey textFieldAtIndex:1];
-
- psw1.placeholder = @"请输入新密码";
- psw2.placeholder = @"请确认密码";
-
- [psw1 setSecureTextEntry:YES];
-
- [alertKey show];
-
- }]];
- [self presentViewController:alert animated:true completion:nil];
- }
- -(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
- {
- if (alertView.tag == 11) {
- if (buttonIndex == 1)
- {
- if ([SubmitNumType isEqualToString:@"-1"]) {
- [self submit];
- }else{
- [self bindAccountZfmm];
- }
- }
- }
- }
- //设置登录密码 成功后重新登录
- -(void)submit
- {
- if (![psw1.text isEqualToString:psw2.text])
- {
- UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"提示" message:@"密码不一致,请您核查" delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
- [alert show];
- return;
- }
-
- NSUserDefaults *ud = [NSUserDefaults standardUserDefaults];
- // NSString *nameString = [ud objectForKey:@"identifyNum"];
-
- NSMutableArray *arr=[NSMutableArray array];
- [arr addPro:@"loginCode" Value:defUser.userDict[@"loginCode"]];
- [arr addPro:@"pwd" Value:psw1.text];
- [arr addPro:@"dqbh" Value:defUser.userDict[@"city"]];
-
- NSString* method = @"savePwdN";
- [MBProgressHUD showLoadToView:self.view];
- [jiaPeiManager requestAnythingWithURL:method array:arr data:nil completion:^(NSDictionary * root) {
- [MBProgressHUD hideHUDForView:self.view];
- //NSLog(@"密码返回数据->%@",root);
- if (!root)
- {
- ShowMsgFailed();
- return;
- }
- if ( 1 == [root[@"code"] integerValue]) {
- ShowMsg(root[@"body"]);
- return;
- }
- ShowMsg(@"修改成功,请重新登录!");
-
- //这里要做的事 到登录页面 改变登录状态 清除原来的密码信息
- [ud setObject:@"" forKey:@"password"];
- //异步储存 防止信息未存储 强制立即将数据写入磁盘
- [ud synchronize];
- myDelegate.isLogin = NO;
- if ([defUser.car_type isEqualToString:@"2"]) {
- defUser.car_type = @"C1";
- defUser.isZhiGeZheng = @"NO";
- myDelegate.subject = @"1";
- }
- [defUser removeUserInfo];
-
- [self userLoginAction];
- }];
- }
- //设置支付密码
- -(void)bindAccountZfmm
- {
- psw1.delegate = nil;
- if (![psw1.text isEqualToString:psw2.text])
- {
- UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"提示" message:@"密码不一致,请您核查" delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
- [alert show];
- return;
- }
- NSMutableArray *arr =[NSMutableArray array];
- [arr addPro:@"user" Value:defUser.userDict[@"id"]];
- [arr addPro:@"pwd" Value:[psw1.text md5Encrypt]];
-
- NSString* method = @"bindAccountZfmm";
- [MBProgressHUD showLoadToView:self.view];
- [jiaPeiManager requestAnythingWithURL:method array:arr data:nil completion:^(NSDictionary * root) {
- [MBProgressHUD hideHUDForView:self.view];
- //NSLog(@"支付密码返回数据--->%@--->%@",arr,root);
- if (!root)
- {
- ShowMsgFailed();
- return;
- }
- if ( 1 == [root[@"code"] integerValue]) {
- ShowMsg(root[@"body"]);
- return;
- }
-
- ShowMsgSuc();
- [self upDateUserInfo];
- }];
-
- }
- #pragma mark - <QMUIAlbumViewControllerDelegate>
- - (QMUIImagePickerViewController *)imagePickerViewControllerForAlbumViewController:(QMUIAlbumViewController *)albumViewController {
- QMUIImagePickerViewController *imagePickerViewController = [[QMUIImagePickerViewController alloc] init];
- imagePickerViewController.imagePickerViewControllerDelegate = self;
- imagePickerViewController.maximumSelectImageCount = 1;
- return imagePickerViewController;
- }
- #pragma mark - <QMUIImagePickerViewControllerDelegate>
- - (void)imagePickerViewController:(QMUIImagePickerViewController *)imagePickerViewController didFinishPickingImageWithImagesAssetArray:(NSMutableArray<QMUIAsset *> *)imagesAssetArray {
- // 储存最近选择了图片的相册,方便下次直接进入该相册
- [QMUIImagePickerHelper updateLastestAlbumWithAssetsGroup:imagePickerViewController.assetsGroup ablumContentType:QMUIAlbumContentTypeOnlyPhoto userIdentify:nil];
- [self sendImageWithImagesAssetArray:imagesAssetArray];
- }
- #pragma mark - <QMUIImagePickerPreviewViewControllerDelegate>
- - (void)imagePickerPreviewViewController:(QMUIImagePickerPreviewViewController *)imagePickerPreviewViewController didCheckImageAtIndex:(NSInteger)index {
- [self updateImageCountLabelForPreviewView:imagePickerPreviewViewController];
- }
- - (void)imagePickerPreviewViewController:(QMUIImagePickerPreviewViewController *)imagePickerPreviewViewController didUncheckImageAtIndex:(NSInteger)index {
- [self updateImageCountLabelForPreviewView:imagePickerPreviewViewController];
- }
- // 更新选中的图片数量
- - (void)updateImageCountLabelForPreviewView:(QMUIImagePickerPreviewViewController *)imagePickerPreviewViewController {
- // QDMultipleImagePickerPreviewViewController *customImagePickerPreviewViewController = (QDMultipleImagePickerPreviewViewController *)imagePickerPreviewViewController;
- // NSUInteger selectedCount = [imagePickerPreviewViewController.selectedImageAssetArray count];
- // if (selectedCount > 0) {
- // customImagePickerPreviewViewController.imageCountLabel.text = [[NSString alloc] initWithFormat:@"%@", @(selectedCount)];
- // customImagePickerPreviewViewController.imageCountLabel.hidden = NO;
- // [QMUIImagePickerHelper springAnimationOfImageSelectedCountChangeWithCountLabel:customImagePickerPreviewViewController.imageCountLabel];
- // } else {
- // customImagePickerPreviewViewController.imageCountLabel.hidden = YES;
- // }
- }
- - (void)presentAlbumViewControllerWithTitle:(NSString *)title {
- // 创建一个 QMUIAlbumViewController 实例用于呈现相簿列表
- QMUIAlbumViewController *albumViewController = [[QMUIAlbumViewController alloc] init];
- albumViewController.albumViewControllerDelegate = self;
- albumViewController.contentType = QMUIAlbumContentTypeOnlyPhoto;
- albumViewController.title = title;
- RQBaseNavigationController *navigationController = [[RQBaseNavigationController alloc] initWithRootViewController:albumViewController];
-
- // 获取最近发送图片时使用过的相簿,如果有则直接进入该相簿
- [albumViewController pickLastAlbumGroupDirectlyIfCan];
- [self presentPanModal:navigationController];
- }
- - (void)sendImageWithImagesAssetArray:(NSMutableArray<QMUIAsset *> *)imagesAssetArray {
- __weak __typeof(self)weakSelf = self;
-
- for (QMUIAsset *asset in imagesAssetArray) {
- [QMUIImagePickerHelper requestImageAssetIfNeeded:asset completion:^(QMUIAssetDownloadStatus downloadStatus, NSError *error) {
- if (downloadStatus == QMUIAssetDownloadStatusDownloading) {
- // [weakSelf startLoadingWithText:@"从 iCloud 加载中"];
- } else if (downloadStatus == QMUIAssetDownloadStatusSucceed) {
- [weakSelf sendImageWithImagesAssetIfDownloadStatusSucceed:asset];
- } else {
- // [weakSelf showTipLabelWithText:@"iCloud 下载错误,请重新选图"];
- }
- }];
- }
- }
- - (void)sendImageWithImagesAssetIfDownloadStatusSucceed:(QMUIAsset *)imagesAsset {
- @weakify(self)
- CGFloat photoWidth = (RQ_SCREEN_WIDTH - (16.f * 4) - 90.f - (8.f * 3)) / 4.f;
- NSMutableArray <QMUIAsset *>*arr = @[imagesAsset].mutableCopy;
- if ([QMUIImagePickerHelper imageAssetsDownloaded:arr]) {
- [[[arr.rac_sequence.signal deliverOnMainThread] distinctUntilChanged] subscribeNext:^(QMUIAsset * _Nullable asset) {
- @strongify(self)
- UIImage *image = asset.originImage;
- headImg = image;
- [self uploadHeadImage:image];
- }];
- }
- }
- @end
|