diff --git a/xplan-ios.xcodeproj/project.pbxproj b/xplan-ios.xcodeproj/project.pbxproj index 346156be..f55fb558 100644 --- a/xplan-ios.xcodeproj/project.pbxproj +++ b/xplan-ios.xcodeproj/project.pbxproj @@ -161,6 +161,10 @@ E8B825CD26EA18C8009E8E9F /* ThemeColor.m in Sources */ = {isa = PBXBuildFile; fileRef = E8B825CC26EA18C8009E8E9F /* ThemeColor.m */; }; E8B825D026EA3825009E8E9F /* LoginPasswordViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = E8B825CF26EA3825009E8E9F /* LoginPasswordViewController.m */; }; E8B846BC26FD7C1200A777FE /* UploadImage.m in Sources */ = {isa = PBXBuildFile; fileRef = E8B846BB26FD7C1200A777FE /* UploadImage.m */; }; + E8B846BF26FD827900A777FE /* XPMineUserInfoAlbumViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = E8B846BE26FD827900A777FE /* XPMineUserInfoAlbumViewController.m */; }; + E8B846C226FD82DC00A777FE /* XPMineUserInfoAlbumCollectionViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = E8B846C126FD82DC00A777FE /* XPMineUserInfoAlbumCollectionViewCell.m */; }; + E8B846C526FDB41A00A777FE /* XPMineUserInfolbumPresenter.m in Sources */ = {isa = PBXBuildFile; fileRef = E8B846C426FDB41A00A777FE /* XPMineUserInfolbumPresenter.m */; }; + E8B846C726FDB45000A777FE /* XPMineUserInfoAlbumProtocol.h in Sources */ = {isa = PBXBuildFile; fileRef = E8B846C626FDB44100A777FE /* XPMineUserInfoAlbumProtocol.h */; }; E8CEA03D26EA3DE500644B44 /* LoginPasswordPresent.m in Sources */ = {isa = PBXBuildFile; fileRef = E8CEA03C26EA3DE500644B44 /* LoginPasswordPresent.m */; }; E8E70D7726F2F15100F03460 /* XPMineViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = E8E70D7626F2F15100F03460 /* XPMineViewController.m */; }; E8E70D7A26F2F16600F03460 /* XPMinePresent.m in Sources */ = {isa = PBXBuildFile; fileRef = E8E70D7926F2F16600F03460 /* XPMinePresent.m */; }; @@ -480,6 +484,13 @@ E8B825CF26EA3825009E8E9F /* LoginPasswordViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = LoginPasswordViewController.m; sourceTree = ""; }; E8B846BA26FD7C1200A777FE /* UploadImage.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = UploadImage.h; sourceTree = ""; }; E8B846BB26FD7C1200A777FE /* UploadImage.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = UploadImage.m; sourceTree = ""; }; + E8B846BD26FD827900A777FE /* XPMineUserInfoAlbumViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPMineUserInfoAlbumViewController.h; sourceTree = ""; }; + E8B846BE26FD827900A777FE /* XPMineUserInfoAlbumViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPMineUserInfoAlbumViewController.m; sourceTree = ""; }; + E8B846C026FD82DC00A777FE /* XPMineUserInfoAlbumCollectionViewCell.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPMineUserInfoAlbumCollectionViewCell.h; sourceTree = ""; }; + E8B846C126FD82DC00A777FE /* XPMineUserInfoAlbumCollectionViewCell.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPMineUserInfoAlbumCollectionViewCell.m; sourceTree = ""; }; + E8B846C326FDB41A00A777FE /* XPMineUserInfolbumPresenter.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPMineUserInfolbumPresenter.h; sourceTree = ""; }; + E8B846C426FDB41A00A777FE /* XPMineUserInfolbumPresenter.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPMineUserInfolbumPresenter.m; sourceTree = ""; }; + E8B846C626FDB44100A777FE /* XPMineUserInfoAlbumProtocol.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPMineUserInfoAlbumProtocol.h; sourceTree = ""; }; E8CEA03B26EA3DE500644B44 /* LoginPasswordPresent.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = LoginPasswordPresent.h; sourceTree = ""; }; E8CEA03C26EA3DE500644B44 /* LoginPasswordPresent.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = LoginPasswordPresent.m; sourceTree = ""; }; E8CEA03E26EA3E0200644B44 /* LoginPasswordProtocol.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = LoginPasswordProtocol.h; sourceTree = ""; }; @@ -1169,6 +1180,8 @@ E8EEB91326FC7786007C6EBA /* XPMineUserInfoNickViewController.m */, E8EEB91526FC7B35007C6EBA /* XPMineUserInfoDesViewController.h */, E8EEB91626FC7B35007C6EBA /* XPMineUserInfoDesViewController.m */, + E8B846BD26FD827900A777FE /* XPMineUserInfoAlbumViewController.h */, + E8B846BE26FD827900A777FE /* XPMineUserInfoAlbumViewController.m */, ); path = MineInfo; sourceTree = ""; @@ -1307,6 +1320,8 @@ E8EEB90026FC31B6007C6EBA /* XPMineUserInfoPresenter.m */, E8EEB90D26FC6AB8007C6EBA /* XPMineUserInfoEditPresenter.h */, E8EEB90E26FC6AB8007C6EBA /* XPMineUserInfoEditPresenter.m */, + E8B846C326FDB41A00A777FE /* XPMineUserInfolbumPresenter.h */, + E8B846C426FDB41A00A777FE /* XPMineUserInfolbumPresenter.m */, ); path = Presenter; sourceTree = ""; @@ -1326,6 +1341,7 @@ E88B5CB926FB327500DA9178 /* XPMineTeenagerPwdProtocol.h */, E8EEB90226FC31CE007C6EBA /* XPMineUserInfoProtocol.h */, E8EEB91026FC6AD3007C6EBA /* XPMineUserInfoEditProtocol.h */, + E8B846C626FDB44100A777FE /* XPMineUserInfoAlbumProtocol.h */, ); path = Protocol; sourceTree = ""; @@ -1390,6 +1406,8 @@ E8EEB8FD26FC2DF8007C6EBA /* XPMineUserInfoCustomNavView.m */, E8EEB90726FC579A007C6EBA /* XPMineUserInfoEditTableViewCell.h */, E8EEB90826FC579A007C6EBA /* XPMineUserInfoEditTableViewCell.m */, + E8B846C026FD82DC00A777FE /* XPMineUserInfoAlbumCollectionViewCell.h */, + E8B846C126FD82DC00A777FE /* XPMineUserInfoAlbumCollectionViewCell.m */, ); path = MineInfo; sourceTree = ""; @@ -1527,6 +1545,7 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + E8B846C726FDB45000A777FE /* XPMineUserInfoAlbumProtocol.h in Sources */, E8EEB91126FC6AE2007C6EBA /* XPMineUserInfoEditProtocol.h in Sources */, E8EEB90326FC31DC007C6EBA /* XPMineUserInfoProtocol.h in Sources */, E88B5CBA26FB329C00DA9178 /* XPMineTeenagerPwdProtocol.h in Sources */, @@ -1537,6 +1556,7 @@ E824544826F5945300BE8163 /* XPMinePayPwdProtocol.h in Sources */, E824543A26F5880E00BE8163 /* XPLoginVerifBindPhoneProtocol.h in Sources */, E824543826F5820A00BE8163 /* XPLoginVerifBindPhonePresenter.m in Sources */, + E8B846BF26FD827900A777FE /* XPMineUserInfoAlbumViewController.m in Sources */, E824545C26F5EEBA00BE8163 /* XPMineVerifIdentityPresenter.m in Sources */, E8AC723726F49982007D6E91 /* XPMineNotificaProtocol.h in Sources */, E8AC723226F49710007D6E91 /* XPMineNotificationTableViewCell.m in Sources */, @@ -1598,6 +1618,7 @@ E824544626F5934700BE8163 /* XPMinePayPwdPresenter.m in Sources */, 186A536A26FC6F2E00D67B2C /* XCShareItem.m in Sources */, 189DD54B26DE338800AB55B1 /* BaseViewController.m in Sources */, + E8B846C226FD82DC00A777FE /* XPMineUserInfoAlbumCollectionViewCell.m in Sources */, E8EEB91726FC7B35007C6EBA /* XPMineUserInfoDesViewController.m in Sources */, E8E70D8626F2F55C00F03460 /* XPMineAccountView.m in Sources */, E81C279026EB314D0031E639 /* LoginForgetEditView.m in Sources */, @@ -1648,6 +1669,7 @@ E8B825BF26E9E57D009E8E9F /* LoginTicketInfo.m in Sources */, 187EEEF026E89FE8002833B2 /* AccountInfoStorage.m in Sources */, 186A536B26FC6F2E00D67B2C /* XCShareItemCell.m in Sources */, + E8B846C526FDB41A00A777FE /* XPMineUserInfolbumPresenter.m in Sources */, E872309326E8D31500B90D4F /* LoginVerifCodeView.m in Sources */, 186A534626FC6ED900D67B2C /* TTPopup.m in Sources */, E81C278C26EAFAF60031E639 /* Base64.m in Sources */, diff --git a/xplan-ios/Assets.xcassets/Mine/mine_user_info_album_add.imageset/Contents.json b/xplan-ios/Assets.xcassets/Mine/mine_user_info_album_add.imageset/Contents.json new file mode 100644 index 00000000..e0c2a92e --- /dev/null +++ b/xplan-ios/Assets.xcassets/Mine/mine_user_info_album_add.imageset/Contents.json @@ -0,0 +1,22 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "filename" : "mine_user_info_album_add@2x.png", + "idiom" : "universal", + "scale" : "2x" + }, + { + "filename" : "mine_user_info_album_add@3x.png", + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/xplan-ios/Assets.xcassets/Mine/mine_user_info_album_add.imageset/mine_user_info_album_add@2x.png b/xplan-ios/Assets.xcassets/Mine/mine_user_info_album_add.imageset/mine_user_info_album_add@2x.png new file mode 100644 index 00000000..bb379184 Binary files /dev/null and b/xplan-ios/Assets.xcassets/Mine/mine_user_info_album_add.imageset/mine_user_info_album_add@2x.png differ diff --git a/xplan-ios/Assets.xcassets/Mine/mine_user_info_album_add.imageset/mine_user_info_album_add@3x.png b/xplan-ios/Assets.xcassets/Mine/mine_user_info_album_add.imageset/mine_user_info_album_add@3x.png new file mode 100644 index 00000000..59df2c39 Binary files /dev/null and b/xplan-ios/Assets.xcassets/Mine/mine_user_info_album_add.imageset/mine_user_info_album_add@3x.png differ diff --git a/xplan-ios/Assets.xcassets/Mine/mine_user_info_edit_photo_delete.imageset/Contents.json b/xplan-ios/Assets.xcassets/Mine/mine_user_info_edit_photo_delete.imageset/Contents.json new file mode 100644 index 00000000..d2440f23 --- /dev/null +++ b/xplan-ios/Assets.xcassets/Mine/mine_user_info_edit_photo_delete.imageset/Contents.json @@ -0,0 +1,22 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "filename" : "mine_user_info_edit_photo_delete@2x.png", + "idiom" : "universal", + "scale" : "2x" + }, + { + "filename" : "mine_user_info_edit_photo_delete@3x.png", + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/xplan-ios/Assets.xcassets/Mine/mine_user_info_edit_photo_delete.imageset/mine_user_info_edit_photo_delete@2x.png b/xplan-ios/Assets.xcassets/Mine/mine_user_info_edit_photo_delete.imageset/mine_user_info_edit_photo_delete@2x.png new file mode 100644 index 00000000..9e13fc00 Binary files /dev/null and b/xplan-ios/Assets.xcassets/Mine/mine_user_info_edit_photo_delete.imageset/mine_user_info_edit_photo_delete@2x.png differ diff --git a/xplan-ios/Assets.xcassets/Mine/mine_user_info_edit_photo_delete.imageset/mine_user_info_edit_photo_delete@3x.png b/xplan-ios/Assets.xcassets/Mine/mine_user_info_edit_photo_delete.imageset/mine_user_info_edit_photo_delete@3x.png new file mode 100644 index 00000000..93000a57 Binary files /dev/null and b/xplan-ios/Assets.xcassets/Mine/mine_user_info_edit_photo_delete.imageset/mine_user_info_edit_photo_delete@3x.png differ diff --git a/xplan-ios/Base/UI/UIImageView/UIImageConstant.m b/xplan-ios/Base/UI/UIImageView/UIImageConstant.m index 7348c0a2..27b0de71 100644 --- a/xplan-ios/Base/UI/UIImageView/UIImageConstant.m +++ b/xplan-ios/Base/UI/UIImageView/UIImageConstant.m @@ -13,7 +13,7 @@ NSString * const kImageTypeRoomFace = @""; //房间表情 NSString * const kImageTypeRoomGift = @""; //房间礼物 NSString * const kImageTypeUserIcon = @"imageMogr2/auto-orient/thumbnail/150x150"; //用户头像150x150 -NSString * const kImageTypeUserLibaryDetail = @""; //用户相册大图nil +NSString * const kImageTypeUserLibaryDetail = @"imageMogr2/auto-orient/thumbnail/300x300"; //用户相册大图nil NSString * const kImageTypeCornerAvatar = @"imageMogr2/auto-orient/thumbnail/300x300/format/png"; diff --git a/xplan-ios/Main/Mine/Api/Api+Mine.h b/xplan-ios/Main/Mine/Api/Api+Mine.h index b988b8b1..7ac13e1f 100644 --- a/xplan-ios/Main/Mine/Api/Api+Mine.h +++ b/xplan-ios/Main/Mine/Api/Api+Mine.h @@ -74,6 +74,25 @@ NS_ASSUME_NONNULL_BEGIN /// 上传七牛获取token /// @param complection 完成 + (void)qiniuUpLoadImageWithComplection:(HttpRequestHelperCompletion)complection; + +/// 上传用户图像到服务器 +/// @param complection 完成 +/// @param photoStr 相册 +/// @param uid 用户的uid +/// @param ticket ticket ++ (void)uploadUserAlbumWithComplection:(HttpRequestHelperCompletion)complection + photoStr:(NSString *)photoStr + uid:(NSString *)uid + ticket:(NSString *)ticket; +/// 删除用户图像从服务器 +/// @param complection 完成 +/// @param pid 相册 +/// @param uid 用户的uid +/// @param ticket ticket ++ (void)deleteImageFromServerWithComplection:(HttpRequestHelperCompletion)complection + pid:(NSString *)pid + uid:(NSString *)uid + ticket:(NSString *)ticket; @end NS_ASSUME_NONNULL_END diff --git a/xplan-ios/Main/Mine/Api/Api+Mine.m b/xplan-ios/Main/Mine/Api/Api+Mine.m index e58f7621..37906ef9 100644 --- a/xplan-ios/Main/Mine/Api/Api+Mine.m +++ b/xplan-ios/Main/Mine/Api/Api+Mine.m @@ -78,4 +78,23 @@ + (void)qiniuUpLoadImageWithComplection:(HttpRequestHelperCompletion)complection { [self makeRequest:@"qiniu/upload/getUploadToken" method:HttpRequestHelperMethodGET completion:complection, __FUNCTION__, nil]; } + + +/// 上传用户图像到服务器 +/// @param complection 完成 +/// @param photoStr 相册 +/// @param uid 用户的uid +/// @param ticket ticket ++ (void)uploadUserAlbumWithComplection:(HttpRequestHelperCompletion)complection photoStr:(NSString *)photoStr uid:(NSString *)uid ticket:(NSString *)ticket { + [self makeRequest:@"photo/v2/upload" method:HttpRequestHelperMethodPOST completion:complection, __FUNCTION__,photoStr, uid, ticket, nil]; +} + +/// 删除用户图像从服务器 +/// @param complection 完成 +/// @param pid 相册 +/// @param uid 用户的uid +/// @param ticket ticket ++ (void)deleteImageFromServerWithComplection:(HttpRequestHelperCompletion)complection pid:(NSString *)pid uid:(NSString *)uid ticket:(NSString *)ticket { + [self makeRequest:@"photo/delPhoto" method:HttpRequestHelperMethodPOST completion:complection, __FUNCTION__,pid, uid, ticket, nil]; +} @end diff --git a/xplan-ios/Main/Mine/Presenter/XPMineUserInfolbumPresenter.h b/xplan-ios/Main/Mine/Presenter/XPMineUserInfolbumPresenter.h new file mode 100644 index 00000000..024c341a --- /dev/null +++ b/xplan-ios/Main/Mine/Presenter/XPMineUserInfolbumPresenter.h @@ -0,0 +1,29 @@ +// +// XPMineUserInfolbumPresenter.h +// xplan-ios +// +// Created by 冯硕 on 2021/9/24. +// + +#import "BaseMvpPresenter.h" + +NS_ASSUME_NONNULL_BEGIN + +@interface XPMineUserInfolbumPresenter : BaseMvpPresenter +///获取用户信息 +- (void)getUserInfo; +/// 将图片的地址上传到自己的服务器 +/// @param url 图片的地址 + +- (void)uploadUserAlbumWithUrlStr:(NSString *)url; + +/// 相册 +/// @param albumImage 相册的image +- (void)uploadAlbumImage:(UIImage *)albumImage; + +/// 删除用户图片 +/// @param pid 相册的id +- (void)deleteImageUrlFromServerWithPid:(NSString *)pid; +@end + +NS_ASSUME_NONNULL_END diff --git a/xplan-ios/Main/Mine/Presenter/XPMineUserInfolbumPresenter.m b/xplan-ios/Main/Mine/Presenter/XPMineUserInfolbumPresenter.m new file mode 100644 index 00000000..bcb4864e --- /dev/null +++ b/xplan-ios/Main/Mine/Presenter/XPMineUserInfolbumPresenter.m @@ -0,0 +1,66 @@ +// +// XPMineUserInfolbumPresenter.m +// xplan-ios +// +// Created by 冯硕 on 2021/9/24. +// + +#import "XPMineUserInfolbumPresenter.h" +///Api +#import "Api+Mine.h" +///Model +#import "UserInfoModel.h" +///Tool +#import "AccountInfoStorage.h" +#import "UploadImage.h" +///P +#import "XPMineUserInfoAlbumProtocol.h" + +@implementation XPMineUserInfolbumPresenter + +///获取用户信息 +- (void)getUserInfo { + NSString * uid = [AccountInfoStorage instance].getUid; + [Api getUserInfo:[self createHttpCompletion:^(BaseModel * _Nonnull data) { + UserInfoModel * infoModel = [UserInfoModel modelWithDictionary:data.data]; + [[self getView] onGetUserInfoSuccess:infoModel]; + }] uid:uid]; +} + +/// 将图片的地址上传到自己的服务器 +/// @param url 图片的地址 +- (void)uploadUserAlbumWithUrlStr:(NSString *)url { + NSString * uid = [AccountInfoStorage instance].getUid; + NSString * ticket = [AccountInfoStorage instance].getTicket; + [Api uploadUserAlbumWithComplection:[self createHttpCompletion:^(BaseModel * _Nonnull data) { + [[self getView] uploadUserAlbumSuccess]; + } showLoading:YES] photoStr:url uid:uid ticket:ticket]; +} + +/// 相册 +/// @param albumImage 相册的image +- (void)uploadAlbumImage:(UIImage *)albumImage { + [Api qiniuUpLoadImageWithComplection:[self createHttpCompletion:^(BaseModel * _Nonnull data) { + NSString *key = data.data[@"key"]; + NSString *token = data.data[@"token"]; + [UploadImage uploadImage:albumImage named:key token:token success:^(NSString * _Nonnull key, NSDictionary * _Nonnull resp) { + NSString *url = resp[@"path"]; + [[self getView] uploadAlbumImageToThirdSuccess:url]; + } failure:^(NSNumber * _Nonnull resCode, NSString * _Nonnull message) { + [[self getView] showErrorToast:@"上传失败"]; + }]; + } showLoading:YES]]; +} + + +/// 删除用户图片 +/// @param pid 相册的id +- (void)deleteImageUrlFromServerWithPid:(NSString *)pid { + NSString * uid = [AccountInfoStorage instance].getUid; + NSString * ticket = [AccountInfoStorage instance].getTicket; + [Api deleteImageFromServerWithComplection:[self createHttpCompletion:^(BaseModel * _Nonnull data) { + [[self getView] deleteUserAlbumSuccess]; + } showLoading:YES] pid:pid uid:uid ticket:ticket]; +} + +@end diff --git a/xplan-ios/Main/Mine/Protocol/XPMineUserInfoAlbumProtocol.h b/xplan-ios/Main/Mine/Protocol/XPMineUserInfoAlbumProtocol.h new file mode 100644 index 00000000..2bea98ae --- /dev/null +++ b/xplan-ios/Main/Mine/Protocol/XPMineUserInfoAlbumProtocol.h @@ -0,0 +1,23 @@ +// +// XPMineUserInfoAlbumProtocol.h +// xplan-ios +// +// Created by 冯硕 on 2021/9/24. +// + +#import + +NS_ASSUME_NONNULL_BEGIN +@class UserInfoModel; +@protocol XPMineUserInfoAlbumProtocol +///获取用户信息成功 +- (void)onGetUserInfoSuccess:(UserInfoModel *)userInfo; +///上传用户的头像成功 +- (void)uploadUserAlbumSuccess; +///上传图片 到第三方成功 +- (void)uploadAlbumImageToThirdSuccess:(NSString *)url; +///删除用户的头像成功 +- (void)deleteUserAlbumSuccess; +@end + +NS_ASSUME_NONNULL_END diff --git a/xplan-ios/Main/Mine/View/Cell/MineInfo/XPMineUserInfoAlbumCollectionViewCell.h b/xplan-ios/Main/Mine/View/Cell/MineInfo/XPMineUserInfoAlbumCollectionViewCell.h new file mode 100644 index 00000000..c91efd6b --- /dev/null +++ b/xplan-ios/Main/Mine/View/Cell/MineInfo/XPMineUserInfoAlbumCollectionViewCell.h @@ -0,0 +1,29 @@ +// +// XPMineUserInfoAlbumCollectionViewCell.h +// xplan-ios +// +// Created by 冯硕 on 2021/9/24. +// + +#import + +NS_ASSUME_NONNULL_BEGIN +@class UserPhoto, XPMineUserInfoAlbumCollectionViewCell; + +@protocol XPMineUserInfoAlbumCollectionViewCellDelegate +///点击了删除某个 +- (void)xPMineUserInfoAlbumCollectionViewCell:(XPMineUserInfoAlbumCollectionViewCell * )cell didDeleteItem:(UserPhoto *)photo; +@end + +@interface XPMineUserInfoAlbumCollectionViewCell : UICollectionViewCell +///代理 +@property (nonatomic,weak) id delegate; +///相册 +@property (nonatomic,strong) UserPhoto *photo; +///添加 +@property (nonatomic,copy) NSString *addImageName; +///是否编辑 +@property (nonatomic,assign) BOOL isEdit; +@end + +NS_ASSUME_NONNULL_END diff --git a/xplan-ios/Main/Mine/View/Cell/MineInfo/XPMineUserInfoAlbumCollectionViewCell.m b/xplan-ios/Main/Mine/View/Cell/MineInfo/XPMineUserInfoAlbumCollectionViewCell.m new file mode 100644 index 00000000..2dd661ad --- /dev/null +++ b/xplan-ios/Main/Mine/View/Cell/MineInfo/XPMineUserInfoAlbumCollectionViewCell.m @@ -0,0 +1,98 @@ +// +// XPMineUserInfoAlbumCollectionViewCell.m +// xplan-ios +// +// Created by 冯硕 on 2021/9/24. +// + +#import "XPMineUserInfoAlbumCollectionViewCell.h" +///Third +#import +///Tool +#import "UIButton+EnlargeTouchArea.h" +#import "UIImageView+LoadImage.h" +///Model +#import "UserPhoto.h" + +@interface XPMineUserInfoAlbumCollectionViewCell () +/// +@property (nonatomic,strong) UIImageView *logoImageView; +/// +@property (nonatomic,strong) UIButton *deleteButton; +@end + +@implementation XPMineUserInfoAlbumCollectionViewCell + +- (instancetype)initWithFrame:(CGRect)frame { + self = [super initWithFrame:frame]; + if (self) { + [self initSubViews]; + [self initSubViewConstraints]; + } + return self; +} +#pragma mark - Response +- (void)deleteButtonAction:(UIButton *)sender { + if (self.delegate && [self.delegate respondsToSelector:@selector(xPMineUserInfoAlbumCollectionViewCell:didDeleteItem:)]) { + [self.delegate xPMineUserInfoAlbumCollectionViewCell:self didDeleteItem:self.photo]; + } +} +#pragma mark - Private Method +- (void)initSubViews { + [self.contentView addSubview:self.logoImageView]; + [self.contentView addSubview:self.deleteButton]; +} + +- (void)initSubViewConstraints { + [self.logoImageView mas_makeConstraints:^(MASConstraintMaker *make) { + make.edges.mas_equalTo(self.contentView); + }]; + + [self.deleteButton mas_makeConstraints:^(MASConstraintMaker *make) { + make.size.mas_equalTo(CGSizeMake(25, 25)); + make.top.right.mas_equalTo(self.contentView).inset(0); + }]; +} + +#pragma mark - Getters And Setters +- (void)setPhoto:(UserPhoto *)photo { + _photo = photo; + if (_photo) { + [self.logoImageView load_setImageImageWithUrl:_photo.photoUrl placeholderImage:[UIImageConstant defaultAvatarPlaceholder] type:ImageTypeUserLibaryDetail]; + } +} + +- (void)setIsEdit:(BOOL)isEdit { + _isEdit = isEdit; + self.deleteButton.hidden = !_isEdit; +} + +- (void)setAddImageName:(NSString *)addImageName { + _addImageName = addImageName; + if (_addImageName.length > 0) { + self.logoImageView.image = [UIImage imageNamed:_addImageName]; + } +} + +- (UIImageView *)logoImageView { + if (!_logoImageView) { + _logoImageView = [[UIImageView alloc] init]; + _logoImageView.userInteractionEnabled = YES; + _logoImageView.layer.cornerRadius = 5; + _logoImageView.layer.masksToBounds = YES; + _logoImageView.contentMode = UIViewContentModeScaleAspectFill; + } + return _logoImageView; +} + +- (UIButton *)deleteButton { + if (!_deleteButton) { + _deleteButton = [UIButton buttonWithType:UIButtonTypeCustom]; + [_deleteButton setImage:[UIImage imageNamed:@"mine_user_info_edit_photo_delete"] forState:UIControlStateNormal]; + [_deleteButton setImage:[UIImage imageNamed:@"mine_user_info_edit_photo_delete"] forState:UIControlStateSelected]; + [_deleteButton addTarget:self action:@selector(deleteButtonAction:) forControlEvents:UIControlEventTouchUpInside]; + } + return _deleteButton; +} + +@end diff --git a/xplan-ios/Main/Mine/View/Cell/MineInfo/XPMineUserInfoEditTableViewCell.m b/xplan-ios/Main/Mine/View/Cell/MineInfo/XPMineUserInfoEditTableViewCell.m index cd818774..0df82df4 100644 --- a/xplan-ios/Main/Mine/View/Cell/MineInfo/XPMineUserInfoEditTableViewCell.m +++ b/xplan-ios/Main/Mine/View/Cell/MineInfo/XPMineUserInfoEditTableViewCell.m @@ -13,6 +13,7 @@ #import "UIImageView+LoadImage.h" ///Model #import "XPMineUserInfoEditModel.h" +#import "UserPhoto.h" @interface XPMineUserInfoEditTableViewCell () ///容器 @@ -68,7 +69,7 @@ [self.photoViewArray addObject:self.firstPhotoImageView]; [self.photoViewArray addObject:self.secondPhotoImageView]; - [self.photoViewArray addObject:self.secondPhotoImageView]; + [self.photoViewArray addObject:self.thirdPhotoImageView]; } - (void)initSubViewConstraints { @@ -105,14 +106,14 @@ }]; } -- (void)loadPhotoViewWithPhotoArray:(NSArray *)array { +- (void)loadPhotoViewWithPhotoArray:(NSArray *)array { if (array.count > 3) { array = [array subarrayWithRange:NSMakeRange(0, 3)]; } for (int i = 0; i < array.count; i++) { UIImageView * imageView = [self.photoViewArray objectAtIndex:i]; - NSString * imageUrl = [array objectAtIndex:i]; - [imageView load_setImageImageWithUrl:imageUrl placeholderImage:[UIImageConstant defaultAvatarPlaceholder]]; + NSString * imageUrl = [array objectAtIndex:i].photoUrl; + [imageView load_setImageImageWithUrl:imageUrl placeholderImage:[UIImageConstant defaultAvatarPlaceholder] type:ImageTypeUserIcon]; } } @@ -124,7 +125,7 @@ self.phototStackView.hidden = YES; self.avatarImageView.hidden = NO; if (model.avatarUrl.length > 0) { - [self.avatarImageView load_setImageImageWithUrl:model.avatarUrl placeholderImage:[UIImageConstant defaultAvatarPlaceholder]]; + [self.avatarImageView load_setImageImageWithUrl:model.avatarUrl placeholderImage:[UIImageConstant defaultAvatarPlaceholder] type:ImageTypeUserIcon]; } } break; diff --git a/xplan-ios/Main/Mine/View/MineInfo/XPMineUserInfoAlbumViewController.h b/xplan-ios/Main/Mine/View/MineInfo/XPMineUserInfoAlbumViewController.h new file mode 100644 index 00000000..40ebde63 --- /dev/null +++ b/xplan-ios/Main/Mine/View/MineInfo/XPMineUserInfoAlbumViewController.h @@ -0,0 +1,16 @@ +// +// XPMineUserInfoAlbumViewController.h +// xplan-ios +// +// Created by 冯硕 on 2021/9/24. +// + +#import "MvpViewController.h" + +NS_ASSUME_NONNULL_BEGIN + +@interface XPMineUserInfoAlbumViewController : MvpViewController + +@end + +NS_ASSUME_NONNULL_END diff --git a/xplan-ios/Main/Mine/View/MineInfo/XPMineUserInfoAlbumViewController.m b/xplan-ios/Main/Mine/View/MineInfo/XPMineUserInfoAlbumViewController.m new file mode 100644 index 00000000..64463f43 --- /dev/null +++ b/xplan-ios/Main/Mine/View/MineInfo/XPMineUserInfoAlbumViewController.m @@ -0,0 +1,273 @@ +// +// XPMineUserInfoAlbumViewController.m +// xplan-ios +// +// Created by 冯硕 on 2021/9/24. +// + +#import "XPMineUserInfoAlbumViewController.h" +///Third +#import +#import +#import "SDPhotoBrowser.h" +#import "UIImageConstant.h" +#import "TTPopup.h" +#import "YYUtility.h" +///Tool +#import "ThemeColor.h" +///Model +#import "UserInfoModel.h" +///View +#import "XPMineUserInfoAlbumCollectionViewCell.h" +///P +#import "XPMineUserInfolbumPresenter.h" +#import "XPMineUserInfoAlbumProtocol.h" + +@interface XPMineUserInfoAlbumViewController () +///列表 +@property (nonatomic,strong) UICollectionView *collectionView; +///数据源 +@property (nonatomic,strong) NSArray *datasource; +///完成 +@property (nonatomic,strong) UIButton *complectButton; +///是否编辑 +@property (nonatomic,assign) BOOL isEdit; +@end + +@implementation XPMineUserInfoAlbumViewController + +- (XPMineUserInfolbumPresenter*)createPresenter { + return [[XPMineUserInfolbumPresenter alloc] init]; +} + +- (void)viewDidLoad { + [super viewDidLoad]; + [self loadUserInfo]; + [self initSubViews]; + [self initSubViewConstraints]; + [self initEvents]; + +} + +#pragma mark - Private Method +- (void)initSubViews { + self.title = @"我的相册"; + ///添加完成按钮 + [self addNavigationItemWithItems:@[self.complectButton] isLeft:NO]; + [self.view addSubview:self.collectionView]; +} + +- (void)initSubViewConstraints { + [self.collectionView mas_makeConstraints:^(MASConstraintMaker *make) { + make.edges.mas_equalTo(self.view); + }]; +} + +- (void)initEvents { + @weakify(self); + [[self.complectButton rac_signalForControlEvents:UIControlEventTouchUpInside] subscribeNext:^(__kindof UIControl * _Nullable x) { + @strongify(self); + x.selected = !x.selected; + self.isEdit = x.selected; + [self.collectionView reloadData]; + }]; +} + +- (void)loadUserInfo { + [self.presenter getUserInfo]; +} + +/// 取消编辑 +- (void)cancelEditing { + self.complectButton.selected = NO; + self.isEdit = NO; + [self.collectionView reloadData]; +} + +#pragma mark - 选择图片 +- (void)showPhotoView { + @weakify(self); + TTActionSheetConfig *cameraConfig = [TTActionSheetConfig normalTitle:@"拍照上传" clickAction:^{ + [YYUtility checkCameraAvailable:^{ + @strongify(self); + UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init]; + imagePicker.delegate = self; + imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera; + imagePicker.allowsEditing = YES; + [self presentViewController:imagePicker animated:YES completion:NULL]; + } denied:^{ + @strongify(self); + [self showNotPhoto:@"相机不可用" content:@"相机权限受限,点击确定去系统设置"]; + } restriction:^{ + @strongify(self); + [self showNotPhoto:@"相机不可用" content:@"相册权限受限,点击确定去系统设置"]; + }]; + }]; + + TTActionSheetConfig *photoLibrayConfig = [TTActionSheetConfig normalTitle:@"本地相册" clickAction:^{ + [YYUtility checkAssetsLibrayAvailable:^{ + @strongify(self); + UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init]; + imagePicker.modalPresentationCapturesStatusBarAppearance = YES; + imagePicker.delegate = self; + imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary; + imagePicker.allowsEditing = YES; + [self presentViewController:imagePicker animated:YES completion:NULL]; + } denied:^{ + @strongify(self); + [self showNotPhoto:@"相册不可用" content:@"相册权限受限,点击确定去系统设置"]; + } restriction:^{ + @strongify(self); + [self showNotPhoto:@"相册不可用" content:@"相册权限受限,点击确定去系统设置"]; + }]; + }]; + + [TTPopup actionSheetWithItems:@[cameraConfig, photoLibrayConfig]]; +} + +- (void)showNotPhoto:(NSString *)title content:(NSString *)content{ + TTAlertConfig *config = [[TTAlertConfig alloc] init]; + config.title = title; + config.message = content; + [TTPopup alertWithConfig:config confirmHandler:^{ + NSURL *url = [NSURL URLWithString:UIApplicationOpenSettingsURLString]; + if ([[UIApplication sharedApplication] canOpenURL:url]) { + [[UIApplication sharedApplication] openURL:url]; + } + } cancelHandler:^{ + }]; +} + +#pragma mark - UICollectionViewDelegate And UICollectionViewDatasource +- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section { + return self.datasource.count + 1; +} + +- (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath { + XPMineUserInfoAlbumCollectionViewCell * cell = [collectionView dequeueReusableCellWithReuseIdentifier:NSStringFromClass([XPMineUserInfoAlbumCollectionViewCell class]) forIndexPath:indexPath]; + cell.delegate = self; + if (indexPath.row == 0) { + cell.addImageName = @"mine_user_info_album_add"; + cell.isEdit = NO; + } else { + if (self.datasource.count > 0) { + cell.photo = [self.datasource objectAtIndex:indexPath.row - 1]; + cell.isEdit = self.isEdit; + } + } + return cell; +} + +- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath { + [collectionView deselectItemAtIndexPath:indexPath animated:YES]; + if (indexPath.row == 0) { + if (self.datasource.count < 8) { + [self showPhotoView]; + [self cancelEditing]; + }else{ + [self showErrorToast:@"最多只能上传8张照片"]; + } + }else { + if (!self.isEditing) { + SDPhotoBrowser *browser = [[SDPhotoBrowser alloc]init]; + browser.sourceImagesContainerView = self.collectionView; + browser.delegate = self; + browser.imageCount = self.datasource.count; + browser.currentImageIndex = indexPath.item - 1; + browser.isHaveUserAdd = YES; + [browser show]; + } + } +} + +#pragma mark - XPMineUserInfoAlbumCollectionViewCellDelegate +- (void)xPMineUserInfoAlbumCollectionViewCell:(XPMineUserInfoAlbumCollectionViewCell *)cell didDeleteItem:(UserPhoto *)photo { + TTAlertConfig * config = [[TTAlertConfig alloc] init]; + config.title = @"删除是不可逆操作"; + config.message = @"是否需要删除?"; + [TTPopup alertWithConfig:config confirmHandler:^{ + [self.presenter deleteImageUrlFromServerWithPid:photo.pid]; + } cancelHandler:^{ + + }]; +} + +#pragma mark - SDPhotoBrowserDelegate +- (UIImage *)photoBrowser:(SDPhotoBrowser *)browser placeholderImageForIndex:(NSInteger)index { + return [UIImage imageNamed:[UIImageConstant defaultAvatarPlaceholder]]; +} + +- (NSURL *)photoBrowser:(SDPhotoBrowser *)browser highQualityImageURLForIndex:(NSInteger)index { + return [NSURL URLWithString:self.datasource[index].photoUrl]; +} + + +#pragma mark - UIImagePickerControllerDelegate +- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info { + + [picker dismissViewControllerAnimated:YES completion:^{ + UIImage *selectedPhoto = [info objectForKey:UIImagePickerControllerOriginalImage]; + if (selectedPhoto) { + if (picker.sourceType == UIImagePickerControllerSourceTypeCamera) { + UIImageWriteToSavedPhotosAlbum(selectedPhoto, nil, nil, nil); + } + [self.presenter uploadAlbumImage:selectedPhoto]; + } + }]; +} + +- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker { + [picker dismissViewControllerAnimated:YES completion:^{ + + }]; +} + +#pragma mark - XPMineUserInfoAlbumProtocol +- (void)onGetUserInfoSuccess:(UserInfoModel *)userInfo { + self.datasource = userInfo.privatePhoto; + [self.collectionView reloadData]; +} +///上传第三方服务器 +- (void)uploadAlbumImageToThirdSuccess:(NSString *)url { + [self.presenter uploadUserAlbumWithUrlStr:url]; +} +///上传自己服务器 +- (void)uploadUserAlbumSuccess { + [self.presenter getUserInfo]; + [self showSuccessToast:@"更新成功"]; +} + +- (void)deleteUserAlbumSuccess { + [self.presenter getUserInfo]; + [self showSuccessToast:@"删除成功"]; +} +#pragma mark - Getters And Setters +- (UICollectionView *)collectionView{ + if (!_collectionView) { + UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init]; + layout.sectionInset = UIEdgeInsetsMake(10, 10, 10, 10); + layout.itemSize = CGSizeMake((self.view.frame.size.width - 50) / 3, (self.view.frame.size.width - 50) / 3); + layout.minimumLineSpacing = 15; + layout.minimumInteritemSpacing = 15; + _collectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:layout]; + _collectionView.dataSource = self; + _collectionView.delegate = self; + _collectionView.backgroundColor = [UIColor clearColor]; + [_collectionView registerClass:[XPMineUserInfoAlbumCollectionViewCell class] forCellWithReuseIdentifier:NSStringFromClass([XPMineUserInfoAlbumCollectionViewCell class])]; + } + return _collectionView; +} + +- (UIButton *)complectButton { + if (!_complectButton) { + _complectButton = [UIButton buttonWithType:UIButtonTypeCustom]; + [_complectButton setTitle:@"编辑" forState:UIControlStateNormal]; + [_complectButton setTitle:@"完成" forState:UIControlStateSelected]; + [_complectButton setTitleColor:[ThemeColor mainTextColor] forState:UIControlStateNormal]; + [_complectButton setTitleColor:[ThemeColor mainTextColor] forState:UIControlStateSelected]; + _complectButton.titleLabel.font = [UIFont systemFontOfSize:15]; + } + return _complectButton; +} + +@end diff --git a/xplan-ios/Main/Mine/View/MineInfo/XPMineUserInfoEditViewController.m b/xplan-ios/Main/Mine/View/MineInfo/XPMineUserInfoEditViewController.m index a82b39ac..0f83584e 100644 --- a/xplan-ios/Main/Mine/View/MineInfo/XPMineUserInfoEditViewController.m +++ b/xplan-ios/Main/Mine/View/MineInfo/XPMineUserInfoEditViewController.m @@ -26,6 +26,7 @@ ///VC #import "XPMineUserInfoNickViewController.h" #import "XPMineUserInfoDesViewController.h" +#import "XPMineUserInfoAlbumViewController.h" @interface XPMineUserInfoEditViewController () ///列表 @@ -182,7 +183,8 @@ break; case XPMineUserInfoEditType_Photo: { -#warning to do 选择相册 + XPMineUserInfoAlbumViewController * albumVC = [[XPMineUserInfoAlbumViewController alloc] init]; + [self.navigationController pushViewController:albumVC animated:YES]; } break; diff --git a/xplan-ios/Main/Mine/View/MineInfo/XPMineUserInfoViewController.m b/xplan-ios/Main/Mine/View/MineInfo/XPMineUserInfoViewController.m index 4b2d20df..30ff2be4 100644 --- a/xplan-ios/Main/Mine/View/MineInfo/XPMineUserInfoViewController.m +++ b/xplan-ios/Main/Mine/View/MineInfo/XPMineUserInfoViewController.m @@ -21,7 +21,7 @@ ///VC #import "XPMineUserInfoEditViewController.h" -@interface XPMineUserInfoViewController () +@interface XPMineUserInfoViewController () ///列别 @property (nonatomic,strong) UITableView *tableView; ///头部视图 @@ -48,13 +48,22 @@ [super viewDidLoad]; [self initSubViews]; [self initSubViewConstraints]; - } + +- (void)viewWillAppear:(BOOL)animated { + [super viewWillAppear:animated]; + if (self.uid > 0) { + NSString * uidStr = [NSString stringWithFormat:@"%lld", self.uid]; + [self.presenter getUserInfoWithUid:uidStr]; + } +} + #pragma mark - Private Method - (void)initSubViews { [self.view addSubview:self.headView]; [self.view addSubview:self.tableView]; [self.view addSubview:self.navView]; +#warning to do 头像无法点击的问题 self.tableView.tableHeaderView = self.tableViewHeadView; } diff --git a/xplan-ios/Main/Mine/View/SubViews/MineInfo/XPMineUserInfoHeaderView.m b/xplan-ios/Main/Mine/View/SubViews/MineInfo/XPMineUserInfoHeaderView.m index 3b8c0327..f59702c9 100644 --- a/xplan-ios/Main/Mine/View/SubViews/MineInfo/XPMineUserInfoHeaderView.m +++ b/xplan-ios/Main/Mine/View/SubViews/MineInfo/XPMineUserInfoHeaderView.m @@ -136,6 +136,7 @@ _cycleScrollView.delegate = self; _cycleScrollView.bannerImageViewContentMode = UIViewContentModeScaleAspectFill; _cycleScrollView.pageControlStyle = SDCycleScrollViewPageContolStyleNone;; + _cycleScrollView.placeholderImage = [UIImage imageNamed:[UIImageConstant defaultAvatarPlaceholder]]; _cycleScrollView.autoScroll = NO; } return _cycleScrollView; @@ -157,7 +158,7 @@ _pageLabel.textColor = [ThemeColor textThirdColor]; _pageLabel.textAlignment = NSTextAlignmentCenter; _pageLabel.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:1]; - _pageLabel.alpha = 0.2; + _pageLabel.alpha = 0.1; _pageLabel.layer.masksToBounds = YES; _pageLabel.layer.cornerRadius = 8; }