| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200 |
- //
- // EvaluateViewController.m
- // jitao
- //
- // Created by 罗云飞 on 2018/8/10.
- // Copyright © 2018年 罗云飞. All rights reserved.
- //
- #import "EvaluateViewController.h"
- #import "HCSStarRatingView.h"
- @interface EvaluateViewController ()<UITextViewDelegate>
- {
- NSString *descriptionStr;//成果描述 接收字符串
- NSString *star;//
- }
- @end
- @implementation EvaluateViewController
- - (void)viewDidLoad {
- [super viewDidLoad];
- [self setNavTitle:@"发表评价"];
- star = @"0";
- [self loadUI];
-
- // Do any additional setup after loading the view.
- }
- - (void)loadUI{
- UITextView *_textview = [[UITextView alloc] init];
- _textview.font = NewFont(fitScreenWidth(12));
- _textview.textColor = NewRGBColor(199, 199, 205, 1);
- _textview.backgroundColor = [UIColor colorWithString:@"#F2F2F2"];
- _textview.text = @"请在此输入您对商品的评价";
- ViewBorderRadius(_textview, 5, 1, NewLineGrayColor);
- _textview.delegate = self;
- [self.view addSubview:_textview];
-
- _textview.sd_layout
- .leftSpaceToView(self.view, 15)
- .rightSpaceToView(self.view, 15)
- .topSpaceToView(self.view, NavHeader+15)
- .heightIs(215);
-
- UILabel *fuwu = [UILabel new];
- fuwu.text = @"服务满意度";
- fuwu.font = NewFont(fitScreenWidth(13));
- [fuwu setSingleLineAutoResizeWithMaxWidth:0];
- [self.view addSubview:fuwu];
-
- fuwu.sd_layout
- .leftEqualToView(_textview)
- .topSpaceToView(_textview, 20)
- .heightIs(15);
-
- HCSStarRatingView *starRatingView = [[HCSStarRatingView alloc] initWithFrame:CGRectMake(50, 200, 200, 15)];
- starRatingView.maximumValue = 5;
- starRatingView.minimumValue = 0;
- starRatingView.value = 0;
- starRatingView.tintColor = NewButtonColor;
- [starRatingView addTarget:self action:@selector(didChangeValue:) forControlEvents:UIControlEventValueChanged];
- [self.view addSubview:starRatingView];
-
- starRatingView.sd_layout
- .leftSpaceToView(fuwu, 10)
- .heightIs(30)
- .widthIs(100)
- .centerYEqualToView(fuwu);
-
- UIButton *tijiaoPJ = [UIButton new];
- [tijiaoPJ setTitle:@"提交评价" forState:UIControlStateNormal];
- [tijiaoPJ setBackgroundColor:NewButtonColor];
- tijiaoPJ.titleLabel.font = NewFont(18);
- ViewRadius(tijiaoPJ, 6);
- NewTouchUpInside(tijiaoPJ, tijiaoPJclick:);
- [self.view addSubview:tijiaoPJ];
-
- tijiaoPJ.sd_layout
- .leftSpaceToView(self.view, 45)
- .rightSpaceToView(self.view, 45)
- .heightIs(45)
- .topSpaceToView(_textview, 78);
- }
- - (void)tijiaoPJclick:(UIButton *)sender {
- NSLog(@"%@",@"提交评价");
- NSMutableDictionary *parameters = NewMutableDictionaryInit;
- if (descriptionStr == nil || [descriptionStr isEqualToString:@""]) {
- // [self.view makeToast:@"请先输入评价内容" duration:1.0 position:CSToastPositionBottom];
- [MBProgressHUD showError:@"请先输入评价内容" toView:self.view];
- return;
- }
- if ([star isEqualToString:@"0"]) {
- [MBProgressHUD showError:@"请给商品评价" toView:self.view];
- return;
- }
- [parameters safeSetObject:self.commodityId forKey:@"commodityId"];//
- [parameters safeSetObject:descriptionStr forKey:@"content"];//
- [parameters safeSetObject:star forKey:@"star"];//
- [parameters safeSetObject:self.orderNo forKey:@"orderNo"];//
-
- if ([self.pingluntype isEqualToString:@"0"] || [self.pingluntype isEqualToString:@"1"]) {
- [parameters safeSetObject:@"0" forKey:@"commodityType"];//商品类型 0-项目 1-顾问、专家
- }else if ([self.pingluntype isEqualToString:@"5"] || [self.pingluntype isEqualToString:@"6"]){
- [parameters safeSetObject:@"1" forKey:@"commodityType"];//商品类型 0-项目 1-顾问、专家
- }
-
- [NetworkRequestManager requestPostWithInterfacePrefix:JT_NewapplyComment parameters:parameters onSuccess:^(id requestData) {
- if ([requestData[@"error"] count] !=0) {
- for (NSDictionary *dic in requestData[@"error"]) {
- [MBProgressHUD showError:dic[@"message"] toView:self.view];
- }
- }else{
- [MBProgressHUD showSuccess:@"提交评价成功!" toView:self.view];
- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
- NewPopViewController;
- });
- }
- } onFailure:^{
-
- }];
-
- //0-项目,1-成果,2-需求,3-专家,4-顾问
- // 商品类型 0-项目 1-顾问、专家
- // [NetworkRequestManager requestPostWithInterfacePrefix:JT_NewapplyComment parameters:parameters onSuccess:^(id requestData) {
- // if ([requestData[@"error"] count] !=0) {
- // for (NSDictionary *dic in requestData[@"error"]) {
- // [MBProgressHUD showError:dic[@"message"] toView:self.view];
- // }
- // }else{
- // [MBProgressHUD showSuccess:@"提交评价成功!" toView:self.view];
- // dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
- // NewPopViewController;
- // });
- // }
- // } onFailure:^{
- //
- // }];
- }
- - (void)didChangeValue:(HCSStarRatingView *)sender{
- NSLog(@"Changed rating to %.1f", sender.value);
- NSInteger haha = sender.value;
- star = [NSString stringWithFormat:@"%ld",haha];
- }
- #pragma mark - UITextView获得焦点之后,并且已经是第一响应者
- -(void)textViewDidBeginEditing:(UITextView *)textView
- {
- // NSLog(@"UITextView获得焦点之后,并且已经是第一响应者");
- if ([textView.text isEqualToString:@"请在此输入您对商品的评价"]) {
- textView.text = @"";
- textView.textColor = NewGrayColor;
- }
- }
- #pragma mark - UITextView失去焦点之后
- -(void)textViewDidEndEditing:(UITextView *)textView
- {
- //NSLog(@"UITextView失去焦点");
- if ([textView.text isEqualToString:@""] || textView.text.length == 0) {
- textView.text = @"请在此输入您对商品的评价";
- textView.textColor = NewRGBColor(199, 199, 205, 1);
- }
- }
- #pragma mark - 详细地址限制字数
- -(void)textViewDidChangeSelection:(UITextView *)textView
- {
- if(textView.text.length > 500){
- textView.text = [textView.text substringWithRange:NSMakeRange(0,500)];
- }
- if (textView.text.length > 0) {
- NSLog(@"textView.text:%@",textView.text);
- if ([textView.text isEqualToString:@"请在此输入您对商品的评价"]) {
- descriptionStr = @"";
- }else{
- descriptionStr = nil;
- descriptionStr = textView.text;
- }
- }
- }
- - (void)didReceiveMemoryWarning {
- [super didReceiveMemoryWarning];
- // Dispose of any resources that can be recreated.
- }
- /*
- #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
|