203 lines
9.5 KiB
Objective-C
203 lines
9.5 KiB
Objective-C
//
|
|
// YMMineSettingPresent.m
|
|
// YUMI
|
|
//
|
|
// Created by YUMI on 2021/9/17.
|
|
//
|
|
|
|
#import "XPMineSettingPresent.h"
|
|
#import "Api+Mine.h"
|
|
#import "Api+Room.h"
|
|
///P
|
|
#import "XPMineSettingProtocol.h"
|
|
///Model
|
|
#import "UserInfoModel.h"
|
|
#import "AccountModel.h"
|
|
#import "XPMineSettingItemModel.h"
|
|
#import "YYUtility.h"
|
|
#import "XPVersionUpdateModel.h"
|
|
#import "Api+Main.h"
|
|
///Tool
|
|
#import "AccountInfoStorage.h"
|
|
#import "XPRoomMiniManager.h"
|
|
#import "RtcManager.h"
|
|
#import "ClientConfig.h"
|
|
///Third
|
|
#import <NIMSDK/NIMSDK.h>
|
|
|
|
@interface XPMineSettingPresent ()
|
|
///手机号
|
|
@property (nonatomic,strong) XPMineSettingItemModel *phoneItem;
|
|
///支付密码
|
|
@property (nonatomic,strong) XPMineSettingItemModel *payItem;
|
|
///登录密码
|
|
@property (nonatomic,strong) XPMineSettingItemModel *loginItem;
|
|
///数据源
|
|
@property (nonatomic,strong) NSArray *datasouce;
|
|
@end
|
|
|
|
@implementation XPMineSettingPresent
|
|
- (id<XPMineSettingProtocol>)getView {
|
|
return (id<XPMineSettingProtocol>) [super getView];
|
|
}
|
|
|
|
|
|
/// 获取数据源
|
|
/// @param userinfo 当前的用户信息
|
|
- (void)getMineSettingDataSourceWith:(UserInfoModel *)userinfo {
|
|
if (self.datasouce.count > 0) {
|
|
self.phoneItem.subTitle = userinfo.isBindPhone ? userinfo.phone : YMLocalizedString(@"XPMineSettingPresent0");
|
|
self.payItem.subTitle = userinfo.isBindPaymentPwd ? YMLocalizedString(@"XPMineSettingPresent26") : YMLocalizedString(@"XPMineSettingPresent2");
|
|
} else {
|
|
if ([ClientConfig shareConfig].canOpen) {
|
|
XPMineSettingItemModel * phoneItem = [[XPMineSettingItemModel alloc] init];
|
|
phoneItem.title = YMLocalizedString(@"XPMineSettingPresent3");
|
|
phoneItem.subTitle = userinfo.isBindPhone ? userinfo.phone : YMLocalizedString(@"XPMineSettingPresent4");
|
|
phoneItem.type = XPMineSettingItemType_Phone;
|
|
self.phoneItem = phoneItem;
|
|
|
|
XPMineSettingItemModel * loginItem = [[XPMineSettingItemModel alloc] init];
|
|
loginItem.title = userinfo.isBindPasswd ? YMLocalizedString(@"XPMineLoginPasswordViewController6") : YMLocalizedString(@"XPMineSettingPresent6");
|
|
loginItem.subTitle = YMLocalizedString(@"XPMineSettingPresent7");
|
|
loginItem.type = XPMineSettingItemType_Login_Password;
|
|
self.loginItem = loginItem;
|
|
|
|
XPMineSettingItemModel * blackListItem = [[XPMineSettingItemModel alloc] init];
|
|
blackListItem.title = YMLocalizedString(@"XPMineSettingPresent8");
|
|
blackListItem.subTitle = @"";
|
|
blackListItem.type = XPMineSettingItemType_Black_Manager;
|
|
|
|
XPMineSettingItemModel * payItem = [[XPMineSettingItemModel alloc] init];
|
|
payItem.title = YMLocalizedString(@"XPMineSettingPresent9");
|
|
payItem.subTitle = userinfo.isBindPaymentPwd ? YMLocalizedString(@"XPMineSettingPresent26") : YMLocalizedString(@"XPMineSettingPresent11");
|
|
payItem.type = XPMineSettingItemType_Pay_Password;
|
|
self.payItem = payItem;
|
|
|
|
XPMineSettingItemModel * notificaItem = [[XPMineSettingItemModel alloc] init];
|
|
notificaItem.title = YMLocalizedString(@"XPMineSettingPresent12");
|
|
notificaItem.subTitle = YMLocalizedString(@"XPMineSettingPresent13");
|
|
notificaItem.type = XPMineSettingItemType_Notification_Remind;
|
|
|
|
XPMineSettingItemModel * privacyItem = [[XPMineSettingItemModel alloc] init];
|
|
privacyItem.title = YMLocalizedString(@"XPMineSettingPresent14");
|
|
privacyItem.subTitle = @"";
|
|
privacyItem.type = XPMineSettingItemType_Permission;
|
|
|
|
XPMineSettingItemModel * helperItem = [[XPMineSettingItemModel alloc] init];
|
|
helperItem.title = YMLocalizedString(@"XPMineSettingPresent15");
|
|
helperItem.subTitle = @"";
|
|
helperItem.type = XPMineSettingItemType_Helper;
|
|
|
|
XPMineSettingItemModel * feedbackItem = [[XPMineSettingItemModel alloc] init];
|
|
feedbackItem.title = YMLocalizedString(@"XPMineSettingPresent16");
|
|
feedbackItem.subTitle = @"";
|
|
feedbackItem.type = XPMineSettingItemType_Feedback;
|
|
|
|
XPMineSettingItemModel * clearMemoryItem = [[XPMineSettingItemModel alloc] init];
|
|
clearMemoryItem.title = YMLocalizedString(@"XPMineSettingPresent17");
|
|
clearMemoryItem.subTitle = @"";
|
|
clearMemoryItem.type = XPMineSettingItemType_Clear_Memory;
|
|
|
|
XPMineSettingItemModel *updateItem = [[XPMineSettingItemModel alloc] init];
|
|
updateItem.title = YMLocalizedString(@"XPMineSettingPresent18");
|
|
updateItem.subTitle = @"";
|
|
updateItem.type = XPMineSettingItemType_CheckUpdate;
|
|
|
|
XPMineSettingItemModel * aboutusItem = [[XPMineSettingItemModel alloc] init];
|
|
aboutusItem.title = [NSString stringWithFormat:@"%@%@",YMLocalizedString(@"XPMineAboutUsViewController0"), AppName];
|
|
aboutusItem.subTitle = @"";
|
|
aboutusItem.type = XPMineSettingItemType_About_Us;
|
|
|
|
NSArray * oneSection = @[phoneItem];
|
|
NSArray * twoSection = @[loginItem,payItem, notificaItem, blackListItem];
|
|
NSArray * threeSection = @[privacyItem];
|
|
NSArray * fourthSection = @[helperItem, feedbackItem, clearMemoryItem, updateItem, aboutusItem];
|
|
|
|
self.datasouce = @[oneSection, twoSection, threeSection, fourthSection];
|
|
}else{
|
|
XPMineSettingItemModel * blackListItem = [[XPMineSettingItemModel alloc] init];
|
|
blackListItem.title = YMLocalizedString(@"XPMineSettingPresent20");
|
|
blackListItem.subTitle = @"";
|
|
blackListItem.type = XPMineSettingItemType_Black_Manager;
|
|
|
|
XPMineSettingItemModel * phoneItem = [[XPMineSettingItemModel alloc] init];
|
|
phoneItem.title = YMLocalizedString(@"XPMineSettingPresent21");
|
|
phoneItem.subTitle = userinfo.isBindPhone ? userinfo.phone : @"";
|
|
phoneItem.type = XPMineSettingItemType_Phone;
|
|
self.phoneItem = phoneItem;
|
|
|
|
XPMineSettingItemModel * loginItem = [[XPMineSettingItemModel alloc] init];
|
|
loginItem.title = userinfo.isBindPasswd ? YMLocalizedString(@"XPMineLoginPasswordViewController6") : YMLocalizedString(@"XPMineSettingPresent23");
|
|
loginItem.subTitle = @"";
|
|
loginItem.type = XPMineSettingItemType_Login_Password;
|
|
self.loginItem = loginItem;
|
|
|
|
XPMineSettingItemModel * clearMemoryItem = [[XPMineSettingItemModel alloc] init];
|
|
clearMemoryItem.title = YMLocalizedString(@"XPMineSettingPresent24");
|
|
clearMemoryItem.subTitle = @"";
|
|
clearMemoryItem.type = XPMineSettingItemType_Clear_Memory;
|
|
|
|
XPMineSettingItemModel * deleteItem = [[XPMineSettingItemModel alloc] init];
|
|
deleteItem.title = YMLocalizedString(@"XPMineSettingPresent25");
|
|
deleteItem.subTitle = @"";
|
|
deleteItem.type = XPMineSettingItemType_Delete_Account;
|
|
|
|
NSArray * oneSection = @[blackListItem];
|
|
NSArray * twoSection = @[phoneItem, loginItem];
|
|
NSArray * threeSection = @[clearMemoryItem, deleteItem];
|
|
|
|
self.datasouce = @[oneSection, twoSection, threeSection];
|
|
}
|
|
}
|
|
|
|
[[self getView] getMineSettingDatasourceSuccess:self.datasouce];
|
|
}
|
|
|
|
// 获取用户信息
|
|
- (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];
|
|
}
|
|
|
|
|
|
/// 退出当前账号
|
|
- (void)logoutCurrentAccount {
|
|
if([XPRoomMiniManager shareManager].getRoomInfo) {
|
|
NSString *roomUid = [NSString stringWithFormat:@"%ld", [XPRoomMiniManager shareManager].getRoomInfo.uid];
|
|
///上报退房
|
|
[Api requestReportUserOutRoom:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) {
|
|
} uid:[[AccountInfoStorage instance] getUid] roomUid:roomUid ticket:[[AccountInfoStorage instance] getTicket]];
|
|
///退出房间
|
|
NSString * roomId = [NSString stringWithFormat:@"%ld", [XPRoomMiniManager shareManager].getRoomInfo.roomId];
|
|
[[NIMSDK sharedSDK].chatroomManager exitChatroom:roomId completion:nil];
|
|
[[RtcManager instance] exitRoom];
|
|
[[XPRoomMiniManager shareManager] configRoomInfo:nil];
|
|
[[XPRoomMiniManager shareManager] configUserInfo:nil];
|
|
[[XPRoomMiniManager shareManager] configCurrentMusic:nil isPlaying:NO];
|
|
[[XPRoomMiniManager shareManager] resetLocalMessage];
|
|
}
|
|
AccountModel * account = [[AccountInfoStorage instance] accountModel];
|
|
[Api logoutCurrentAccount:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
|
|
[[self getView] logoutCurrentAccountSuccess];
|
|
}] access_token:account.access_token];
|
|
[self logout];
|
|
}
|
|
|
|
#pragma mark - 版本更新
|
|
-(void)getVersionUpdate{
|
|
NSString *appVersion = [YYUtility appVersion];
|
|
NSString *os = @"ios";
|
|
NSString *channel = [YYUtility getAppSource];
|
|
[Api requestVersionUpdate:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
|
|
XPVersionUpdateModel *model = [XPVersionUpdateModel modelWithDictionary:data.data];
|
|
[[self getView] getVersionUpdate:model];
|
|
} fail:^(NSInteger code, NSString * _Nullable msg) {
|
|
[[self getView] getVersionUpdateFail];
|
|
} errorToast:NO] appVersion:appVersion os:os channel:channel];
|
|
}
|
|
|
|
@end
|