You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
203 lines
7.5 KiB
203 lines
7.5 KiB
![]()
2 years ago
|
//
|
||
|
// AddFeedbackViewController.m
|
||
|
// LekangGuard
|
||
|
//
|
||
|
// Created by ecell on 2023/7/4.
|
||
|
//
|
||
|
|
||
|
#import "AddFeedbackViewController.h"
|
||
|
|
||
|
@interface AddFeedbackViewController ()<UITextViewDelegate>
|
||
|
|
||
|
@property (nonatomic ,weak) UITextField *emailField;
|
||
|
@property (nonatomic ,weak) UITextField *phoneField;
|
||
|
@property (nonatomic ,weak) UITextField *themeField;
|
||
|
@property (nonatomic ,weak) UITextView *contentView;
|
||
|
|
||
|
@property (nonatomic ,weak) UILabel *tiLabel;
|
||
|
|
||
|
@property (nonatomic ,weak) UIButton *okBtn;
|
||
|
|
||
|
@end
|
||
|
|
||
|
@implementation AddFeedbackViewController
|
||
|
|
||
|
- (void)viewDidLoad {
|
||
|
[super viewDidLoad];
|
||
|
// Do any additional setup after loading the view.
|
||
|
|
||
|
self.zx_navTitle = @"反馈意见";
|
||
|
|
||
|
UIView *bgView = [UICommon ui_view:CGRectZero backgroundColor:KKWhiteColorColor cornerRadius:0 borderWidth:0 borderColor:KKClearColor];
|
||
|
bgView.frame = CGRectMake(0, iPhoneX_NavHeight, SCREEN_WIDTH, Adapted(110));
|
||
|
[self.view addSubview:bgView];
|
||
|
|
||
|
UIView *bgView1 = [UICommon ui_view:CGRectZero backgroundColor:KKWhiteColorColor cornerRadius:0 borderWidth:0 borderColor:KKClearColor];
|
||
|
bgView1.frame = CGRectMake(0, bgView.bottom+15, SCREEN_WIDTH, Adapted(55));
|
||
|
[self.view addSubview:bgView1];
|
||
|
|
||
|
UIView *bgView2 = [UICommon ui_view:CGRectZero backgroundColor:KKWhiteColorColor cornerRadius:0 borderWidth:0 borderColor:KKClearColor];
|
||
|
bgView2.frame = CGRectMake(0, bgView1.bottom+15, SCREEN_WIDTH, Adapted(230));
|
||
|
[self.view addSubview:bgView2];
|
||
|
|
||
|
NSArray *titleArr = @[@"号码:",@"邮箱:",@"主题:"];
|
||
|
NSArray *placeholderArr = @[@"请输入您的手机号",@"请输入您的邮箱",@"请输入你要反馈的主题"];
|
||
|
for (int i = 0; i < titleArr.count; i++)
|
||
|
{
|
||
|
UILabel *titleLabel = [UICommon ui_label:CGRectZero lines:0 align:NSTextAlignmentCenter font:FontADA_(14) textColor:KKTextBlackColor text:titleArr[i] Radius:0];
|
||
|
if (i < 2)
|
||
|
[bgView addSubview:titleLabel];
|
||
|
else
|
||
|
[bgView1 addSubview:titleLabel];
|
||
|
[titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
|
make.left.equalTo(self.view).offset(15);
|
||
|
if (i < titleArr.count-1)
|
||
|
make.top.equalTo(bgView).offset(i*55);
|
||
|
else
|
||
|
make.centerY.equalTo(bgView1);
|
||
|
make.height.mas_equalTo(Adapted(55));
|
||
|
}];
|
||
|
|
||
|
|
||
|
UITextField *textfield = [UICommon ui_textField:CGRectZero textColor:KKTextBlackColor backColor:KKClearColor font:FontADA_(14) maxTextNum:40 placeholderColor:KKGrey143 placeholder:placeholderArr[i] toMaxNum:nil change:nil];
|
||
|
if (i < 2)
|
||
|
[bgView addSubview:textfield];
|
||
|
else
|
||
|
[bgView1 addSubview:textfield];
|
||
|
if (i == 0)
|
||
|
{
|
||
|
textfield.keyboardType = UIKeyboardTypePhonePad;
|
||
|
self.phoneField = textfield;
|
||
|
}
|
||
|
else if (i == 1)
|
||
|
{
|
||
|
textfield.keyboardType = UIKeyboardTypeTwitter;
|
||
|
self.emailField = textfield;
|
||
|
}
|
||
|
else if (i == 2)
|
||
|
{
|
||
|
self.themeField = textfield;
|
||
|
}
|
||
|
[textfield mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
|
make.left.equalTo(self.view).offset(70);
|
||
|
make.right.equalTo(self.view.mas_right).inset(15);
|
||
|
make.centerY.equalTo(titleLabel);
|
||
|
make.height.mas_equalTo(Adapted(44));
|
||
|
}];
|
||
|
}
|
||
|
|
||
|
|
||
|
UITextView *textview = [UICommon ui_textView:CGRectZero textColor:KKTextBlackColor backColor:KKClearColor font:FontADA_(14) alignment:NSTextAlignmentLeft inputView:nil];
|
||
|
textview.delegate = self;
|
||
|
self.contentView = textview;
|
||
|
[bgView2 addSubview:textview];
|
||
|
[textview mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
|
make.left.right.equalTo(self.view).inset(15);
|
||
|
make.top.equalTo(bgView2).offset(15);
|
||
|
make.bottom.equalTo(bgView2.mas_bottom).inset(15);
|
||
|
}];
|
||
|
|
||
|
UILabel *tiLabel = [UICommon ui_label:CGRectZero lines:0 align:NSTextAlignmentCenter font:FontADA_(14) textColor:KKGrey219 text:@"请输入您的宝贵反馈内容" Radius:0];
|
||
|
self.tiLabel = tiLabel;
|
||
|
[bgView2 addSubview:tiLabel];
|
||
|
[tiLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
|
make.left.equalTo(textview).offset(5);
|
||
|
make.top.equalTo(textview).offset(8);
|
||
|
}];
|
||
|
|
||
|
UIButton *okBtn = [UICommon ui_buttonSimple:CGRectZero font:FontADA_(15) normalColor:KKWhiteColorColor normalText:@"提交" click:^(id x) {
|
||
|
[self AddFeedbackModel];
|
||
|
}];
|
||
|
okBtn.backgroundColor = KKMainColor;
|
||
|
okBtn.layer.cornerRadius = 5;
|
||
|
okBtn.layer.masksToBounds = YES;
|
||
|
self.okBtn = okBtn;
|
||
|
[self.view addSubview:okBtn];
|
||
|
[okBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
|
make.left.right.equalTo(self.view).inset(15);
|
||
|
make.bottom.equalTo(self.view.mas_bottom).inset(100);
|
||
|
make.height.mas_equalTo(Adapted(50));
|
||
|
}];
|
||
|
|
||
|
if (self.model)
|
||
|
{
|
||
|
self.phoneField.text = self.model.phoneNumber;
|
||
|
self.emailField.text = self.model.email;
|
||
|
self.themeField.text = self.model.docSubject;
|
||
|
self.contentView.text = self.model.content;
|
||
|
self.tiLabel.hidden = YES;
|
||
|
if([self.model.status isEqualToString:@"closed"])
|
||
|
{
|
||
|
self.okBtn.hidden = YES;
|
||
|
self.phoneField.enabled = NO;
|
||
|
self.emailField.enabled = NO;
|
||
|
self.themeField.enabled = NO;
|
||
|
self.contentView.editable = NO;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
- (void)textViewDidChange:(UITextView *)textView
|
||
|
{
|
||
|
self.tiLabel.hidden = textView.text.length > 0 ? YES : NO;
|
||
|
}
|
||
|
|
||
|
#pragma mark 新增意见反馈
|
||
|
/// 新增意见反馈
|
||
|
- (void)AddFeedbackModel
|
||
|
{
|
||
|
if (self.phoneField.text.length <= 0)
|
||
|
{
|
||
|
[UICommon MessageErrorText:@"请输入您的手机号"];
|
||
|
return;
|
||
|
}
|
||
|
if (self.emailField.text.length <= 0)
|
||
|
{
|
||
|
[UICommon MessageErrorText:@"请输入您的邮箱"];
|
||
|
return;
|
||
|
}
|
||
|
if (self.themeField.text.length <= 0)
|
||
|
{
|
||
|
[UICommon MessageErrorText:@"请输入您要反馈的主题"];
|
||
|
return;
|
||
|
}
|
||
|
if (self.contentView.text.length <= 0)
|
||
|
{
|
||
|
[UICommon MessageErrorText:@"请输入您要反馈的内容"];
|
||
|
return;
|
||
|
}
|
||
|
[UICommon MessageUpload:@"加载中"];
|
||
|
NSMutableDictionary *parameters = [NSMutableDictionary dictionary];
|
||
|
[parameters setValue:self.contentView.text forKey:@"content"];
|
||
|
[parameters setValue:self.emailField.text forKey:@"email"];
|
||
|
[parameters setValue:self.phoneField.text forKey:@"phoneNumber"];
|
||
|
if (self.model)
|
||
|
[parameters setValue:self.model.Id forKey:@"id"];
|
||
|
[parameters setValue:self.themeField.text forKey:@"docSubject"];
|
||
|
[[[APIManager sharedManager] APPOST:self.model ? FeedbackUpdate_URL : AddFeedback_URL parameters:parameters isJson:YES resultClass:nil] subscribeNext:^(id _Nullable x) {
|
||
|
[UICommon HidenLoading];
|
||
|
[UICommon MessageSuccessText:self.model ? @"更新成功" : @"提交成功"];
|
||
|
self.addOk();
|
||
|
AfterDispatch(1, ^{
|
||
|
[self.navigationController popViewControllerAnimated:YES];
|
||
|
});
|
||
|
} error:^(NSError * _Nullable error) {
|
||
|
NSDictionary *dic = error.userInfo;
|
||
|
[UICommon MessageErrorText:dic[NSLocalizedDescriptionKey]];
|
||
|
}];
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
/*
|
||
|
#pragma mark - Navigation
|
||
|
|
||
|
// In a storyboard-based application, you will often want to do a little preparation before navigation
|
||
|
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
|
||
|
// Get the new view controller using [segue destinationViewController].
|
||
|
// Pass the selected object to the new view controller.
|
||
|
}
|
||
|
*/
|
||
|
|
||
|
@end
|