EvaluateViewController.m 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. //
  2. // EvaluateViewController.m
  3. // jitao
  4. //
  5. // Created by 罗云飞 on 2018/8/10.
  6. // Copyright © 2018年 罗云飞. All rights reserved.
  7. //
  8. #import "EvaluateViewController.h"
  9. #import "HCSStarRatingView.h"
  10. @interface EvaluateViewController ()<UITextViewDelegate>
  11. {
  12. NSString *descriptionStr;//成果描述 接收字符串
  13. NSString *star;//
  14. }
  15. @end
  16. @implementation EvaluateViewController
  17. - (void)viewDidLoad {
  18. [super viewDidLoad];
  19. [self setNavTitle:@"发表评价"];
  20. star = @"0";
  21. [self loadUI];
  22. // Do any additional setup after loading the view.
  23. }
  24. - (void)loadUI{
  25. UITextView *_textview = [[UITextView alloc] init];
  26. _textview.font = NewFont(fitScreenWidth(12));
  27. _textview.textColor = NewRGBColor(199, 199, 205, 1);
  28. _textview.backgroundColor = [UIColor colorWithString:@"#F2F2F2"];
  29. _textview.text = @"请在此输入您对商品的评价";
  30. ViewBorderRadius(_textview, 5, 1, NewLineGrayColor);
  31. _textview.delegate = self;
  32. [self.view addSubview:_textview];
  33. _textview.sd_layout
  34. .leftSpaceToView(self.view, 15)
  35. .rightSpaceToView(self.view, 15)
  36. .topSpaceToView(self.view, NavHeader+15)
  37. .heightIs(215);
  38. UILabel *fuwu = [UILabel new];
  39. fuwu.text = @"服务满意度";
  40. fuwu.font = NewFont(fitScreenWidth(13));
  41. [fuwu setSingleLineAutoResizeWithMaxWidth:0];
  42. [self.view addSubview:fuwu];
  43. fuwu.sd_layout
  44. .leftEqualToView(_textview)
  45. .topSpaceToView(_textview, 20)
  46. .heightIs(15);
  47. HCSStarRatingView *starRatingView = [[HCSStarRatingView alloc] initWithFrame:CGRectMake(50, 200, 200, 15)];
  48. starRatingView.maximumValue = 5;
  49. starRatingView.minimumValue = 0;
  50. starRatingView.value = 0;
  51. starRatingView.tintColor = NewButtonColor;
  52. [starRatingView addTarget:self action:@selector(didChangeValue:) forControlEvents:UIControlEventValueChanged];
  53. [self.view addSubview:starRatingView];
  54. starRatingView.sd_layout
  55. .leftSpaceToView(fuwu, 10)
  56. .heightIs(30)
  57. .widthIs(100)
  58. .centerYEqualToView(fuwu);
  59. UIButton *tijiaoPJ = [UIButton new];
  60. [tijiaoPJ setTitle:@"提交评价" forState:UIControlStateNormal];
  61. [tijiaoPJ setBackgroundColor:NewButtonColor];
  62. tijiaoPJ.titleLabel.font = NewFont(18);
  63. ViewRadius(tijiaoPJ, 6);
  64. NewTouchUpInside(tijiaoPJ, tijiaoPJclick:);
  65. [self.view addSubview:tijiaoPJ];
  66. tijiaoPJ.sd_layout
  67. .leftSpaceToView(self.view, 45)
  68. .rightSpaceToView(self.view, 45)
  69. .heightIs(45)
  70. .topSpaceToView(_textview, 78);
  71. }
  72. - (void)tijiaoPJclick:(UIButton *)sender {
  73. NSLog(@"%@",@"提交评价");
  74. NSMutableDictionary *parameters = NewMutableDictionaryInit;
  75. if (descriptionStr == nil || [descriptionStr isEqualToString:@""]) {
  76. // [self.view makeToast:@"请先输入评价内容" duration:1.0 position:CSToastPositionBottom];
  77. [MBProgressHUD showError:@"请先输入评价内容" toView:self.view];
  78. return;
  79. }
  80. if ([star isEqualToString:@"0"]) {
  81. [MBProgressHUD showError:@"请给商品评价" toView:self.view];
  82. return;
  83. }
  84. [parameters safeSetObject:self.commodityId forKey:@"commodityId"];//
  85. [parameters safeSetObject:descriptionStr forKey:@"content"];//
  86. [parameters safeSetObject:star forKey:@"star"];//
  87. [parameters safeSetObject:self.orderNo forKey:@"orderNo"];//
  88. if ([self.pingluntype isEqualToString:@"0"] || [self.pingluntype isEqualToString:@"1"]) {
  89. [parameters safeSetObject:@"0" forKey:@"commodityType"];//商品类型 0-项目 1-顾问、专家
  90. }else if ([self.pingluntype isEqualToString:@"5"] || [self.pingluntype isEqualToString:@"6"]){
  91. [parameters safeSetObject:@"1" forKey:@"commodityType"];//商品类型 0-项目 1-顾问、专家
  92. }
  93. [NetworkRequestManager requestPostWithInterfacePrefix:JT_NewapplyComment parameters:parameters onSuccess:^(id requestData) {
  94. if ([requestData[@"error"] count] !=0) {
  95. for (NSDictionary *dic in requestData[@"error"]) {
  96. [MBProgressHUD showError:dic[@"message"] toView:self.view];
  97. }
  98. }else{
  99. [MBProgressHUD showSuccess:@"提交评价成功!" toView:self.view];
  100. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  101. NewPopViewController;
  102. });
  103. }
  104. } onFailure:^{
  105. }];
  106. //0-项目,1-成果,2-需求,3-专家,4-顾问
  107. // 商品类型 0-项目 1-顾问、专家
  108. // [NetworkRequestManager requestPostWithInterfacePrefix:JT_NewapplyComment parameters:parameters onSuccess:^(id requestData) {
  109. // if ([requestData[@"error"] count] !=0) {
  110. // for (NSDictionary *dic in requestData[@"error"]) {
  111. // [MBProgressHUD showError:dic[@"message"] toView:self.view];
  112. // }
  113. // }else{
  114. // [MBProgressHUD showSuccess:@"提交评价成功!" toView:self.view];
  115. // dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  116. // NewPopViewController;
  117. // });
  118. // }
  119. // } onFailure:^{
  120. //
  121. // }];
  122. }
  123. - (void)didChangeValue:(HCSStarRatingView *)sender{
  124. NSLog(@"Changed rating to %.1f", sender.value);
  125. NSInteger haha = sender.value;
  126. star = [NSString stringWithFormat:@"%ld",haha];
  127. }
  128. #pragma mark - UITextView获得焦点之后,并且已经是第一响应者
  129. -(void)textViewDidBeginEditing:(UITextView *)textView
  130. {
  131. // NSLog(@"UITextView获得焦点之后,并且已经是第一响应者");
  132. if ([textView.text isEqualToString:@"请在此输入您对商品的评价"]) {
  133. textView.text = @"";
  134. textView.textColor = NewGrayColor;
  135. }
  136. }
  137. #pragma mark - UITextView失去焦点之后
  138. -(void)textViewDidEndEditing:(UITextView *)textView
  139. {
  140. //NSLog(@"UITextView失去焦点");
  141. if ([textView.text isEqualToString:@""] || textView.text.length == 0) {
  142. textView.text = @"请在此输入您对商品的评价";
  143. textView.textColor = NewRGBColor(199, 199, 205, 1);
  144. }
  145. }
  146. #pragma mark - 详细地址限制字数
  147. -(void)textViewDidChangeSelection:(UITextView *)textView
  148. {
  149. if(textView.text.length > 500){
  150. textView.text = [textView.text substringWithRange:NSMakeRange(0,500)];
  151. }
  152. if (textView.text.length > 0) {
  153. NSLog(@"textView.text:%@",textView.text);
  154. if ([textView.text isEqualToString:@"请在此输入您对商品的评价"]) {
  155. descriptionStr = @"";
  156. }else{
  157. descriptionStr = nil;
  158. descriptionStr = textView.text;
  159. }
  160. }
  161. }
  162. - (void)didReceiveMemoryWarning {
  163. [super didReceiveMemoryWarning];
  164. // Dispose of any resources that can be recreated.
  165. }
  166. /*
  167. #pragma mark - Navigation
  168. // In a storyboard-based application, you will often want to do a little preparation before navigation
  169. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  170. // Get the new view controller using [segue destinationViewController].
  171. // Pass the selected object to the new view controller.
  172. }
  173. */
  174. @end