67 lines
2.1 KiB
Objective-C
67 lines
2.1 KiB
Objective-C
//
|
|
// YMMineUserInfolbumPresenter.m
|
|
// YUMI
|
|
//
|
|
// Created by YUMI 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 uploadUserAlbum:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
|
|
[[self getView] uploadUserAlbumSuccess];
|
|
} showLoading:YES] photoStr:url uid:uid ticket:ticket];
|
|
}
|
|
|
|
/// 相册
|
|
/// @param albumImage 相册的image
|
|
- (void)uploadAlbumImage:(UIImage *)albumImage {
|
|
[Api qiniuUpLoadImage:[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:YMLocalizedString(@"XPMineUserInfolbumPresenter0")];
|
|
}];
|
|
} showLoading:YES]];
|
|
}
|
|
|
|
|
|
/// 删除用户图片
|
|
/// @param pid 相册的id
|
|
- (void)deleteImageUrlFromServerWithPid:(NSString *)pid {
|
|
NSString * uid = [AccountInfoStorage instance].getUid;
|
|
NSString * ticket = [AccountInfoStorage instance].getTicket;
|
|
[Api deleteImageFromServer:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
|
|
[[self getView] deleteUserAlbumSuccess];
|
|
} showLoading:YES] pid:pid uid:uid ticket:ticket];
|
|
}
|
|
|
|
@end
|