1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- //
- // ASGiftCardListViewModel.m
- // Asteria
- //
- // Created by iOS on 2023/12/2.
- //
- #import "ASGiftCardListViewModel.h"
- @implementation ASGiftCardListViewModel
- - (instancetype)init
- {
- self = [super init];
- if (self) {
- self.unUseCardList = [NSMutableArray array];
- self.cantUseCardList = [NSMutableArray array];
- }
- return self;
- }
- - (void)getUnuseCardList:(NSInteger)page com:(void(^)(BOOL hasNext, NSString *msg))com {
- NSMutableDictionary *dic = [NSMutableDictionary dictionary];
- dic[@"page"] = [NSString stringWithFormat:@"%ld", page];
- dic[@"status"] = @"1";
- [ASNetTools.shared getWithPath:getUserGiftCardUrl param:dic success:^(id _Nonnull json) {
- NSInteger pagesize = [NSString stringWithFormat:@"%@", json[@"pageSize"]].integerValue;
- NSArray *list = json[@"list"];
- NSMutableArray *arr = [ASGiftCardModel mj_objectArrayWithKeyValuesArray:list];
- if (page == 1) {
- self.unUseCardList = arr;
- } else {
- [self.unUseCardList addObjectsFromArray:arr];
- }
- if (arr.count >= pagesize){
- com(true, @"");
- } else {
- com(false, @"");
- }
- } faild:^(NSString * _Nonnull code, NSString * _Nonnull msg) {
- com(false, msg);
- }];
- }
- - (void)getCantUseCardList:(NSInteger)page com:(void(^)(BOOL hasNext, NSString *msg))com {
- NSMutableDictionary *dic = [NSMutableDictionary dictionary];
- dic[@"page"] = [NSString stringWithFormat:@"%ld", page];
- dic[@"status"] = @"2";
- [ASNetTools.shared getWithPath:getUserGiftCardUrl param:dic success:^(id _Nonnull json) {
- NSInteger pagesize = [NSString stringWithFormat:@"%@", json[@"pageSize"]].integerValue;
- NSArray *list = json[@"list"];
- NSMutableArray *arr = [ASGiftCardModel mj_objectArrayWithKeyValuesArray:list];
- if (page == 1) {
- self.unUseCardList = arr;
- } else {
- [self.unUseCardList addObjectsFromArray:arr];
- }
- if (arr.count >= pagesize){
- com(true, @"");
- } else {
- com(false, @"");
- }
- } faild:^(NSString * _Nonnull code, NSString * _Nonnull msg) {
- com(false, msg);
- }];
- }
- @end
|