// // QXPublishViewController.m // QXLive // // Created by 启星 on 2025/5/27. // #import "QXPublishViewController.h" #import "QXTextView.h" #import "QXUserInfoEditFooterView.h" #import "QXSelectedTopicView.h" #import "QXTopicListView.h" #import "QXLocationManager.h" #import "QXDynamicNetwork.h" @interface QXPublishViewController () @property (nonatomic,strong)QXTextView *textView; @property (nonatomic,strong)QXSelectedTopicView *topicView; @property (nonatomic,strong)QXUserInfoEditFooterView *pickerView; @property (nonatomic,strong)NSString *images; @property (nonatomic,strong)NSString *city; @property (nonatomic,strong)UIButton* commitBtn; @end @implementation QXPublishViewController - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view. } -(void)viewWillAppear:(BOOL)animated{ [super viewWillAppear:animated]; [self.navigationController setNavigationBarHidden:NO animated:YES]; } -(void)setNavgationItems{ [super setNavgationItems]; self.navigationItem.title = QXText(@"动态发布"); } -(void)initSubViews{ self.topicView = [[QXSelectedTopicView alloc] initWithFrame:CGRectMake(16, NavContentHeight+12, SCREEN_WIDTH-32, 44)]; self.topicView.backgroundColor = RGB16(0xEFF2F8); [self.topicView addRoundedCornersWithRadius:11]; MJWeakSelf [self.topicView addTapBlock:^(id _Nonnull obj) { QXTopicListView *listView = [[QXTopicListView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, ScaleWidth(374))]; listView.selecctedTopicBlock = ^(NSArray * _Nonnull topicArr) { weakSelf.topicView.selectedTopic = topicArr; }; [[QXGlobal shareGlobal] showView:listView popType:(PopViewTypeBottomToUpActionSheet) tapDismiss:YES finishBlock:^{ }]; }]; [self.view addSubview:self.topicView]; self.textView = [[QXTextView alloc] initWithFrame:CGRectMake(16, self.topicView.bottom+12, SCREEN_WIDTH-32, 180)]; self.textView.placehoulder = QXText(@"此刻想和大家分享点什么"); self.textView.font = [UIFont systemFontOfSize:12]; self.textView.maxLength = 1200; self.textView.backgroundColor = [UIColor whiteColor]; [self.textView addRoundedCornersWithRadius:7]; [self.view addSubview:self.textView]; int itemWidth = (self.view.width-16*2-20*2)/3; self.pickerView = [[QXUserInfoEditFooterView alloc] initWithFrame:CGRectMake(0, self.textView.bottom, SCREEN_WIDTH, itemWidth*3+12*2+20*2)]; self.pickerView.backgroundColor = [UIColor clearColor]; self.pickerView.maxCount = 9; self.pickerView.hideTitle = YES; self.pickerView.delegate = self; [self.view addSubview:self.pickerView]; [[QXLocationManager shareManager] startLoction]; [QXLocationManager shareManager].delegate = self; self.commitBtn = [[UIButton alloc] init]; [self.commitBtn setTitle:QXText(@"发布") forState:(UIControlStateNormal)]; self.commitBtn.titleLabel.font = [UIFont systemFontOfSize:14];; [self.commitBtn setTitleColor:QXConfig.btnTextColor forState:(UIControlStateNormal)]; [self.commitBtn addRoundedCornersWithRadius:21]; self.commitBtn.backgroundColor = QXConfig.themeColor; [self.commitBtn addTarget:self action:@selector(commitAction) forControlEvents:(UIControlEventTouchUpInside)]; [self.view addSubview:self.commitBtn]; [self.commitBtn mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(38); make.right.mas_equalTo(-38); make.height.mas_equalTo(42); make.bottom.mas_equalTo(-(kSafeAreaBottom)); }]; } -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{ [self.view endEditing:YES]; } -(void)commitAction{ // if (self.topicView.selectedTopic.count == 0) { // showToast(@"请选择话题"); // return; // } if (self.textView.text.length == 0) { showToast(@"发布内容不能为空"); return; } // if (self.images.length == 0) { // showToast(@"请上传图片"); // return; // } NSString *topic = @""; if (self.topicView.selectedTopic.count > 0) { for (QXTopicModel*md in self.topicView.selectedTopic) { if (topic.length == 0) { topic = [topic stringByAppendingFormat:@"%@",md.topic_id]; }else{ topic = [topic stringByAppendingFormat:@",%@",md.topic_id]; } } } MJWeakSelf [QXDynamicNetwork publishDynamicWithImages:self.images content:self.textView.text topic_id:topic ip:self.city successBlock:^(NSDictionary * _Nonnull dict) { if (weakSelf.publishFinishBlock) { weakSelf.publishFinishBlock(); } [weakSelf.navigationController popViewControllerAnimated:YES]; } failBlock:^(NSError * _Nonnull error, NSString * _Nonnull msg) { }]; } -(void)locationSuccessWithCity:(NSString *)city province:(NSString * _Nonnull)province area:(NSString * _Nonnull)area address:(NSString * _Nonnull)address{ [[QXLocationManager shareManager] stopLoction]; self.city = city; } -(void)didUploadFinishedWithImageUrlList:(NSArray *)urlList{ self.images = [urlList componentsJoinedByString:@","]; } @end