12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- //
- // ASPointsViewModel.m
- // Asteria
- //
- // Created by iOS on 2023/12/2.
- //
- #import "ASPointsViewModel.h"
- @implementation ASPointsViewModel
- - (instancetype)init
- {
- self = [super init];
- if (self) {
- self.allList = [NSMutableArray array];
- self.usedList = [NSMutableArray array];
- }
- return self;
- }
- - (void)getAllList:(NSInteger)page com:(void(^)(BOOL hasNext, NSString *msg))com {
- NSMutableDictionary *dic = [NSMutableDictionary dictionary];
- dic[@"page"] = [NSString stringWithFormat:@"%ld", page];
- dic[@"obtained"] = @"0";
- dic[@"used"] = @"0";
- [ASNetTools.shared getWithPath:getPointsDetailUrl param:dic success:^(id _Nonnull json) {
- NSInteger pagesize = [NSString stringWithFormat:@"%@", json[@"pageSize"]].integerValue;
- NSArray *list = json[@"list"];
- NSMutableArray *arr = [ASPointDetailModel mj_objectArrayWithKeyValuesArray:list];
- if (page == 1) {
- self.allList = arr;
- } else {
- [self.allList addObjectsFromArray:arr];
- }
- if (arr.count >= pagesize){
- com(true, @"");
- } else {
- com(false, @"");
- }
- } faild:^(NSString * _Nonnull code, NSString * _Nonnull msg) {
- com(false, msg);
- }];
- }
- - (void)getUsedList:(NSInteger)page com:(void(^)(BOOL hasNext, NSString *msg))com{
- NSMutableDictionary *dic = [NSMutableDictionary dictionary];
- dic[@"page"] = [NSString stringWithFormat:@"%ld", page];
- dic[@"used"] = @"1";
- dic[@"obtained"] = @"0";
- [ASNetTools.shared getWithPath:getPointsDetailUrl param:dic success:^(id _Nonnull json) {
- NSInteger pagesize = [NSString stringWithFormat:@"%@", json[@"pageSize"]].integerValue;
- NSArray *list = json[@"list"];
- NSMutableArray *arr = [ASPointDetailModel mj_objectArrayWithKeyValuesArray:list];
- if (page == 1) {
- self.usedList = arr;
- } else {
- [self.usedList addObjectsFromArray:arr];
- }
- if (arr.count >= pagesize){
- com(true, @"");
- } else {
- com(false, @"");
- }
- } faild:^(NSString * _Nonnull code, NSString * _Nonnull msg) {
- com(false, msg);
- }];
- }
- @end
|