OrderDetailViewController.m 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  1. //
  2. // OrderDetailViewController.m
  3. // model
  4. //
  5. // Created by 杨键 on 2018/8/20.
  6. // Copyright © 2018年 Mine. All rights reserved.
  7. //
  8. #import "OrderDetailViewController.h"
  9. @interface OrderDetailViewController ()
  10. {
  11. NSString *orderPK;
  12. }
  13. @property (nonatomic, strong) NSDictionary *orderDetailDic;
  14. @end
  15. @implementation OrderDetailViewController
  16. -(instancetype)initWithOrderpk:(NSString *)orderpk{
  17. if (self) {
  18. orderPK = orderpk;
  19. }
  20. return self;
  21. }
  22. - (void)viewDidLoad {
  23. [super viewDidLoad];
  24. self.view.backgroundColor = [UIColor whiteColor];
  25. [self creatNavBar];
  26. [self getOrderDetailFromNetworking];
  27. }
  28. - (void)creatNavBar {
  29. self.title = @"订单详情";
  30. //
  31. UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
  32. btn.frame = CGRectMake(0, 0, 40, 40);
  33. [btn setImage:[UIImage imageNamed:@"fanhui2"] forState:UIControlStateNormal];
  34. btn.imageEdgeInsets = UIEdgeInsetsMake(0, -20, 0, 0); // backBtn2
  35. [btn addTarget:self action:@selector(backClick) forControlEvents:UIControlEventTouchUpInside];
  36. UIBarButtonItem *leftItem = [[UIBarButtonItem alloc] initWithCustomView:btn];
  37. UIBarButtonItem *nagetiveSpacer = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:nil];
  38. // nagetiveSpacer.width = -12;//这个值可以根据自己需要自己调整
  39. self.navigationItem.leftBarButtonItems = @[nagetiveSpacer, leftItem];
  40. }
  41. - (void)backClick {
  42. [self.navigationController popViewControllerAnimated:YES];
  43. }
  44. -(void)getOrderDetailFromNetworking{
  45. [MBProgressHUD showHUDAddedTo:self.view animated:YES];
  46. NSDictionary *dic = [[NSDictionary alloc] initWithObjectsAndKeys:orderPK,@"orderpk", nil];
  47. [YanCNetWorkManager requestPostWithURLStr:Url_doGetOrderInfo(PublicUrl) parameters:dic finish:^(id dataDic) {
  48. [MBProgressHUD hideHUDForView:self.view animated:YES];
  49. NSString *issuccess = dataDic[@"msg"];
  50. if ([issuccess isEqualToString:@"success"]) {
  51. self.orderDetailDic = dataDic[@"data"];
  52. [self creatSubViews];
  53. } else {
  54. [MBProgressHUD showInfo:@"请求失败!"];
  55. }
  56. } enError:^(NSError *error) {
  57. [MBProgressHUD hideHUDForView:self.view animated:YES];
  58. }];
  59. }
  60. - (void)creatSubViews {
  61. UIImageView *bgImage = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"dingdanbeijing"]];
  62. [self.view addSubview:bgImage];
  63. [bgImage mas_makeConstraints:^(MASConstraintMaker *make) {
  64. make.top.equalTo(self.view.mas_top);
  65. make.left.equalTo(self.view.mas_left);
  66. make.right.equalTo(self.view.mas_right);
  67. make.height.equalTo(@120);
  68. }];
  69. UIImageView *liheImage = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"dingdanlihe"]];
  70. [bgImage addSubview:liheImage];
  71. [liheImage mas_makeConstraints:^(MASConstraintMaker *make) {
  72. make.centerY.equalTo(bgImage.mas_centerY);
  73. make.right.equalTo(self.view.mas_right).offset(-35);
  74. make.width.equalTo(@85);
  75. make.height.equalTo(@72);
  76. }];
  77. UILabel *stateLabel = [[UILabel alloc]init];
  78. stateLabel.textColor = [UIColor whiteColor];
  79. stateLabel.font = [UIFont systemFontOfSize:16];
  80. [bgImage addSubview:stateLabel];
  81. [stateLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  82. make.centerY.equalTo(bgImage.mas_centerY);
  83. make.left.equalTo(bgImage.mas_left).offset(35);
  84. make.width.equalTo(@100);
  85. make.height.equalTo(@20);
  86. }];
  87. NSString *orderState = [self.orderDetailDic objectForKey:@"orderstate"];
  88. if([orderState isEqualToString:@"0"]){
  89. stateLabel.text = @"待付款";
  90. }else if([orderState isEqualToString:@"1"]){
  91. stateLabel.text = @"已付款";
  92. }else if([orderState isEqualToString:@"2"]){
  93. stateLabel.text = @"取消订单";
  94. }else if([orderState isEqualToString:@"3"]){
  95. stateLabel.text = @"已接单";
  96. }else if([orderState isEqualToString:@"4"]){
  97. stateLabel.text = @"模特取消";
  98. }else if([orderState isEqualToString:@"5"]){
  99. stateLabel.text = @"已完成";
  100. }else if([orderState isEqualToString:@"6"]){
  101. stateLabel.text = @"订单超时";
  102. }
  103. UIView *titleBgView = [[UIView alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(bgImage.frame), ScreenWidth, 115)];
  104. titleBgView.backgroundColor = [UIColor whiteColor];
  105. [self.view addSubview:titleBgView];
  106. UILabel *titleLabel = [[UILabel alloc]initWithFrame:CGRectMake(20, 10, ScreenWidth-20, 20)];
  107. titleLabel.text = [NSString stringWithFormat:@"活动名称:%@",[self.orderDetailDic objectForKey:@"sname"]];
  108. titleLabel.textColor = RGB(51, 51, 51);
  109. titleLabel.font = [UIFont systemFontOfSize:14];
  110. [titleBgView addSubview:titleLabel];
  111. UILabel *addressLabel = [[UILabel alloc]initWithFrame:CGRectMake(20, 35, ScreenWidth-20, 20)];
  112. addressLabel.text = [NSString stringWithFormat:@"活动地址:%@",[self.orderDetailDic objectForKey:@"addr"]];
  113. addressLabel.textColor = RGB(51, 51, 51);
  114. addressLabel.font = [UIFont systemFontOfSize:14];
  115. [titleBgView addSubview:addressLabel];
  116. UILabel *nameLabel = [[UILabel alloc]initWithFrame:CGRectMake(20, 60, ScreenWidth-20, 20)];
  117. nameLabel.text = [NSString stringWithFormat:@"联 系 人:%@",[self.orderDetailDic objectForKey:@"linkman"]];
  118. nameLabel.textColor = RGB(51, 51, 51);
  119. nameLabel.font = [UIFont systemFontOfSize:14];
  120. [titleBgView addSubview:nameLabel];
  121. UILabel *phoneLabel = [[UILabel alloc]initWithFrame:CGRectMake(20, 85, 72, 20)];
  122. phoneLabel.text = @"联系电话:";
  123. phoneLabel.textColor = RGB(51, 51, 51);
  124. phoneLabel.font = [UIFont systemFontOfSize:14];
  125. [titleBgView addSubview:phoneLabel];
  126. UIButton *phoneButton = [[UIButton alloc]initWithFrame:CGRectMake(90, 80, 100, 30)];
  127. [phoneButton setTitle:[self.orderDetailDic objectForKey:@"linkphone"] forState:UIControlStateNormal];
  128. [phoneButton setTitleColor:RGBValueColor(0x3e8bf1, 1) forState:UIControlStateNormal];
  129. phoneButton.titleLabel.font = [UIFont systemFontOfSize:14];
  130. [phoneButton setTitleEdgeInsets:UIEdgeInsetsMake(0, 0, 0, 5)];
  131. [phoneButton addTarget:self action:@selector(clickPhone) forControlEvents:UIControlEventTouchUpInside];
  132. [titleBgView addSubview:phoneButton];
  133. UIView *line1 = [[UIView alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(titleBgView.frame), ScreenWidth, 10)];
  134. line1.backgroundColor = RGB(247, 247, 247);
  135. [self.view addSubview:line1];
  136. UIView *nameBgView = [[UIView alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(line1.frame), ScreenWidth, 175)];
  137. nameBgView.backgroundColor = [UIColor whiteColor];
  138. [self.view addSubview:nameBgView];
  139. UIImageView *headImg = [[UIImageView alloc]initWithFrame:CGRectMake(20, 20, 100, 100)];
  140. [headImg sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@/%@", PublicUrl, [self.orderDetailDic objectForKey:@"hphoto"]]] placeholderImage:[UIImage imageNamed:@"morentouxiang"]];
  141. [nameBgView addSubview:headImg];
  142. UILabel *skillLabel = [[UILabel alloc]initWithFrame:CGRectMake(140, 18, ScreenWidth-140, 20)];
  143. skillLabel.text = [self.orderDetailDic objectForKey:@"skillname"];
  144. skillLabel.textColor = RGB(51, 51, 51);
  145. skillLabel.font = [UIFont systemFontOfSize:14];
  146. [nameBgView addSubview:skillLabel];
  147. UILabel *priceLabel = [[UILabel alloc]initWithFrame:CGRectMake(140, 45, ScreenWidth-140, 20)];
  148. priceLabel.text = [NSString stringWithFormat:@"技能单价:%@元/h",[self.orderDetailDic objectForKey:@"sprice"]];
  149. priceLabel.textColor = RGB(51, 51, 51);
  150. priceLabel.font = [UIFont systemFontOfSize:14];
  151. [nameBgView addSubview:priceLabel];
  152. UILabel *timeLabel = [[UILabel alloc]initWithFrame:CGRectMake(140, 72, ScreenWidth-140, 20)];
  153. timeLabel.text = [NSString stringWithFormat:@"活动时长:%@h",[self.orderDetailDic objectForKey:@"scount"]];
  154. timeLabel.textColor = RGB(51, 51, 51);
  155. timeLabel.font = [UIFont systemFontOfSize:14];
  156. [nameBgView addSubview:timeLabel];
  157. UILabel *stimeLabel = [[UILabel alloc]initWithFrame:CGRectMake(140, 100, ScreenWidth-140, 20)];
  158. stimeLabel.text = [NSString stringWithFormat:@"开始时间:%@",[self.orderDetailDic objectForKey:@"sdate"]];
  159. stimeLabel.textColor = RGB(51, 51, 51);
  160. stimeLabel.font = [UIFont systemFontOfSize:14];
  161. [nameBgView addSubview:stimeLabel];
  162. UIView *line2 = [[UIView alloc]initWithFrame:CGRectMake(0, 135, ScreenWidth, 0.5)];
  163. line2.backgroundColor = RGB(221, 221, 221);
  164. [nameBgView addSubview:line2];
  165. UILabel *totalLabel = [[UILabel alloc]initWithFrame:CGRectMake(20, 140, ScreenWidth-40, 30)];
  166. totalLabel.text = [self.orderDetailDic objectForKey:@"coin"];
  167. totalLabel.textAlignment = NSTextAlignmentRight;
  168. totalLabel.font = [UIFont systemFontOfSize:16];
  169. [nameBgView addSubview:totalLabel];
  170. NSMutableAttributedString *saleTimeLabStr =[[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:@"总计:%@元",[self.orderDetailDic objectForKey:@"coin"]] ];
  171. [saleTimeLabStr addAttribute:NSForegroundColorAttributeName
  172. value:RGBValueColor(0xfe4086, 1.0)
  173. range:NSMakeRange(3, saleTimeLabStr.length-3)];
  174. [saleTimeLabStr addAttribute:NSForegroundColorAttributeName
  175. value:RGB(51, 51, 51)
  176. range:NSMakeRange(0, 3)];
  177. totalLabel.attributedText = saleTimeLabStr;
  178. UIView *line3 = [[UIView alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(nameBgView.frame), ScreenWidth, 10)];
  179. line3.backgroundColor = RGB(247, 247, 247);
  180. [self.view addSubview:line3];
  181. UILabel *orderIdLabel = [[UILabel alloc]initWithFrame:CGRectMake(20, CGRectGetMaxY(line3.frame)+10, ScreenWidth-20, 30)];
  182. orderIdLabel.text = [NSString stringWithFormat:@"订单编号:%@",[self.orderDetailDic objectForKey:@"ordernumber"]];
  183. orderIdLabel.textColor = RGB(51, 51, 51);
  184. orderIdLabel.font = [UIFont systemFontOfSize:14];
  185. [self.view addSubview:orderIdLabel];
  186. UIView *line4 = [[UIView alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(line3.frame)+50, ScreenWidth, 0.5)];
  187. line4.backgroundColor = RGB(221, 221, 221);
  188. [self.view addSubview:line4];
  189. UILabel *dateLabel = [[UILabel alloc]initWithFrame:CGRectMake(20, CGRectGetMaxY(line4.frame)+10, ScreenWidth-20, 30)];
  190. dateLabel.text = [NSString stringWithFormat:@"创建时间:%@",[self.orderDetailDic objectForKey:@"odate"]];
  191. dateLabel.textColor = RGB(51, 51, 51);
  192. dateLabel.font = [UIFont systemFontOfSize:14];
  193. [self.view addSubview:dateLabel];
  194. }
  195. -(void)clickPhone{
  196. NSString* PhoneStr = [NSString stringWithFormat:@"tel://%@",[self.orderDetailDic objectForKey:@"linkphone"]];
  197. UIApplication * app = [UIApplication sharedApplication];
  198. if ([app canOpenURL:[NSURL URLWithString:PhoneStr]]) {
  199. [app openURL:[NSURL URLWithString:PhoneStr]];
  200. }
  201. }
  202. - (void)didReceiveMemoryWarning {
  203. [super didReceiveMemoryWarning];
  204. // Dispose of any resources that can be recreated.
  205. }
  206. /*
  207. #pragma mark - Navigation
  208. // In a storyboard-based application, you will often want to do a little preparation before navigation
  209. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  210. // Get the new view controller using [segue destinationViewController].
  211. // Pass the selected object to the new view controller.
  212. }
  213. */
  214. @end