OrderDetailViewController.m 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294
  1. //
  2. // OrderDetailViewController.m
  3. // IBOSSmini
  4. //
  5. // Created by guan hong hou on 2017/5/24.
  6. // Copyright © 2017年 elongtian. All rights reserved.
  7. //
  8. #import "OrderDetailViewController.h"
  9. #import "OrderDetailTableViewCell.h"
  10. #import "DateFormat.h"
  11. @interface OrderDetailViewController ()
  12. @end
  13. @implementation OrderDetailViewController
  14. #pragma mark - 公共函数
  15. /**
  16. viewDidLoad函数
  17. */
  18. - (void)viewDidLoad {
  19. [super viewDidLoad];
  20. _detailArr=[[NSArray alloc] init];
  21. _cartModel=[ShopCartModel new];
  22. self.navigationItem.title=@"订单明细";
  23. _vCustomTableView = [[UITableView alloc] initWithFrame:CGRectMake(10,10, self.view.frame.size.width-20, self.view.frame.size.height-20)];
  24. _vCustomTableView.autoresizingMask = UIViewAutoresizingFlexibleHeight;
  25. _vCustomTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
  26. _vCustomTableView.backgroundColor=[UIColor clearColor];
  27. _vCustomTableView.delegate = self;
  28. _vCustomTableView.dataSource=self;
  29. _vCustomTableView.showsVerticalScrollIndicator = NO;
  30. [self.view addSubview:_vCustomTableView];
  31. UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
  32. [button setBackgroundImage:[UIImage imageNamed:@"icon_back"]
  33. forState:UIControlStateNormal];
  34. [button addTarget:self action:@selector(goBack)
  35. forControlEvents:UIControlEventTouchUpInside];
  36. button.frame = CGRectMake(0, 0, 15, 18);
  37. UIBarButtonItem *menuButton = [[UIBarButtonItem alloc] initWithCustomView:button];
  38. self.navigationItem.leftBarButtonItem = menuButton;
  39. [self initHeaderView];
  40. [self reloadData];
  41. }
  42. /**
  43. 安全区改变
  44. */
  45. -(void)viewSafeAreaInsetsDidChange{
  46. _vCustomTableView.frame = CGRectMake(10, 10, self.view.safeAreaLayoutGuide.layoutFrame.size.width-20, self.view.safeAreaLayoutGuide.layoutFrame.size.height);
  47. [super viewSafeAreaInsetsDidChange];
  48. }
  49. /**
  50. didReceiveMemoryWarning函数
  51. */
  52. - (void)didReceiveMemoryWarning {
  53. [super didReceiveMemoryWarning];
  54. }
  55. #pragma mark -委托函数
  56. //订单细节数据加载成功接口
  57. - (void)onLoadFinish:(ASIDownManager *)sender {
  58. NSDictionary *dic = [sender.mWebStr JSONValue];
  59. [self cancel];
  60. if (dic && [dic isKindOfClass:[NSDictionary class]]) {
  61. int iStatus = [[dic objectForKey:@"Status"] intValue];
  62. NSString *message=[dic objectForKey:@"Message"];
  63. if (iStatus == 0) {
  64. NSArray * approvArr=[dic objectForKey:@"Result"];
  65. if(approvArr!=nil&&approvArr.count>0)
  66. {
  67. _detailArr= approvArr;
  68. if( _detailArr.count==0){
  69. [self showAlertViewText:@"未找到匹配结果"];
  70. }
  71. [_cartModel parseOrderDetailArr:_detailArr];
  72. [_vCustomTableView reloadData];
  73. }
  74. }
  75. else if(iStatus==ActionResultStatusAuthError
  76. ||iStatus==ActionResultStatusNoLogin
  77. ||iStatus==ActionResultStatusLogined ||iStatus == ActionResultStatusLoginedInvalid){
  78. [self showReLoginDialog:message];
  79. return;
  80. }
  81. else {
  82. [self showAlertViewText:message];
  83. }
  84. }
  85. }
  86. //数据加载失败接口
  87. - (void)onLoadFail:(ASIDownManager *)sender {
  88. [self cancel];
  89. [self showAlertViewText:@"加载失败"];
  90. }
  91. //tableview的高度
  92. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
  93. {
  94. return 560;
  95. }
  96. //tableview的分区数
  97. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
  98. {
  99. return _detailArr.count;
  100. }
  101. //tableview分区的间隔高度
  102. - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
  103. {
  104. return 10;
  105. }
  106. //tableview的行数
  107. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  108. {
  109. return 1;
  110. }
  111. //tableview分区
  112. - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
  113. {
  114. UIView* myView =[[UIView alloc]init];
  115. myView.backgroundColor = [UIColor clearColor];
  116. return myView;
  117. }
  118. //获取tableviewcell
  119. - (UITableViewCell *)tableView:(UITableView *)tableView
  120. cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  121. NSString *cellIdentifier=@"OrderDetailCell";
  122. OrderDetailTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
  123. cell=[[OrderDetailTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
  124. NSArray *checkArr=_cartModel.orderDetailArr;
  125. ShopCartItemModel *infoModel=checkArr[indexPath.section];
  126. [cell parseOrderInfo:infoModel];
  127. return cell;
  128. }
  129. #pragma mark - 私有函数
  130. //返回函数
  131. -(void)goBack{
  132. [self.navigationController popViewControllerAnimated:YES];
  133. }
  134. //初始化headerview
  135. -(void)initHeaderView{
  136. UIView *headerContentView=[[UIView alloc]init];
  137. headerContentView.layer.cornerRadius=CornerRadius;
  138. headerContentView.backgroundColor=[UIColor whiteColor];
  139. headerContentView.frame=CGRectZero;
  140. _vCustomTableView.tableHeaderView=headerContentView;
  141. CGFloat xpadding=10;
  142. CGFloat ypadding=10;
  143. UILabel *lblTitleOrderNo=[[UILabel alloc]init];
  144. lblTitleOrderNo.frame=CGRectMake(xpadding, ypadding,80,25);
  145. lblTitleOrderNo.text=@"订单单号:";
  146. lblTitleOrderNo.font=orderTextFont;
  147. [headerContentView addSubview:lblTitleOrderNo];
  148. _lblOrderNo=[[UILabel alloc]init];
  149. _lblOrderNo.frame=CGRectMake(CGRectGetMaxX(lblTitleOrderNo.frame), ypadding,250, 25);
  150. _lblOrderNo.text=[_dicInfo objectForKey:@"OrderNo"];
  151. _lblOrderNo.font=orderTextFont;
  152. [headerContentView addSubview:_lblOrderNo];
  153. UIImageView *separatorImg=[[UIImageView alloc]init];
  154. separatorImg.frame=CGRectMake(0,CGRectGetMaxY(lblTitleOrderNo.frame)+10,Screen_Width, 1);
  155. [separatorImg setImage:[UIImage imageNamed:@"dash"]];
  156. [headerContentView addSubview:separatorImg];
  157. UILabel *lblTitleCustomerName=[[UILabel alloc]init];
  158. lblTitleCustomerName.frame=CGRectMake(xpadding,CGRectGetMaxY(separatorImg.frame)+10,80,25);
  159. lblTitleCustomerName.text=@"客户名称:";
  160. lblTitleCustomerName.font=orderTextFont;
  161. [headerContentView addSubview:lblTitleCustomerName];
  162. _lblCustomerName=[[UILabel alloc]init];
  163. _lblCustomerName.frame=CGRectMake(CGRectGetMaxX(lblTitleCustomerName.frame), CGRectGetMaxY(separatorImg.frame)+10,250, 25);
  164. _lblCustomerName.text=[_dicInfo objectForKey:@"CustomerName"];
  165. _lblCustomerName.font=orderTextFont;
  166. [headerContentView addSubview:_lblCustomerName];
  167. UILabel *lblTitleCustomerAddress=[[UILabel alloc]init];
  168. lblTitleCustomerAddress.frame=CGRectMake(xpadding,CGRectGetMaxY(lblTitleCustomerName.frame)+10,80,25);
  169. lblTitleCustomerAddress.text=@"客户地址:";
  170. lblTitleCustomerAddress.font=orderTextFont;
  171. [headerContentView addSubview:lblTitleCustomerAddress];
  172. _lblCustomerAddress=[[UILabel alloc]init];
  173. _lblCustomerAddress.frame=CGRectMake(CGRectGetMaxX(lblTitleCustomerAddress.frame), CGRectGetMaxY(lblTitleCustomerName.frame)+10,250, 25);
  174. _lblCustomerAddress.text=[_dicInfo objectForKey:@"Address"];
  175. _lblCustomerAddress.font=orderTextFont;
  176. [headerContentView addSubview:_lblCustomerAddress];
  177. UILabel *lblTitleMarkedPriceAmount=[[UILabel alloc]init];
  178. lblTitleMarkedPriceAmount.frame=CGRectMake(xpadding,CGRectGetMaxY(lblTitleCustomerAddress.frame)+10,80,25);
  179. lblTitleMarkedPriceAmount.text=@"标价总额:";
  180. lblTitleMarkedPriceAmount.font=orderTextFont;
  181. [headerContentView addSubview:lblTitleMarkedPriceAmount];
  182. _lblMarkedPriceAmount=[[UILabel alloc]init];
  183. _lblMarkedPriceAmount.frame=CGRectMake(CGRectGetMaxX(lblTitleMarkedPriceAmount.frame), CGRectGetMaxY(lblTitleCustomerAddress.frame)+10,250, 25);
  184. _lblMarkedPriceAmount.text=[NSString stringWithFormat:@"%@",[_dicInfo objectForKey:@"MarkedPriceAmount"]];
  185. _lblMarkedPriceAmount.font=orderTextFont;
  186. [headerContentView addSubview:_lblMarkedPriceAmount];
  187. UILabel *lblTitleGoodsAmount=[[UILabel alloc]init];
  188. lblTitleGoodsAmount.frame=CGRectMake(xpadding,CGRectGetMaxY(lblTitleMarkedPriceAmount.frame)+10,80,25);
  189. lblTitleGoodsAmount.text=@"货物总额:";
  190. lblTitleGoodsAmount.font=orderTextFont;
  191. [headerContentView addSubview: lblTitleGoodsAmount];
  192. _lblGoodsAmount=[[UILabel alloc]init];
  193. _lblGoodsAmount.frame=CGRectMake(CGRectGetMaxX(lblTitleGoodsAmount.frame), CGRectGetMaxY(lblTitleMarkedPriceAmount.frame)+10,250, 25);
  194. _lblGoodsAmount.text=[NSString stringWithFormat:@"%@",[_dicInfo objectForKey:@"GoodsAmount"]];;
  195. _lblGoodsAmount.font=orderTextFont;
  196. [headerContentView addSubview: _lblGoodsAmount];
  197. UILabel *lblTitleDepartment=[[UILabel alloc]init];
  198. lblTitleDepartment.frame=CGRectMake(xpadding,CGRectGetMaxY(lblTitleGoodsAmount.frame)+10,80,25);
  199. lblTitleDepartment.text=@"业务部门:";
  200. lblTitleDepartment.font=orderTextFont;
  201. [headerContentView addSubview: lblTitleDepartment];
  202. _lblDepartment=[[UILabel alloc]init];
  203. _lblDepartment.frame=CGRectMake(CGRectGetMaxX(lblTitleDepartment.frame), CGRectGetMaxY(lblTitleGoodsAmount.frame)+10,250, 25);
  204. _lblDepartment.text=[NSString stringWithFormat:@"%@",[_dicInfo objectForKey:@"OrganizationName"]];;
  205. _lblDepartment.font=orderTextFont;
  206. [headerContentView addSubview:_lblDepartment];
  207. UILabel *lblTitleChannel=[[UILabel alloc]init];
  208. lblTitleChannel.frame=CGRectMake(xpadding,CGRectGetMaxY(lblTitleDepartment.frame)+10,80,25);
  209. lblTitleChannel.text=@"渠 道:";
  210. lblTitleChannel.font=orderTextFont;
  211. [headerContentView addSubview:lblTitleChannel];
  212. _lblChannelName=[[UILabel alloc]init];
  213. _lblChannelName.frame=CGRectMake(CGRectGetMaxX(lblTitleChannel.frame), CGRectGetMaxY(lblTitleDepartment.frame)+10,250, 25);
  214. _lblChannelName.text=[NSString stringWithFormat:@"%@",[_dicInfo objectForKey:@"ChannelName"]];;
  215. _lblChannelName.font=orderTextFont;
  216. [headerContentView addSubview: _lblChannelName];
  217. UILabel *lblTitleSalesMan=[[UILabel alloc]init];
  218. lblTitleSalesMan.frame=CGRectMake(xpadding,CGRectGetMaxY(lblTitleChannel.frame)+10,80,25);
  219. lblTitleSalesMan.text=@"业 务 员:";
  220. lblTitleSalesMan.font=orderTextFont;
  221. [headerContentView addSubview: lblTitleSalesMan];
  222. _lblStaffName=[[UILabel alloc]init];
  223. _lblStaffName.frame=CGRectMake(CGRectGetMaxX(lblTitleSalesMan.frame), CGRectGetMaxY(lblTitleChannel.frame)+10,250, 25);
  224. _lblStaffName.text=[NSString stringWithFormat:@"%@",[_dicInfo objectForKey:@"StaffName"]];;
  225. _lblStaffName.font=orderTextFont;
  226. [headerContentView addSubview:_lblStaffName];
  227. UILabel *lblTitleCreateDate=[[UILabel alloc]init];
  228. lblTitleCreateDate.frame=CGRectMake(xpadding,CGRectGetMaxY(lblTitleSalesMan.frame)+10,80,25);
  229. lblTitleCreateDate.text=@"创建日期:";
  230. lblTitleCreateDate.font=orderTextFont;
  231. [headerContentView addSubview: lblTitleCreateDate];
  232. _lblCreateDate=[[UILabel alloc]init];
  233. _lblCreateDate.frame=CGRectMake(CGRectGetMaxX(lblTitleCreateDate.frame), CGRectGetMaxY( lblTitleSalesMan.frame)+10,250, 25);
  234. NSString *createTime=[_dicInfo objectForKey:@"CreateTime"];
  235. createTime= [DateFormat dateFormatSplit:createTime];
  236. _lblCreateDate.text=createTime;
  237. _lblCreateDate.font=orderTextFont;
  238. [headerContentView addSubview:_lblCreateDate];
  239. headerContentView.frame=CGRectMake(0,0 ,_vCustomTableView.frame.size.width,CGRectGetMaxY(lblTitleCreateDate.frame));
  240. }
  241. //加载订单明细
  242. -(void)reloadData{
  243. self.mDownManager = [[ASIDownManager alloc] init];
  244. _mDownManager.delegate = self;
  245. _mDownManager.OnImageDown = @selector(onLoadFinish:);
  246. _mDownManager.OnImageFail = @selector(onLoadFail:);
  247. [self startLoading];
  248. NSString *urlStr = ServerURL;
  249. NSMutableDictionary *dict = [NSMutableDictionary dictionary];
  250. [dict setObject:@"GetIOrderDetailSourceIphone" forKey:@"Action"];
  251. [dict setObject:[NSString stringWithFormat:@"%@",kkAccountCode]forKey:@"AccountCode"];
  252. [dict setObject:kkUserCode forKey:@"UserCode"];
  253. [dict setObject:kkUserPwd forKey:@"UserPassword"];
  254. [dict setObject:kkSessionKey forKey:@"SessionKey"];
  255. [dict setObject:_orderId forKey:@"OrderID"];
  256. [_mDownManager postHttpRequest:urlStr dic:dict path:nil fileName:nil];
  257. }
  258. //取消进度条
  259. - (void)cancel {
  260. [self stopLoading];
  261. }
  262. @end