ASHomeViewModel.m 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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:%@------", homeTop, json);
  27. NSMutableArray *arr = [ASJumpModel mj_objectArrayWithKeyValuesArray:json[@"banner"]];
  28. NSMutableArray *cateArr = [ASJumpModel mj_objectArrayWithKeyValuesArray:json[@"category"]];
  29. weakSelf.banners = arr;
  30. weakSelf.categorys = cateArr;
  31. success();
  32. } faild:^(NSString * _Nonnull code, NSString * _Nonnull msg) {
  33. NSLog(@"------url:%@---code:%@---msg:%@---", homeTop, code, msg);
  34. weakSelf.banners = [NSMutableArray array];
  35. weakSelf.categorys = [NSMutableArray array];
  36. success();
  37. }];
  38. }
  39. -(void)getHomeListData:(btnClickBlock)success {
  40. __weak typeof(self) weakSelf = self;
  41. [ASNetTools.shared getMsgWithPath:HomeList param:@{} success:^(id _Nonnull json) {
  42. NSLog(@"------url:%@---json:%@------", HomeList, json);
  43. NSMutableArray *arr = [ASHomeMainListModel mj_objectArrayWithKeyValuesArray:json];
  44. weakSelf.listData = arr;
  45. success();
  46. } faild:^(NSString * _Nonnull code, NSString * _Nonnull msg) {
  47. NSLog(@"------url:%@---code:%@---msg:%@---", HomeList, code, msg);
  48. weakSelf.listData = [NSMutableArray array];
  49. success();
  50. }];
  51. }
  52. @end