123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101 |
- //
- // ASAddressViewModel.m
- // Asteria
- //
- // Created by iOS on 2024/5/7.
- //
- #import "ASAddressViewModel.h"
- @implementation ASAddressViewModel
- - (void)upAddress:(ASAddressModel *)addressModel complate:(void(^)(BOOL,NSString *))complate {
- [ASNetTools.shared formData_postWithPath:saveAddress param:addressModel.params success:^(id _Nonnull json) {
- [ASUserInfoManager.shared getInfo];
- complate(true, @"");
- } faild:^(NSString * _Nonnull code, NSString * _Nonnull msg) {
- complate(false, msg);
- }];
- }
- - (void)deleteAnAddress:(ASAddressModel *)addressModel complate:(void(^)(BOOL,NSString *))complate {
-
- // [ASNetTools.shared postWithPath:delAddress param:@{@"id":addressModel.Id} success:^(id _Nonnull json) {
- // [ASUserInfoManager.shared getInfo];
- // complate(true, @"");
- // } faild:^(NSString * _Nonnull code, NSString * _Nonnull msg) {
- // complate(false, msg);
- // }];
-
- [ASNetTools.shared formData_postWithPath:delAddress param:@{@"id":addressModel.Id} success:^(id _Nonnull json) {
- [ASUserInfoManager.shared getInfo];
- complate(true, @"");
- } faild:^(NSString * _Nonnull code, NSString * _Nonnull msg) {
- complate(false, msg);
- }];
-
- // [ASNetTools.shared getWithPath:delAddress param:@{@"id":addressModel.Id} success:^(id _Nonnull json) {
- //
- // } faild:^(NSString * _Nonnull code, NSString * _Nonnull msg) {
- //
- // }];
- }
- - (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
|