// // ASHomeViewModel.m // Asteria // // Created by iOS on 2024/5/16. // #import "ASHomeViewModel.h" @implementation ASHomeViewModel - (NSMutableArray *)banners { if (!_banners) { NSMutableArray *arr = [NSMutableArray array]; _banners = arr; } return _banners; } - (NSMutableArray *)categorys { if (!_categorys) { NSMutableArray *arr = [NSMutableArray array]; _categorys = arr; } return _categorys; } -(void)getHomeTopData:(btnClickBlock)success { __weak typeof(self) weakSelf = self; [ASNetTools.shared getMsgWithPath:homeTop param:@{} success:^(id _Nonnull json) { NSLog(@"------url:%@---json:%@------", homeTop, json); NSMutableArray *arr = [ASJumpModel mj_objectArrayWithKeyValuesArray:json[@"banner"]]; NSMutableArray *cateArr = [ASJumpModel mj_objectArrayWithKeyValuesArray:json[@"category"]]; weakSelf.banners = arr; weakSelf.categorys = cateArr; success(); } faild:^(NSString * _Nonnull code, NSString * _Nonnull msg) { NSLog(@"------url:%@---code:%@---msg:%@---", homeTop, code, msg); weakSelf.banners = [NSMutableArray array]; weakSelf.categorys = [NSMutableArray array]; success(); }]; } -(void)getHomeListData:(btnClickBlock)success { __weak typeof(self) weakSelf = self; [ASNetTools.shared getMsgWithPath:HomeList param:@{} success:^(id _Nonnull json) { NSLog(@"------url:%@---json:%@------", HomeList, json); NSMutableArray *arr = [ASHomeMainListModel mj_objectArrayWithKeyValuesArray:json]; weakSelf.listData = arr; success(); } faild:^(NSString * _Nonnull code, NSString * _Nonnull msg) { NSLog(@"------url:%@---code:%@---msg:%@---", HomeList, code, msg); weakSelf.listData = [NSMutableArray array]; success(); }]; } @end