@ -43,6 +43,14 @@
@@ -43,6 +43,14 @@
/ / / 是否编辑
@ property ( nonatomic , assign ) BOOL isEdit ;
@ property ( nonatomic , assign ) NSInteger Sex ;
@ property ( nonatomic , strong ) NSString * Weight ;
@ property ( nonatomic , strong ) NSString * Height ;
@ property ( nonatomic , assign ) BOOL isSelectIcon ;
@ end
@ implementation EditDeviceViewController
@ -64,6 +72,7 @@
@@ -64,6 +72,7 @@
/ / Do any additional setup after loading the view .
self . zx_navTitle = GJText ( @ "设备资料") ;
self . isEdit = NO ;
self . isSelectIcon = NO ;
[ self zx_setRightBtnWithImg : ImageName_ ( @ "icon_or_code ") clickedBlock : ^( ZXNavItemBtn * _Nonnull btn ) {
QRCodeMsgViewController * vc = [ QRCodeMsgViewController new ] ;
[ self . navigationController pushViewController : vc animated : YES ] ;
@ -80,6 +89,31 @@
@@ -80,6 +89,31 @@
[ self zx_leftClickedBlock : ^( ZXNavItemBtn * _Nonnull btn ) {
if ( self . isEdit )
{
if ( APIManager . sharedManager . deviceModel . identity == 2 )
{
if ( !self . isEditing &&
[ self . nameField . text isEqualToString : self . devModel . name ] &&
self . Sex == self . devModel . sex &&
[ self . phoneField . text isEqualToString : self . devModel . phone ] &&
[ self . relationLabel . text isEqualToString : self . devModel . relation ] &&
[ self . Height isEqualToString : self . devModel . height ] &&
[ self . Weight isEqualToString : self . devModel . weight ] )
{
[ self . navigationController popViewControllerAnimated : YES ] ;
return ;
}
}
else
{
if ( [ self . relationLabel . text isEqualToString : self . devModel . relation ] &&
[ self . Height isEqualToString : self . devModel . height ] &&
[ self . Weight isEqualToString : self . devModel . weight ] )
{
[ self . navigationController popViewControllerAnimated : YES ] ;
return ;
}
}
EasyAlertView * alertV = [ EasyAlertView alertViewWithTitle : nil subtitle : GJText ( @ "是否保存修改") AlertViewType : AlertViewTypeSystemAlert config : nil ] ;
[ alertV addAlertItem : ^EasyAlertItem * {
return [ EasyAlertItem itemWithTitle : GJText ( @ "取消") type : AlertItemTypeSystemCancel callback : ^( EasyAlertView * showview , long index ) {
@ -162,6 +196,8 @@
@@ -162,6 +196,8 @@
/ / / 头像
UIButton * iconBtn = [ UICommon ui_buttonSimple : CGRectZero font : FontADA_ ( 0 ) normalColor : KKWhiteColorColor normalText : @ "" click : ^( id x ) {
[ UICommon resignKeyboard ] ;
if ( self . devModel . identity != 2 )
return ;
if ( !self . isEdit )
return ;
[ self selectIcon ] ;
@ -178,13 +214,14 @@
@@ -178,13 +214,14 @@
else if ( i == 1 || i == titleArr . count - 1 )
{
/ / / 姓名和电话号码
UITextField * textfield = [ UICommon ui_textField : CGRectZero textColor : KKTextBlackColor backColor : KKClearColor font : FontADA_ ( 13 ) maxTextNum : i == titleArr . count - 1 ? 11 : 20 placeholderColor : KKGrey143 placeholder : i == 1 ? GJText ( @ "请输入姓名") : GJText ( @ "请输入设备电话号码") toMaxNum : ^( UITextField * textField ) {
UITextField * textfield = [ UICommon ui_textField : CGRectZero textColor : KKGrey121 backColor : KKClearColor font : FontADA_ ( 13 ) maxTextNum : i == titleArr . count - 1 ? 11 : 20 placeholderColor : KKGrey143 placeholder : i == 1 ? GJText ( @ "请输入姓名") : GJText ( @ "请输入设备电话号码") toMaxNum : ^( UITextField * textField ) {
} change : ^( UITextField * textField ) {
} ] ;
textfield . textAlignment = NSTextAlignmentRight ;
if ( self . devModel . identity != 2 )
textfield . enabled = NO ;
if ( i == 1 )
{
textfield . text = self . devModel . name ;
@ -209,14 +246,17 @@
@@ -209,14 +246,17 @@
NSArray * sexArr = @ [ GJText ( @ "男") ,
GJText ( @ "女") ,
GJText ( @ "保密") ] ;
NSInteger sex = self . devModel . sex - 1 < 0 ? 2 : self . devModel . sex - 1 ;
UIButton * sexBtn = [ UICommon ui_buttonSimple : CGRectZero font : FontADA_ ( 13 ) normalColor : KKTextBlackColor normalText : sexArr [ sex ] click : ^( UIButton * btn ) {
NSInteger sexs = self . devModel . sex - 1 < 0 ? 2 : self . devModel . sex - 1 ;
self . Sex = self . devModel . sex ;
UIButton * sexBtn = [ UICommon ui_buttonSimple : CGRectZero font : FontADA_ ( 13 ) normalColor : KKGrey121 normalText : sexArr [ sexs ] click : ^( UIButton * btn ) {
[ UICommon resignKeyboard ] ;
if ( self . devModel . identity != 2 )
return ;
if ( !self . isEdit )
return ;
[ BRStringPickerView showPickerWithTitle : GJText ( @ "请选择性别") dataSourceArr : sexArr selectIndex : self . devModel . sex - 1 resultBlock : ^( BRResultModel * _Nullable resultModel ) {
[ btn setTitle : resultModel . value forState : 0 ] ;
self . devModel . s ex = resultModel . index + 1 ;
self . S ex = resultModel . index + 1 ;
} ] ;
} ] ;
sexBtn . contentHorizontalAlignment = UIControlContentHorizontalAlignmentRight ;
@ -330,7 +370,7 @@
@@ -330,7 +370,7 @@
{
[ BRStringPickerView showPickerWithTitle : GJText ( @ "请选择身高") dataSourceArr : hArr selectIndex : idx resultBlock : ^( BRResultModel * _Nullable resultModel ) {
[ weakself . heightBtn setTitle : resultModel . value forState : 0 ] ;
weakself . devModel . h eight = resultModel . value ;
weakself . H eight = resultModel . value ;
} ] ;
}
} ] ;
@ -342,7 +382,7 @@
@@ -342,7 +382,7 @@
{
[ BRStringPickerView showPickerWithTitle : GJText ( @ "请选择体重") dataSourceArr : wArr selectIndex : idx resultBlock : ^( BRResultModel * _Nullable resultModel ) {
[ weakself . weightBtn setTitle : resultModel . value forState : 0 ] ;
weakself . devModel . w eight = resultModel . value ;
weakself . W eight = resultModel . value ;
} ] ;
}
} ] ;
@ -352,17 +392,21 @@
@@ -352,17 +392,21 @@
commBtn . tag = i ;
if ( i == 1 )
{
[ commBtn setTitleColor : KKGrey121 forState : 0 ] ;
[ commBtn setTitle : self . devModel . birthday forState : 0 ] ;
commBtn . enabled = NO ;
self . birthdayBtn = commBtn ;
}
else if ( i == 2 )
{
[ commBtn setTitle : self . devModel . height forState : 0 ] ;
self . Height = self . devModel . height ;
self . heightBtn = commBtn ;
}
else if ( i == 3 )
{
[ commBtn setTitle : self . devModel . weight forState : 0 ] ;
self . Weight = self . devModel . weight ;
self . weightBtn = commBtn ;
}
commBtn . contentHorizontalAlignment = UIControlContentHorizontalAlignmentRight ;
@ -433,20 +477,24 @@
@@ -433,20 +477,24 @@
{
UIImage * curImg = [ info objectForKey : @ "UIImagePickerControllerOriginalImage "] ;
[ picker dismissViewControllerAnimated : YES completion : nil ] ;
[ self . iconBtn setImage : curImg forState : 0 ] ;
[ self . iconBtn setImage : [ UICommon reduceImage : curImg percent : 0.5 ] forState : 0 ] ;
self . isSelectIcon = YES ;
}
- ( void ) setIsEditMsg
{
self . nameField . enabled = self . isEdit ;
self . phoneField . enabled = self . isEdit ;
self . nameField . textColor = self . isEdit ? KKTextBlackColor : KKGrey121 ;
self . phoneField . textColor = self . isEdit ? KKTextBlackColor : KKGrey121 ;
if ( self . devModel . identity == 2 )
{
self . nameField . enabled = self . isEdit ;
self . phoneField . enabled = self . isEdit ;
self . nameField . textColor = self . isEdit ? KKTextBlackColor : KKGrey121 ;
self . phoneField . textColor = self . isEdit ? KKTextBlackColor : KKGrey121 ;
[ self . sexBtn setTitleColor : self . isEdit ? KKTextBlackColor : KKGrey121 forState : 0 ] ;
}
[ self . sexBtn setTitleColor : self . isEdit ? KKTextBlackColor : KKGrey121 forState : 0 ] ;
[ self . birthdayBtn setTitleColor : self . isEdit ? KKTextBlackColor : KKGrey121 forState : 0 ] ;
/ / [ self . birthdayBtn setTitleColor : self . isEdit ? KKTextBlackColor : KKGrey121 forState : 0 ] ;
[ self . heightBtn setTitleColor : self . isEdit ? KKTextBlackColor : KKGrey121 forState : 0 ] ;
[ self . weightBtn setTitleColor : self . isEdit ? KKTextBlackColor : KKGrey121 forState : 0 ] ;
self . relationLabel . textColor = self . isEdit ? KKTextBlackColor : KKGrey121 ;
@ -460,13 +508,13 @@
@@ -460,13 +508,13 @@
{
if ( self . phoneField . text . length < = 0 )
{
[ UICommon MessageErrorText : NSLocalizedString ( @ "请输入号码", nil ) ] ;
[ UICommon MessageErrorText : @ "请输入号码"] ;
return ;
}
if ( self . nameField . text . length < = 0 )
{
[ UICommon MessageErrorText : NSLocalizedString ( @ "请输入姓名", nil ) ] ;
[ UICommon MessageErrorText : @ "请输入姓名"] ;
return ;
}
[ UICommon MessageUpload : @ "加载中"] ;
@ -474,13 +522,13 @@
@@ -474,13 +522,13 @@
self . iconFile = UIImageJPEGRepresentation ( self . iconBtn . currentImage , 1.0 f ) ;
NSMutableDictionary * parameters = [ NSMutableDictionary dictionary ] ;
[ parameters setValue : APIManager . sharedManager . deviceModel . imei forKey : @ "imei "] ;
[ parameters setValue : self . devModel . h eight forKey : @ "height "] ;
[ parameters setValue : self . H eight forKey : @ "height "] ;
[ parameters setValue : self . nameField . text forKey : @ "name "] ;
[ parameters setValue : self . phoneField . text forKey : @ "phone "] ;
[ parameters setValue : self . relationLabel . text forKey : @ "relation "] ;
[ parameters setValue : @ ( self . devModel . relationImageId ) forKey : @ "relationImageId "] ;
[ parameters setValue : @ ( self . devModel . s ex) forKey : @ "sex "] ;
[ parameters setValue : self . devModel . w eight forKey : @ "weight "] ;
[ parameters setValue : @ ( self . S ex) forKey : @ "sex "] ;
[ parameters setValue : self . W eight forKey : @ "weight "] ;
[ [ [ APIManager sharedManager ] uploadFileWithURL : UpdateDeviceInfo_URL parameters : parameters filePath : @ "" fileData : self . iconFile ] subscribeNext : ^( id _Nullable x ) {
[ super updataNotificat ] ;
[ UICommon HidenLoading ] ;