This commit is contained in:
启星
2025-08-11 10:43:19 +08:00
commit fb2c58d96f
8839 changed files with 709982 additions and 0 deletions

View File

@@ -0,0 +1,78 @@
//
// UserManager.h
// MoHuanXingYu
//
// Created by aa on 2019/6/12.
// Copyright © 2019 MoHuanXingYu. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface BJUserInfo : NSObject
/*用户token*/
@property(nonatomic, copy) NSString *login_token;
/*用户头像*/
@property(nonatomic, copy) NSString *head_pic;
/*用户昵称*/
@property(nonatomic, copy) NSString *nick_name;
/*用户token*/
@property(nonatomic, copy) NSString *uid;
/*用户user_name手机号*/
@property(nonatomic, copy) NSString *user_name;
/*TXIM user_sig*/
@property(nonatomic, copy) NSString *user_sig;
@property(nonatomic, copy) NSString *guild_id;
/***********下面方法暂时废弃**********/
//@property (nonatomic,copy)NSString *userid;//用户id
@property (nonatomic,copy)NSString *headimgurl;//头像
@property (nonatomic,copy)NSString *phone;//手机号
@property (nonatomic,copy)NSString *username;//用户名
@property (nonatomic,copy)NSString *nickname;//用户昵称
@property (nonatomic,copy)NSString *token;//用户token
//@property (nonatomic,copy)NSString *birthday;//生日
@property (nonatomic,copy)NSString *openid;//
@property (nonatomic,copy)NSString *ry_token;//
@property (nonatomic,copy)NSString *ry_uid;//
@property (nonatomic,copy)NSString *sex;//性别
@end
@interface BJUserManager : NSObject
/// 刷新并存储用户信息
/// @param finishBlock 回调
+ (void)bj_refreshUserInfo:(void(^)(BOOL isOk))finishBlock;
/**
存储用户信息
@param dic 服务器获取来的用户信息字典
@return 存储结果
*/
+ (BOOL)saveUserInfo:(NSDictionary *)dic;
/**
取用户信息
@return 返回用户信息模型
*/
+ (BJUserInfo *)userInfo;
/**
清空用户信息
@return 清空结果
*/
+ (BOOL)clearUserInfo;
@end

View File

@@ -0,0 +1,91 @@
//
// UserManager.m
// MoHuanXingYu
//
// Created by aa on 2019/6/12.
// Copyright © 2019 MoHuanXingYu. All rights reserved.
//
#import "BJUserManager.h"
@implementation BJUserInfo
- (NSString *)login_token {
return C_string(GVUSER.token);
}
@end
@implementation BJUserManager
+ (void)onUpdatePhoneHistory:(NSString *)head_pic user_name:(NSString *)user_name {
if (user_name.length <= 0) {
return;
}
NSArray *arr = [[NSUserDefaults standardUserDefaults] objectForKey:Login_Phone_History];
NSMutableArray *mArr = [[NSMutableArray alloc] initWithArray:arr];
NSInteger index = -1;
for (NSInteger i = 0; i < mArr.count; i++) {
NSDictionary *dict = mArr[i];
if ([user_name isEqualToString:dict[@"user_name"]]) {
index = i;
}
}
NSDictionary *dict = @{@"head_pic":head_pic, @"user_name":user_name};
if (index == -1) {
[mArr insertObject:dict atIndex:0];
}else {
mArr[index] = dict;
}
[[NSUserDefaults standardUserDefaults] setObject:[mArr copy] forKey:Login_Phone_History];
[[NSUserDefaults standardUserDefaults] synchronize];
}
+ (void)bj_refreshUserInfo:(void(^)(BOOL isOk))finishBlock {
[RCMicHTTP postWithURLString:@"/api/user/get_user_info" parameters:nil response:^(RCMicHTTPResult *result) {
if (result.success) {
if (result.errorCode == 200 && [result.content isKindOfClass:NSDictionary.class]) {
[BJUserManager saveUserInfo:result.content];
finishBlock? finishBlock(YES) : nil;
}else {
finishBlock? finishBlock(NO) : nil;
// [SVProgressHUD showInfoWithStatus:result.message];
}
}else {
finishBlock? finishBlock(NO) : nil;
// [SVProgressHUD showInfoWithStatus:@"网络错误"];
}
}];
}
+ (BOOL)saveUserInfo:(NSDictionary *)dic {
GVUSER.rawUserDict = dic;
NSString *loginToken = [dic safeStringForKey:@"login_token"];
if (loginToken.length > 0) {
GVUSER.token = loginToken;
}
[BJUserManager onUpdatePhoneHistory:[dic safeStringForKey:@"head_pic"] user_name:[dic safeStringForKey:@"user_name"]];
return YES;
}
+ (BJUserInfo *)userInfo {
NSDictionary *data = GVUSER.rawUserDict;
if ([data isKindOfClass:NSDictionary.class] && data.allKeys.count>0) {
BJUserInfo *model = [BJUserInfo mj_objectWithKeyValues:data];
return model;
}
return nil;
}
+ (BOOL)clearUserInfo
{
GVUSER.rawUserDict = @{};
GVUSER.token = @"";
return YES;
}
@end

