SIdentificationVC.m 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954
  1. //
  2. // SIdentificationVC.m
  3. // BuguLive
  4. //
  5. // Created by 丁凯 on 2017/8/4.
  6. // Copyright © 2017年 xfg. All rights reserved.
  7. //
  8. #import "SIdentificationVC.h"
  9. #import "ThirdTableViewCell.h"
  10. #import "FourTableViewCell.h"
  11. #import "cuserModel.h"
  12. //#import "BGOssManager.h"
  13. #import "RecommendTableViewCell.h"
  14. #import "SBasicInfoCell.h"
  15. #import "RecommendTypeModel.h"
  16. @interface SIdentificationVC ()<UITableViewDelegate,UITableViewDataSource,UITextFieldDelegate,UIActionSheetDelegate,UINavigationControllerDelegate,UIImagePickerControllerDelegate,buttonClickDelegate,sentImgviewDelegate,RecommendTableViewCellDelegate>
  17. {
  18. NSData *_data1;
  19. NSData *_data2;
  20. NSData *_data3;
  21. }
  22. @property ( nonatomic, strong) UITableView *myTableView;
  23. @property ( nonatomic, strong) NSMutableArray *dataArray;
  24. @property ( nonatomic, strong) NSMutableArray *typeArray;
  25. //@property ( nonatomic, strong) BGOssManager *ossManager;
  26. @property ( nonatomic, assign) int is_show_identify_number; //是否显示身份证号码
  27. @property ( nonatomic, copy) NSString *identify_hold_example; //图像图片
  28. @property ( nonatomic, copy) NSString *idTypeStr; //认证类型
  29. @property ( nonatomic, copy) NSString *idNameStr; //认证名称
  30. @property ( nonatomic, copy) NSString *idContactStr; //联系方式
  31. @property ( nonatomic, copy) NSString *idNumStr; //认证的身份证号码
  32. @property ( nonatomic, copy) NSString *urlString1; //第一张图片的url
  33. @property ( nonatomic, copy) NSString *urlString2; //第二张图片的url
  34. @property ( nonatomic, copy) NSString *urlString3; //第三张图片的url
  35. @property ( nonatomic, strong) UILabel *promptLabel; //头部红色提示
  36. @property ( nonatomic, strong) UIView *basicInfoView; //基本资料
  37. @property ( nonatomic, strong) UIView *idNewsView; //认证消息
  38. @property ( nonatomic, strong) UIView *idAuthenView; //身份认证
  39. @property ( nonatomic, strong) UIView *recommendView; //推荐人信息
  40. @property ( nonatomic, strong) UIView *inviteCodeView; //公会邀请码
  41. @property ( nonatomic, strong) UITextField *inviteCodeFiled; //公会邀请码Filed
  42. @property ( nonatomic, strong) UIButton *sumitBtn; //提交
  43. @property ( nonatomic, strong) ThirdTableViewCell *threeCell; //认证信息
  44. @property ( nonatomic, strong) FourTableViewCell *fourCell; //身份认证
  45. @property ( nonatomic, strong) RecommendTableViewCell *recommendCell; //推荐人信息
  46. @property ( nonatomic, strong) RecommendTypeModel *recommendTypeModel;
  47. @property ( nonatomic, assign) int authentication;
  48. @property ( nonatomic, assign) int open_society_code; //是否打开公会认证
  49. @property ( nonatomic, copy) NSString *society_code; //公会认证邀请码
  50. @property ( nonatomic, assign) int invite_id;
  51. @property ( nonatomic, assign) NSInteger recommendType; // 1为选择推荐人ID,2为选择推荐人手机号,初始值为0表示两者都没选
  52. @property ( nonatomic, weak) UIActionSheet *typeSheet; //选择类型
  53. @property ( nonatomic, weak) UIActionSheet *recommendSheet;
  54. @property ( nonatomic, copy) NSString *timeString; //时间戳的字符串
  55. @property ( nonatomic, assign) int tagCount; //通过这个成员变量来获取图片
  56. @property (nonatomic, assign) CGFloat recommendHeight;
  57. @property (nonatomic, assign) NSString *uploadFilePath;
  58. @end
  59. @implementation SIdentificationVC
  60. - (void)viewDidLoad
  61. {
  62. [super viewDidLoad];
  63. }
  64. - (void)initFWUI
  65. {
  66. [super initFWUI];
  67. self.navigationController.navigationBar.hidden = YES;
  68. [self.navigationController setNavigationBarHidden:YES];
  69. UIImageView * topBgImgV = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 250)];
  70. topBgImgV.image = [UIImage imageNamed:@"mine_shiming_topbg"];
  71. [self.view addSubview:topBgImgV];
  72. UIView * navView = [[UIView alloc] initWithFrame:CGRectMake(0, StatusBarHeight, SCREEN_WIDTH, NavigationHeight)];
  73. navView.backgroundColor = UIColor.clearColor;
  74. [self.view addSubview:navView];
  75. UIButton * backBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  76. [backBtn setImage:[UIImage imageNamed:@"com_arrow_vc_back"] forState:UIControlStateNormal];
  77. backBtn.frame = CGRectMake(10, 0, 44, 44);
  78. [backBtn addTarget:self action:@selector(backClick) forControlEvents:UIControlEventTouchUpInside];
  79. [navView addSubview:backBtn];
  80. UILabel * titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(20, NavigationHeight + 14, SCREEN_WIDTH - 40, 30)];
  81. titleLabel.text = ASLocalizedString(@"实名认证");
  82. titleLabel.font = [UIFont boldSystemFontOfSize:28];
  83. titleLabel.textColor = UIColor.blackColor;
  84. [self.view addSubview:titleLabel];
  85. UILabel * subTitleLabel = [[UILabel alloc] initWithFrame:CGRectMake(20, titleLabel.bottom + 15, SCREEN_WIDTH - 40, 15)];
  86. subTitleLabel.text = ASLocalizedString(@"实名认证,更加安全");
  87. subTitleLabel.font = [UIFont systemFontOfSize:14];
  88. subTitleLabel.textColor = UIColor.blackColor;
  89. [self.view addSubview:subTitleLabel];
  90. // if (self.BuguLive.appModel.open_sts == 1)
  91. // {
  92. // self.ossManager = [[BGOssManager alloc]initWithDelegate:self];
  93. // }
  94. self.dataArray = [[NSMutableArray alloc]init];
  95. self.typeArray = [[NSMutableArray alloc]init];
  96. self.recommendType = 0;
  97. self.recommendHeight = 0;
  98. self.navigationItem.title = ASLocalizedString(@"认证");
  99. self.view.backgroundColor = kBackGroundColor;
  100. self.navigationItem.leftBarButtonItem=[UIBarButtonItem itemWithTarget:self action:@selector(backClick) image:@"com_arrow_vc_back" highImage:@"com_arrow_vc_back"];
  101. self.promptLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, kScreenW, 30)];
  102. self.promptLabel.backgroundColor = kAppRedColor;
  103. self.promptLabel.textAlignment = NSTextAlignmentCenter;
  104. self.promptLabel.text = ASLocalizedString(@"带星号项为必填项,为了保证您的利益,请如实填写");
  105. self.promptLabel.font = [UIFont systemFontOfSize:13];
  106. self.promptLabel.textColor = kAppGrayColor1;
  107. self.promptLabel.hidden = YES;
  108. [self.view addSubview:self.promptLabel];
  109. // self.basicInfoView = [self creatViewWithStr:ASLocalizedString(@"基本资料")];
  110. // self.idNewsView = [self creatViewWithStr:ASLocalizedString(@"认证消息")];
  111. // self.idAuthenView = [self creatViewWithStr:ASLocalizedString(@"身份认证")];
  112. // self.recommendView = [self creatViewWithStr:ASLocalizedString(@"推荐人信息")];
  113. self.inviteCodeView = [[UIView alloc]initWithFrame:CGRectMake(10, 0, kScreenW-10, 44)];
  114. self.inviteCodeView.backgroundColor = kWhiteColor;
  115. UILabel *label1 = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 90, 44)];
  116. label1.text = ASLocalizedString(@"公会邀请码");
  117. label1.textColor = kAppGrayColor1;
  118. label1.font = [UIFont systemFontOfSize:17];
  119. [self.inviteCodeView addSubview:label1];
  120. UILabel *label2 = [[UILabel alloc]initWithFrame:CGRectMake(90, 0, 40, 44)];
  121. label2.text = ASLocalizedString(@"(选填)");
  122. label2.textColor = kAppGrayColor3;
  123. label2.font = [UIFont systemFontOfSize:13];
  124. [self.inviteCodeView addSubview:label2];
  125. self.inviteCodeFiled = [[UITextField alloc]initWithFrame:CGRectMake(135, 2, kScreenW-155, 40)];
  126. self.inviteCodeFiled.borderStyle = UITextBorderStyleRoundedRect;
  127. self.inviteCodeFiled.backgroundColor = kWhiteColor;
  128. self.inviteCodeFiled.placeholder = ASLocalizedString(@"请输入您的公会邀请码");
  129. self.inviteCodeFiled.font = [UIFont systemFontOfSize:15];
  130. self.inviteCodeFiled.textColor = kAppGrayColor1;
  131. self.inviteCodeFiled.delegate = self;
  132. [self.inviteCodeView addSubview:self.inviteCodeFiled];
  133. _myTableView = [[UITableView alloc]initWithFrame:CGRectMake(0, topBgImgV.bottom - 38, kScreenW, kScreenH-topBgImgV.bottom-SafeAreaBottomHeight + 38) style:UITableViewStylePlain];
  134. _sumitBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  135. _sumitBtn.frame = CGRectMake(62, 10, kScreenW-124, 45);
  136. // _sumitBtn.layer.cornerRadius = 20;
  137. // _sumitBtn.layer.masksToBounds = YES;
  138. // _sumitBtn.backgroundColor = kAppMainColor;
  139. [_sumitBtn setTitle:ASLocalizedString(@"提交")forState:UIControlStateNormal];
  140. [_sumitBtn setTitleColor:kWhiteColor forState:UIControlStateNormal];
  141. [_sumitBtn setBackgroundImage:[UIImage imageNamed:@"widthBtnBg"] forState:UIControlStateNormal];
  142. [_sumitBtn addTarget:self action:@selector(submitAction) forControlEvents:UIControlEventTouchUpInside];
  143. _myTableView.dataSource = self;
  144. _myTableView.delegate = self;
  145. _myTableView.layer.cornerRadius = 10;
  146. _myTableView.layer.masksToBounds = YES;
  147. _myTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
  148. [_myTableView registerNib:[UINib nibWithNibName:@"SBasicInfoCell" bundle:nil] forCellReuseIdentifier:@"SBasicInfoCell"];
  149. [_myTableView registerNib:[UINib nibWithNibName:@"ThirdTableViewCell" bundle:nil] forCellReuseIdentifier:@"ThirdTableViewCell"];
  150. [_myTableView registerNib:[UINib nibWithNibName:@"FourTableViewCell" bundle:nil] forCellReuseIdentifier:@"FourTableViewCell"];
  151. [self.view addSubview:_myTableView];
  152. UITapGestureRecognizer *tapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(keyboardHide:)];
  153. //设置成NO表示当前控件响应后会传播到其他控件上,默认为YES。
  154. tapGestureRecognizer.cancelsTouchesInView = NO;
  155. //将触摸事件添加到当前view
  156. [_myTableView addGestureRecognizer:tapGestureRecognizer];
  157. [BGMJRefreshManager refresh:_myTableView target:self headerRereshAction:@selector(refresherOfFocusOn) footerRereshAction:nil];
  158. }
  159. - (void)keyboardHide:(UITapGestureRecognizer*)tap
  160. {
  161. [_threeCell.typeTextFiled resignFirstResponder];
  162. [_threeCell.nameTextFiled resignFirstResponder];
  163. [_threeCell.contactTextFiled resignFirstResponder];
  164. [_recommendCell.recommendField resignFirstResponder];
  165. [self.inviteCodeFiled resignFirstResponder];
  166. }
  167. - (void)backClick
  168. {
  169. [self.navigationController popViewControllerAnimated:NO];
  170. }
  171. - (void)initFWData
  172. {
  173. [super initFWData];
  174. [self showMyHud];
  175. [self refresherOfFocusOn];
  176. }
  177. - (void)viewWillAppear:(BOOL)animated
  178. {
  179. [super viewWillAppear:animated];
  180. [IQKeyboardManager sharedManager].enable = YES;
  181. [IQKeyboardManager sharedManager].enableAutoToolbar = YES;
  182. [IQKeyboardManager sharedManager].shouldResignOnTouchOutside = YES;
  183. [IQKeyboardManager sharedManager].keyboardDistanceFromTextField = 5.0f;
  184. self.navigationController.navigationBar.hidden = YES;
  185. [self.navigationController setNavigationBarHidden:YES];
  186. }
  187. - (void)viewDidDisappear:(BOOL)animated
  188. {
  189. [super viewDidDisappear:animated];
  190. [IQKeyboardManager sharedManager].enable = NO;
  191. [IQKeyboardManager sharedManager].enableAutoToolbar = NO;
  192. }
  193. #pragma mark 加载数据和头部刷新
  194. - (void)refresherOfFocusOn
  195. {
  196. NSMutableDictionary *mDict = [NSMutableDictionary dictionary];
  197. [mDict setObject:@"user_center" forKey:@"ctl"];
  198. [mDict setObject:@"authent" forKey:@"act"];
  199. FWWeakify(self)
  200. [self.httpsManager POSTWithParameters:mDict SuccessBlock:^(NSDictionary *responseJson)
  201. {
  202. FWStrongify(self)
  203. [self hideMyHud];
  204. [self.typeArray removeAllObjects];
  205. [self.dataArray removeAllObjects];
  206. if ([responseJson toInt:@"status"] == 1)
  207. {
  208. self.navigationItem.title = [responseJson toString:@"title"];
  209. self.open_society_code = [responseJson toInt:@"open_society_code"];
  210. self.society_code = [[responseJson objectForKey:@"user"] toString:@"society_code"];
  211. self.identify_hold_example = [responseJson toString:@"identify_hold_example"];
  212. self.is_show_identify_number = [responseJson toInt:@"is_show_identify_number"];
  213. self.idTypeStr = [[responseJson objectForKey:@"user"]toString:@"authentication_type"];
  214. self.idNameStr = [[responseJson objectForKey:@"user"]toString:@"authentication_name"];
  215. self.idContactStr = [[responseJson objectForKey:@"user"]toString:@"contact"];
  216. self.idNumStr = [[responseJson objectForKey:@"user"]toString:@"identify_number"];
  217. self.urlString1 = [[responseJson objectForKey:@"user"] toString:@"identify_positive_image"];
  218. self.urlString2 = [[responseJson objectForKey:@"user"] toString:@"identify_nagative_image"];
  219. self.urlString3 = [[responseJson objectForKey:@"user"] toString:@"identify_hold_image"];
  220. self.recommendHeight = [responseJson toInt:@"invite_id"]> 0 ? 0 : 50;
  221. NSArray *array = [responseJson objectForKey:@"authent_list"];
  222. if (array)
  223. {
  224. if (array.count > 0)
  225. {
  226. for (NSMutableDictionary *dict in array)
  227. {
  228. cuserModel *model = [cuserModel mj_objectWithKeyValues:dict];
  229. [_typeArray addObject:model];
  230. }
  231. }
  232. }
  233. _recommendTypeModel = [RecommendTypeModel mj_objectWithKeyValues:responseJson];
  234. _authentication = [[responseJson objectForKey:@"user"]toInt:@"is_authentication"];
  235. _invite_id = [responseJson toInt:@"invite_id"];
  236. // if (_authentication == 1 || _authentication == 2 || _authentication == 3)//1审核中 2认证通过 3审核不通过
  237. // {
  238. self.promptLabel.text = [responseJson toString:@"investor_send_info"];//头部的提示语都通过服务端控制
  239. // }
  240. }else
  241. {
  242. [FanweMessage alertHUD:[responseJson toString:@"error"]];
  243. }
  244. [BGMJRefreshManager endRefresh:_myTableView];
  245. [_myTableView reloadData];
  246. } FailureBlock:^(NSError *error)
  247. {
  248. FWStrongify(self)
  249. [self hideMyHud];
  250. [BGMJRefreshManager endRefresh:_myTableView];
  251. NSLog(@"error==%@",error);
  252. }];
  253. }
  254. #pragma mark label的创建
  255. - (UIView *)creatViewWithStr:(NSString *)str
  256. {
  257. UIView *myView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, kScreenW, 35)];
  258. myView.backgroundColor = kWhiteColor;
  259. UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(10, 0, kScreenW-10, 35)];
  260. label.font = [UIFont systemFontOfSize:17];
  261. label.textColor = kAppGrayColor1;
  262. label.text = str;
  263. label.backgroundColor = kWhiteColor;
  264. [myView addSubview:label];
  265. UIView *lineView = [[UIView alloc]initWithFrame:CGRectMake(10, 34, kScreenW-10, 1)];
  266. lineView.backgroundColor = kAppSpaceColor2;
  267. [myView addSubview:lineView];
  268. return myView;
  269. }
  270. #pragma mark -- dataSource/Delegate
  271. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
  272. {
  273. return AuthenticationTab_Count;
  274. }
  275. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  276. {
  277. // if (section == AuthenticationThreeSection)
  278. // {
  279. // if (self.recommendTypeModel.invite_type_list.count>0 && _invite_id == 0)
  280. // {
  281. // if (_authentication == 1 || _authentication == 2)
  282. // {
  283. // return 0;
  284. // }else
  285. // {
  286. // return 1;
  287. // }
  288. // }else
  289. // {
  290. // return 0;
  291. // }
  292. // }else if (section ==AuthenticationFourSection)
  293. // {
  294. // if (self.open_society_code == 1)
  295. // {
  296. // return 1;
  297. // }else
  298. // {
  299. // return 0;
  300. // }
  301. // }
  302. // else
  303. if (section ==AuthenticationFiveSection)
  304. {
  305. if (_authentication == 1 || _authentication == 2)
  306. {
  307. return 0;
  308. }else
  309. {
  310. return 1;
  311. }
  312. }
  313. else
  314. {
  315. return 1;
  316. }
  317. }
  318. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
  319. {
  320. // if (indexPath.section == AuthenticationZeroSection)
  321. // {
  322. // return 60;
  323. // }else
  324. if (indexPath.section == AuthenticationOneSection)
  325. {
  326. if (_is_show_identify_number == 1)
  327. {
  328. return 395;
  329. }else
  330. {
  331. return 280;
  332. }
  333. }else if(indexPath.section == AuthenticationTwoSection)
  334. {
  335. // return kScreenW<375 ? 150+(kScreenW-20)/2 : 170+(kScreenW-20)/2;
  336. return 169;
  337. }
  338. // else if(indexPath.section == AuthenticationThreeSection)
  339. // {
  340. // return self.recommendHeight;
  341. // }else if(indexPath.section == AuthenticationFourSection)
  342. // {
  343. // return 44;
  344. // }
  345. else
  346. {
  347. return 60;
  348. }
  349. }
  350. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  351. {
  352. // if (indexPath.section == AuthenticationZeroSection)
  353. // {
  354. // SBasicInfoCell *cell = [tableView dequeueReusableCellWithIdentifier:@"SBasicInfoCell"];
  355. // cell.selectionStyle = UITableViewCellSelectionStyleNone;
  356. // cell.myNameLabel.text = [NSString stringWithFormat:ASLocalizedString(@"昵称:%@"),self.nameString];
  357. // cell.mySexLabel.text = [NSString stringWithFormat:ASLocalizedString(@"性别:%@"),[self.sexString intValue] == 1 ? ASLocalizedString(@"男"): ASLocalizedString(@"女")];
  358. // return cell;
  359. // }else
  360. if (indexPath.section == AuthenticationOneSection)
  361. {
  362. _threeCell = [tableView dequeueReusableCellWithIdentifier:@"ThirdTableViewCell"];
  363. _threeCell.delegate = self;
  364. _threeCell.typeTextFiled.delegate = self;
  365. _threeCell.nameTextFiled.delegate = self;
  366. _threeCell.contactTextFiled.delegate = self;
  367. _threeCell.identificationNumFiled.delegate = self;
  368. [_threeCell creatCellWithAuthentication:_authentication andIdTypeStr:self.idTypeStr andIdNameStr:self.idNameStr andIdContactStr:self.idContactStr andIdNumStr:self.idNumStr andShowIdNum:_is_show_identify_number];
  369. return _threeCell;
  370. }else if(indexPath.section == AuthenticationTwoSection)
  371. {
  372. _fourCell = [tableView dequeueReusableCellWithIdentifier:@"FourTableViewCell"];
  373. _fourCell.delegate = self;
  374. [_fourCell creatCellWithAuthentication:_authentication andHeadImgStr1:self.urlString1 andHeadImgStr2:self.urlString2 andHeadImgStr3:self.urlString3 andUrlStr:_identify_hold_example];
  375. return _fourCell;
  376. }
  377. // else if(indexPath.section == AuthenticationThreeSection)
  378. // {
  379. // _recommendCell = [RecommendTableViewCell cellWithTableView:tableView];
  380. // _recommendCell.delegate = self;
  381. // _recommendCell.backgroundColor = kWhiteColor;
  382. // _recommendCell.clipsToBounds = YES;
  383. // _recommendCell.selectionStyle = UITableViewCellSelectionStyleNone;
  384. // return _recommendCell;
  385. // }else if (indexPath.section == AuthenticationFourSection)
  386. // {
  387. // static NSString *CellIdentifier0 = @"CellIdentifier0";
  388. // UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier0];
  389. // if (!cell)
  390. // {
  391. // cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier0];
  392. // cell.accessoryType = UITableViewCellAccessoryNone;
  393. // cell.selectionStyle = UITableViewCellSelectionStyleNone;
  394. // cell.backgroundColor = kWhiteColor;
  395. // [cell.contentView addSubview:self.inviteCodeView];
  396. // }
  397. // if (self.society_code.length)
  398. // {
  399. // self.inviteCodeFiled.text = self.society_code;
  400. // }
  401. // return cell;
  402. // }
  403. else
  404. {
  405. static NSString *CellIdentifier1 = @"CellIdentifier1";
  406. UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier1];
  407. if (!cell)
  408. {
  409. cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier1];
  410. cell.accessoryType = UITableViewCellAccessoryNone;
  411. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  412. [cell.contentView addSubview:self.sumitBtn];
  413. }
  414. return cell;
  415. }
  416. }
  417. - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
  418. {
  419. if (section == AuthenticationFiveSection)
  420. {
  421. return 0.01;
  422. }
  423. // else if (section == AuthenticationThreeSection)
  424. // {
  425. // if (self.recommendTypeModel.invite_type_list.count>0 && _invite_id == 0)
  426. // {
  427. // if (_authentication == 1 || _authentication == 2)
  428. // {
  429. // return 0.01;
  430. // }else
  431. // {
  432. // return 35;
  433. // }
  434. // }else
  435. // {
  436. // return 0.01;
  437. // }
  438. // }else if (section == AuthenticationFourSection)
  439. // {
  440. // return 0.01;
  441. //
  442. // }
  443. else
  444. {
  445. return 0.01;
  446. }
  447. }
  448. - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
  449. {
  450. return 0.01;
  451. }
  452. - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
  453. {
  454. // if (section == AuthenticationZeroSection)
  455. // {
  456. // return self.basicInfoView;
  457. // }else
  458. if (section == AuthenticationOneSection)
  459. {
  460. return self.idNewsView;
  461. }else if(section == AuthenticationTwoSection)
  462. {
  463. return self.idAuthenView;
  464. }
  465. // else if(section == AuthenticationThreeSection)
  466. // {
  467. // if (self.recommendTypeModel.invite_type_list.count>0 && _invite_id == 0)
  468. // {
  469. // if (_authentication == 1 || _authentication == 2)
  470. // {
  471. // return nil;
  472. // }else
  473. // {
  474. // return self.recommendView;
  475. // }
  476. // }else
  477. // {
  478. // return nil;
  479. // }
  480. // }
  481. else
  482. {
  483. return nil;
  484. }
  485. }
  486. #pragma mark ============================UITextFieldDelegate============================
  487. - (BOOL)textFieldShouldReturn:(UITextField *)textField
  488. {
  489. [textField resignFirstResponder];
  490. return YES;
  491. }
  492. - (void)textFieldDidEndEditing:(UITextField *)textField
  493. {
  494. if (textField == _threeCell.contactTextFiled)
  495. {
  496. if (_threeCell.contactTextFiled.text.length < 1)
  497. {
  498. [FanweMessage alertHUD:ASLocalizedString(@"请输入电话号码")];
  499. return;
  500. }
  501. if (_threeCell.contactTextFiled.text.length < 1)
  502. {
  503. [FanweMessage alertHUD:ASLocalizedString(@"请输入11位电话号码")];
  504. return;
  505. }
  506. // if ([_threeCell.contactTextFiled.text isTelephone])
  507. // {
  508. // [FanweMessage alertHUD:ASLocalizedString(@"请输入正确的电话号码")];
  509. // return;
  510. // }
  511. }
  512. }
  513. - (BOOL)textFieldShouldBeginEditing:(UITextField *)textField
  514. {
  515. if (textField == _threeCell.contactTextFiled)
  516. {
  517. textField.keyboardType = UIKeyboardTypeNumberPad ;
  518. return YES;
  519. }else if (textField == self.inviteCodeFiled)
  520. {
  521. if (_authentication == 1 || _authentication == 2)//审核中 认证通过
  522. {
  523. return NO;
  524. }else
  525. {
  526. return YES;
  527. }
  528. }else
  529. {
  530. return YES;
  531. }
  532. }
  533. - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
  534. {
  535. if (textField == _threeCell.contactTextFiled)
  536. {
  537. if (![string isNumber])
  538. {
  539. return NO;
  540. }
  541. if (string.length == 0)
  542. return YES;
  543. NSInteger existedLength = textField.text.length;
  544. NSInteger selectedLength = range.length;
  545. NSInteger replaceLength = string.length;
  546. if (existedLength - selectedLength + replaceLength > 11)
  547. {
  548. return NO;
  549. }
  550. }
  551. return YES;
  552. }
  553. - (void)getIdentificationWithCell:(ThirdTableViewCell *)myCell
  554. {
  555. if (!_typeSheet)
  556. {
  557. UIActionSheet *typeSheet = [[UIActionSheet alloc] initWithTitle:ASLocalizedString(@"认证类型")delegate:self cancelButtonTitle:nil destructiveButtonTitle:nil otherButtonTitles:nil];
  558. for (int i=0; i < [_typeArray count]; i ++)
  559. {
  560. cuserModel *model = [_typeArray objectAtIndex:i];
  561. [typeSheet addButtonWithTitle:model.name];
  562. }
  563. [typeSheet addButtonWithTitle:ASLocalizedString(@"取消")];
  564. typeSheet.cancelButtonIndex = typeSheet.numberOfButtons-1;
  565. typeSheet.delegate = self;
  566. [typeSheet showInView:[UIApplication sharedApplication].keyWindow];
  567. self.typeSheet = typeSheet;
  568. }
  569. [self.typeSheet showInView:[UIApplication sharedApplication].keyWindow];
  570. }
  571. #pragma mark 提交
  572. - (void)submitAction
  573. {
  574. if (_threeCell.typeTextFiled.text.length < 1)
  575. {
  576. [[BGHUDHelper sharedInstance] tipMessage:ASLocalizedString(@"请选择认证类型")];
  577. return;
  578. }
  579. if (_threeCell.nameTextFiled.text.length < 1)
  580. {
  581. [[BGHUDHelper sharedInstance] tipMessage:ASLocalizedString(@"请输入真实姓名")];
  582. return;
  583. }
  584. if (_threeCell.contactTextFiled.text.length < 1)
  585. {
  586. [[BGHUDHelper sharedInstance] tipMessage:ASLocalizedString(@"请输入联系方式")];
  587. return;
  588. }
  589. if (_is_show_identify_number == 1)
  590. {
  591. if (_threeCell.identificationNumFiled.text.length != 18)
  592. {
  593. [[BGHUDHelper sharedInstance] tipMessage:ASLocalizedString(@"请输入18位有效的身份证号码")];
  594. return;
  595. }
  596. }
  597. if (_urlString1.length < 1)
  598. {
  599. [[BGHUDHelper sharedInstance] tipMessage:ASLocalizedString(@"请上传身份证正面照")];
  600. return;
  601. }
  602. if (_urlString2.length < 1)
  603. {
  604. [[BGHUDHelper sharedInstance] tipMessage:ASLocalizedString(@"请上传身份证反面照")];
  605. return;
  606. }
  607. if (_urlString3.length < 1)
  608. {
  609. [[BGHUDHelper sharedInstance] tipMessage:ASLocalizedString(@"请上传手持身份证正面照")];
  610. return;
  611. }
  612. NSMutableDictionary *mDict = [NSMutableDictionary dictionary];
  613. [mDict setObject:@"user_center" forKey:@"ctl"];
  614. [mDict setObject:@"attestation" forKey:@"act"];
  615. if (_threeCell.typeTextFiled.text.length > 0)
  616. {
  617. [mDict setObject:_threeCell.typeTextFiled.text forKey:@"authentication_type"];
  618. }
  619. if (_threeCell.nameTextFiled.text.length > 0)
  620. {
  621. [mDict setObject:_threeCell.nameTextFiled.text forKey:@"authentication_name"];
  622. }
  623. if (_threeCell.identificationNumFiled.text.length > 0)
  624. {
  625. if (_is_show_identify_number == 1)
  626. {
  627. [mDict setObject:_threeCell.identificationNumFiled.text forKey:@"identify_number"];
  628. }else
  629. {
  630. [mDict setObject:@"" forKey:@"identify_number"];
  631. }
  632. }
  633. if (_threeCell.contactTextFiled.text.length > 0)
  634. {
  635. [mDict setObject:_threeCell.contactTextFiled.text forKey:@"contact"];
  636. }
  637. if (_urlString1.length > 0)
  638. {
  639. [mDict setObject:_urlString1 forKey:@"identify_positive_image"];
  640. }
  641. if (_urlString2.length > 0)
  642. {
  643. [mDict setObject:_urlString2 forKey:@"identify_nagative_image"];
  644. }
  645. if (_urlString3.length > 0)
  646. {
  647. [mDict setObject:_urlString3 forKey:@"identify_hold_image"];
  648. }
  649. if (_recommendCell.recommendField.text.length>0)
  650. {
  651. [mDict setObject:@(_recommendType) forKey:@"invite_type"];
  652. [mDict setObject:_recommendCell.recommendField.text forKey:@"invite_input"];
  653. }
  654. if (self.open_society_code == 1)
  655. {
  656. [mDict setObject:self.inviteCodeFiled.text forKey:@"society_code"];
  657. }
  658. [self.httpsManager POSTWithParameters:mDict SuccessBlock:^(NSDictionary *responseJson)
  659. {
  660. if ([responseJson toInt:@"status"] == 1)
  661. {
  662. [self.navigationController popViewControllerAnimated:YES];
  663. }else
  664. {
  665. [[BGHUDHelper sharedInstance] tipMessage:[responseJson toString:@"error"]];
  666. }
  667. } FailureBlock:^(NSError *error)
  668. {
  669. NSLog(@"error===%@",error);
  670. }];
  671. }
  672. #pragma mark 图片的一些操作
  673. - (void)getImgWithtag:(int)tag andCell:(FourTableViewCell *)myCell
  674. {
  675. _tagCount = tag;
  676. UIActionSheet *headImgSheet = [[UIActionSheet alloc] initWithTitle:nil delegate:self cancelButtonTitle:nil destructiveButtonTitle:nil otherButtonTitles:nil];
  677. [headImgSheet addButtonWithTitle:ASLocalizedString(@"相机")];
  678. [headImgSheet addButtonWithTitle:ASLocalizedString(@"从手机相册选择")];
  679. [headImgSheet addButtonWithTitle:ASLocalizedString(@"取消")];
  680. headImgSheet.cancelButtonIndex = headImgSheet.numberOfButtons-1;
  681. headImgSheet.delegate = self;
  682. [headImgSheet showInView:[UIApplication sharedApplication].keyWindow];
  683. }
  684. - (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
  685. {
  686. if (actionSheet == self.typeSheet)
  687. {
  688. if (buttonIndex < self.typeSheet.numberOfButtons - 1)
  689. {
  690. cuserModel *model = [_typeArray objectAtIndex:buttonIndex];
  691. _threeCell.typeTextFiled.text = model.name;
  692. }
  693. }
  694. else if (actionSheet == self.recommendSheet)
  695. {
  696. if (buttonIndex < self.recommendSheet.numberOfButtons - 1)
  697. {
  698. RecommendModel *model = self.recommendTypeModel.invite_type_list[buttonIndex];
  699. _recommendCell.recommendTypeField.text = model.name;
  700. _recommendHeight = model.typeID == 1? 50 : 90;
  701. _recommendType = model.typeID ;
  702. _recommendCell.recommendField.hidden = model.typeID > 1 ? NO : YES;
  703. _recommendCell.recommendField.text = @"";
  704. if (model.typeID>1)
  705. {
  706. _recommendCell.recommendField.placeholder = [NSString stringWithFormat:ASLocalizedString(@"请输入%@"),model.name];
  707. }
  708. [_myTableView reloadData];
  709. }
  710. }
  711. else
  712. {
  713. if (buttonIndex == 0)
  714. {
  715. UIImagePickerController *picker = [[UIImagePickerController alloc] init];
  716. if([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera])
  717. {
  718. picker.sourceType=UIImagePickerControllerSourceTypeCamera;
  719. picker.delegate = self;
  720. picker.allowsEditing = YES;
  721. picker.modalTransitionStyle=UIModalTransitionStyleFlipHorizontal;
  722. }
  723. [self presentViewController:picker animated:YES completion:nil];
  724. }else if (buttonIndex == 1){
  725. UIImagePickerController *picker = [[UIImagePickerController alloc] init];
  726. if([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeSavedPhotosAlbum])
  727. {
  728. picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
  729. picker.delegate = self;
  730. picker.allowsEditing = YES;
  731. picker.modalPresentationStyle = UIModalPresentationOverCurrentContext;
  732. }
  733. [self presentViewController:picker animated:YES completion:nil];
  734. }
  735. }
  736. }
  737. - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
  738. {
  739. NSString *mediaType = [info objectForKey:UIImagePickerControllerEditedImage];
  740. if (mediaType)
  741. {
  742. UIImage *image = [info objectForKey:@"UIImagePickerControllerEditedImage"];
  743. if (!image)
  744. {
  745. image = [info objectForKey:@"UIImagePickerControllerOriginalImage"];
  746. }
  747. // if (self.BuguLive.appModel.open_sts == 1)
  748. // {
  749. // if ([_ossManager isSetRightParameter])
  750. // {
  751. // [self showMyHud];
  752. // [self saveImage:image withName:@"1.png"];
  753. // _timeString = [_ossManager getObjectKeyString];
  754. // [_ossManager asyncPutImage:_timeString localFilePath:_uploadFilePath];
  755. // }
  756. // }
  757. // else
  758. // {
  759. NSData *data=UIImageJPEGRepresentation(image, 1.0);
  760. if (_tagCount == 0)
  761. {
  762. _data1 = data;
  763. [self saveImage:[UIImage imageWithData:data] withName:@"currentImage.png"];
  764. }else if (_tagCount == 1)
  765. {
  766. _data2 = data;
  767. [self saveImage:[UIImage imageWithData:data] withName:@"currentImage1.png"];
  768. }else if (_tagCount == 2)
  769. {
  770. _data3 = data;
  771. [self saveImage:[UIImage imageWithData:data] withName:@"currentImage2.png"];
  772. }
  773. [self performSelector:@selector(uploadAvatar) withObject:nil afterDelay:0.8];
  774. // }
  775. }
  776. [picker dismissViewControllerAnimated:YES completion:nil];
  777. }
  778. - (void)saveImage:(UIImage *)currentImage withName:(NSString *)imageName
  779. {
  780. NSData *imageData = UIImageJPEGRepresentation(currentImage, 0.5);
  781. NSString *fullPath = [[NSHomeDirectory() stringByAppendingPathComponent:@"Documents"] stringByAppendingPathComponent:imageName];
  782. [imageData writeToFile:fullPath atomically:NO];
  783. _uploadFilePath = fullPath;
  784. }
  785. #pragma mark oss代理回调
  786. //- (void)uploadImageWithUrlStr:(NSString *)imageUrlStr withUploadStateCount:(int)stateCount
  787. //{
  788. // [self hideMyHud];
  789. // if (stateCount == 0)
  790. // {
  791. // NSString *imgString= [NSString stringWithFormat:@"%@%@",_ossManager.oss_domain,_timeString];
  792. // if (_tagCount == 0)
  793. // {
  794. // _urlString1=[NSString stringWithFormat:@"./%@",_timeString];
  795. // [_fourCell.headImgView1 sd_setImageWithURL:[NSURL URLWithString:imgString]];
  796. // }else if (_tagCount == 1)
  797. // {
  798. // _urlString2 = [NSString stringWithFormat:@"./%@",_timeString];
  799. // [_fourCell.headImgView2 sd_setImageWithURL:[NSURL URLWithString:imgString]];
  800. // [[BGHUDHelper sharedInstance] tipMessage:ASLocalizedString(@"身份证反面照片上传成功")];
  801. // }else if (_tagCount == 2)
  802. // {
  803. // _urlString3 = [NSString stringWithFormat:@"./%@",_timeString];
  804. // [_fourCell.headImgView3 sd_setImageWithURL:[NSURL URLWithString:imgString]];
  805. // [[BGHUDHelper sharedInstance] tipMessage:ASLocalizedString(@"手持身份证正面照上传成功")];
  806. // }
  807. // }else
  808. // {
  809. // [[BGHUDHelper sharedInstance] tipMessage:ASLocalizedString(@"上传头像失败")];
  810. // }
  811. //}
  812. #pragma mark 使用流文件上传头像
  813. - (void)uploadAvatar
  814. {
  815. [self showMyHud];
  816. NSString *imageFile = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents"];
  817. NSString *photoName;
  818. if (_tagCount == 0)
  819. {
  820. photoName=[imageFile stringByAppendingPathComponent:@"currentImage.png"];
  821. }else if (_tagCount == 1)
  822. {
  823. photoName=[imageFile stringByAppendingPathComponent:@"currentImage1.png"];
  824. }else if (_tagCount == 2)
  825. {
  826. photoName=[imageFile stringByAppendingPathComponent:@"currentImage2.png"];
  827. }
  828. NSURL *fileUrl = [NSURL URLWithString:[NSString stringWithFormat:@"file:%@",photoName]];
  829. NSMutableDictionary *parmDict = [NSMutableDictionary dictionary];
  830. [parmDict setObject:@"avatar" forKey:@"ctl"];
  831. [parmDict setObject:@"uploadImage" forKey:@"act"];
  832. [parmDict setObject:self.user_id forKey:@"id"];
  833. FWWeakify(self)
  834. [self.httpsManager POSTWithDict:parmDict andFileUrl:fileUrl SuccessBlock:^(NSDictionary *responseJson)
  835. {
  836. FWStrongify(self)
  837. [self hideMyHud];
  838. if ([responseJson toInt:@"status"] == 1)
  839. {
  840. if (_tagCount == 0)
  841. {
  842. _urlString1=[responseJson toString:@"path"];
  843. _fourCell.headImgView1.image = [UIImage imageWithData:_data1];
  844. }else if (_tagCount == 1)
  845. {
  846. _urlString2=[responseJson toString:@"path"];
  847. _fourCell.headImgView2.image = [UIImage imageWithData:_data2];
  848. }else if (_tagCount == 2)
  849. {
  850. _urlString3=[responseJson toString:@"path"];
  851. _fourCell.headImgView3.image = [UIImage imageWithData:_data3];
  852. }
  853. }
  854. } FailureBlock:^(NSError *error)
  855. {
  856. FWStrongify(self)
  857. [self hideMyHud];
  858. [[BGHUDHelper sharedInstance] tipMessage:[NSString stringWithFormat:@"%@",error]];
  859. }];
  860. }
  861. - (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker
  862. {
  863. [self dismissViewControllerAnimated:YES completion:^{}];
  864. }
  865. - (void)choseRecommendTypeWithRecommendViewCell:(RecommendTableViewCell *)recommendViewCell
  866. {
  867. if (!_recommendSheet)
  868. {
  869. UIActionSheet * recommendSheet = [[UIActionSheet alloc] initWithTitle:ASLocalizedString(@"推荐人信息类型")delegate:self cancelButtonTitle:nil destructiveButtonTitle:nil otherButtonTitles:nil];
  870. for (int i=0; i < self.recommendTypeModel.invite_type_list.count; i ++)
  871. {
  872. RecommendModel *model = self.recommendTypeModel.invite_type_list[i];
  873. [recommendSheet addButtonWithTitle:model.name];
  874. }
  875. [recommendSheet addButtonWithTitle:ASLocalizedString(@"取消")];
  876. recommendSheet.cancelButtonIndex = recommendSheet.numberOfButtons-1;
  877. recommendSheet.delegate = self;
  878. [recommendSheet showInView:[UIApplication sharedApplication].keyWindow];
  879. self.recommendSheet = recommendSheet;
  880. }
  881. }
  882. @end