LocationViewController.m 2.66 KB
Newer Older
曹云霄's avatar
曹云霄 committed
1 2 3 4 5 6 7 8 9
//
//  LocationViewController.m
//  Lighting
//
//  Created by 曹云霄 on 2017/3/21.
//  Copyright © 2017年 上海勾芒科技有限公司. All rights reserved.
//

#import "LocationViewController.h"
10
#import "YXPickerManager.h"
曹云霄's avatar
曹云霄 committed
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26

@interface LocationViewController ()



@end

@implementation LocationViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
}

#pragma mark -选择地址
- (IBAction)chooseLocationButtonClickAction:(UIButton *)sender {
27 28 29
    ToStoreAddress *storeAddress = [Shoppersmanager manager].storeAddress;
    NSString *address = [NSString stringWithFormat:@"%@-%@-%@",storeAddress.province,storeAddress.city,storeAddress.country];
    [[YXPickerManager shareManager] showAddressPickerView:kMainBlueColor defaultAddress:address commitBlock:^(NSString *address, NSString *zipcode) {
曹云霄's avatar
曹云霄 committed
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
        [sender setTitle:address forState:UIControlStateNormal];
    } cancelBlock:^{
        
    }];
}

#pragma mark -确认
- (IBAction)affirmButtonClickAction:(UIButton *)sender {
    
    NSArray *addressArray = [[self.chooseLocationButton currentTitle] componentsSeparatedByString:@"-"];
    if (addressArray.count < 3) {
        [XBLoadingView showHUDViewWithText:@"请选择所在区域"];return;
    }
    WS(weakSelf);
    ShowAlertView(@"提示", @"确认后不可更改,请检查是否正确", @[@"确认",@"取消"], UIAlertControllerStyleAlert, ^(NSInteger index) {
        if (index == ONE) {
            return;
        }
        [XBLoadingView showHUDViewWithDefault];
        ToStoreAddress *address = [[ToStoreAddress alloc] init];
        address.resellerid = [Shoppersmanager manager].shoppers.employee.currentDepart.fid;
        address.storecode = [Shoppersmanager manager].shoppers.storeCode;
52
        address.createDate = [[NSDate date] httpParameterString];
曹云霄's avatar
曹云霄 committed
53 54 55 56 57 58 59 60 61 62
        address.province = addressArray[0];
        address.city = addressArray[1];
        address.country = addressArray[2];
        [HTTP networkRequestWithURL:SERVERREQUESTURL(ADDRESS) withRequestType:POST withParameter:address withReturnValueBlock:^(id returnValue) {
            
            [XBLoadingView hideHUDViewWithDefault];
            if (RESULT(returnValue)) {
                [XBLoadingView showHUDViewWithSuccessText:@"保存成功" completeBlock:^{
                    [weakSelf dismissViewControllerAnimated:YES completion:nil];
                }];
63
                [weakSelf getStoreAddress:nil];
曹云霄's avatar
曹云霄 committed
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90
                
            }else {
                [XBLoadingView showHUDViewWithText:MESSAGE(returnValue)];
            }
            
        } withFailureBlock:^(NSError *error) {
            [XBLoadingView showHUDViewWithText:error.localizedDescription];
        }];
    });
}
















@end