Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
陈高翔
/
DreamSleep-iOS
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
作业
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit 82b6fc5a
由
cgx
编写于
2022-04-25 15:52:52 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
完成用户昵称及性别修改
1 个父辈
6b150246
隐藏空白字符变更
内嵌
并排
正在显示
17 个修改的文件
包含
362 行增加
和
132 行删除
DreamSleep/DreamSleep.xcodeproj/project.pbxproj
DreamSleep/DreamSleep/H5/ExceptionDefaultView.h
DreamSleep/DreamSleep/Profile/Account/AccountController.m
DreamSleep/DreamSleep/Profile/Account/InfoModifyAlertView.h
DreamSleep/DreamSleep/Profile/Account/PhotoAlertView.m → DreamSleep/DreamSleep/Profile/Account/InfoModifyAlertView.m
DreamSleep/DreamSleep/Profile/Account/NickNameController.h
DreamSleep/DreamSleep/Profile/Account/NickNameController.m
DreamSleep/DreamSleep/Profile/Account/PhotoAlertView.h
DreamSleep/DreamSleep/Profile/Account/UserInfoTableView.h
DreamSleep/DreamSleep/Profile/Account/UserInfoTableView.m
DreamSleep/DreamSleep/Profile/Account/UserInfoView.h
DreamSleep/DreamSleep/Profile/Account/UserInfoView.m
DreamSleep/DreamSleep/Profile/Me/ProfileController.m
DreamSleep/DreamSleep/Profile/UserLogin/LoginUtils.h
DreamSleep/DreamSleep/Profile/UserLogin/LoginUtils.m
DreamSleep/DreamSleep/Profile/UserLogin/UserRequestModel.h
DreamSleep/DreamSleep/Profile/UserLogin/UserRequestModel.m
DreamSleep/DreamSleep.xcodeproj/project.pbxproj
查看文件 @
82b6fc5
...
...
@@ -16,6 +16,7 @@
D01814E8280020F900583D4E /* CWPageControl.m in Sources */ = {isa = PBXBuildFile; fileRef = D01814E6280020F800583D4E /* CWPageControl.m */; };
D01814EB28002A8200583D4E /* DsMiddleView.m in Sources */ = {isa = PBXBuildFile; fileRef = D01814EA28002A8200583D4E /* DsMiddleView.m */; };
D01814EE28002DC700583D4E /* HeaderDataModel.m in Sources */ = {isa = PBXBuildFile; fileRef = D01814ED28002DC700583D4E /* HeaderDataModel.m */; };
D01C9D6728167F9D00163567 /* InfoModifyAlertView.m in Sources */ = {isa = PBXBuildFile; fileRef = D01C9D6628167F9D00163567 /* InfoModifyAlertView.m */; };
D020CE1F280D951400E7E82F /* invite_friend.webp in Resources */ = {isa = PBXBuildFile; fileRef = D020CE1E280D915D00E7E82F /* invite_friend.webp */; };
D027EE2627FB3DC0004BBA61 /* NetLoadingStateView.m in Sources */ = {isa = PBXBuildFile; fileRef = D027EE2527FB3DC0004BBA61 /* NetLoadingStateView.m */; };
D027EE2927FB51D0004BBA61 /* DSGifHeader.m in Sources */ = {isa = PBXBuildFile; fileRef = D027EE2827FB51D0004BBA61 /* DSGifHeader.m */; };
...
...
@@ -52,7 +53,6 @@
D07A4B2D280EA73B00BA0EC0 /* UserInfoView.m in Sources */ = {isa = PBXBuildFile; fileRef = D07A4B2C280EA73B00BA0EC0 /* UserInfoView.m */; };
D07A657D28158A1900C15AF6 /* DsWebController.m in Sources */ = {isa = PBXBuildFile; fileRef = D07A657C28158A1900C15AF6 /* DsWebController.m */; };
D07A65832815911D00C15AF6 /* DsMaskView.m in Sources */ = {isa = PBXBuildFile; fileRef = D07A65822815911D00C15AF6 /* DsMaskView.m */; };
D07DAC8D281048050067A1BF /* PhotoAlertView.m in Sources */ = {isa = PBXBuildFile; fileRef = D07DAC8C281048050067A1BF /* PhotoAlertView.m */; };
D07DAC902810546A0067A1BF /* DSImagePickerController.m in Sources */ = {isa = PBXBuildFile; fileRef = D07DAC8F2810546A0067A1BF /* DSImagePickerController.m */; };
D07DACA42810557D0067A1BF /* CGGeometry+RSKImageCropper.m in Sources */ = {isa = PBXBuildFile; fileRef = D07DAC922810557D0067A1BF /* CGGeometry+RSKImageCropper.m */; };
D07DACA52810557D0067A1BF /* RSKInternalUtility.m in Sources */ = {isa = PBXBuildFile; fileRef = D07DAC932810557D0067A1BF /* RSKInternalUtility.m */; };
...
...
@@ -86,6 +86,7 @@
D0B5ECD527F2F0B2003EDFE3 /* AdaptationUtil.m in Sources */ = {isa = PBXBuildFile; fileRef = D0B5ECD427F2F0B2003EDFE3 /* AdaptationUtil.m */; };
D0B5ECD827F2F1B0003EDFE3 /* ServerAPIUtil.m in Sources */ = {isa = PBXBuildFile; fileRef = D0B5ECD727F2F1B0003EDFE3 /* ServerAPIUtil.m */; };
D0BB9AA4281626F200DB209E /* ExceptionDefaultView.m in Sources */ = {isa = PBXBuildFile; fileRef = D0BB9AA3281626F200DB209E /* ExceptionDefaultView.m */; };
D0BB9AA728164DFB00DB209E /* NickNameController.m in Sources */ = {isa = PBXBuildFile; fileRef = D0BB9AA628164DFB00DB209E /* NickNameController.m */; };
D0BE32E62814D42B006539BE /* HomeRequestModel.m in Sources */ = {isa = PBXBuildFile; fileRef = D0BE32E52814D42B006539BE /* HomeRequestModel.m */; };
D0BE32E9281551EB006539BE /* ShareAlertView.m in Sources */ = {isa = PBXBuildFile; fileRef = D0BE32E8281551EB006539BE /* ShareAlertView.m */; };
D0C09ED728007D9100709D4C /* relax_normal_lottie.json in Resources */ = {isa = PBXBuildFile; fileRef = D0C09ED328007D9100709D4C /* relax_normal_lottie.json */; };
...
...
@@ -140,6 +141,8 @@
D01814EA28002A8200583D4E /* DsMiddleView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = DsMiddleView.m; sourceTree = "<group>"; };
D01814EC28002DC700583D4E /* HeaderDataModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = HeaderDataModel.h; sourceTree = "<group>"; };
D01814ED28002DC700583D4E /* HeaderDataModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = HeaderDataModel.m; sourceTree = "<group>"; };
D01C9D6528167F9D00163567 /* InfoModifyAlertView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = InfoModifyAlertView.h; sourceTree = "<group>"; };
D01C9D6628167F9D00163567 /* InfoModifyAlertView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = InfoModifyAlertView.m; sourceTree = "<group>"; };
D020CE1E280D915D00E7E82F /* invite_friend.webp */ = {isa = PBXFileReference; lastKnownFileType = file; path = invite_friend.webp; sourceTree = "<group>"; };
D027EE2427FB3DC0004BBA61 /* NetLoadingStateView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = NetLoadingStateView.h; sourceTree = "<group>"; };
D027EE2527FB3DC0004BBA61 /* NetLoadingStateView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = NetLoadingStateView.m; sourceTree = "<group>"; };
...
...
@@ -200,8 +203,6 @@
D07A657C28158A1900C15AF6 /* DsWebController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = DsWebController.m; sourceTree = "<group>"; };
D07A65812815911D00C15AF6 /* DsMaskView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DsMaskView.h; sourceTree = "<group>"; };
D07A65822815911D00C15AF6 /* DsMaskView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = DsMaskView.m; sourceTree = "<group>"; };
D07DAC8B281048050067A1BF /* PhotoAlertView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PhotoAlertView.h; sourceTree = "<group>"; };
D07DAC8C281048050067A1BF /* PhotoAlertView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = PhotoAlertView.m; sourceTree = "<group>"; };
D07DAC8E2810546A0067A1BF /* DSImagePickerController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DSImagePickerController.h; sourceTree = "<group>"; };
D07DAC8F2810546A0067A1BF /* DSImagePickerController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DSImagePickerController.m; sourceTree = "<group>"; };
D07DAC922810557D0067A1BF /* CGGeometry+RSKImageCropper.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "CGGeometry+RSKImageCropper.m"; sourceTree = "<group>"; };
...
...
@@ -274,6 +275,8 @@
D0B5ECD727F2F1B0003EDFE3 /* ServerAPIUtil.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ServerAPIUtil.m; sourceTree = "<group>"; };
D0BB9AA2281626F200DB209E /* ExceptionDefaultView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ExceptionDefaultView.h; sourceTree = "<group>"; };
D0BB9AA3281626F200DB209E /* ExceptionDefaultView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ExceptionDefaultView.m; sourceTree = "<group>"; };
D0BB9AA528164DFB00DB209E /* NickNameController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = NickNameController.h; sourceTree = "<group>"; };
D0BB9AA628164DFB00DB209E /* NickNameController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = NickNameController.m; sourceTree = "<group>"; };
D0BE32E42814D42B006539BE /* HomeRequestModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = HomeRequestModel.h; sourceTree = "<group>"; };
D0BE32E52814D42B006539BE /* HomeRequestModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = HomeRequestModel.m; sourceTree = "<group>"; };
D0BE32E7281551EB006539BE /* ShareAlertView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ShareAlertView.h; sourceTree = "<group>"; };
...
...
@@ -595,14 +598,16 @@
D07A4B26280E9BAA00BA0EC0 /* AccountController.m */,
D07DAC8E2810546A0067A1BF /* DSImagePickerController.h */,
D07DAC8F2810546A0067A1BF /* DSImagePickerController.m */,
D0BB9AA528164DFB00DB209E /* NickNameController.h */,
D0BB9AA628164DFB00DB209E /* NickNameController.m */,
D07A4B2B280EA73B00BA0EC0 /* UserInfoView.h */,
D07A4B2C280EA73B00BA0EC0 /* UserInfoView.m */,
D07A4B28280EA6B600BA0EC0 /* UserInfoTableView.h */,
D07A4B29280EA6B600BA0EC0 /* UserInfoTableView.m */,
D053BEE7280F9E310028CCFC /* CloseAlertView.h */,
D053BEE8280F9E310028CCFC /* CloseAlertView.m */,
D0
7DAC8B281048050067A1BF /* Photo
AlertView.h */,
D0
7DAC8C281048050067A1BF /* Photo
AlertView.m */,
D0
1C9D6528167F9D00163567 /* InfoModify
AlertView.h */,
D0
1C9D6628167F9D00163567 /* InfoModify
AlertView.m */,
);
path = Account;
sourceTree = "<group>";
...
...
@@ -1048,7 +1053,6 @@
D0E65FFB2807A654006562F2 /* NSDictionary+HYBUnicodeReadable.m in Sources */,
D0E65FFA2807A654006562F2 /* NSArray+HYBUnicodeReadable.m in Sources */,
D04B3DC027F6F82D0022F8DF /* ProfileController.m in Sources */,
D07DAC8D281048050067A1BF /* PhotoAlertView.m in Sources */,
D0C50B3027FD1BEB00DC68F0 /* PrivacyView.m in Sources */,
D0B5ECD527F2F0B2003EDFE3 /* AdaptationUtil.m in Sources */,
D0F8090428042A0B0097899F /* SafeSleepCell.m in Sources */,
...
...
@@ -1111,6 +1115,8 @@
D0878F4F280C087E005F1B7F /* LoginController.m in Sources */,
D07A657D28158A1900C15AF6 /* DsWebController.m in Sources */,
D0930F1A2801874B006B497A /* UIViewController+Swizzling.m in Sources */,
D01C9D6728167F9D00163567 /* InfoModifyAlertView.m in Sources */,
D0BB9AA728164DFB00DB209E /* NickNameController.m in Sources */,
D0F808FE280421C20097899F /* ThreeMinuteController.m in Sources */,
D07A4B27280E9BAA00BA0EC0 /* AccountController.m in Sources */,
D01814E8280020F900583D4E /* CWPageControl.m in Sources */,
...
...
DreamSleep/DreamSleep/H5/ExceptionDefaultView.h
查看文件 @
82b6fc5
...
...
@@ -13,6 +13,7 @@ NS_ASSUME_NONNULL_BEGIN
typedef
NS_ENUM
(
NSInteger
,
ExceptionType
)
{
ExceptionTypeNet
};
// 处理事件回调
typedef
void
(
^
DealBlock
)(
void
);
...
...
DreamSleep/DreamSleep/Profile/Account/AccountController.m
查看文件 @
82b6fc5
...
...
@@ -83,7 +83,7 @@
#pragma mark - lazy
-
(
UserInfoView
*
)
userInfoView
{
if
(
!
_userInfoView
)
{
_userInfoView
=
[[
UserInfoView
alloc
]
initWithDelegate
:
self
vc
:
self
];
_userInfoView
=
[[
UserInfoView
alloc
]
initWithDelegate
:
self
];
}
return
_userInfoView
;
}
...
...
DreamSleep/DreamSleep/Profile/Account/InfoModifyAlertView.h
0 → 100644
查看文件 @
82b6fc5
//
// InfoModifyAlertView.h
// DreamSleep
//
// Created by peter on 2022/4/25.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
// 弹框类型
typedef
NS_ENUM
(
NSInteger
,
AlertType
)
{
AlertTypePhoto
=
1
,
// 修改用户头像
AlertTypeGender
=
2
// 性别修改
};
@protocol
InfoModifyAlertViewDelegate
<
NSObject
>
@optional
-
(
void
)
didSelectWithType
:
(
AlertType
)
type
index
:
(
int
)
index
;
@end
/// 拍照、性别修改弹框
@interface
InfoModifyAlertView
:
UIView
@property
(
nonatomic
,
weak
)
id
<
InfoModifyAlertViewDelegate
>
delegate
;
@property
(
nonatomic
,
assign
)
AlertType
type
;
-
(
instancetype
)
initWithDelegate
:(
id
<
InfoModifyAlertViewDelegate
>
)
delegate
type
:(
AlertType
)
type
;
-
(
void
)
showInfoModifyAlertView
;
@end
NS_ASSUME_NONNULL_END
DreamSleep/DreamSleep/Profile/Account/
Photo
AlertView.m
→
DreamSleep/DreamSleep/Profile/Account/
InfoModify
AlertView.m
查看文件 @
82b6fc5
//
//
Photo
AlertView.m
//
InfoModify
AlertView.m
// DreamSleep
//
// Created by peter on 2022/4/2
0
.
// Created by peter on 2022/4/2
5
.
//
#import "
Photo
AlertView.h"
#import "
InfoModify
AlertView.h"
#import <AVFoundation/AVFoundation.h>
@interface
Photo
AlertView
()
@property
(
nonatomic
,
strong
)
UIView
*
phot
oView
;
@interface
InfoModify
AlertView
()
@property
(
nonatomic
,
strong
)
UIView
*
inf
oView
;
@end
@implementation
Photo
AlertView
@implementation
InfoModify
AlertView
-
(
instancetype
)
initWithDelegate
:(
id
<
PhotoAlertViewDelegate
>
)
delegat
e
{
-
(
instancetype
)
initWithDelegate
:(
id
<
InfoModifyAlertViewDelegate
>
)
delegate
type
:(
AlertType
)
typ
e
{
if
(
self
=
[
super
initWithFrame
:[
UIScreen
mainScreen
].
bounds
])
{
_delegate
=
delegate
;
_type
=
type
;
self
.
backgroundColor
=
AlertDarkColor
;
self
.
backgroundColor
=
[
self
.
backgroundColor
colorWithAlphaComponent
:
0
.
6
];
...
...
@@ -24,8 +25,13 @@
UITapGestureRecognizer
*
tapGR
=
[[
UITapGestureRecognizer
alloc
]
initWithTarget
:
self
action
:
@selector
(
tapAction
:
)];
[
self
addGestureRecognizer
:
tapGR
];
[
self
addSubview
:
self
.
photoView
];
[
self
.
photoView
mas_makeConstraints
:
^
(
MASConstraintMaker
*
make
)
{
[
self
addSubview
:
self
.
infoView
];
UIButton
*
btn1
=
[
self
btnWithType
:
type
index
:
1
superView
:
self
.
infoView
];
UIButton
*
btn2
=
[
self
btnWithType
:
type
index
:
2
superView
:
self
.
infoView
];
UIButton
*
dismissBtn
=
[
self
btnWithType
:
type
index
:
3
superView
:
self
];
[
dismissBtn
cornerRadius
:
12
.
0
];
[
self
.
infoView
mas_makeConstraints
:
^
(
MASConstraintMaker
*
make
)
{
make
.
centerX
.
equalTo
(
self
);
make
.
left
.
equalTo
(
self
).
offset
(
15
);
make
.
right
.
equalTo
(
self
).
offset
(
-
15
);
...
...
@@ -33,28 +39,23 @@
make
.
height
.
equalTo
(
@106
);
}];
UIButton
*
photoBtn
=
[
self
btnWithTitle
:
@"拍照"
index
:
1
superView
:
self
.
photoView
];
UIButton
*
albumBtn
=
[
self
btnWithTitle
:
@"从相册中选择"
index
:
2
superView
:
self
.
photoView
];
UIButton
*
dismissBtn
=
[
self
btnWithTitle
:
@"取消"
index
:
3
superView
:
self
];
[
dismissBtn
cornerRadius
:
12
.
0
];
[
photoBtn
mas_makeConstraints
:
^
(
MASConstraintMaker
*
make
)
{
make
.
top
.
equalTo
(
self
.
photoView
);
make
.
centerX
.
equalTo
(
self
.
photoView
);
make
.
left
.
right
.
equalTo
(
self
.
photoView
);
[
btn1
mas_makeConstraints
:
^
(
MASConstraintMaker
*
make
)
{
make
.
top
.
equalTo
(
self
.
infoView
);
make
.
centerX
.
equalTo
(
self
.
infoView
);
make
.
left
.
right
.
equalTo
(
self
.
infoView
);
}];
[
albumBtn
mas_makeConstraints
:
^
(
MASConstraintMaker
*
make
)
{
make
.
centerX
.
equalTo
(
self
.
phot
oView
);
make
.
left
.
right
.
equalTo
(
self
.
phot
oView
);
make
.
size
.
equalTo
(
photoBtn
);
make
.
top
.
equalTo
(
photoBtn
.
mas_bottom
);
make
.
bottom
.
equalTo
(
self
.
phot
oView
);
[
btn2
mas_makeConstraints
:
^
(
MASConstraintMaker
*
make
)
{
make
.
centerX
.
equalTo
(
self
.
inf
oView
);
make
.
left
.
right
.
equalTo
(
self
.
inf
oView
);
make
.
size
.
equalTo
(
btn1
);
make
.
top
.
equalTo
(
btn1
.
mas_bottom
);
make
.
bottom
.
equalTo
(
self
.
inf
oView
);
}];
[
dismissBtn
mas_makeConstraints
:
^
(
MASConstraintMaker
*
make
)
{
make
.
centerX
.
equalTo
(
self
.
phot
oView
);
make
.
left
.
right
.
equalTo
(
photoBtn
);
make
.
size
.
equalTo
(
photoBtn
);
make
.
top
.
equalTo
(
self
.
phot
oView
.
mas_bottom
).
offset
(
20
);
make
.
centerX
.
equalTo
(
self
.
inf
oView
);
make
.
left
.
right
.
equalTo
(
btn1
);
make
.
size
.
equalTo
(
btn1
);
make
.
top
.
equalTo
(
self
.
inf
oView
.
mas_bottom
).
offset
(
20
);
}];
}
return
self
;
...
...
@@ -64,38 +65,50 @@
-
(
void
)
clickAction
:(
UIButton
*
)
sender
{
[
self
dismissPhotoAlertView
];
if
(
sender
.
tag
==
1
)
{
// 拍照
// 相机鉴权
if
([
UIImagePickerController
isSourceTypeAvailable
:
UIImagePickerControllerSourceTypeCamera
])
{
AVAuthorizationStatus
authStatus
=
[
AVCaptureDevice
authorizationStatusForMediaType
:
AVMediaTypeVideo
];
if
(
authStatus
==
AVAuthorizationStatusRestricted
||
authStatus
==
AVAuthorizationStatusDenied
)
{
[
DSProgressHUD
showDetailInfo
:
@"请前往iPhone的“设置-隐私-相机”,允许APP访问您的相机。"
];
return
;
switch
(
self
.
type
)
{
case
AlertTypePhoto
:
if
(
sender
.
tag
==
1
)
{
// 拍照
// 相机鉴权
if
([
UIImagePickerController
isSourceTypeAvailable
:
UIImagePickerControllerSourceTypeCamera
])
{
AVAuthorizationStatus
authStatus
=
[
AVCaptureDevice
authorizationStatusForMediaType
:
AVMediaTypeVideo
];
if
(
authStatus
==
AVAuthorizationStatusRestricted
||
authStatus
==
AVAuthorizationStatusDenied
)
{
[
DSProgressHUD
showDetailInfo
:
@"请前往iPhone的“设置-隐私-相机”,允许APP访问您的相机。"
];
return
;
}
}
else
{
[
DSProgressHUD
showDetailInfo
:
@"您的设备无摄像头!"
];
return
;
}
[
self
didClickInfoModifyAlertView
:
AlertTypePhoto
index
:
1
];
}
else
if
(
sender
.
tag
==
2
)
{
// 从相册中选取
[
self
didClickInfoModifyAlertView
:
AlertTypePhoto
index
:
2
];
}
break
;
case
AlertTypeGender
:
{
if
(
sender
.
tag
!=
3
)
{
[
self
didClickInfoModifyAlertView
:
AlertTypeGender
index
:(
int
)
sender
.
tag
];
}
}
else
{
[
DSProgressHUD
showDetailInfo
:
@"您的设备无摄像头!"
];
return
;
}
[
self
didClickPhotoAlertView
:
1
];
}
else
if
(
sender
.
tag
==
2
)
{
// 从相册中选取
[
self
didClickPhotoAlertView
:
2
];
default:
break
;
}
}
-
(
void
)
didClick
PhotoAlertView
:(
int
)
index
{
if
(
self
.
delegate
&&
[
self
.
delegate
respondsToSelector
:
@selector
(
didSelectWith
I
ndex
:)])
{
[
self
.
delegate
didSelectWith
I
ndex
:
index
];
-
(
void
)
didClick
InfoModifyAlertView
:(
AlertType
)
type
index
:(
int
)
index
{
if
(
self
.
delegate
&&
[
self
.
delegate
respondsToSelector
:
@selector
(
didSelectWith
Type
:
i
ndex
:
)])
{
[
self
.
delegate
didSelectWith
Type
:
type
i
ndex
:
index
];
}
}
-
(
void
)
tapAction
:(
UITapGestureRecognizer
*
)
gesture
{
if
(
!
CGRectContainsPoint
(
self
.
phot
oView
.
frame
,
[
gesture
locationInView
:
self
]))
{
if
(
!
CGRectContainsPoint
(
self
.
inf
oView
.
frame
,
[
gesture
locationInView
:
self
]))
{
[
self
dismissPhotoAlertView
];
}
}
#pragma mark - public
-
(
void
)
show
Photo
AlertView
{
-
(
void
)
show
InfoModify
AlertView
{
[
DSKeyWindow
addSubview
:
self
];
}
...
...
@@ -104,17 +117,23 @@
}
#pragma mark - lazy
-
(
UIView
*
)
phot
oView
{
if
(
!
_
phot
oView
)
{
_
phot
oView
=
[
UIView
new
];
[
_
phot
oView
cornerRadius
:
12
.
0
];
_
phot
oView
.
dk_backgroundColorPicker
=
DKColorPickerWithKey
(
TabBarBG
);
-
(
UIView
*
)
inf
oView
{
if
(
!
_
inf
oView
)
{
_
inf
oView
=
[
UIView
new
];
[
_
inf
oView
cornerRadius
:
12
.
0
];
_
inf
oView
.
dk_backgroundColorPicker
=
DKColorPickerWithKey
(
TabBarBG
);
}
return
_
phot
oView
;
return
_
inf
oView
;
}
#pragma mark - others
-
(
UIButton
*
)
btnWithTitle
:
(
NSString
*
)
title
index
:
(
int
)
index
superView
:
(
UIView
*
)
sv
{
-
(
UIButton
*
)
btnWithType
:
(
AlertType
)
type
index
:
(
int
)
index
superView
:
(
UIView
*
)
sv
{
NSString
*
title
=
@"取消"
;
if
(
index
==
1
)
{
title
=
type
==
AlertTypePhoto
?
@"拍照"
:
@"男"
;
}
else
if
(
index
==
2
)
{
title
=
type
==
AlertTypePhoto
?
@"从相册中选择"
:
@"女"
;
}
UIButton
*
btn
=
[
UIButton
dkBtnTitle
:
title
font
:
BoldFont
(
15
)];
btn
.
dk_backgroundColorPicker
=
DKColorPickerWithKey
(
TabBarBG
);
btn
.
tag
=
index
;
...
...
DreamSleep/DreamSleep/Profile/Account/NickNameController.h
0 → 100644
查看文件 @
82b6fc5
//
// NickNameController.h
// DreamSleep
//
// Created by peter on 2022/4/25.
//
#import <UIKit/UIKit.h>
#import "UserRequestModel.h"
NS_ASSUME_NONNULL_BEGIN
typedef
void
(
^
SaveBlock
)(
void
);
/// 修改昵称页面
@interface
NickNameController
:
UIViewController
@property
(
nonatomic
,
copy
)
SaveBlock
block
;
-
(
instancetype
)
initWithBlock
:(
SaveBlock
)
block
;
@end
NS_ASSUME_NONNULL_END
DreamSleep/DreamSleep/Profile/Account/NickNameController.m
0 → 100644
查看文件 @
82b6fc5
//
// NickNameController.m
// DreamSleep
//
// Created by peter on 2022/4/25.
//
#import "NickNameController.h"
@interface
NickNameController
()
@property
(
nonatomic
,
strong
)
UIView
*
mainView
;
@property
(
nonatomic
,
strong
)
UIImageView
*
portraitIV
;
@property
(
nonatomic
,
strong
)
UIImageView
*
cameraIV
;
@property
(
nonatomic
,
strong
)
UITextField
*
nickTF
;
@property
(
nonatomic
,
strong
)
UIButton
*
saveBtn
;
@end
@implementation
NickNameController
-
(
instancetype
)
initWithBlock
:(
SaveBlock
)
block
{
if
(
self
=
[
super
init
])
{
_block
=
block
;
}
return
self
;
}
-
(
void
)
viewDidLoad
{
[
super
viewDidLoad
];
self
.
navigationItem
.
title
=
@"修改昵称"
;
self
.
view
.
dk_backgroundColorPicker
=
DKColorPickerWithKey
(
VCViewBG
);
[
self
.
view
addSubview
:
self
.
mainView
];
[
self
.
mainView
addSubview
:
self
.
portraitIV
];
[
self
.
mainView
addSubview
:
self
.
cameraIV
];
[
self
.
mainView
addSubview
:
self
.
nickTF
];
[
self
.
mainView
addSubview
:
self
.
saveBtn
];
[
self
.
mainView
mas_makeConstraints
:
^
(
MASConstraintMaker
*
make
)
{
make
.
left
.
right
.
equalTo
(
self
.
view
);
make
.
top
.
equalTo
(
self
.
view
).
offset
(
83
);
}];
[
self
.
portraitIV
mas_makeConstraints
:
^
(
MASConstraintMaker
*
make
)
{
make
.
size
.
mas_equalTo
(
CGSizeMake
(
145
,
145
));
make
.
top
.
equalTo
(
self
.
mainView
);
make
.
centerX
.
equalTo
(
self
.
mainView
);
}];
[
self
.
cameraIV
mas_makeConstraints
:
^
(
MASConstraintMaker
*
make
)
{
make
.
right
.
equalTo
(
self
.
portraitIV
).
offset
(
-
6
);
make
.
bottom
.
equalTo
(
self
.
portraitIV
).
offset
(
-
6
);
}];
[
self
.
nickTF
mas_makeConstraints
:
^
(
MASConstraintMaker
*
make
)
{
make
.
centerX
.
equalTo
(
self
.
mainView
);
make
.
top
.
equalTo
(
self
.
portraitIV
.
mas_bottom
).
offset
(
60
);
make
.
size
.
mas_equalTo
(
CGSizeMake
(
155
,
40
));
}];
[
self
.
saveBtn
mas_makeConstraints
:
^
(
MASConstraintMaker
*
make
)
{
make
.
centerX
.
equalTo
(
self
.
mainView
);
make
.
size
.
equalTo
(
self
.
nickTF
);
make
.
top
.
equalTo
(
self
.
nickTF
.
mas_bottom
).
offset
(
15
);
make
.
bottom
.
equalTo
(
self
.
mainView
);
}];
}
-
(
void
)
touchesBegan
:
(
NSSet
<
UITouch
*>
*
)
touches
withEvent
:
(
UIEvent
*
)
event
{
[
self
.
view
endEditing
:
YES
];
}
#pragma mark - Actions
-
(
void
)
saveAction
{
[
DSProgressHUD
showProgressHUDWithInfo
:
@""
];
NSDictionary
*
data
=
@{
@"nick_name"
:
self
.
nickTF
.
text
};
WS
(
weakSelf
);
[
UserRequestModel
updateUserInfoWithData
:
data
completion
:
^
(
UserRequestModel
*
_Nonnull
requestModel
)
{
[
DSProgressHUD
dissmissProgressHUD
];
if
(
requestModel
.
resCode
==
DSResCodeSuccess
)
{
[
DSProgressHUD
showToast
:
@"修改成功"
];
[
LoginUtils
updateUserInfo
:
data
];
if
(
weakSelf
.
block
)
{
weakSelf
.
block
();
}
[
weakSelf
.
navigationController
popViewControllerAnimated
:
YES
];
}
}];
}
#pragma mark - lazy
-
(
UIView
*
)
mainView
{
if
(
!
_mainView
)
{
_mainView
=
[
UIView
new
];
}
return
_mainView
;
}
-
(
UIImageView
*
)
portraitIV
{
if
(
!
_portraitIV
)
{
_portraitIV
=
[
UIImageView
new
];
[
_portraitIV
yy_setImageWithURL
:[
NSURL
URLWithString
:[
LoginUtils
getFaceImg
]]
placeholder
:[
UIImage
imageNamed
:
@"portrait"
]];
[
_portraitIV
cornerRadius
:
145
/
2
.
0
];
}
return
_portraitIV
;
}
-
(
UIImageView
*
)
cameraIV
{
if
(
!
_cameraIV
)
{
_cameraIV
=
[[
UIImageView
alloc
]
initWithImage
:[
UIImage
imageNamed
:
@"cameraIcon"
]];
}
return
_cameraIV
;
}
-
(
UITextField
*
)
nickTF
{
if
(
!
_nickTF
)
{
_nickTF
=
[
UITextField
new
];
_nickTF
.
font
=
BoldFont
(
16
);
_nickTF
.
dk_textColorPicker
=
DKColorPickerWithKey
(
TEXT
);
UserModel
*
model
=
[
LoginUtils
getUserLoginData
];
_nickTF
.
text
=
model
.
nick_name
;
_nickTF
.
dk_backgroundColorPicker
=
DKColorPickerWithColors
(
DSWhite
,
CornerViewDarkColor
,
DSWhite
);
_nickTF
.
textAlignment
=
NSTextAlignmentCenter
;
[
_nickTF
cornerRadius
:
20
];
}
return
_nickTF
;
}
-
(
UIButton
*
)
saveBtn
{
if
(
!
_saveBtn
)
{
_saveBtn
=
[
UIButton
btnWithTitle
:
@"保存"
titleColor
:
DSWhite
font
:
BoldFont
(
16
)
bgColor
:
BrandColor
];
[
_saveBtn
addTarget
:
self
action
:
@selector
(
saveAction
)
forControlEvents
:
UIControlEventTouchUpInside
];
[
_saveBtn
cornerRadius
:
20
];
}
return
_saveBtn
;
}
@end
DreamSleep/DreamSleep/Profile/Account/PhotoAlertView.h
deleted
100644 → 0
查看文件 @
6b15024
//
// PhotoAlertView.h
// DreamSleep
//
// Created by peter on 2022/4/20.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@protocol
PhotoAlertViewDelegate
<
NSObject
>
@optional
/// 点击拍照或者相册
/// @param index 1:拍照,2:相册
-
(
void
)
didSelectWithIndex
:
(
int
)
index
;
@end
/// 拍照、相册弹框
@interface
PhotoAlertView
:
UIView
@property
(
nonatomic
,
weak
)
id
<
PhotoAlertViewDelegate
>
delegate
;
-
(
instancetype
)
initWithDelegate
:(
id
<
PhotoAlertViewDelegate
>
)
delegate
;
-
(
void
)
showPhotoAlertView
;
@end
NS_ASSUME_NONNULL_END
DreamSleep/DreamSleep/Profile/Account/UserInfoTableView.h
查看文件 @
82b6fc5
...
...
@@ -9,17 +9,9 @@
NS_ASSUME_NONNULL_BEGIN
@protocol
UserInfoTableViewDelegate
<
NSObject
>
-
(
void
)
didSelectRowAtIndexPath
:
(
NSIndexPath
*
)
indexPath
;
@end
/// 昵称、性别、生日用户数据修改view
@interface
UserInfoTableView
:
UITableView
@property
(
nonatomic
,
weak
)
id
<
UserInfoTableViewDelegate
>
setDelegate
;
-
(
instancetype
)
initWithFrame
:(
CGRect
)
frame
delegate
:(
id
<
UserInfoTableViewDelegate
>
)
delegate
;
@end
NS_ASSUME_NONNULL_END
DreamSleep/DreamSleep/Profile/Account/UserInfoTableView.m
查看文件 @
82b6fc5
...
...
@@ -6,6 +6,8 @@
//
#import "UserInfoTableView.h"
#import "NickNameController.h"
#import "InfoModifyAlertView.h"
/// 自定义用户信息显示数据model
@interface
UserShowModel
:
NSObject
...
...
@@ -88,22 +90,19 @@
@end
@interface
UserInfoTableView
()
<
UITableViewDelegate
>
@interface
UserInfoTableView
()
<
UITableViewDelegate
,
InfoModifyAlertViewDelegate
>
@property
(
nonatomic
,
strong
)
DSDataSource
*
infoDataSource
;
@property
(
nonatomic
,
strong
)
NSArray
*
dataArr
;
@end
@implementation
UserInfoTableView
-
(
instancetype
)
initWithFrame
:(
CGRect
)
frame
delegate
:(
id
<
UserInfoTableViewDelegate
>
)
delegate
{
if
(
self
=
[
super
initWithFrame
:
frame
style
:
UITableViewStylePlain
])
{
self
.
dataArr
=
[
UserShowModel
getUserShowDatas
];
self
.
setDelegate
=
delegate
;
-
(
instancetype
)
initWithFrame
:(
CGRect
)
frame
style
:(
UITableViewStyle
)
style
{
if
(
self
=
[
super
initWithFrame
:
frame
style
:
style
])
{
[
self
cornerRadius
:
10
];
self
.
scrollEnabled
=
NO
;
self
.
dk_backgroundColorPicker
=
DKColorPickerWithColors
(
DSWhite
,
CornerViewDarkColor
,
DSWhite
);
self
.
separatorStyle
=
UITableViewCellSeparatorStyleNone
;
[
self
.
infoDataSource
addDataArray
:
self
.
dataArr
];
[
self
.
infoDataSource
addDataArray
:
[
UserShowModel
getUserShowDatas
]
];
}
return
self
;
}
...
...
@@ -128,7 +127,35 @@
}
-
(
void
)
tableView
:
(
UITableView
*
)
tableView
didSelectRowAtIndexPath
:
(
NSIndexPath
*
)
indexPath
{
DSLog
(
@"indexPath:%ld"
,
indexPath
.
row
);
if
(
indexPath
.
row
==
0
)
{
// 修改昵称
WS
(
weakSelf
);
NickNameController
*
nickVC
=
[[
NickNameController
alloc
]
initWithBlock
:
^
{
[
weakSelf
.
infoDataSource
addDataArray
:[
UserShowModel
getUserShowDatas
]];
[
weakSelf
reloadData
];
}];
[
self
.
ds_viewController
.
navigationController
pushViewController
:
nickVC
animated
:
YES
];
}
else
if
(
indexPath
.
row
==
1
)
{
// 修改性别
InfoModifyAlertView
*
genderView
=
[[
InfoModifyAlertView
alloc
]
initWithDelegate
:
self
type
:
AlertTypeGender
];
[
genderView
showInfoModifyAlertView
];
}
else
if
(
indexPath
.
row
==
2
)
{
// 修改生日
}
}
#pragma mark - InfoModifyAlertViewDelegate
-
(
void
)
didSelectWithType
:
(
AlertType
)
type
index
:
(
int
)
index
{
[
DSProgressHUD
showProgressHUDWithInfo
:
@""
];
NSDictionary
*
data
=
@{
@"gender"
:
@
(
index
==
1
?
1
:
0
)};
WS
(
weakSelf
);
[
UserRequestModel
updateUserInfoWithData
:
data
completion
:
^
(
UserRequestModel
*
_Nonnull
requestModel
)
{
[
DSProgressHUD
dissmissProgressHUD
];
if
(
requestModel
.
resCode
==
DSResCodeSuccess
)
{
[
DSProgressHUD
showToast
:
@"修改成功"
];
[
LoginUtils
updateUserInfo
:
data
];
[
weakSelf
.
infoDataSource
addDataArray
:[
UserShowModel
getUserShowDatas
]];
[
weakSelf
reloadData
];
}
}];
}
@end
DreamSleep/DreamSleep/Profile/Account/UserInfoView.h
查看文件 @
82b6fc5
...
...
@@ -18,7 +18,7 @@ NS_ASSUME_NONNULL_BEGIN
@property
(
nonatomic
,
weak
)
id
<
UserInfoViewDelegate
>
delegate
;
-
(
instancetype
)
initWithDelegate
:(
id
<
UserInfoViewDelegate
>
)
delegate
vc
:(
UIViewController
*
)
vc
;
-
(
instancetype
)
initWithDelegate
:(
id
<
UserInfoViewDelegate
>
)
delegate
;
@end
...
...
DreamSleep/DreamSleep/Profile/Account/UserInfoView.m
查看文件 @
82b6fc5
...
...
@@ -6,26 +6,26 @@
//
#import "UserInfoView.h"
#import "
Photo
AlertView.h"
#import "
InfoModify
AlertView.h"
#import "UserInfoTableView.h"
#import "DSImagePickerController.h"
#import "RSKImageCropper.h"
#import "UserRequestModel.h"
@interface
UserInfoView
()
<
PhotoAlertViewDelegate
,
UserInfoTable
ViewDelegate
,
DSImagePickerControllerDelegate
,
RSKImageCropViewControllerDelegate
>
@interface
UserInfoView
()
<
InfoModifyAlert
ViewDelegate
,
DSImagePickerControllerDelegate
,
RSKImageCropViewControllerDelegate
>
@property
(
nonatomic
,
strong
)
UIButton
*
portraitBtn
;
@property
(
nonatomic
,
strong
)
Photo
AlertView
*
photoAlertView
;
@property
(
nonatomic
,
strong
)
InfoModify
AlertView
*
photoAlertView
;
@property
(
nonatomic
,
strong
)
UserInfoTableView
*
userInfoTV
;
@property
(
nonatomic
,
strong
)
UIButton
*
layoutBtn
;
@end
@implementation
UserInfoView
-
(
instancetype
)
initWithDelegate
:(
id
<
UserInfoViewDelegate
>
)
delegate
vc
:(
UIViewController
*
)
vc
{
-
(
instancetype
)
initWithDelegate
:(
id
<
UserInfoViewDelegate
>
)
delegate
{
if
(
self
=
[
super
initWithFrame
:
CGRectMake
(
0
,
0
,
kScreenWidth
,
kScreenHeight
-
kTopHeight
(
0
))])
{
_delegate
=
delegate
;
[
self
.
portraitBtn
yy_setImageWithURL
:[
NSURL
URLWithString
:[
LoginUtils
getFaceImg
]]
forState
:
UIControlStateNormal
placeholder
:
[
UIImage
imageNamed
:
@"
basicPlaceholder
"
]];
[
self
.
portraitBtn
yy_setImageWithURL
:[
NSURL
URLWithString
:[
LoginUtils
getFaceImg
]]
forState
:
UIControlStateNormal
placeholder
:
[
UIImage
imageNamed
:
@"
portrait
"
]];
[
self
addSubview
:
self
.
userInfoTV
];
[
self
addSubview
:
self
.
layoutBtn
];
...
...
@@ -42,7 +42,7 @@
#pragma mark - Actions
-
(
void
)
updatePortraitAction
{
[
self
.
photoAlertView
show
Photo
AlertView
];
[
self
.
photoAlertView
show
InfoModify
AlertView
];
}
-
(
void
)
layoutAction
{
...
...
@@ -51,8 +51,8 @@
}
}
#pragma mark -
Photo
AlertViewDelegate
-
(
void
)
didSelectWith
I
ndex
:
(
int
)
index
{
#pragma mark -
InfoModify
AlertViewDelegate
-
(
void
)
didSelectWith
Type
:
(
AlertType
)
type
i
ndex
:
(
int
)
index
{
ImagePickerStyle
style
=
index
==
1
?
ImagePickerStyleCamera
:
ImagePickerStylePhotoLibrary
;
DSImagePickerController
*
imagePicker
=
[[
DSImagePickerController
alloc
]
initWithImagePickerStyle
:
style
delegate
:
self
];
[
self
.
ds_viewController
presentViewController
:
imagePicker
animated
:
YES
completion
:
nil
];
...
...
@@ -83,11 +83,6 @@
}];
}
#pragma mark - UserInfoTableViewDelegate
-
(
void
)
didSelectRowAtIndexPath
:
(
NSIndexPath
*
)
indexPath
{
}
#pragma mark - lazy
-
(
UIButton
*
)
portraitBtn
{
if
(
!
_portraitBtn
)
{
...
...
@@ -111,16 +106,16 @@
return
_portraitBtn
;
}
-
(
Photo
AlertView
*
)
photoAlertView
{
-
(
InfoModify
AlertView
*
)
photoAlertView
{
if
(
!
_photoAlertView
)
{
_photoAlertView
=
[[
PhotoAlertView
alloc
]
initWithDelegate
:
self
];
_photoAlertView
=
[[
InfoModifyAlertView
alloc
]
initWithDelegate
:
self
type
:
AlertTypePhoto
];
}
return
_photoAlertView
;
}
-
(
UserInfoTableView
*
)
userInfoTV
{
if
(
!
_userInfoTV
)
{
_userInfoTV
=
[[
UserInfoTableView
alloc
]
initWithFrame
:
CGRectMake
(
15
,
CGRectGetMaxY
(
self
.
portraitBtn
.
frame
)
+
60
,
kScreenWidth
-
30
,
150
)
delegate
:
self
];
_userInfoTV
=
[[
UserInfoTableView
alloc
]
initWithFrame
:
CGRectMake
(
15
,
CGRectGetMaxY
(
self
.
portraitBtn
.
frame
)
+
60
,
kScreenWidth
-
30
,
150
)
style
:
UITableViewStylePlain
];
}
return
_userInfoTV
;
}
...
...
DreamSleep/DreamSleep/Profile/Me/ProfileController.m
查看文件 @
82b6fc5
...
...
@@ -141,10 +141,10 @@
-
(
void
)
updateUserView
{
UserModel
*
model
=
[
LoginUtils
getUserLoginData
];
if
(
model
)
{
[
self
.
headIV
yy_setImageWithURL
:[
NSURL
URLWithString
:
model
.
face_img
]
placeholder
:[
UIImage
imageNamed
:
@"
basicPlaceholder
"
]];
[
self
.
headIV
yy_setImageWithURL
:[
NSURL
URLWithString
:
model
.
face_img
]
placeholder
:[
UIImage
imageNamed
:
@"
portrait
"
]];
self
.
nickLab
.
text
=
model
.
nick_name
;
}
else
{
self
.
headIV
.
image
=
[
UIImage
imageNamed
:
@"
basicPlaceholder
"
];
self
.
headIV
.
image
=
[
UIImage
imageNamed
:
@"
portrait
"
];
self
.
nickLab
.
text
=
@""
;
}
}
...
...
@@ -157,6 +157,7 @@
_headIV
=
[[
UIImageView
alloc
]
initWithFrame
:
CGRectMake
(
10
,
10
,
60
,
60
)];
_headIV
.
centerY
=
_userInfoView
.
centerY
;
[
_headIV
cornerRadius
:
30
];
_headIV
.
dk_alphaPicker
=
DKAlphaPickerWithAlphas
(
1
.
0
,
.
5
,
.
5
);
[
_userInfoView
addSubview
:
_headIV
];
_nickLab
=
[
UILabel
dkLabWithFont
:
BoldFont
(
15
)];
...
...
DreamSleep/DreamSleep/Profile/UserLogin/LoginUtils.h
查看文件 @
82b6fc5
...
...
@@ -37,6 +37,10 @@ NS_ASSUME_NONNULL_BEGIN
/// @param face_img face_img
+
(
void
)
updateFaceImg
:(
NSString
*
)
face_img
;
/// 更新用户数据
/// @param infos @{key, value}
+
(
void
)
updateUserInfo
:(
NSDictionary
*
)
infos
;
/// 保存用户登录数据
+
(
void
)
saveUserLoginData
:(
UserModel
*
)
model
;
...
...
DreamSleep/DreamSleep/Profile/UserLogin/LoginUtils.m
查看文件 @
82b6fc5
...
...
@@ -48,6 +48,20 @@
[
self
saveUserLoginData
:
userModel
];
}
+
(
void
)
updateUserInfo
:
(
NSDictionary
*
)
infos
{
NSString
*
key
=
[
infos
allKeys
][
0
];
id
value
=
infos
[
key
];
UserModel
*
userModel
=
[
self
getUserLoginData
];
if
([
key
isEqualToString
:
@"nick_name"
])
{
userModel
.
nick_name
=
value
;
}
else
if
([
key
isEqualToString
:
@"gender"
])
{
userModel
.
gender
=
[
value
boolValue
];
}
else
if
([
key
isEqualToString
:
@"birthday"
])
{
userModel
.
birthday
=
value
;
}
[
self
saveUserLoginData
:
userModel
];
}
+
(
void
)
saveUserLoginData
:
(
UserModel
*
)
model
{
NSData
*
userData
=
[
NSKeyedArchiver
archivedDataWithRootObject
:
model
];
kSetUserDefaultsObj
(
userData
,
UserBasicInfo
);
...
...
DreamSleep/DreamSleep/Profile/UserLogin/UserRequestModel.h
查看文件 @
82b6fc5
...
...
@@ -42,6 +42,11 @@ NS_ASSUME_NONNULL_BEGIN
/// @param completion completion
+
(
NSURLSessionDataTask
*
)
updateFaceImgRequest
:(
UIImage
*
)
faceImg
completion
:(
void
(
^
)(
UserRequestModel
*
requestModel
))
completion
;
/// 用户更新信息接口
/// @param data @{key, value}:nick_name,gender,birthday
/// @param completion completion
+
(
NSURLSessionDataTask
*
)
updateUserInfoWithData
:(
NSDictionary
*
)
data
completion
:(
void
(
^
)(
UserRequestModel
*
requestModel
))
completion
;
@end
NS_ASSUME_NONNULL_END
DreamSleep/DreamSleep/Profile/UserLogin/UserRequestModel.m
查看文件 @
82b6fc5
...
...
@@ -123,14 +123,19 @@
}];
}
// 修改用户信息
+
(
NSURLSessionDataTask
*
)
updateUserInfoWithCompletion
:(
void
(
^
)(
UserRequestModel
*
requestModel
))
completion
{
+
(
NSURLSessionDataTask
*
)
updateUserInfoWithData
:(
NSDictionary
*
)
data
completion
:(
void
(
^
)(
UserRequestModel
*
requestModel
))
completion
{
UserRequestModel
*
requestModel
=
[[
UserRequestModel
alloc
]
init
];
NSString
*
api
=
@"update_user"
;
NSString
*
argStr
=
[
NSString
stringWithFormat
:
@"mutation{%@(gender:%d,nick_name:
\"
%@
\"
)}"
,
api
,
1
,
@"ggg"
];
return
[
self
httpPostBodyRequestWithParam
:@{
@"query"
:
argStr
}
view
:
nil
hasNetActivity
:
YES
loadingInfo
:
nil
hasFailInfo
:
YES
success
:^
(
id
_Nonnull
responseObj
)
{
DSLog
(
@"修改用户接口dataDic:%@"
,
responseObj
);
NSString
*
key
=
[
data
allKeys
][
0
];
id
value
=
data
[
key
];
NSString
*
argStr
=
@""
;
if
([
key
isEqualToString
:
@"gender"
])
{
argStr
=
[
NSString
stringWithFormat
:
@"mutation{%@(%@:%d)}"
,
api
,
key
,
[
value
intValue
]];
}
else
{
argStr
=
[
NSString
stringWithFormat
:
@"mutation{%@(%@:
\"
%@
\"
)}"
,
api
,
key
,
value
];
}
return
[
self
httpPostBodyRequestWithAPI
:
api
params
:@{
@"query"
:
argStr
}
view
:
nil
hasNetActivity
:
YES
loadingInfo
:
nil
hasFailInfo
:
YES
success
:^
(
NSDictionary
*
_Nonnull
apiDic
)
{
DSLog
(
@"修改用户接口dataDic:%@"
,
apiDic
);
requestModel
.
resCode
=
DSResCodeSuccess
;
completion
(
requestModel
);
}
failure
:^
(
id
_Nonnull
failureInfo
)
{
...
...
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论