// // ASCouponsListViewModel.m // Asteria // // Created by iOS on 2023/11/30. // #import "ASCouponsListViewModel.h" @implementation ASCouponsListViewModel - (instancetype)init { self = [super init]; if (self) { self.couponList = [NSMutableArray array]; } return self; } - (void)getCouponList:(NSInteger)page com:(void(^)(BOOL hasNext, NSString *msg))com { NSMutableDictionary *dic = [NSMutableDictionary dictionary]; dic[@"page"] = [NSString stringWithFormat:@"%ld", page]; [ASNetTools.shared getWithPath:getUserCouponUrl param:dic success:^(id _Nonnull json) { NSInteger pagesize = [NSString stringWithFormat:@"%@", json[@"pageSize"]].integerValue; NSArray *list = json[@"list"]; NSMutableArray *arr = [ASCouponsModel mj_objectArrayWithKeyValuesArray:list]; if (page == 1) { self.couponList = arr; } else { [self.couponList addObjectsFromArray:arr]; } if (arr.count >= pagesize){ com(true, @""); } else { com(false, @""); } } faild:^(NSString * _Nonnull code, NSString * _Nonnull msg) { com(false, msg); }]; } @end