| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264 |
- //
- // OrderDetailViewController.m
- // model
- //
- // Created by 杨键 on 2018/8/20.
- // Copyright © 2018年 Mine. All rights reserved.
- //
- #import "OrderDetailViewController.h"
- @interface OrderDetailViewController ()
- {
- NSString *orderPK;
- }
- @property (nonatomic, strong) NSDictionary *orderDetailDic;
- @end
- @implementation OrderDetailViewController
- -(instancetype)initWithOrderpk:(NSString *)orderpk{
- if (self) {
- orderPK = orderpk;
- }
- return self;
- }
- - (void)viewDidLoad {
- [super viewDidLoad];
-
- self.view.backgroundColor = [UIColor whiteColor];
-
- [self creatNavBar];
- [self getOrderDetailFromNetworking];
- }
- - (void)creatNavBar {
- self.title = @"订单详情";
- //
- UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
- btn.frame = CGRectMake(0, 0, 40, 40);
- [btn setImage:[UIImage imageNamed:@"fanhui2"] forState:UIControlStateNormal];
- btn.imageEdgeInsets = UIEdgeInsetsMake(0, -20, 0, 0); // backBtn2
- [btn addTarget:self action:@selector(backClick) forControlEvents:UIControlEventTouchUpInside];
- UIBarButtonItem *leftItem = [[UIBarButtonItem alloc] initWithCustomView:btn];
- UIBarButtonItem *nagetiveSpacer = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:nil];
- // nagetiveSpacer.width = -12;//这个值可以根据自己需要自己调整
- self.navigationItem.leftBarButtonItems = @[nagetiveSpacer, leftItem];
- }
- - (void)backClick {
- [self.navigationController popViewControllerAnimated:YES];
- }
- -(void)getOrderDetailFromNetworking{
-
- [MBProgressHUD showHUDAddedTo:self.view animated:YES];
- NSDictionary *dic = [[NSDictionary alloc] initWithObjectsAndKeys:orderPK,@"orderpk", nil];
-
- [YanCNetWorkManager requestPostWithURLStr:Url_doGetOrderInfo(PublicUrl) parameters:dic finish:^(id dataDic) {
- [MBProgressHUD hideHUDForView:self.view animated:YES];
-
- NSString *issuccess = dataDic[@"msg"];
- if ([issuccess isEqualToString:@"success"]) {
-
- self.orderDetailDic = dataDic[@"data"];
-
- [self creatSubViews];
- } else {
- [MBProgressHUD showInfo:@"请求失败!"];
- }
- } enError:^(NSError *error) {
- [MBProgressHUD hideHUDForView:self.view animated:YES];
- }];
- }
- - (void)creatSubViews {
-
- UIImageView *bgImage = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"dingdanbeijing"]];
- [self.view addSubview:bgImage];
- [bgImage mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(self.view.mas_top);
- make.left.equalTo(self.view.mas_left);
- make.right.equalTo(self.view.mas_right);
- make.height.equalTo(@120);
- }];
-
- UIImageView *liheImage = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"dingdanlihe"]];
- [bgImage addSubview:liheImage];
- [liheImage mas_makeConstraints:^(MASConstraintMaker *make) {
- make.centerY.equalTo(bgImage.mas_centerY);
- make.right.equalTo(self.view.mas_right).offset(-35);
- make.width.equalTo(@85);
- make.height.equalTo(@72);
- }];
-
- UILabel *stateLabel = [[UILabel alloc]init];
- stateLabel.textColor = [UIColor whiteColor];
- stateLabel.font = [UIFont systemFontOfSize:16];
- [bgImage addSubview:stateLabel];
- [stateLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.centerY.equalTo(bgImage.mas_centerY);
- make.left.equalTo(bgImage.mas_left).offset(35);
- make.width.equalTo(@100);
- make.height.equalTo(@20);
- }];
- NSString *orderState = [self.orderDetailDic objectForKey:@"orderstate"];
- if([orderState isEqualToString:@"0"]){
- stateLabel.text = @"待付款";
- }else if([orderState isEqualToString:@"1"]){
- stateLabel.text = @"已付款";
- }else if([orderState isEqualToString:@"2"]){
- stateLabel.text = @"取消订单";
- }else if([orderState isEqualToString:@"3"]){
- stateLabel.text = @"已接单";
- }else if([orderState isEqualToString:@"4"]){
- stateLabel.text = @"模特取消";
- }else if([orderState isEqualToString:@"5"]){
- stateLabel.text = @"已完成";
- }else if([orderState isEqualToString:@"6"]){
- stateLabel.text = @"订单超时";
- }
-
- UIView *titleBgView = [[UIView alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(bgImage.frame), ScreenWidth, 115)];
- titleBgView.backgroundColor = [UIColor whiteColor];
- [self.view addSubview:titleBgView];
-
- UILabel *titleLabel = [[UILabel alloc]initWithFrame:CGRectMake(20, 10, ScreenWidth-20, 20)];
- titleLabel.text = [NSString stringWithFormat:@"活动名称:%@",[self.orderDetailDic objectForKey:@"sname"]];
- titleLabel.textColor = RGB(51, 51, 51);
- titleLabel.font = [UIFont systemFontOfSize:14];
- [titleBgView addSubview:titleLabel];
-
- UILabel *addressLabel = [[UILabel alloc]initWithFrame:CGRectMake(20, 35, ScreenWidth-20, 20)];
- addressLabel.text = [NSString stringWithFormat:@"活动地址:%@",[self.orderDetailDic objectForKey:@"addr"]];
- addressLabel.textColor = RGB(51, 51, 51);
- addressLabel.font = [UIFont systemFontOfSize:14];
- [titleBgView addSubview:addressLabel];
-
- UILabel *nameLabel = [[UILabel alloc]initWithFrame:CGRectMake(20, 60, ScreenWidth-20, 20)];
- nameLabel.text = [NSString stringWithFormat:@"联 系 人:%@",[self.orderDetailDic objectForKey:@"linkman"]];
- nameLabel.textColor = RGB(51, 51, 51);
- nameLabel.font = [UIFont systemFontOfSize:14];
- [titleBgView addSubview:nameLabel];
-
- UILabel *phoneLabel = [[UILabel alloc]initWithFrame:CGRectMake(20, 85, 72, 20)];
- phoneLabel.text = @"联系电话:";
- phoneLabel.textColor = RGB(51, 51, 51);
- phoneLabel.font = [UIFont systemFontOfSize:14];
- [titleBgView addSubview:phoneLabel];
-
- UIButton *phoneButton = [[UIButton alloc]initWithFrame:CGRectMake(90, 80, 100, 30)];
- [phoneButton setTitle:[self.orderDetailDic objectForKey:@"linkphone"] forState:UIControlStateNormal];
- [phoneButton setTitleColor:RGBValueColor(0x3e8bf1, 1) forState:UIControlStateNormal];
- phoneButton.titleLabel.font = [UIFont systemFontOfSize:14];
- [phoneButton setTitleEdgeInsets:UIEdgeInsetsMake(0, 0, 0, 5)];
- [phoneButton addTarget:self action:@selector(clickPhone) forControlEvents:UIControlEventTouchUpInside];
- [titleBgView addSubview:phoneButton];
-
- UIView *line1 = [[UIView alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(titleBgView.frame), ScreenWidth, 10)];
- line1.backgroundColor = RGB(247, 247, 247);
- [self.view addSubview:line1];
-
- UIView *nameBgView = [[UIView alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(line1.frame), ScreenWidth, 175)];
- nameBgView.backgroundColor = [UIColor whiteColor];
- [self.view addSubview:nameBgView];
-
- UIImageView *headImg = [[UIImageView alloc]initWithFrame:CGRectMake(20, 20, 100, 100)];
- [headImg sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@/%@", PublicUrl, [self.orderDetailDic objectForKey:@"hphoto"]]] placeholderImage:[UIImage imageNamed:@"morentouxiang"]];
- [nameBgView addSubview:headImg];
-
- UILabel *skillLabel = [[UILabel alloc]initWithFrame:CGRectMake(140, 18, ScreenWidth-140, 20)];
- skillLabel.text = [self.orderDetailDic objectForKey:@"skillname"];
- skillLabel.textColor = RGB(51, 51, 51);
- skillLabel.font = [UIFont systemFontOfSize:14];
- [nameBgView addSubview:skillLabel];
-
- UILabel *priceLabel = [[UILabel alloc]initWithFrame:CGRectMake(140, 45, ScreenWidth-140, 20)];
- priceLabel.text = [NSString stringWithFormat:@"技能单价:%@元/h",[self.orderDetailDic objectForKey:@"sprice"]];
- priceLabel.textColor = RGB(51, 51, 51);
- priceLabel.font = [UIFont systemFontOfSize:14];
- [nameBgView addSubview:priceLabel];
-
- UILabel *timeLabel = [[UILabel alloc]initWithFrame:CGRectMake(140, 72, ScreenWidth-140, 20)];
- timeLabel.text = [NSString stringWithFormat:@"活动时长:%@h",[self.orderDetailDic objectForKey:@"scount"]];
- timeLabel.textColor = RGB(51, 51, 51);
- timeLabel.font = [UIFont systemFontOfSize:14];
- [nameBgView addSubview:timeLabel];
-
- UILabel *stimeLabel = [[UILabel alloc]initWithFrame:CGRectMake(140, 100, ScreenWidth-140, 20)];
- stimeLabel.text = [NSString stringWithFormat:@"开始时间:%@",[self.orderDetailDic objectForKey:@"sdate"]];
- stimeLabel.textColor = RGB(51, 51, 51);
- stimeLabel.font = [UIFont systemFontOfSize:14];
- [nameBgView addSubview:stimeLabel];
-
- UIView *line2 = [[UIView alloc]initWithFrame:CGRectMake(0, 135, ScreenWidth, 0.5)];
- line2.backgroundColor = RGB(221, 221, 221);
- [nameBgView addSubview:line2];
-
- UILabel *totalLabel = [[UILabel alloc]initWithFrame:CGRectMake(20, 140, ScreenWidth-40, 30)];
- totalLabel.text = [self.orderDetailDic objectForKey:@"coin"];
- totalLabel.textAlignment = NSTextAlignmentRight;
- totalLabel.font = [UIFont systemFontOfSize:16];
- [nameBgView addSubview:totalLabel];
-
-
- NSMutableAttributedString *saleTimeLabStr =[[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:@"总计:%@元",[self.orderDetailDic objectForKey:@"coin"]] ];
- [saleTimeLabStr addAttribute:NSForegroundColorAttributeName
- value:RGBValueColor(0xfe4086, 1.0)
- range:NSMakeRange(3, saleTimeLabStr.length-3)];
- [saleTimeLabStr addAttribute:NSForegroundColorAttributeName
- value:RGB(51, 51, 51)
- range:NSMakeRange(0, 3)];
- totalLabel.attributedText = saleTimeLabStr;
-
- UIView *line3 = [[UIView alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(nameBgView.frame), ScreenWidth, 10)];
- line3.backgroundColor = RGB(247, 247, 247);
- [self.view addSubview:line3];
-
- UILabel *orderIdLabel = [[UILabel alloc]initWithFrame:CGRectMake(20, CGRectGetMaxY(line3.frame)+10, ScreenWidth-20, 30)];
- orderIdLabel.text = [NSString stringWithFormat:@"订单编号:%@",[self.orderDetailDic objectForKey:@"ordernumber"]];
- orderIdLabel.textColor = RGB(51, 51, 51);
- orderIdLabel.font = [UIFont systemFontOfSize:14];
- [self.view addSubview:orderIdLabel];
-
- UIView *line4 = [[UIView alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(line3.frame)+50, ScreenWidth, 0.5)];
- line4.backgroundColor = RGB(221, 221, 221);
- [self.view addSubview:line4];
-
- UILabel *dateLabel = [[UILabel alloc]initWithFrame:CGRectMake(20, CGRectGetMaxY(line4.frame)+10, ScreenWidth-20, 30)];
- dateLabel.text = [NSString stringWithFormat:@"创建时间:%@",[self.orderDetailDic objectForKey:@"odate"]];
- dateLabel.textColor = RGB(51, 51, 51);
- dateLabel.font = [UIFont systemFontOfSize:14];
- [self.view addSubview:dateLabel];
- }
- -(void)clickPhone{
-
- NSString* PhoneStr = [NSString stringWithFormat:@"tel://%@",[self.orderDetailDic objectForKey:@"linkphone"]];
- UIApplication * app = [UIApplication sharedApplication];
- if ([app canOpenURL:[NSURL URLWithString:PhoneStr]]) {
- [app openURL:[NSURL URLWithString:PhoneStr]];
- }
- }
- - (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
|