1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
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
//
// LocationViewController.m
// Lighting
//
// Created by 曹云霄 on 2017/3/21.
// Copyright © 2017年 上海勾芒科技有限公司. All rights reserved.
//
#import "LocationViewController.h"
#import "YXPickerManager.h"
@interface LocationViewController ()
@end
@implementation LocationViewController
- (void)viewDidLoad {
[super viewDidLoad];
}
#pragma mark -选择地址
- (IBAction)chooseLocationButtonClickAction:(UIButton *)sender {
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) {
[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;
address.createDate = [[NSDate date] httpParameterString];
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];
}];
[weakSelf getStoreAddress:nil];
}else {
[XBLoadingView showHUDViewWithText:MESSAGE(returnValue)];
}
} withFailureBlock:^(NSError *error) {
[XBLoadingView showHUDViewWithText:error.localizedDescription];
}];
});
}
@end