ResellerViewController.m 3.29 KB
Newer Older
曹云霄's avatar
曹云霄 committed
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
//
//  ResellerViewController.m
//  Lighting
//
//  Created by 曹云霄 on 2017/3/6.
//  Copyright © 2017年 上海勾芒科技有限公司. All rights reserved.
//

#import "ResellerViewController.h"
#import "CustomWKWebViewController.h"


@interface ResellerViewController ()<UITextFieldDelegate>

@end

@implementation ResellerViewController

- (void)viewDidLoad {
    [super viewDidLoad];

}

#pragma mark -保存经销商ID  ->验证
- (void)modifyResellerInformation
{
    NSString *storeNumber = self.storeNumberTextField.text;
    if ([[self class] isBlankString:storeNumber]) {
        [XBLoadingView showHUDViewWithText:@"输入无效"];return;
    }
    if ([storeNumber isEqualToString:@"无"]) {
        [self saveResellerInformation:storeNumber];return;
    }
    //验证
    NSDictionary *dict = @{@"mfcode":storeNumber};
    [XBLoadingView showHUDViewWithDefault];
    WS(weakSelf);
    [HTTP networkWithDictionaryRequestWithURL:RESELLER withRequestType:GET withParameter:dict withReturnValueBlock:^(id returnValue) {
        
        [XBLoadingView hideHUDViewWithDefault];
        if ([returnValue[@"code"] isEqualToString:@"1"]) {
            [XBLoadingView showHUDViewWithSuccessText:@"验证成功" completeBlock:^{
                [weakSelf saveResellerInformation:storeNumber];
            }];
        }else {
            [XBLoadingView showHUDViewWithText:returnValue[@"msg"]];
        }
        
    } withFailureBlock:^(NSError *error) {
        [XBLoadingView showHUDViewWithText:error.localizedDescription];
    }];
}

#pragma mark -保存经销商门店编号
- (void)saveResellerInformation:(NSString *)storeCode
{
    [XBLoadingView showHUDViewWithDefault];
    WS(weakSelf);
    TOResellerstoreEntity *entity = [[TOResellerstoreEntity alloc] init];
60
    entity.createDate = [[NSDate date] httpParameterString];
曹云霄's avatar
曹云霄 committed
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 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118
    entity.storecode =  storeCode;
    entity.resellerid = [Shoppersmanager manager].shoppers.employee.currentDepart.fid;
    [HTTP networkRequestWithURL:SERVERREQUESTURL(SAVERESELLER) withRequestType:POST withParameter:entity withReturnValueBlock:^(id returnValue) {
        
        [XBLoadingView hideHUDViewWithDefault];
        if (RESPONSE(returnValue)) {
            [XBLoadingView showHUDViewWithSuccessText:@"绑定成功" completeBlock:^{
                if ([weakSelf.delegate respondsToSelector:@selector(storeCodeBindedSuccess)]) {
                    [weakSelf.delegate storeCodeBindedSuccess];
                }
                [weakSelf dismissViewControllerAnimated:YES completion:nil];
            }];
        }else {
            [XBLoadingView showHUDViewWithText:MESSAGE(returnValue)];
        }
        
    } withFailureBlock:^(NSError *error) {
        [XBLoadingView showHUDViewWithText:error.localizedDescription];
    }];
}


#pragma mark -帮助按钮
- (IBAction)helpButtonClickAction:(UIButton *)sender {
    
    CustomWKWebViewController *webView = [[CustomWKWebViewController alloc] init];
    webView.type = Image;
    webView.urlString = [[NSBundle mainBundle] pathForResource:@"reference" ofType:@"png"];
    [self presentViewController:webView animated:YES completion:nil];
}


#pragma mark -确认按钮
- (IBAction)sureButtonClickAction:(UIButton *)sender {
    
    [self.storeNumberTextField resignFirstResponder];
    [self modifyResellerInformation];
}



















@end