View File

@@ -0,0 +1,121 @@
//
// MLRoomInformationModel.h
// MoHuanXingYu
//
// Created by aa on 2019/6/14.
// Copyright © 2019 MoHuanXingYu. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface MLRoomInformationModel : NSObject
//房间ID
@property(nonatomic, copy) NSString *rid;
//房间号
@property(nonatomic, copy) NSString *room_number;
//房间名字
@property(nonatomic, copy) NSString *room_name;
//房间封面
@property(nonatomic, copy) NSString *room_cover;
//厅主ID
@property(nonatomic, copy) NSString *room_owner_uid;
//房间公告
@property(nonatomic, copy) NSString *room_intro;
//房间是否在线
@property(nonatomic, copy) NSString *is_online;
//游客数量
@property(nonatomic, copy) NSString *visitor_num;
//直播间背景图片
@property(nonatomic, copy) NSString *room_background_image;
//是否收藏了该直播间1收藏2未收藏
@property(nonatomic, copy) NSString *is_collect;
//厅主魅力值
@property(nonatomic, copy) NSString *room_owner_meili;
//欢迎语,系统通知
@property(nonatomic, copy) NSString *room_welcome;
//身份1房主2管理员其他普通用户
@property(nonatomic, copy) NSString *identity;
/*是否显示转盘*/
@property(nonatomic, strong) NSString *box_off;
/*房主信息*/
@property(nonatomic, strong) NSDictionary *room_owner_info;
/*-----------------下面属性废弃----------------*/
@property (nonatomic, strong) NSString *openid;
@property (nonatomic, strong) NSString *uid;
@property (nonatomic, strong) NSString *room_type;
@property (nonatomic, strong) NSString *week_star;
@property (nonatomic, strong) NSString *ranking;
@property (nonatomic, strong) NSString *freshTime;
@property (nonatomic, strong) NSString *numid;
@property (nonatomic, strong) NSString *updated_at;
@property (nonatomic, strong) NSString *sex;
@property (nonatomic, strong) NSString *nickname;
@property(nonatomic, copy) NSString *bright_num;//靓号,为空不是靓号
@property(nonatomic, copy) NSString *room_people;//房间在线人数
@property(nonatomic, copy) NSString *send_gift_price;//判断是否显示金蛋或宝箱1显示0不显示
@property (nonatomic, strong) NSString *room_status;
@property (nonatomic, strong) NSString *roomBlack;
@property (nonatomic, strong) NSString *secret_chat;
@property (nonatomic, strong) NSString *roomAdmin;
@property (nonatomic, strong) NSString *is_top;
//进入房间的用户的身份判断
//1房主 4评委 2管理员 5一般用户
@property (nonatomic, strong) NSString *user_type;
@property (nonatomic, strong) NSString *room_background;
@property (nonatomic, strong) NSString *created_at;
@property (nonatomic, strong) NSString *room_pass;
@property (nonatomic, strong) NSString *is_popular;
@property (nonatomic, strong) NSString *name;
@property (nonatomic, strong) NSString *giftPrice;
@property (nonatomic, strong) NSString *headimgurl;
@property (nonatomic, strong) NSString *is_mykeep;//1: 已收藏 2为收藏
@property (nonatomic, strong) NSString *is_sound;
@property (nonatomic, strong) NSString *is_speak;
@property (nonatomic, strong) NSString *uid_sound;
@property (nonatomic, strong) NSString *uid_black;
@property (nonatomic, assign) BOOL isBanned;
@property (nonatomic, strong) NSString *is_afk;
@property (nonatomic, strong) NSString *back_img;
@property (nonatomic, strong) NSString *hot;
@property (nonatomic, strong) NSString *mic_color;
@property (nonatomic, strong) NSString *txk;
@property(nonatomic, copy) NSString *meili;//新增主播魅力值
+(instancetype)currentAccount;
@end
@interface MLRoomInformationManager : NSObject
/**
存储用户信息
@param dic 服务器获取来的用户信息字典
@return <#return value description#>
*/
+ (BOOL)saveUserInfo:(MLRoomInformationModel *)dic;
/**
取用户信息
@return 返回用户信息模型
*/
+ (MLRoomInformationModel *)userInfo;
/**
清空用户信息
@return <#return value description#>
*/
+ (BOOL)clearUserInfo;
@end

