ASHomeViewModel.m 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. //
  2. // ASHomeViewModel.m
  3. // Asteria
  4. //
  5. // Created by iOS on 2024/5/16.
  6. //
  7. #import "ASHomeViewModel.h"
  8. @implementation ASHomeViewModel
  9. - (NSMutableArray<ASJumpModel *> *)banners {
  10. if (!_banners) {
  11. NSMutableArray *arr = [NSMutableArray array];
  12. _banners = arr;
  13. }
  14. return _banners;
  15. }
  16. - (NSMutableArray<ASJumpModel *> *)categorys {
  17. if (!_categorys) {
  18. NSMutableArray *arr = [NSMutableArray array];
  19. _categorys = arr;
  20. }
  21. return _categorys;
  22. }
  23. -(void)getHomeTopData:(btnClickBlock)success {
  24. __weak typeof(self) weakSelf = self;
  25. [ASNetTools.shared getMsgWithPath:homeTop param:@{} success:^(id _Nonnull json) {
  26. NSLog(@"------url:%@---json:%@------", getHotList, json);
  27. NSMutableArray *arr = [ASJumpModel mj_objectArrayWithKeyValuesArray:json[@"banner"]];
  28. weakSelf.banners = arr;
  29. NSMutableArray *cateArr = [ASJumpModel mj_objectArrayWithKeyValuesArray:json[@"category"]];
  30. weakSelf.banners = arr;
  31. weakSelf.categorys = cateArr;
  32. success();
  33. } faild:^(NSString * _Nonnull code, NSString * _Nonnull msg) {
  34. NSLog(@"------url:%@---code:%@---msg:%@---", getHotList, code, msg);
  35. weakSelf.banners = [NSMutableArray array];
  36. weakSelf.categorys = [NSMutableArray array];
  37. success();
  38. }];
  39. }
  40. @end