123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642 |
- //
- // SPSBBankDetailsViewController.m
- // 我的社保
- //
- // Created by shanp on 2021/5/19.
- //
- #import "SPSBBankDetailsViewController.h"
- #import "SPSBUIGeneralHeader.h"
- #import "SPSBTextField.h"
- #import "SPSBSQLProfile.h"
- #import "SPSBPurchasersModel.h"
- #import "SPSBBusinessManager.h"
- #import "SPSBVerificationProfile.h"
- #import <UITextView+JXHPlaceHolder.h>
- #import "UIViewController+SPSBNetworkManager.h"
- #import "SPSBChooseBankTableViewController.h"
- #import <JXHVerificationTools.h>
- #import "SPSBChooseCityViewController.h"
- #import "SPSBQueryCityModel.h"
- #import "SPSBNavigationController.h"
- #define spsb_bankDetailsTitleTag 3000
- #define spsb_bankDetailsContentTag 4000
- #define spsb_bankDetailsLineTag 5000
- #define spsb_bankDetailsContentLeft 130
- #define spsb_bankDetailsTextViewRight 15
- #define spsb_bankDetailsTextViewWidth (jxh_screenWidth() - 130 - 15)
- #define spsb_bankDetailsRowHeight 50
- @interface SPSBBankDetailsViewController ()<UITextViewDelegate, UITextFieldDelegate> {
- NSArray *_titleArray;
- NSMutableArray<NSString *> *_contentArray;
- NSMutableArray<NSString *> *_editContentArray;
- UITextView *_textView;
- SPSBTextField *_textField;
- CGFloat _textViewHeight;
- UIButton *_rightButton;
- UIView *_headerView;
- UIView *_footerView;
- UITableViewCell *_nameCell;
- bool _isBankCodeInput;
- }
- @property (nonatomic, strong) UITableViewCell *spsb_numberCell;
- @property (nonatomic, strong) UITableViewCell *spsb_bankCell;
- @property (nonatomic, strong) UITableViewCell *spsb_branchCell;
- @property (nonatomic, strong) UITableViewCell *spsb_cityCell;
- @end
- @implementation SPSBBankDetailsViewController
- - (instancetype)init {
- self = [super initWithStyle:UITableViewStyleGrouped backgroundColor:SPSBTableViewBackgroundColorGray];
- if (!self) return nil;
- return self;
- }
- - (void)viewDidLoad {
- [super viewDidLoad];
- [self initData];
- [self setupUI];
- }
- - (void)initData {
- _isBankCodeInput = false;
- _titleArray = [@[@"银行卡号", @"开户银行", @"开户支行", @"开户城市"] mutableCopy];
- NSString *bankCity = [self getBankCityWithCid:_spsb_purchasers.spsb_bank_cid];
- _contentArray = [@[[_spsb_purchasers.spsb_bank_code isEqualToString:@""] ? @"未填写" : spsb_changeDisplayBankCode(_spsb_purchasers.spsb_bank_code),
- [_spsb_purchasers.spsb_bank isEqualToString:@""] ? @"未填写" : _spsb_purchasers.spsb_bank,
- [_spsb_purchasers.spsb_bank_branch isEqualToString:@""] ? @"未填写" : _spsb_purchasers.spsb_bank_branch, [bankCity isEqualToString:@""] ? @"未填写" : bankCity] mutableCopy];
- _editContentArray = [@[_spsb_purchasers.spsb_bank_code, _spsb_purchasers.spsb_bank, _spsb_purchasers.spsb_bank_branch, _spsb_purchasers.spsb_bank_cid] mutableCopy];
- }
- - (NSString *)getBankCityWithCid:(NSString *)cid {
- if (cid.length == 0) return cid;
- NSArray *array = [JXHFMDBManager searchWithPath:SPSBShanpQueryCitySQL backKey:@"city_name" condition:^id(FMDatabase *database) {
- return [database executeQuery:@"select * from t_sp_query_city where cid = ?", cid];
- }];
- if (array.count == 0) return @"";
- return array[0];
- }
- #pragma mark - Action
- - (void)rightButtonAction {
- if (!_spsb_isEdit) {
- [self changeStatus];
- return;
- }
- [self saveAction];
- }
- - (void)changeStatus {
- _spsb_isEdit = !_spsb_isEdit;
- [self reloadView];
- [self.tableView reloadData];
- }
- - (void)saveAction {
- jxh_endEdit();
- if (!jxh_isNumber(_editContentArray[0]) || ((NSString *)_editContentArray[0]).length < SPSBMinBankNumLength) {
- [self.view showToastWithTitle:@"请输入正确的银行卡号"];
- return;
- }
-
- if (_editContentArray[1].length < SPSBMinBankNameLength) {
- [self.view showToastWithTitle:@"请输入正确的银行名称"];
- return;
- }
-
- if (((NSString *)_editContentArray[2]).length < 1) {
- [self.view showToastWithTitle:@"请输入正确的银行支行名称"];
- return;
- }
-
- if (((NSString *)_editContentArray[3]).length < 1) {
- [self.view showToastWithTitle:@"请选择开户城市"];
- return;
- }
- [self uploadBank];
- }
- - (void)chooseBank {
- if (_isBankCodeInput) {
- _isBankCodeInput = false;
- //先结束输入以获取textfield内容
- jxh_endEdit();
- [self getBankWithInChooseBank:true];
- return;
- }
- jxh_endEdit();
- SPSBChooseBankTableViewController *vc = SPSBChooseBankTableViewController.new;
- @weakify(self)
- vc.spsb_completionAction = ^(NSString * _Nonnull bank) {
- @strongify(self)
- [self changeBank:bank];
- };
- [self.navigationController pushViewController:vc animated:true];
- }
- - (void)changeBank:(NSString *)bank {
- _editContentArray[1] = bank;
- [self.tableView reloadData];
- }
- - (void)chooseCity {
- SPSBChooseCityViewController *vc = SPSBChooseCityViewController.new;
- @weakify(self)
- vc.spsb_finishChoose = ^(SPSBQueryCityModel * _Nonnull model) {
- @strongify(self)
- [self finishChooseCity:model];
- };
- SPSBNavigationController *nav = [[SPSBNavigationController alloc] initWithRootViewController:vc];
- [self presentViewController:nav animated:true completion:nil];
- }
- - (void)finishChooseCity:(SPSBQueryCityModel *)model {
- _editContentArray[3] = model.spsb_cid;
- _contentArray[3] = model.spsb_city_name;
- [self.tableView reloadData];
- }
- - (void)handleCache {
- NSMutableDictionary *dict = [[_spsb_purchasers getDictionary] mutableCopy];
- dict[@"bank_code"] = _editContentArray[0];
- dict[@"bank"] = _editContentArray[1];
- dict[@"bank_branch"] = _editContentArray[2];
- dict[@"bank_cid"] = _editContentArray[3];
- _spsb_purchasers = [SPSBPurchasersModel getModelWithDictionary:dict];
- @synchronized(spsb_purchasersArray()) {
- NSMutableArray *arr;
- NSArray *cacheArray = [JXHFMDBManager searchWithPath:SPSBShanpSocialInsuranceLocationSQL key:SPSBmyPurchasersSQLKey condition:^id(FMDatabase *database) {
- return [database executeQuery:@"select * from cache_data where key = ?", SPSBmyPurchasersSQLKey];
- }];
- if (cacheArray) {
- arr = [NSMutableArray arrayWithArray:cacheArray];
- for (NSInteger i = 0; i < arr.count; i ++) {
- NSDictionary *dic = arr[i];
- if ([[NSString stringWithFormat:@"%@", dic[@"id"]] isEqualToString:_spsb_purchasers.spsb_id]) {
- [arr removeObject:dic];
- [arr insertObject:dict atIndex:i];
- dict = nil;
- break;
- }
- }
- if (dict) {
- [arr addObject:dict];
- }
- [JXHFMDBManager updateWithPath:SPSBShanpSocialInsuranceLocationSQL condition:^id(FMDatabase *database) {
- return @([database executeUpdate:@"delete from cache_data where key = ?", SPSBmyPurchasersSQLKey]);
- }];
- } else {
- arr = [NSMutableArray arrayWithArray:@[dict]];
- }
- spsb_setPurchasersArray([SPSBPurchasersModel getModelListWithArray:arr]);
- [JXHFMDBManager updateWithPath:SPSBShanpSocialInsuranceLocationSQL condition:^id(FMDatabase *database) {
- return @([database executeUpdate:@"insert into cache_data values(?, ?)", SPSBmyPurchasersSQLKey, jxh_archiver(arr, SPSBmyPurchasersSQLKey)]);
- }];
- }
- if (_spsb_hadChnaged) {
- _spsb_hadChnaged(_spsb_purchasers);
- }
- }
- #pragma mark - Network Action
- - (void)uploadBank {
- @weakify(self)
- [self networkUseMethod:SPSBNetworkMethodPOST loadingTips:@"正在保存" isLogin:true url:spsb_appUrl(SPSBUrlModifyBank) urlParameters:nil parameters:^NSDictionary * _Nonnull{
- return @{@"sbu_id": self->_spsb_purchasers.spsb_id, @"bank": self->_editContentArray[1], @"bank_branch": self->_editContentArray[2], @"bank_code": self->_editContentArray[0], @"bank_cid": self->_editContentArray[3]};
- } success:^NSString * _Nullable(NSError * _Nonnull error, id _Nullable data) {
- @strongify(self)
- [self handleCache];
- [self.navigationController popViewControllerAnimated:true];
- return @"保存成功";
- } failure:^NSString * _Nullable(NSError * _Nonnull error, id _Nullable data) {
- return @"保存失败";
- }];
- }
- - (void)getBankWithInChooseBank:(bool)flag {
- @weakify(self)
- [self networkUseMethod:SPSBNetworkMethodGET loadingTips:nil isLogin:false url:[NSString stringWithFormat:@"%@%@", SPSBAlipayGetBank, _editContentArray[0]] urlParameters:nil parameters:nil success:^NSString * _Nullable(NSError * _Nonnull error, id _Nullable data) {
- return nil;
- } failure:^NSString * _Nullable(NSError * _Nonnull error, id _Nullable data) {
- debugLog(@"%@", data);
- @strongify(self)
- if (data && data[@"bank"]) {
- NSDictionary *bankDic = spsb_alipayBankDictionary();
- if (bankDic[data[@"bank"]]) {
- NSString *bank = bankDic[data[@"bank"]];
- [self changeBank:bank];
- return nil;
- }
- }
- if (flag) {
- [self chooseBank];
- }
- return nil;
- }];
- }
- #pragma mark - UITextFieldDelegate
- - (void)textFieldDidBeginEditing:(UITextField *)textField {
- _isBankCodeInput = true;
- }
- - (BOOL)textFieldShouldEndEditing:(UITextField *)textField {
- _editContentArray[0] = textField.text;
- if (_isBankCodeInput) {
- _isBankCodeInput = false;
- [self getBankWithInChooseBank:false];
- }
-
- return true;
- }
- #pragma mark - UITextViewDelegate
- - (BOOL)textViewShouldBeginEditing:(UITextView *)textView {
- jxh_handleInputTextView(textView, textView.font, 4, 0, NSTextAlignmentRight);
- return true;
- }
- - (void)textViewDidChange:(UITextView *)textView {
- UITextRange *selectedRange = [textView markedTextRange];
- if (!selectedRange) {
- if (textView.text.length > SPSBMaxBankBranceLength) {
- textView.text = [textView.text substringToIndex:SPSBMaxBankBranceLength];
- }
- _editContentArray[2] = textView.text;
- }
- CGFloat height = [textView sizeThatFits:(CGSize){spsb_bankDetailsTextViewWidth, CGFLOAT_MAX}].height;
- if (height == _textViewHeight) return;
- _textViewHeight = height;
- [textView makeConstraints:^(JXHConstraintMaker *make) {
- make.height.update(height);
- }];
- if ([textView isFirstResponder]) {
- if (@available(iOS 11.0, *)) {
- [self.tableView performBatchUpdates:^{
-
- } completion:^(BOOL finished) {
-
- }];
- } else {
- [self.tableView beginUpdates];
- [self.tableView endUpdates];
- }
- } else {
- [self.tableView reloadData];
- }
-
- }
- #pragma mark - Delegate & DataSource
- static NSString * const reuseIdentifier = @"Cell";
- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
- switch (indexPath.row) {
- case 0:
- return self.spsb_numberCell;
- break;
- case 1:
- return self.spsb_bankCell;
- break;
- case 2:
- return self.spsb_branchCell;
- break;
- case 3:
- return self.spsb_cityCell;
- break;
-
- default:
- break;
- }
- UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:reuseIdentifier];
- if (!cell) {
- cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:reuseIdentifier];
- }
- return cell;
- }
- - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
- return 4;
- }
- - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
- if (_spsb_isEdit && indexPath.row == 2) {
- CGFloat height = _textViewHeight + 18;
- if (height < spsb_bankDetailsRowHeight) return spsb_bankDetailsRowHeight;
- return height;
- }
- return spsb_bankDetailsRowHeight;
- }
- - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
- [tableView deselectRowAtIndexPath:indexPath animated:false];
- if (!_spsb_isEdit) return;
- switch (indexPath.row) {
- case 1:
- [self chooseBank];
- break;
- case 3:
- [self chooseCity];
- break;
-
- default:
- break;
- }
- }
- - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
- return _spsb_purchasers.spsb_bank_code.length == 0 ? 110 : 146;
- }
- - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
- if (!_headerView) {
- _headerView = UIView.new;
-
- UILabel *tipsLabel = [UILabel convenienceWithFont:spsb_font(13) text:@"已缴纳的社保流水费用,将返还于该银行卡号上" textColor:spsb_999999_color()];
- [_headerView addSubview:tipsLabel];
- [tipsLabel makeConstraints:^(JXHConstraintMaker *make) {
- make.leading.equalTo(15);
- make.top.equalTo(22);
- }];
-
- _nameCell = [self createCellWithTitle:@"持卡人姓名" content:_spsb_purchasers.spsb_user_name];
- _nameCell.contentView.backgroundColor = spsb_FFFFFF_color(1.f);
- [_headerView addSubview:_nameCell];
- [_nameCell makeConstraints:^(JXHConstraintMaker *make) {
- make.leading.and.trailing.equalTo(0);
- make.top.equalTo(48);
- make.height.equalTo(spsb_bankDetailsRowHeight);
- }];
-
- [_nameCell.contentView viewWithTag:spsb_bankDetailsLineTag].hidden = true;
-
- if (_spsb_purchasers.spsb_bank_code.length != 0) {
- tipsLabel = [UILabel convenienceWithFont:spsb_font(13) text:@"修改卡号后请通知客服,以免社保流水返还到旧卡上" textColor:spsb_999999_color()];
- [_headerView addSubview:tipsLabel];
- [tipsLabel makeConstraints:^(JXHConstraintMaker *make) {
- make.leading.equalTo(15);
- make.top.equalTo(self->_nameCell.bottom).offset(22);
- }];
- }
- }
- UILabel *content = [_nameCell.contentView viewWithTag:spsb_bankDetailsContentTag];
- content.textColor = _spsb_isEdit ? spsb_AAAAAA_color() : spsb_808080_color();
- return _headerView;
- }
- - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
- if (_spsb_isEdit && _spsb_purchasers.spsb_bank_code.length == 0) {
- return 93;
- }
- return jxh_onePixe();
- }
- - (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section {
- if (_spsb_isEdit && _spsb_purchasers.spsb_bank_code.length == 0) {
- if (!_footerView) {
- _footerView = UIView.new;
-
- UIButton *addButton = [UIButton convenienceWithFont:spsb_semiboldFont(16) target:self action:@selector(saveAction)];
- [addButton setTitle:@"添加" titleColor:spsb_FFFFFF_color(1.f) image:nil backgroundImage:jxh_getImage(confirm_n) state:JXHButtonControlStateNormal];
- [addButton setBackgroundImage:jxh_getImage(confirm_h) state:JXHButtonControlStateHighlighted];
- [addButton setLayerCornerRadius:22.5 clipToBounds:true];
- [_footerView addSubview:addButton];
- [addButton makeConstraints:^(JXHConstraintMaker *make) {
- make.top.equalTo(24);
- make.leading.equalTo(16);
- make.trailing.equalTo(-16);
- make.height.equalTo(45);
- }];
- }
- return _footerView;
- }
- return UIView.new;
- }
- #pragma mark - UI
- - (void)setupUI {
- [self createRightButton];
- [self setupTableView];
- [self reloadView];
-
- }
- - (void)reloadView {
- self.title = _spsb_isEdit ? (_spsb_purchasers.spsb_bank_code.length == 0 ? @"添加银行卡" : @"修改银行卡") : @"银行卡信息";
- _rightButton.hidden = _spsb_isEdit && _spsb_purchasers.spsb_bank_code.length == 0;
- _rightButton.selected = _spsb_isEdit;
- }
- - (void)setupTableView {
- if (@available(iOS 11.0, *)) {
- self.tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentAutomatic;
- }
- }
- - (void)createRightButton {
- _rightButton = [UIButton convenienceWithFont:spsb_font(15) target:self action:@selector(rightButtonAction)];
- [_rightButton setTitle:@"编辑" titleColor:spsb_3296FB_color() state:JXHButtonControlStateNormal | JXHButtonControlStateHighlighted];
- [_rightButton setTitle:@"保存" state:JXHButtonControlStateSelected | JXHButtonControlStateSelectedAndHighlighted];
- [_rightButton setContentHorizontalAlignment:UIControlContentHorizontalAlignmentRight];
- _rightButton.frame = CGRectMake(0, 0, 60, 44);
- UIBarButtonItem *rightItem = [[UIBarButtonItem alloc] initWithCustomView:_rightButton];
- self.navigationItem.rightBarButtonItem = rightItem;
- }
- - (UITableViewCell *)spsb_numberCell {
- if (!_spsb_numberCell) {
- _spsb_numberCell = [self createCellWithTitle:_titleArray[0] content:_contentArray[0]];
-
- _textField = [SPSBTextField convenienceWithFont:spsb_font(16) placeholder:@"仅支持储蓄卡" placeholderColor:spsb_CCCCCC_color() textColor:spsb_666666_color() clearButtonMode:UITextFieldViewModeWhileEditing returnType:UIReturnKeyDone keyboardType:UIKeyboardTypePhonePad delegate:self];
- _textField.text = _editContentArray[0];
- _textField.spsb_maxCount = SPSBMaxBankNumLength;
- _textField.textAlignment = NSTextAlignmentRight;
- [_spsb_numberCell.contentView addSubview:_textField];
- [_textField makeConstraints:^(JXHConstraintMaker *make) {
- make.leading.equalTo(spsb_bankDetailsContentLeft);
- make.right.equalTo(-15);
- make.top.and.bottom.equalTo(0);
- }];
- }
- UILabel *contentLabel = [_spsb_numberCell.contentView viewWithTag:spsb_bankDetailsContentTag];
- if (_spsb_isEdit) {
- contentLabel.hidden = true;
- _textField.hidden = false;
- } else {
- contentLabel.hidden = false;
- _textField.hidden = true;
- }
- [_spsb_numberCell.contentView viewWithTag:spsb_bankDetailsLineTag].hidden = true;
- return _spsb_numberCell;
- }
- - (UITableViewCell *)spsb_bankCell {
- if (!_spsb_bankCell) {
- _spsb_bankCell = [self createCellWithTitle:_titleArray[1] content:_contentArray[1]];
- UILabel *contentLabel = [_spsb_bankCell.contentView viewWithTag:spsb_bankDetailsContentTag];
- [contentLabel removeFromSuperview];
- UIStackView *view = [UIStackView convenienceWithAxis:UILayoutConstraintAxisHorizontal alignment:UIStackViewAlignmentCenter distribution:UIStackViewDistributionEqualSpacing spacing:7];
- [_spsb_bankCell.contentView addSubview:view];
- [view makeConstraints:^(JXHConstraintMaker *make) {
- make.trailing.equalTo(-15);
- make.top.and.bottom.equalTo(0);
- }];
-
- UIImageView *icon = UIImageView.new;
- icon.tag = 10000;
- [view addArrangedSubview:icon];
-
- [view addArrangedSubview:contentLabel];
-
- UIImageView *arrow = [[UIImageView alloc] initWithImage:jxh_getImage(list_arrow)];
- arrow.tag = 10001;
- [view addArrangedSubview:arrow];
- }
- UIImageView *icon = [_spsb_bankCell.contentView viewWithTag:10000];
- UIImageView *arrow = [_spsb_bankCell.contentView viewWithTag:10001];
- UILabel *contentLabel = [_spsb_bankCell.contentView viewWithTag:spsb_bankDetailsContentTag];
- if (_spsb_isEdit) {
- arrow.hidden = false;
- if ([_editContentArray[1] isEqualToString:@""]) {
- contentLabel.textColor = spsb_CCCCCC_color();
- contentLabel.text = @"请选择";
- } else {
- contentLabel.textColor = spsb_666666_color();
- contentLabel.text = _editContentArray[1];
- }
- _spsb_bankCell.selectionStyle = UITableViewCellSelectionStyleDefault;
- } else {
- arrow.hidden = true;
- contentLabel.text = _contentArray[1];
- contentLabel.textColor = spsb_808080_color();
- _spsb_bankCell.selectionStyle = UITableViewCellSelectionStyleNone;
- }
- NSString *bank = contentLabel.text;
- NSString *image = spsb_bankIconDictionary()[bank];
- if (image) {
- icon.image = [UIImage imageNamed:image];
- } else {
- icon.image = nil;
- }
- return _spsb_bankCell;
- }
- - (UITableViewCell *)spsb_branchCell {
- if (!_spsb_branchCell) {
- _spsb_branchCell = [self createCellWithTitle:_titleArray[2] content:_contentArray[2]];
-
- _textView = UITextView.new;
- _textView.delegate = self;
- _textView.textColor = spsb_666666_color();
- _textView.font = spsb_font(16);
- _textView.textAlignment = NSTextAlignmentRight;
- _textView.enablesReturnKeyAutomatically = true;
- [_textView setTextContainerInset:UIEdgeInsetsZero];
- _textView.textContainer.lineFragmentPadding = 0;
- _textView.scrollEnabled = false;
- _textView.text = _editContentArray[2];
- UILabel *label = [UILabel convenienceWithFont:spsb_font(16) text:@"请输入开户支行" textColor:spsb_CCCCCC_color() textAlignment:NSTextAlignmentRight];
- [_textView setPlaceholderLabel:label];
- [_spsb_branchCell.contentView addSubview:_textView];
- [_textView makeConstraints:^(JXHConstraintMaker *make) {
- make.leading.equalTo(spsb_bankDetailsContentLeft);
- make.trailing.equalTo(-spsb_bankDetailsTextViewRight);
- make.centerY.equalTo(0);
- make.height.equalTo(0);
- }];
- _textViewHeight = 0.f;
- }
- UILabel *contentLabel = [_spsb_branchCell.contentView viewWithTag:spsb_bankDetailsContentTag];
- if (_spsb_isEdit) {
- contentLabel.hidden = true;
- _textView.hidden = false;
- [self textViewDidChange:_textView];
- } else {
- contentLabel.hidden = false;
- _textView.hidden = true;
- }
- return _spsb_branchCell;
- }
- - (UITableViewCell *)spsb_cityCell {
- if (!_spsb_cityCell) {
- _spsb_cityCell = [self createCellWithTitle:_titleArray[3] content:_contentArray[3]];
- UILabel *contentLabel = [_spsb_cityCell.contentView viewWithTag:spsb_bankDetailsContentTag];
- [contentLabel removeFromSuperview];
- UIStackView *view = [UIStackView convenienceWithAxis:UILayoutConstraintAxisHorizontal alignment:UIStackViewAlignmentCenter distribution:UIStackViewDistributionEqualSpacing spacing:7];
- [_spsb_cityCell.contentView addSubview:view];
- [view makeConstraints:^(JXHConstraintMaker *make) {
- make.trailing.equalTo(-15);
- make.top.and.bottom.equalTo(0);
- }];
-
- [view addArrangedSubview:contentLabel];
-
- UIImageView *arrow = [[UIImageView alloc] initWithImage:jxh_getImage(list_arrow)];
- arrow.tag = 10001;
- [view addArrangedSubview:arrow];
- }
- UILabel *contentLabel = [_spsb_cityCell.contentView viewWithTag:spsb_bankDetailsContentTag];
- UIImageView *arrow = [_spsb_cityCell.contentView viewWithTag:10001];
- if (_spsb_isEdit) {
- arrow.hidden = false;
- NSString *city = [self getBankCityWithCid:_editContentArray[3]];
- if ([city isEqualToString:@""]) {
- _editContentArray[3] = @"";
- contentLabel.textColor = spsb_CCCCCC_color();
- contentLabel.text = @"请选择";
- } else {
- contentLabel.textColor = spsb_666666_color();
- contentLabel.text = city;
- }
- _spsb_cityCell.selectionStyle = UITableViewCellSelectionStyleDefault;
- } else {
- arrow.hidden = true;
- contentLabel.text = _contentArray[3];
- contentLabel.textColor = spsb_808080_color();
- _spsb_cityCell.selectionStyle = UITableViewCellSelectionStyleNone;
- }
- return _spsb_cityCell;
- }
- - (UITableViewCell *)createCellWithTitle:(NSString *)title content:(NSString *)content {
- UITableViewCell *cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:reuseIdentifier];
- cell.selectionStyle = UITableViewCellSelectionStyleNone;
- UILabel *titleLabel = [UILabel convenienceWithFont:spsb_font(16) text:title textColor:spsb_333333_color()];
- titleLabel.tag = spsb_bankDetailsTitleTag;
- [cell.contentView addSubview:titleLabel];
- [titleLabel makeConstraints:^(JXHConstraintMaker *make) {
- make.leading.equalTo(15);
- make.top.equalTo(0);
- make.height.equalTo(spsb_bankDetailsRowHeight);
- }];
-
- UILabel *contentLabel = [UILabel convenienceWithFont:spsb_font(16) text:content textColor:spsb_808080_color() textAlignment:NSTextAlignmentRight];
- contentLabel.tag = spsb_bankDetailsContentTag;
- [cell.contentView addSubview:contentLabel];
- [contentLabel makeConstraints:^(JXHConstraintMaker *make) {
- make.leading.equalTo(spsb_bankDetailsContentLeft);
- make.trailing.equalTo(-15);
- make.centerY.equalTo(0);
- }];
-
- UIView *line = [cell.contentView createLineWithLocation:JXHLineLocationTop headOffset:15 footOffset:0];
- line.tag = spsb_bankDetailsLineTag;
- return cell;
- }
- @end
- #undef spsb_bankDetailsTitleTag
- #undef spsb_bankDetailsContentTag
- #undef spsb_bankDetailsLineTag
- #undef spsb_bankDetailsContentLeft
- #undef spsb_bankDetailsTextViewRight
- #undef spsb_bankDetailsTextViewWidth
- #undef spsb_bankDetailsRowHeight
|