//
//  ViewController.m
//  XFBPayDemo
//
//  Created by chenwei on 15/11/17.
//  Copyright © 2015年 chenwei. All rights reserved.
//

#import "ViewController.h"
#import "XFBPayListViewController.h"



@interface ViewController ()

@property (nonatomic, assign) BOOL isDebug;
@property (weak, nonatomic) IBOutlet UITextField *moneyTextField;
@property (weak, nonatomic) IBOutlet UITextField *tradeNoTextField;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];

    // Do any additional setup after loading the view, typically from a nib.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}




- (IBAction)payButtonAction:(id)sender
{
    self.tradeNoTextField.text = [self generateTradeNO];
    XFBPayListViewController *payVC = [[XFBPayListViewController alloc] init];
    payVC.money = self.moneyTextField.text;
    payVC.tradeNo = self.tradeNoTextField.text;
    [self.navigationController pushViewController:payVC animated:YES];
}


- (NSString *)generateTradeNO
{
    NSString *resultStr1 = [NSString stringWithFormat:@"%ld",time(NULL)];
    return resultStr1;
    static int kNumber = 20;
    
    NSString *sourceStr = @"0123456789ABCDEFGHIGLKLMNOPQRSTUVWXYZ";
    NSMutableString *resultStr = [[NSMutableString alloc] init];
    
    for (int i = 0; i < kNumber; i++)
    {
        unsigned index = arc4random() % [sourceStr length];
        NSString *oneStr = [sourceStr substringWithRange:NSMakeRange(index, 1)];
        [resultStr appendString:oneStr];
    }
    return resultStr;
}


- (void)touchesEnded:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
{
    [self.view endEditing:YES];
}

@end
