dkahgld

ZBSaleTrendVC.m 2.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. //
  2. // ZBSaleTrendVC.m
  3. // ZBProject
  4. //
  5. // Created by 学丽 on 2019/4/9.
  6. // Copyright © 2019 ZB. All rights reserved.
  7. //
  8. #import "ZBSaleTrendVC.h"
  9. @interface ZBSaleTrendVC ()
  10. @property(nonatomic,strong) SSWLineChartView *barChartView;
  11. @property(nonatomic,copy)NSString *types;
  12. @end
  13. @implementation ZBSaleTrendVC
  14. - (void)viewDidLoad {
  15. [super viewDidLoad];
  16. self.view.backgroundColor =[UIColor whiteColor];
  17. self.types = @"1";
  18. [self.view addSubview:self.barChartView];
  19. [self.barChartView mas_makeConstraints:^(MASConstraintMaker *make) {
  20. make.top.mas_equalTo(self.view.mas_top).offset(20);
  21. make.left.mas_equalTo(10);
  22. make.right.mas_equalTo(-10);
  23. make.height.mas_offset(329);
  24. }];
  25. [self OrderStatistics];
  26. }
  27. -(SSWLineChartView *)barChartView
  28. {
  29. if (!_barChartView) {
  30. _barChartView =[[SSWLineChartView alloc]initWithChartType:SSWChartsTypeBar];
  31. _barChartView.layer.cornerRadius=3;
  32. _barChartView.layer.masksToBounds=YES;
  33. _barChartView.backgroundColor = [UIColor whiteColor];
  34. _barChartView.unit = @"单";
  35. _barChartView.showEachYValus=NO;
  36. _barChartView.yScaleValue=100;
  37. __weak ZBSaleTrendVC *weakSelf = self;
  38. _barChartView.changeBtn = ^(UIButton *button) {
  39. if (button.tag == 1001) {
  40. weakSelf.types =@"1";
  41. }else{
  42. weakSelf.types = @"0";
  43. }
  44. [weakSelf OrderStatistics];
  45. };
  46. }
  47. return _barChartView;
  48. }
  49. #pragma mark---订单统计
  50. -(void)OrderStatistics
  51. {
  52. if (![AccountTool isLogin]) {
  53. return;
  54. }
  55. [LoadingView showInView:self.view];
  56. [ZBHTTP post:getOrderStatisticsURL params:@{@"type":self.types} success:^(id _Nonnull json) {
  57. [LoadingView dismiss];
  58. NSArray *resultA =(NSArray *)json;
  59. NSMutableArray *xArray=[NSMutableArray array];
  60. NSMutableArray *valueArray =[NSMutableArray array];
  61. for (NSDictionary *dics in resultA) {
  62. [xArray addObject:dics[@"time"]];
  63. [valueArray addObject:dics[@"num"]];
  64. }
  65. self.barChartView.xValuesArr = [xArray mutableCopy];
  66. self.barChartView.yValuesArr=[valueArray mutableCopy];
  67. } failure:^(NSError * _Nonnull error) {
  68. [LoadingView dismiss];
  69. }];
  70. }
  71. @end