// // ASAddressViewModel.m // Asteria // // Created by iOS on 2024/5/7. // #import "ASAddressViewModel.h" @implementation ASAddressViewModel - (void)upAddress:(ASAddressModel *)addressModel complate:(void(^)(BOOL,NSString *))complate { complate(true, @""); } - (void)deleteAnAddress:(ASAddressModel *)addressModel complate:(void(^)(BOOL))complate { complate(true); } - (void)getCountryList:(void(^)(void))success { [ASNetTools.shared getWithPath:CountryList param:@{} success:^(id _Nonnull json) { NSArray *list = json; NSMutableArray *arr = [KWCountryAddressModel mj_objectArrayWithKeyValuesArray:list]; NSMutableArray *result = [NSMutableArray array]; for (KWCountryAddressModel *m in arr) { if (m.full_name_english == nil || m.full_name_english.isEmpty) { continue; } [result addObject:m]; } self.countryArr = result; success(); } faild:^(NSString * _Nonnull code, NSString * _Nonnull msg) { self.countryArr = [NSMutableArray array]; success(); }]; } - (void)getProvinceList:(NSString *)country_id success:(void(^)(void))success { self.hadGetProvince = false; self.provinceArr = [NSMutableArray array]; if (country_id == nil || country_id.isEmpty) { success(); return; } for (KWCountryAddressModel *m in self.countryArr) { if (m.country_id == nil || m.country_id.isEmpty) { continue; } if ([m.country_id isEqualToString:country_id] && m.available_regions != nil) { self.hadGetProvince = true; self.provinceArr = [NSMutableArray arrayWithArray:m.available_regions]; break; } } success(); } - (NSArray *)countryNameList { NSMutableArray *arr = [NSMutableArray array]; for (KWCountryAddressModel* item in self.countryArr) { [arr addObject:item.full_name_english]; } return arr; } - (NSArray *)provinceNameList { NSMutableArray *arr = [NSMutableArray array]; for (KWProvinceAddressModel* item in self.provinceArr) { [arr addObject:item.name]; } return arr; } @end