123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899 |
- //
- // XYVoiceRoomCreateViewModel.m
- // Starbuds
- //
- // Created by 翟玉磊 on 2020/7/7.
- // Copyright © 2020 翟玉磊. All rights reserved.
- //
- #import "XYVoiceRoomCreateViewModel.h"
- #import "XYVoiceRoomCreateCellModel.h"
- @implementation XYVoiceRoomCreateViewModel
- - (instancetype)init
- {
- self = [super init];
- if (self) {
-
- }
- return self;
- }
- - (void)getInitValueRequestCompleted:(void(^)(NSError *error))completed {
-
- [[XYVoiceRoomAPIManager new] getAuthRtcConfigSuccessHandler:^(ZYLResponseModel *responseModel) {
-
- // 获取语音房标签
- NSArray *rtcRoomCategories = responseModel.data[@"rtcRoomCategories"];
- NSMutableArray *tempTags = [NSMutableArray array];
- for (NSDictionary *dict in rtcRoomCategories) {
- XYVoiceRoomTagModel *model = XYVoiceRoomTagModel.new;
- model.tagName = dict[@"categoryName"];
- model.tagId = dict[@"categoryId"];
- [tempTags addObject:model];
- }
- self.voiceRoomTagModels = [tempTags copy];
-
- // 获取语音房类型
- NSArray *rtcRoomTypes = responseModel.data[@"rtcRoomTypes"];
- NSMutableArray *tempTypes = [NSMutableArray array];
- for (NSDictionary *dict in rtcRoomTypes) {
- XYVoiceRoomTypeModel *model = XYVoiceRoomTypeModel.new;
- model.typeName = dict[@"roomTypeName"];
- model.typeId = [NSString stringWithFormat:@"%ld", [dict[@"roomType"] integerValue]];
- [tempTypes addObject:model];
- }
- self.voiceRoomTypeModels = [tempTypes copy];
-
- XYVoiceRoomCreateCellModel *nameModel = [XYVoiceRoomCreateCellModel createWithTitle:kLocalizedString(@"房间名称") placeholder:kLocalizedString(@"请输入房间名称") isShowMore:NO isShowBottomLine:YES isInput:YES];
- [self.dataSource addObject:nameModel];
-
- XYVoiceRoomCreateCellModel *tagModel = [XYVoiceRoomCreateCellModel createWithTitle:kLocalizedString(@"房间标签") placeholder:kLocalizedString(@"默认") isShowMore:YES isShowBottomLine:YES isInput:NO];
- // 获取默认标签
- XYVoiceRoomTagModel *categoryModel = [self.voiceRoomTagModels firstObject];
- if (categoryModel) {
- tagModel.content = categoryModel.tagName;
- tagModel.infoId = categoryModel.tagId;
- }
- [self.dataSource addObject:tagModel];
-
- XYVoiceRoomCreateCellModel *typeModel = [XYVoiceRoomCreateCellModel createWithTitle:kLocalizedString(@"房间类型") placeholder:kLocalizedString(@"默认") isShowMore:YES isShowBottomLine:NO isInput:NO];
- // 获取默认标签
- XYVoiceRoomTypeModel *roomTypeModel = [self.voiceRoomTypeModels firstObject];
- if (roomTypeModel) {
- typeModel.content = roomTypeModel.typeName;
- typeModel.infoId = roomTypeModel.typeId;
- }
- [self.dataSource addObject:typeModel];
-
- !completed?:completed(nil);
- } failureHandler:^(ZYLNetworkError *error) {
- !completed?:completed(error);
- }];
- }
- - (NSArray *)voiceRoomTagModels {
- if (!_voiceRoomTagModels) {
- _voiceRoomTagModels = [NSArray array];
- }
- return _voiceRoomTagModels;
- }
- - (NSArray *)voiceRoomTypeModels {
- if (!_voiceRoomTypeModels) {
- _voiceRoomTypeModels = [NSArray array];
- }
- return _voiceRoomTypeModels;
- }
- @end
- @implementation XYVoiceRoomTagModel
- @end
- @implementation XYVoiceRoomTypeModel
- @end
|