Files
mier_ios/SweetParty/主类/音悦新增/广播头条/SEARoomHeadlinesPublishView.m
2025-08-11 10:43:19 +08:00

149 lines
4.5 KiB
Objective-C

//
// SEARoomHeadlinesPublishView.m
// romantic
//
// Created by Xmac on 2024/5/28.
// Copyright © 2024 romantic. All rights reserved.
//
#import "SEARoomHeadlinesPublishView.h"
@interface SEARoomHeadlinesPublishView ()<UITextViewDelegate,UITextFieldDelegate>
@property (weak, nonatomic) IBOutlet UIView *mineView;
@property (weak, nonatomic) IBOutlet UITextView *textView;
@property (weak, nonatomic) IBOutlet UILabel *countLabel;
@property (weak, nonatomic) IBOutlet UITextField *currentPriceTF;
@property (weak, nonatomic) IBOutlet UIButton *confirmButton;
@property (nonatomic, assign) NSInteger currentPrice;
@property (nonatomic, assign) NSInteger pay_integral; //支付金币
@property (nonatomic, assign) NSInteger step_integral; //每次增加金币
@end
@implementation SEARoomHeadlinesPublishView
- (void)awakeFromNib
{
[super awakeFromNib];
self.currentPrice = 0;
[self setupUI];
self.confirmButton.backgroundColor = [UIColor bm_colorGradientChangeWithSize:CGSizeMake(APPW-30, 48) direction:(FXGradientChangeDirectionHorizontal) startColor:HEXCOLOR(0x9FF6DD) endColor:HEXCOLOR(0x0DFFB9)];
[self requestGetTopLineIntegral];
}
- (void)setupUI
{
self.mineView.frame = CGRectMake(0, APPH, APPW, APPH);
self.textView.delegate = self;
self.currentPriceTF.delegate = self;
}
- (IBAction)moneyAddPriceButtonClick:(UIButton *)sender {
[self endEditing:YES];
self.currentPrice+=self.step_integral;
self.currentPriceTF.text = [NSString stringWithFormat:@"%ld",self.currentPrice];
}
- (IBAction)moneySubtractButtonClick:(UIButton *)sender {
[self endEditing:YES];
if (self.currentPrice <= 0) {
self.currentPrice = 0;
}else{
self.currentPrice-=1;
}
self.currentPriceTF.text = [NSString stringWithFormat:@"%ld",self.currentPrice];
}
- (void)textFieldDidEndEditing:(UITextField *)textField
{
self.currentPrice = textField.text.integerValue;
}
- (IBAction)rechargeButtonClick:(UIButton *)sender {
[self sheetViewforViewClose];
if (self.topUpButtonClickBlock){
self.topUpButtonClickBlock();
}
}
- (IBAction)confirmButtonClick:(UIButton *)sender {
if (self.currentPrice == 0){
[HelpPageDefine showMessage:@"请输入金额"];
return;
}
[self publishToSendTrumpet];
}
- (void)publishToSendTrumpet
{
if (self.textView.text.length <= 0) {
[HelpPageDefine showMessage:@"请输入内容"];
return;
}
NSMutableDictionary *dict = [NSMutableDictionary dictionary];
[dict setValue:C_string(self.rid) forKey:@"rid"];
[dict setValue:[NSString stringWithFormat:@"%ld",self.currentPrice] forKey:@"pay_integral"];
[dict setValue:self.textView.text forKey:@"content"];
[[AFNetworkRequset shared] postRequestWithParams:dict Path:@"/api/user_top_line/publish_top_line" Loading:YES Hud:YES Success:^(id _Nonnull responseDic) {
[HelpPageDefine showMessage:responseDic[@"msg"]];
[self sheetViewforViewClose];
} Failure:^(id _Nonnull errorData) {
}];
}
- (void)requestGetTopLineIntegral
{
[[AFNetworkRequset shared] postRequestWithParams:@{} Path:@"/api/user_top_line/get_top_line_integral" Loading:YES Hud:YES Success:^(id _Nonnull responseDic) {
NSDictionary *data = [responseDic safeDictionaryForKey:@"data"];
self.pay_integral = [data safeIntForKey:@"pay_integral"];
self.step_integral = [data safeIntForKey:@"step_integral"];
self.currentPrice = self.pay_integral;
self.currentPriceTF.text = [NSString stringWithFormat:@"%ld",self.currentPrice];
} Failure:^(id _Nonnull errorData) {
}];
}
- (IBAction)cancelButtonClick:(UIButton *)sender {
[self sheetViewforViewClose];
}
- (void)sheetViewforViewAppear
{
//滑出动画
[UIView animateWithDuration:0.3 animations:^{
self.mineView.frame = CGRectMake(0, 0, ScreenWidth, self.mineView.height);
} completion:^(BOOL finished) {
}];
}
- (void)sheetViewforViewClose
{
self.backgroundColor = HEXCOLORA(0x000000, 0);
[UIView animateWithDuration:0.3 animations:^{
self.frame = CGRectMake(0, ScreenHeight, ScreenWidth, ScreenHeight);
} completion:^(BOOL finished) {
[self removeFromSuperview];
}];
}
- (void)textViewDidChange:(UITextView *)textView {
NSInteger maxLength = 30;
if (textView.text.length > maxLength) {
[HelpPageDefine showMessage:[NSString stringWithFormat:@"最多输入%ld字", maxLength]];
textView.text = [textView.text substringToIndex:maxLength];
}
_countLabel.text = [NSString stringWithFormat:@"%ld/30",textView.text.length];
}
@end