View File

@@ -0,0 +1,97 @@
//
// MLRoomInformationModel.m
// MoHuanXingYu
//
// Created by aa on 2019/6/14.
// Copyright © 2019 MoHuanXingYu. All rights reserved.
//
#import "MLRoomInformationModel.h"
#import <MJExtension.h>
@implementation MLRoomInformationModel
+(instancetype)currentAccount{
static MLRoomInformationModel *account;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
if (!account) {
account = [[MLRoomInformationModel alloc] init];
account.isBanned = YES;
}
});
return account;
}
@end
@implementation MLRoomInformationManager
+ (BOOL)saveUserInfo:(MLRoomInformationModel *)dic
{
return [NSKeyedArchiver archiveRootObject:[dic mj_keyValues] toFile:[self path]];
}
+ (MLRoomInformationModel *)userInfo
{
id data = [NSKeyedUnarchiver unarchiveObjectWithFile:[self path]];
MLRoomInformationModel *model = [MLRoomInformationModel mj_objectWithKeyValues:data];
model.isBanned = YES;
return model;
}
+ (BOOL)clearUserInfo
{
NSFileManager *defaultManager = [NSFileManager defaultManager];
if ([defaultManager isDeletableFileAtPath:[self path]])
{
//
return [defaultManager removeItemAtPath:[self path] error:nil];
}
else
{
return NO;
}
}
/**
Documents/ ()iTunes
Library,CachesiTunes.
Library/Caches: 使()iTunes
Library/Preferences: NSUserDefaultsplistiTunes
@return <#return value description#>
*/
+(NSString *)path
{
//
// NSString *homeDir = NSHomeDirectory();
// // Documents
// NSString *docDir = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask,YES) firstObject];
// //Library
// NSString *libDir = [NSSearchPathForDirectoriesInDomains(NSLibraryDirectory,NSUserDomainMask,YES) lastObject];
// // cache
// NSString *cachesDir = [NSSearchPathForDirectoriesInDomains(NSCachesDirectory,NSUserDomainMask,YES) firstObject];
// // tmp
NSString *tmpDir = NSTemporaryDirectory();
// //
// NSString *bundle = [[NSBundle mainBundle] bundlePath];
NSString *name = @"MLRoomInformationModel";
NSString *type = @"sql";
NSString *allName = [NSString stringWithFormat:@"%@.%@",name,type];
return [tmpDir stringByAppendingPathComponent:allName];;
}
@end