123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372 |
- //
- // EvaluationAndPayVC.m
- // jiaPei
- //
- // Created by apple on 16/6/8.
- // Copyright © 2016年 JCZ. All rights reserved.
- //
- #import "EvaluationAndPayVC.h"
- #import "CDPStarEvaluation.h"
- #import "APViewController.h"
- @interface EvaluationAndPayVC ()<UITextViewDelegate,CDPStarEvaluationDelegate>
- {
- UITextView *mainTV;
- UILabel *holderLabel;
- CDPStarEvaluation *serverStar;//星形评价
- CDPStarEvaluation *payStar;
- CDPStarEvaluation *teachStar;
- UILabel *serverLabel;//评论级别label
- UILabel *payLabel;
- UILabel *teachLabel;
-
- UILabel *timeLabel;
- UILabel *remarkLabel;
- }
- @end
- @implementation EvaluationAndPayVC
- - (void)viewDidLoad {
- [super viewDidLoad];
-
- if (_isFinishEva) {
- self.title = @"我的评价";
- }else{
- self.title = @"评价";
- }
- [self configNavigationBar];
- self.view.backgroundColor = backGroundColor;
- [self myInit];
- }
- -(void)viewDidDisappear:(BOOL)animated
- {
- [super viewDidDisappear:animated];
- [self.view endEditing:YES];
- }
- -(void)myInit
- {
- // if (_isFinishEva) {
- // UIBarButtonItem *item = [[UIBarButtonItem alloc] initWithTitle:@"支付" style:UIBarButtonItemStyleDone target:self action:@selector(clickToComplain)];
- // item.tintColor = defGreen;
- // self.navigationItem.rightBarButtonItem = item;
- // }
-
-
- CGFloat x,y,w,h,bd;
- x = y = bd = 10;
- w = kSize.width - 2*bd;
- h = 100;
- //480 568 667 736
- if (kSize.height > 568) {
- h = 150;
- }
-
- if (_isFinishEva) {
-
- h = 0;
- }else{
-
- mainTV = [[UITextView alloc] setxywh];
- mainTV.backgroundColor = [UIColor whiteColor];
- mainTV.delegate = self;
- mainTV.returnKeyType = UIReturnKeyDone;
- [self.view addSubview:mainTV];
-
- holderLabel = [[UILabel alloc] initWithFrame:CGRectMake(x + 10, y, w, 30)];
- holderLabel.text = @"对本次培训的评价(100字以内)";
- [holderLabel setFont:NormalFont TextColor:contentTextColor];
- [self.view addSubview:holderLabel];
- }
- //CDPStarEvaluation星形评价
- y += h + 2*bd;
- h = 20;
- UILabel *starLabel = [[UILabel alloc] setxywh];
- starLabel.text = @"星级评价:";
- [starLabel setFont:[UIFont scaleSize:Font17]];
- [self.view addSubview:starLabel];
-
- y += h + bd/2.0;
- h = (kSize.width-2*bd)*0.5/4.98;
- NSArray *nameArray = @[@"服务星级",@"收费星级",@"教学星级"];
- NSMutableArray *stars = [NSMutableArray arrayWithCapacity:3];
- NSMutableArray *labels = [NSMutableArray arrayWithCapacity:3];
- for (int i = 0; i < 3; i ++) {
-
- //777/156=4.98077 468/94=4.97872
- // w = kSize.width*0.625;
- // h = kSize.height*0.07042254;
-
- x = bd;
- w = (kSize.width-2*bd)*0.2;
- UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(x, y + i*(h + bd/2.0), w, h)];
- label.text = nameArray[i];
- label.textAlignment = NSTextAlignmentLeft;
- [label setFont:[UIFont scaleSize:Font17]];
- [self.view addSubview:label];
-
- x += w;
- w = (kSize.width-2*bd)*0.5;
- CDPStarEvaluation *evaluation=[[CDPStarEvaluation alloc] initWithFrame:CGRectMake(x, y + i*(h + bd/2.0), w, h) onTheView:self.view];
- evaluation.delegate = self;
- evaluation.delegateTag = i;
- [stars addObject:evaluation];
-
- x += w;
- w = (kSize.width-2*bd)*0.3;
- label = [[UILabel alloc] initWithFrame:CGRectMake(x, y + i*(h + bd/2.0), w, h)];
- label.textAlignment = NSTextAlignmentRight;
- label.text = @"请评分";
- [label setFont:[UIFont scaleSize:Font17]];
- [self.view addSubview:label];
- [labels addObject:label];
- }
-
- serverStar = stars[0];
- payStar = stars[1];
- teachStar = stars[2];
- serverLabel = labels[0];
- payLabel = labels[1];
- teachLabel = labels[2];
-
- if (_isFinishEva) {
-
- x = 2*bd;
- y += 3*(h + bd/2.0) + 2*bd;
- w = kSize.width - 2*x;
- h = 30;
- timeLabel = [[UILabel alloc] initWithFrame:CGRectMake(x, y, w, h)];
- [timeLabel setText:@"" Font:Font17 TextColor:contentTextColor Alignment:NSTextAlignmentRight];
- [self.view addSubview:timeLabel];
- [timeLabel addViewWithRect:CGRectMake(10, y+h, kSize.width - 20, 1)];
-
-
- x = 2 * bd;
- y += h + 5;
- w = kSize.width - 2*x;
- h = 30;
- remarkLabel = [[UILabel alloc] initWithFrame:CGRectMake(x, y, w, h)];
- [remarkLabel setText:@"" Font:Font17 TextColor:kTitleColor Alignment:NSTextAlignmentLeft];
- [self.view addSubview:remarkLabel];
-
-
- [self getOrderEvaluateById];
- }else{
-
- x = 2 * bd;
- y += 3*(h + bd/2.0) + 4*bd;
- w = kSize.width - 2*x;
- h = 50;
-
- UIButton *commentBtn = [[UIButton alloc] setxywh];
- [commentBtn setTitle:@"提交评价" textColor:[UIColor whiteColor] font:Font17 fotState:UIControlStateNormal];
- commentBtn.backgroundColor=[UIColor colorWithRed:242/255.0 green:130/255.0 blue:32/255.0 alpha:1];
- [commentBtn target:self tag:1];
- [self.view addSubview:commentBtn];
- }
- }
- //-(void)clickToComplain
- //{
- // //在这里判断下 是否已完成评价 如果评价过 则可以去支付 防止评价完退出又进来无法支付
- // if ([_dataDic[@"RO_STATUS"] isEqualToString:@"3"]) {
- // ShowMsg(@"您已完成支付");
- // return;
- // }
- // if (![_dataDic[@"RO_STATUS"] isEqualToString:@"2"]) {
- // ShowMsg(@"请先评价");
- // return;
- // }
- //
- // [self goAndPay];
- //}
- -(void)btnClick:(UIButton *)sender
- {
- [self.view endEditing:YES];
- if (sender.tag == 1) {
-
- if (mainTV.text.length < 1) {
- ShowMsg(@"请填写评论");
- return;
- }
- if (mainTV.text.length > 100) {
- ShowMsg(@"评论内容不能超出100字");
- return;
- }
- if (serverStar.width*5 < 0.10 || payStar.width*5 < 0.10 || teachStar.width*5 < 0.10) {
- ShowMsg(@"请为本次培训打分");
- return;
- }
- [self uploadReserveEvaluate];
- }
-
- }
- //-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
- //{
- // [self goAndPay];
- //}
- -(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
- {
- [self.view endEditing:YES];
- }
- #pragma mark textViewDelegate
- -(BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text
- {
- NSMutableString * content = [[NSMutableString alloc]initWithString:textView.text];
- [content replaceCharactersInRange:range withString:text];
- if (content.length < 1) {
- holderLabel.hidden = NO;
- }else{
- holderLabel.hidden = YES;
- }
-
- if ([@"\n" isEqualToString:text] == YES) {
- //如果是换行键 就隐藏键盘
- [self.view endEditing:YES];
- return NO;
- }
- return YES;
- }
- #pragma mark CDPStarEvaluationDelegate获得实时评价级别
- -(void)theCurrentCommentText:(NSString *)commentText Tag:(NSInteger)tag{
-
- switch (tag) {
- case 0:
- serverLabel.text = [NSString stringWithFormat:@"%@(%.1f分)",commentText,serverStar.width*5];
- break;
- case 1:
- payLabel.text = [NSString stringWithFormat:@"%@(%.1f分)",commentText,payStar.width*5];
- break;
- case 2:
- teachLabel.text = [NSString stringWithFormat:@"%@(%.1f分)",commentText,teachStar.width*5];
- break;
- default:
- break;
- }
- }
- #pragma mark 数据请求
- -(void)uploadReserveEvaluate
- {
- if (![Util connectedToNetWork]) {
- showMsgUnconnect();
- return;
- }
-
- NSMutableArray *arr=[NSMutableArray array];
- [arr addPro:@"orderId" Value:_dataDic[@"RO_ID"]];
- [arr addPro:@"serverStar" Value:[NSString stringWithFormat:@"%.1f",serverStar.width*5]];
- [arr addPro:@"payStar" Value:[NSString stringWithFormat:@"%.1f",payStar.width*5]];
- [arr addPro:@"teachStar" Value:[NSString stringWithFormat:@"%.1f",teachStar.width*5]];
- [arr addPro:@"remark" Value:mainTV.text];
- [arr addPro:@"user" Value:defUser.sfzmhm];
- [arr addPro:@"userName" Value:defUser.userName];
- [arr addPro:@"dqbh" Value:defUser.userDict[@"city"]];
-
- //这个类评论功能暂时用不到,下面这个接口已改
- NSString* method = @"uploadReserveEvaluate";
- [MBProgressHUD showLoadToView:self.view];
- [jiaPeiManager requestAnythingWithURL:method array:arr data:nil completion:^(NSDictionary *root) {
-
- [MBProgressHUD hideHUDForView:self.view];
- if (!root) {
- ShowMsgFailed();
- return;
- }
- if ([root[@"code"] isEqualToString:@"1"]) {
- ShowMsg(root[@"body"]);
- return;
- }
-
- if ([root[@"body"] isEqualToString:@"0"]) {
- ShowMsg(@"评价成功");
-
- //这样应该没问题吧 不管是从订单过来还是从支付页面过来 都可以这样直接返回才对哒
- // UIViewController *orderVC = self.navigationController.viewControllers[1];
- //[self.navigationController popViewControllerAnimated:YES];
- [self.navigationController popViewControllerAnimated:YES];
- }
-
- // UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:nil message:@"评论成功!" delegate:self cancelButtonTitle:@"支付" otherButtonTitles:nil, nil];
- // [alertView show];
- }];
- }
- -(void)getOrderEvaluateById
- {
- if (![Util connectedToNetWork]) {
- return;
- }
-
- NSMutableArray *arr=[NSMutableArray array];
-
- [arr addPro:@"orderId" Value:_dataDic[@"RO_ID"]];
- [arr addPro:@"user" Value:defUser.userDict[@"id"]];
-
- NSString* method = @"getOrderEvaluateById";//这个类评论功能暂时用不到,下面这个接口已改
- [MBProgressHUD showLoadToView:self.view];
- [jiaPeiManager requestAnythingWithURL:method array:arr data:nil completion:^(NSDictionary *root) {
-
- [MBProgressHUD hideHUDForView:self.view];
- if (!root) {
- ShowMsgFailed();
- return;
- }
- if ([root[@"code"] isEqualToString:@"1"]) {
- ShowMsg(root[@"body"]);
- return;
- }
-
- NSDictionary *dic = root[@"body"];
- timeLabel.text = [dic[@"crDate"] substringToIndex:16];
-
- NSString *contentString = [NSString stringWithFormat:@"评价:%@",dic[@"remark"]];
- if ([dic[@"remark"] length] < 1) {
- contentString = @"评价:暂无";
- }
- remarkLabel.height = [contentString heightForWid:kSize.width - 40 Font:Font17] + 10;
- remarkLabel.text = contentString;
-
- [serverStar setStarWithFloat:[dic[@"serverStar"] floatValue]/5.0];
- [payStar setStarWithFloat:[dic[@"payStar"] floatValue]/5.0];
- [teachStar setStarWithFloat:[dic[@"teachStar"] floatValue]/5.0];
-
- serverLabel.text = [NSString stringWithFormat:@"%@(%@分)",serverStar.commentText,dic[@"serverStar"]];
- payLabel.text = [NSString stringWithFormat:@"%@(%@分)",payStar.commentText,dic[@"payStar"]];
- teachLabel.text = [NSString stringWithFormat:@"%@(%@分)",teachStar.commentText,dic[@"teachStar"]];
- }];
- }
- //支付
- //-(void)goAndPay
- //{
- // if (_dataDic) {
- // APViewController *ap = [[APViewController alloc] init];
- // ap.orderDic = _dataDic;
- // [self.navigationController pushViewController:ap animated:YES];
- // }else{
- // ShowMsg(@"订单信息错误,请重试");
- // }
- //}
- - (void)didReceiveMemoryWarning {
- [super didReceiveMemoryWarning];
- }
- @end
|