|
@@ -10,8 +10,15 @@
|
|
|
#import <UITextView+JXHPlaceHolder.h>
|
|
|
#import "XSTTVerificationProfile.h"
|
|
|
#import <JXHTextField.h>
|
|
|
+#import "XSTTPickerViewController.h"
|
|
|
+#import <JXHFMDBManager.h>
|
|
|
+#import "XSTTSQLProfile.h"
|
|
|
+#import "XSTTConfirmAlertViewController.h"
|
|
|
+#import "XSTTAddressModel.h"
|
|
|
+#import "UIView+XSTTLoadingTipsView.h"
|
|
|
+#import "UIViewController+XSTTNetworkManager.h"
|
|
|
|
|
|
-@interface XSTTEditAddressViewController ()<UITextViewDelegate, UITextFieldDelegate, UIScrollViewDelegate> {
|
|
|
+@interface XSTTEditAddressViewController ()<UITextViewDelegate, UITextFieldDelegate, UIScrollViewDelegate, XSTTPickerViewDelegate> {
|
|
|
UIScrollView *_bgView;
|
|
|
UIButton *_saveButton;
|
|
|
JXHTextField *_name;
|
|
@@ -21,6 +28,12 @@
|
|
|
UISwitch *_default;
|
|
|
NSString *_lastText;
|
|
|
NSString *_tempText;
|
|
|
+
|
|
|
+ NSMutableArray<NSArray<NSString *> *> *_areaArray;
|
|
|
+ XSTTAddressModel *_data;
|
|
|
+
|
|
|
+ NSMutableArray<XSTTAddressDistrictModel *> *_chooseAreaData;
|
|
|
+ NSMutableArray<NSNumber *> *_chooseIndexs;
|
|
|
}
|
|
|
|
|
|
@end
|
|
@@ -29,14 +42,276 @@
|
|
|
|
|
|
- (void)viewDidLoad {
|
|
|
[super viewDidLoad];
|
|
|
+ [self initData];
|
|
|
+ if (_xstt_addressId) {
|
|
|
+ [self getData];
|
|
|
+ } else {
|
|
|
+ [self setNewData];
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+- (void)setNewData {
|
|
|
+ _data = XSTTAddressModel.new;
|
|
|
[self setupUI];
|
|
|
+ [self setCityData];
|
|
|
+}
|
|
|
+
|
|
|
+- (void)initData {
|
|
|
+ _areaArray = NSMutableArray.new;
|
|
|
+ NSArray *p = [JXHFMDBManager searchWithPath:XSTTCityCacheDataSQL backKey:@"name" condition:^id _Nonnull(FMDatabase * _Nonnull database) {
|
|
|
+ return [database executeQuery:@"select * from t_xstt_city_province"];
|
|
|
+ }];
|
|
|
+ if (p.count == 0) {
|
|
|
+ [self noCityDataWarning];
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ [_areaArray addObject:p];
|
|
|
}
|
|
|
|
|
|
#pragma mark - Action
|
|
|
- (void)saveAction {
|
|
|
+ if (_name.text.length < XSTTNameMinWords) {
|
|
|
+ [self.view showToastWithTitle:@"请正确输入收货人"];
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ NSMutableString *phone = [NSMutableString stringWithString:_number.text];
|
|
|
+ [phone replaceOccurrencesOfString:@" " withString:@"" options:1 range:NSMakeRange(0, phone.length)];
|
|
|
+ if (phone.length != XSTTPhoneNumberWords || !jxh_isNumber(phone)) {
|
|
|
+ [self.view showToastWithTitle:@"请正确输入手机号码"];
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (_chooseAreaData.count != 3) {
|
|
|
+ [self.view showToastWithTitle:@"请选择省市区"];
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (_address.text.length <= 0) {
|
|
|
+ [self.view showToastWithTitle:@"请输入详细地址"];
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ [self updateDataWithPhone:phone];
|
|
|
+}
|
|
|
+
|
|
|
+- (void)noCityDataWarning {
|
|
|
+ XSTTConfirmAlertViewController *vc = [XSTTConfirmAlertViewController alertWithTitle:@"城市数据缺失请重新打开App" content:nil];
|
|
|
+ @weakify(self)
|
|
|
+ [vc setConfirmButtonTitle:nil titleColor:nil action:^{
|
|
|
+ @strongify(self)
|
|
|
+ [self.navigationController popViewControllerAnimated:true];
|
|
|
+ }];
|
|
|
+ [self presentViewController:vc animated:true completion:nil];
|
|
|
+}
|
|
|
+
|
|
|
+- (void)setCityData {
|
|
|
+ NSArray *p = _areaArray[0];
|
|
|
+ if (_data.xstt_districtList.count == 3) {
|
|
|
+ _chooseAreaData = _data.xstt_districtList.mutableCopy;
|
|
|
+ NSInteger pI = [p indexOfObject:_chooseAreaData[0].xstt_districtName];
|
|
|
+ NSArray *c = [JXHFMDBManager searchWithPath:XSTTCityCacheDataSQL backKey:@"name" condition:^id _Nonnull(FMDatabase * _Nonnull database) {
|
|
|
+ return [database executeQuery:@"select * from t_xstt_city_city where pid = ?", self->_chooseAreaData[0].xstt_districtId];
|
|
|
+ }];
|
|
|
+ if (c.count == 0) {
|
|
|
+ [self noCityDataWarning];
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ _areaArray[1] = c;
|
|
|
+ NSInteger cI = [c indexOfObject:_chooseAreaData[1].xstt_districtName];
|
|
|
+ NSArray *d = [JXHFMDBManager searchWithPath:XSTTCityCacheDataSQL backKey:@"name" condition:^id _Nonnull(FMDatabase * _Nonnull database) {
|
|
|
+ return [database executeQuery:@"select * from t_xstt_city_district where pid = ?", self->_chooseAreaData[1].xstt_districtId];
|
|
|
+ }];
|
|
|
+ if (d.count == 0) {
|
|
|
+ [self noCityDataWarning];
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ _areaArray[2] = d;
|
|
|
+ NSInteger dI = [d indexOfObject:_chooseAreaData[2].xstt_districtName];
|
|
|
+ _chooseIndexs = @[@(pI), @(cI), @(dI)].mutableCopy;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ _chooseAreaData = NSMutableArray.new;
|
|
|
+ NSArray *ids = [JXHFMDBManager searchWithPath:XSTTCityCacheDataSQL backKey:@"id" condition:^id _Nonnull(FMDatabase * _Nonnull database) {
|
|
|
+ return [database executeQuery:@"select * from t_xstt_city_province where name = ?", p[0]];
|
|
|
+ }];
|
|
|
+ if (ids.count == 0) {
|
|
|
+ [self noCityDataWarning];
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ NSArray *c = [JXHFMDBManager searchWithPath:XSTTCityCacheDataSQL backKey:@"name" condition:^id _Nonnull(FMDatabase * _Nonnull database) {
|
|
|
+ return [database executeQuery:@"select * from t_xstt_city_city where pid = ?", ids[0]];
|
|
|
+ }];
|
|
|
+ if (c.count == 0) {
|
|
|
+ [self noCityDataWarning];
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ _areaArray[1] = c;
|
|
|
+ ids = [JXHFMDBManager searchWithPath:XSTTCityCacheDataSQL backKey:@"id" condition:^id _Nonnull(FMDatabase * _Nonnull database) {
|
|
|
+ return [database executeQuery:@"select * from t_xstt_city_city where name = ?", c[0]];
|
|
|
+ }];
|
|
|
+ if (ids.count == 0) {
|
|
|
+ [self noCityDataWarning];
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ NSArray *d = [JXHFMDBManager searchWithPath:XSTTCityCacheDataSQL backKey:@"name" condition:^id _Nonnull(FMDatabase * _Nonnull database) {
|
|
|
+ return [database executeQuery:@"select * from t_xstt_city_district where pid = ?", ids[0]];
|
|
|
+ }];
|
|
|
+ if (d.count == 0) {
|
|
|
+ [self noCityDataWarning];
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ _areaArray[2] = d;
|
|
|
+ _chooseIndexs = @[@0, @0, @0].mutableCopy;
|
|
|
+}
|
|
|
+
|
|
|
+- (void)chooseArea {
|
|
|
+ XSTTPickerViewController *vc = XSTTPickerViewController.new;
|
|
|
+ vc.xstt_pickerDelegate = self;
|
|
|
+ vc.xstt_dataArray = _areaArray;
|
|
|
+ @weakify(self)
|
|
|
+ vc.xstt_finishChose = ^(XSTTPickerView * _Nonnull pickerView) {
|
|
|
+ @strongify(self)
|
|
|
+ [self completeToChoseAreaWithPickerView:pickerView];
|
|
|
+ };
|
|
|
+ vc.xstt_willDisplay = ^(XSTTPickerView * _Nonnull pickerView) {
|
|
|
+ @strongify(self)
|
|
|
+ [pickerView setRow:self->_chooseIndexs[0].integerValue inComponent:0 animated:false];
|
|
|
+ [pickerView setRow:self->_chooseIndexs[1].integerValue inComponent:1 animated:false];
|
|
|
+ [pickerView setRow:self->_chooseIndexs[2].integerValue inComponent:2 animated:false];
|
|
|
+ };
|
|
|
+ [self presentViewController:vc animated:false completion:nil];
|
|
|
+}
|
|
|
+
|
|
|
+- (void)completeToChoseAreaWithPickerView:(XSTTPickerView *)pickerView {
|
|
|
+ _chooseIndexs = @[pickerView.xstt_choseArray[0], pickerView.xstt_choseArray[1], pickerView.xstt_choseArray[2]].mutableCopy;
|
|
|
+ NSArray *array = [JXHFMDBManager searchWithPath:XSTTCityCacheDataSQL backKey:nil condition:^id _Nonnull(FMDatabase * _Nonnull database) {
|
|
|
+ return [database executeQuery:@"select * from t_xstt_city_province where name = ?", self->_areaArray[0][pickerView.xstt_choseArray[0].integerValue]];
|
|
|
+ }];
|
|
|
+ if (array.count == 0) {
|
|
|
+ [self noCityDataWarning];
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ XSTTAddressDistrictModel *model = XSTTAddressDistrictModel.new;
|
|
|
+ model.xstt_pid = array[0][@"pid"];
|
|
|
+ model.xstt_districtId = array[0][@"id"];
|
|
|
+ model.xstt_districtName = array[0][@"name"];
|
|
|
+ _chooseAreaData[0] = model;
|
|
|
+ array = [JXHFMDBManager searchWithPath:XSTTCityCacheDataSQL backKey:nil condition:^id _Nonnull(FMDatabase * _Nonnull database) {
|
|
|
+ return [database executeQuery:@"select * from t_xstt_city_city where name = ?", self->_areaArray[1][pickerView.xstt_choseArray[1].integerValue]];
|
|
|
+ }];
|
|
|
+ if (array.count == 0) {
|
|
|
+ [self noCityDataWarning];
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ model = XSTTAddressDistrictModel.new;
|
|
|
+ model.xstt_pid = array[0][@"pid"];
|
|
|
+ model.xstt_districtId = array[0][@"id"];
|
|
|
+ model.xstt_districtName = array[0][@"name"];
|
|
|
+ _chooseAreaData[1] = model;
|
|
|
+ array = [JXHFMDBManager searchWithPath:XSTTCityCacheDataSQL backKey:nil condition:^id _Nonnull(FMDatabase * _Nonnull database) {
|
|
|
+ return [database executeQuery:@"select * from t_xstt_city_district where name = ?", self->_areaArray[2][pickerView.xstt_choseArray[2].integerValue]];
|
|
|
+ }];
|
|
|
+ if (array.count == 0) {
|
|
|
+ [self noCityDataWarning];
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ model = XSTTAddressDistrictModel.new;
|
|
|
+ model.xstt_pid = array[0][@"pid"];
|
|
|
+ model.xstt_districtId = array[0][@"id"];
|
|
|
+ model.xstt_districtName = array[0][@"name"];
|
|
|
+ _chooseAreaData[2] = model;
|
|
|
+
|
|
|
+ _area.text = [NSString stringWithFormat:@"%@ %@ %@", _chooseAreaData[0].xstt_districtName, _chooseAreaData[1].xstt_districtName, _chooseAreaData[2].xstt_districtName];
|
|
|
+ _area.textColor = xstt_000000_color(0.6);
|
|
|
}
|
|
|
|
|
|
#pragma mark - Network Action
|
|
|
+- (void)getData {
|
|
|
+ [self networkUseMethod:XSTTNetworkMethodGET loadingTips:XSTTGetDataLoadingCommonTips isLogin:true signKey:XSTTNetworkSignKeyApp url:xstt_appUrl(XSTTURLGetAddressDetails) urlParameters:nil parameters:^NSDictionary * _Nonnull{
|
|
|
+ return @{@"userAddressId": self->_xstt_addressId};
|
|
|
+ } success:^NSString * _Nullable(NSError * _Nonnull error, id _Nullable data) {
|
|
|
+ self->_data = [XSTTAddressModel getModelWithDictionary:data[@"data"]];
|
|
|
+ [self setupUI];
|
|
|
+ [self setCityData];
|
|
|
+ return @"";
|
|
|
+ } failure:^NSString * _Nullable(NSError * _Nonnull error, id _Nullable data) {
|
|
|
+ self->_xstt_addressId = nil;
|
|
|
+ [self setNewData];
|
|
|
+ return XSTTGetDataFailureCommonTips;
|
|
|
+ }];
|
|
|
+}
|
|
|
+
|
|
|
+- (void)updateDataWithPhone:(NSString *)phone {
|
|
|
+ [self networkUseMethod:XSTTNetworkMethodPOST loadingTips:@"正在上传" isLogin:true signKey:XSTTNetworkSignKeyApp url:xstt_appUrl(_xstt_addressId ? XSTTURLUpdateAddress : XSTTURLCreateNewAddress) urlParameters:nil parameters:^NSDictionary * _Nonnull{
|
|
|
+ NSMutableDictionary *dic = @{@"districtId": self->_chooseAreaData[2].xstt_districtId, @"detailAddress": jxh_deleteBothSidesSpace(self->_address.text), @"defaultAddress": @(self->_default.on), @"phone": phone, @"name": jxh_deleteBothSidesSpace(self->_name.text)}.mutableCopy;
|
|
|
+ if (self->_xstt_addressId) { dic[@"userAddressId"] = self->_xstt_addressId; }
|
|
|
+ return dic;
|
|
|
+ } success:^NSString * _Nullable(NSError * _Nonnull error, id _Nullable data) {
|
|
|
+ self->_xstt_finishEdit();
|
|
|
+ return @"上传成功";
|
|
|
+ } failure:^NSString * _Nullable(NSError * _Nonnull error, id _Nullable data) {
|
|
|
+ return @"上传失败";
|
|
|
+ }];
|
|
|
+}
|
|
|
+
|
|
|
+#pragma mark - XSTTPickerViewDelegate
|
|
|
+- (void)pickerView:(XSTTPickerView *)pickerView didChoseRow:(NSInteger)row inComponent:(NSInteger)component {
|
|
|
+ if (component == 0) {
|
|
|
+ NSArray *p = _areaArray[0];
|
|
|
+ NSArray *ids = [JXHFMDBManager searchWithPath:XSTTCityCacheDataSQL backKey:@"id" condition:^id _Nonnull(FMDatabase * _Nonnull database) {
|
|
|
+ return [database executeQuery:@"select * from t_xstt_city_province where name = ?", p[row]];
|
|
|
+ }];
|
|
|
+ if (ids.count == 0) {
|
|
|
+ [self noCityDataWarning];
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ NSArray *c = [JXHFMDBManager searchWithPath:XSTTCityCacheDataSQL backKey:@"name" condition:^id _Nonnull(FMDatabase * _Nonnull database) {
|
|
|
+ return [database executeQuery:@"select * from t_xstt_city_city where pid = ?", ids[0]];
|
|
|
+ }];
|
|
|
+ if (c.count == 0) {
|
|
|
+ [self noCityDataWarning];
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ _areaArray[1] = c;
|
|
|
+ ids = [JXHFMDBManager searchWithPath:XSTTCityCacheDataSQL backKey:@"id" condition:^id _Nonnull(FMDatabase * _Nonnull database) {
|
|
|
+ return [database executeQuery:@"select * from t_xstt_city_city where name = ?", c[0]];
|
|
|
+ }];
|
|
|
+ if (ids.count == 0) {
|
|
|
+ [self noCityDataWarning];
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ NSArray *d = [JXHFMDBManager searchWithPath:XSTTCityCacheDataSQL backKey:@"name" condition:^id _Nonnull(FMDatabase * _Nonnull database) {
|
|
|
+ return [database executeQuery:@"select * from t_xstt_city_district where pid = ?", ids[0]];
|
|
|
+ }];
|
|
|
+ if (d.count == 0) {
|
|
|
+ [self noCityDataWarning];
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ _areaArray[2] = d;
|
|
|
+ _chooseIndexs = @[@(row), @0, @0].mutableCopy;
|
|
|
+ [pickerView reloadViewWithData:_areaArray];
|
|
|
+ [pickerView chooseRow:0 inComponent:1 animated:true];
|
|
|
+ [pickerView chooseRow:0 inComponent:2 animated:true];
|
|
|
+ } else if (component == 1) {
|
|
|
+ NSArray *c = _areaArray[1];
|
|
|
+ NSArray *ids = [JXHFMDBManager searchWithPath:XSTTCityCacheDataSQL backKey:@"id" condition:^id _Nonnull(FMDatabase * _Nonnull database) {
|
|
|
+ return [database executeQuery:@"select * from t_xstt_city_city where name = ?", c[row]];
|
|
|
+ }];
|
|
|
+ if (ids.count == 0) {
|
|
|
+ [self noCityDataWarning];
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ NSArray *d = [JXHFMDBManager searchWithPath:XSTTCityCacheDataSQL backKey:@"name" condition:^id _Nonnull(FMDatabase * _Nonnull database) {
|
|
|
+ return [database executeQuery:@"select * from t_xstt_city_district where pid = ?", ids[0]];
|
|
|
+ }];
|
|
|
+ if (d.count == 0) {
|
|
|
+ [self noCityDataWarning];
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ _areaArray[2] = d;
|
|
|
+ _chooseIndexs[1] = @(row);
|
|
|
+ _chooseIndexs[2] = @0;
|
|
|
+ [pickerView reloadViewWithData:_areaArray];
|
|
|
+ [pickerView chooseRow:0 inComponent:2 animated:true];
|
|
|
+ }
|
|
|
+}
|
|
|
|
|
|
#pragma mark - UIScrollViewDelegate
|
|
|
- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
|
|
@@ -99,9 +374,36 @@
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
+- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {
|
|
|
+ if (textField == _number) {
|
|
|
+ NSMutableString *num = textField.text.mutableCopy;
|
|
|
+ if (range.length > 0) {
|
|
|
+ [num replaceCharactersInRange:range withString:@""];
|
|
|
+ } else {
|
|
|
+ [num replaceCharactersInRange:range withString:string];
|
|
|
+ }
|
|
|
+ [num replaceOccurrencesOfString:@" " withString:@"" options:1 range:NSMakeRange(0, num.length)];
|
|
|
+ if (!jxh_isNumber(num)) return false;
|
|
|
+ if (num.length > 3) {
|
|
|
+ [num replaceCharactersInRange:NSMakeRange(3, 0) withString:@" "];
|
|
|
+ }
|
|
|
+ if (num.length > 8) {
|
|
|
+ [num replaceCharactersInRange:NSMakeRange(8, 0) withString:@" "];
|
|
|
+ }
|
|
|
+ if (num.length > XSTTPhoneNumberWords + 2) {
|
|
|
+ _number.text = [num substringWithRange:NSMakeRange(0, XSTTPhoneNumberWords + 2)];
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ _number.text = num;
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ return true;
|
|
|
+}
|
|
|
+
|
|
|
#pragma mark - UI
|
|
|
- (void)setupUI {
|
|
|
- self.title = _xstt_data == nil ? @"添加收货地址" : @"编辑收货地址";
|
|
|
+ self.title = _xstt_addressId == nil ? @"添加收货地址" : @"编辑收货地址";
|
|
|
[self createBgView];
|
|
|
[self createContentView];
|
|
|
[self createBottomButton];
|
|
@@ -120,7 +422,7 @@
|
|
|
}
|
|
|
|
|
|
- (void)createContentView {
|
|
|
- NSArray *titles = @[@"收货人", @"手机号码", @"所在地区", @"详细地址", @"详细地址"];
|
|
|
+ NSArray *titles = @[@"收货人", @"手机号码", @"所在地区", @"详细地址", @"设为默认地址"];
|
|
|
UIView *tempView = nil;
|
|
|
for (NSInteger i = 0; i < titles.count; i ++) {
|
|
|
UIView *view = UIView.new;
|
|
@@ -167,6 +469,7 @@
|
|
|
make.leading.equalTo(116);
|
|
|
make.top.and.bottom.equalTo(0);
|
|
|
}];
|
|
|
+ if (_data.xstt_name) { _name.text = _data.xstt_name; }
|
|
|
}
|
|
|
break;
|
|
|
case 1: {
|
|
@@ -178,16 +481,20 @@
|
|
|
}];
|
|
|
|
|
|
_number = [JXHTextField convenienceWithFont:xstt_font(17) placeholder:@"请输入手机号码" placeholderColor:xstt_000000_color(0.4) textColor:xstt_000000_color(0.6) clearButtonMode:UITextFieldViewModeWhileEditing returnType:UIReturnKeyDone keyboardType:UIKeyboardTypeNumberPad delegate:self];
|
|
|
- _number.jxh_maxCount = XSTTPhoneNumberWords;
|
|
|
+ _number.jxh_maxCount = XSTTPhoneNumberWords + 2;
|
|
|
[view addSubview:_number];
|
|
|
[_number makeConstraints:^(JXHConstraintMaker *make) {
|
|
|
make.trailing.equalTo(-XSTTMargin);
|
|
|
make.leading.equalTo(num.trailing).offset(12);
|
|
|
make.top.and.bottom.equalTo(0);
|
|
|
}];
|
|
|
+
|
|
|
+ if (_data.xstt_phone) { _number.text = _data.xstta_showPhone; }
|
|
|
}
|
|
|
break;
|
|
|
case 2: {
|
|
|
+ [view addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(chooseArea)]];
|
|
|
+
|
|
|
_area = [UILabel convenienceWithFont:xstt_font(17) text:@"请选择省市区" textColor:xstt_000000_color(0.4)];
|
|
|
[view addSubview:_area];
|
|
|
[_area makeConstraints:^(JXHConstraintMaker *make) {
|
|
@@ -202,12 +509,17 @@
|
|
|
make.trailing.equalTo(-8);
|
|
|
make.centerY.equalTo(0);
|
|
|
}];
|
|
|
+
|
|
|
+ if (_data.xstt_districtList.count == 3) {
|
|
|
+ _area.text = [NSString stringWithFormat:@"%@ %@ %@", _data.xstt_districtList[0].xstt_districtName, _data.xstt_districtList[1].xstt_districtName, _data.xstt_districtList[2].xstt_districtName];
|
|
|
+ _area.textColor = xstt_000000_color(0.6);
|
|
|
+ }
|
|
|
}
|
|
|
break;
|
|
|
case 3: {
|
|
|
_address = UITextView.new;
|
|
|
_address.font = xstt_font(17);
|
|
|
- _address.textColor = xstt_000000_color(0.8);
|
|
|
+ _address.textColor = xstt_000000_color(0.6);
|
|
|
_address.enablesReturnKeyAutomatically = true;
|
|
|
// [_address setTextContainerInset:(UIEdgeInsets){12, XSTTMargin, 12, XSTTMargin}];
|
|
|
_address.textContainer.lineFragmentPadding = 0;
|
|
@@ -222,11 +534,12 @@
|
|
|
make.top.greaterThanOrEqualTo(8);
|
|
|
make.bottom.lessThanOrEqualTo(-8);
|
|
|
}];
|
|
|
+ if (_data.xstt_detailAddress) { _address.text = _data.xstt_detailAddress; }
|
|
|
}
|
|
|
break;
|
|
|
case 4: {
|
|
|
_default = UISwitch.new;
|
|
|
-// [_default addTarget:self action:@selector(changeDefault) forControlEvents:UIControlEventValueChanged];
|
|
|
+// [_default addTarget:self action:@selector(changeDefault:) forControlEvents:UIControlEventValueChanged];
|
|
|
_default.onTintColor = xstt_FF5700_color();
|
|
|
[view addSubview:_default];
|
|
|
[_default makeConstraints:^(JXHConstraintMaker *make) {
|
|
@@ -234,6 +547,7 @@
|
|
|
make.centerY.equalTo(0);
|
|
|
make.size.equalTo((CGSize){51, 31});
|
|
|
}];
|
|
|
+ if (_data.xstt_defaultAddress) { _default.on = _data.xstt_defaultAddress.boolValue; }
|
|
|
}
|
|
|
break;
|
|
|
|
|
@@ -247,8 +561,8 @@
|
|
|
CGSize size = (CGSize){jxh_screenWidth() - XSTTMargin * 2, 45};
|
|
|
_saveButton = [UIButton convenienceWithTarget:self action:@selector(saveAction)];
|
|
|
[_saveButton setStatusType:XSTTButtonStatusTypePrimary font:xstt_mediumFont(17) size:size];
|
|
|
- [_saveButton setTitle:_xstt_data == nil ? @"保存" : @"确认修改" state:JXHButtonControlStateNormal];
|
|
|
- _saveButton.enabled = _xstt_data != nil;
|
|
|
+ [_saveButton setTitle:_xstt_addressId == nil ? @"保存" : @"确认修改" state:JXHButtonControlStateNormal];
|
|
|
+// _saveButton.enabled = _xstt_addressId != nil;
|
|
|
[self.view addSubview:_saveButton];
|
|
|
[_saveButton makeConstraints:^(JXHConstraintMaker *make) {
|
|
|
make.leading.equalTo(XSTTMargin);
|