网银支付

   导入第三方库:

  UPPayPlugin文件

  导入framework:

 


.h 文件

//  Created by cjw on 16-05-12.

//  Copyright (c) 2016 cjw. All rights reserved.

//


#import <UIKit/UIKit.h>

#import "UPPayPluginDelegate.h"



@interface ViewController : UIViewController<UPPayPluginDelegate, UIAlertViewDelegate,UITableViewDataSource,UITableViewDelegate,UITextFieldDelegate>



@property(nonatomic, retain)UITableView *tableView;


@end


.m 文件


//  Created by cjw on 16-05-12.

//  Copyright (c) 2016 cjw. All rights reserved.

//

#include <sys/socket.h> // Per msqr

#include <sys/sysctl.h>

#include <net/if.h>

#include <net/if_dl.h>

#import "ViewController.h"

#import "UPPayPlugin.h"


#define KBtn_width        200

#define KBtn_height       80

#define KXOffSet          (self.view.frame.size.width - KBtn_width) / 2

#define KYOffSet          80

#define kCellHeight_Normal  50

#define kCellHeight_Manual  145


#define kBtnFirstTitle    @"获取订单,开始测试"

#define kWaiting          @"正在获取TN,请稍后..."

#define kNote             @"提示"         

#define kConfirm          @"确定"

#define kErrorNet         @"网络错误"

#define kResult           @"支付结果:%@"



#define kMode_Development             @"01"

#define kURL_TN_Normal                @"http://202.101.25.178:8080/sim/gettn"

#define kURL_TN_Configure             @"http://202.101.25.178:8080/sim/app.jsp?user=123456789"


#define UPRelease(X) if (X !=nil) {[X release];X = nil;}


@interface ViewController ()

{

    UIAlertView* _alertView;

    NSMutableData* _responseData;

    CGFloat _maxWidth;

    CGFloat _maxHeight;

    

    UITextField *_urlField;

    UITextField *_modeField;

    UITextField *_curField;

}


@property(nonatomic, copy)NSString *tnMode;


- (void)extendedLayout;


- (void)showAlertWait;

- (void)showAlertMessage:(NSString*)msg;

- (void)hideAlert;


- (void)startNetWithURL:(NSURL *)url;


- (UITextField *)textFieldWithFrame:(CGRect)frame placeHolder:(NSString *)placeHolder;


- (void)buttonAction;


@end


@implementation ViewController

@synthesize contentTableView;

@synthesize tnMode;




- (void)viewDidLoad

{

    [super viewDidLoad];

    self.view.backgroundColor = [UIColor whiteColor];

    self.title = @"商户测试";

    

    //判断手机系统

    [self extendedLayout];

    

    //初始化tableview

    self.tableView = ({

        UITableView *tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, _maxWidth, _maxHeight) style:UITableViewStyleGrouped];

        tableView.delegate = self;

        tableView.dataSource = self;

        tableView;

    });

    

    [self.view addSubview:self.contentTableView];

}


//判断手机系统

- (void)extendedLayout

{

    BOOL iOS7 = [UIDevice currentDevice].systemVersion.floatValue >= 7.0;

    if (iOS7) {

        self.edgesForExtendedLayout = UIRectEdgeNone;

        self.automaticallyAdjustsScrollViewInsets = NO;

    }

    

    CGFloat offset = iOS7 ? 64 : 44;

    _maxWidth = CGRectGetWidth([UIScreen mainScreen].bounds);

    _maxHeight = CGRectGetHeight([UIScreen mainScreen].bounds)-offset;

    

    self.navigationController.navigationBar.translucent = NO;

}



//点击cell的时候就去网络请求数据

- (void)startNetWithURL:(NSURL *)url

{

    [_curField resignFirstResponder];

    _curField = nil;

    [self showAlertWait];

    

    NSURLRequest * urlRequest=[NSURLRequest requestWithURL:url];

    NSURLConnection* urlConn = [[NSURLConnection alloc] initWithRequest:urlRequest delegate:self];

    [urlConn start];

}

//用到的时候创建UITextField

- (UITextField *)textFieldWithFrame:(CGRect)frame placeHolder:(NSString *)placeHolder

{

    UITextField *textField = [[UITextField alloc] initWithFrame:frame] ;

    textField.placeholder = placeHolder;

    textField.borderStyle = UITextBorderStyleRoundedRect;

    textField.backgroundColor = [UIColor clearColor];

    textField.delegate = self;

    return textField;

}


#pragma mark - Alert初始化


- (void)showAlertWait

{

    [self hideAlert];

    _alertView = [[UIAlertView alloc] initWithTitle:kWaiting message:nil delegate:self cancelButtonTitle:nil otherButtonTitles: nil];

    [_alertView show];

    UIActivityIndicatorView* aiv = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhite];

    aiv.center = CGPointMake(_alertView.frame.size.width / 2.0f - 15, _alertView.frame.size.height / 2.0f + 10 );

    [aiv startAnimating];

    [_alertView addSubview:aiv];


}


- (void)showAlertMessage:(NSString*)msg

{

    [self hideAlert];

    _alertView = [[UIAlertView alloc] initWithTitle:kNote message:msg delegate:self cancelButtonTitle:kConfirm otherButtonTitles:nil, nil];

    [_alertView show];

  

}

- (void)hideAlert

{

    if (_alertView != nil)

    {

        [_alertView dismissWithClickedButtonIndex:0 animated:NO];

        _alertView = nil;

    }

}


- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex

{

    _alertView = nil;

}


#pragma mark - 网络请求


- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse*)response

{

    NSHTTPURLResponse* rsp = (NSHTTPURLResponse*)response;

    //获取网络返回码

    NSInteger code = [rsp statusCode];

    if (code != 200)

    {

        

        [self showAlertMessage:kErrorNet];

        [connection cancel];

    }

    else

    {

        _responseData = [[NSMutableData alloc] init];

    }

}

//有数据的时候就接受数据

- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data

{

    [_responseData appendData:data];

}


- (void)connectionDidFinishLoading:(NSURLConnection *)connection

{

    [self hideAlert];

    NSString* tn = [[NSMutableString alloc] initWithData:_responseData encoding:NSUTF8StringEncoding];

    if (tn != nil && tn.length > 0)

    {

        NSLog(@"tn=%@",tn);

        //请求成功:把TN传给 UPPayplugin 此处设置代理监听支付结果

        [UPPayPlugin startPay:tn mode:self.tnMode viewController:self delegate:self];

    }

}


-(void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error

{

    [self showAlertMessage:kErrorNet];

}



#pragma mark 监听支付结果

- (void)UPPayPluginResult:(NSString *)result

{

    NSString* msg = [NSString stringWithFormat:kResult, result];

    [self showAlertMessage:msg];

}





#pragma mark -

#pragma mark UITableView 代理方法


- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath

{

    

    switch (indexPath.row) {

        case 0:

            

            self.tnMode = kMode_Development;

            [self startNetWithURL:[NSURL URLWithString:kURL_TN_Normal]];

            [tableView deselectRowAtIndexPath:indexPath animated:YES];

            

            break;

        case 1:

            self.tnMode = kMode_Development;

            [self startNetWithURL:[NSURL URLWithString:kURL_TN_Configure]];

            [tableView deselectRowAtIndexPath:indexPath animated:YES];

            break;

        case 2:

            [tableView deselectRowAtIndexPath:indexPath animated:NO];

            break;

            

        default:

            break;

    }

}


#pragma mark -

#pragma mark UITableView 数据源代理


- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath

{

    return (indexPath.row == 2) ? kCellHeight_Manual : kCellHeight_Normal;

}


- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView

{

    return 1;

}


- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)sectionIndex

{

    return 3;

}




- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath

{

    UITableViewCell *cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:nil];

    

    switch (indexPath.row) {

        case 0:

        {

            cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;

            cell.textLabel.text = @"普通订单";

            cell.detailTextLabel.text = @"mode=01";

        }

            

            break;

        case 1:

        {

            cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;

            cell.textLabel.text = @"配置用户123456789";

            cell.detailTextLabel.text = @"mode=01";

        }

            break;

        case 2:

        {

             //点击cell的时候去掉选中效果,

            [cell setSelectionStyle:UITableViewCellSelectionStyleNone];

            

            CGRect urlFrame = CGRectMake(10, 10, CGRectGetWidth(tableView.frame)-20, 35);

            _urlField = [self textFieldWithFrame:urlFrame placeHolder:@"获取TN地址"];

            [cell.contentView addSubview:_urlField];

            

            CGRect modeFrame = CGRectMake(10, 55, CGRectGetWidth(tableView.frame)-20, 35);

            _modeField = [self textFieldWithFrame:modeFrame placeHolder:@"mode"];

            [cell.contentView addSubview:_modeField];

            

            CGRect btnFrame = CGRectMake(50, 100, CGRectGetWidth(tableView.frame)-100, 35);

            UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];

            button.frame = btnFrame;

            [button addTarget:self action:@selector(buttonAction) forControlEvents:UIControlEventTouchUpInside];

            [button setTitle:@"      " forState:UIControlStateNormal];

            [cell.contentView addSubview:button];

            

        }

            break;

        

            

        default:

            break;

    }

    

    

    

    return cell;

}


- (void)buttonAction

{

    self.tnMode = _modeField.text;

    [self startNetWithURL:[NSURL URLWithString:_urlField.text]];

}



#pragma mark UITextFieldDelegate

- (void)textFieldDidBeginEditing:(UITextField *)textField

{

    _curField = textField;

}


@end



 


内容概要:本文档是一份关于交换路由配置的学习笔记,系统地介绍了网络设备的远程管理、交换机与路由器的核心配置技术。内容涵盖Telnet、SSH、Console三种远程控制方式的配置方法;详细讲解了VLAN划分原理及Access、Trunk、Hybrid端口的工作机制,以及端口镜像、端口汇聚、端口隔离等交换技术;深入解析了STP、MSTP、RSTP生成树协议的作用与配置步骤;在路由部分,涵盖了IP地址配置、DHCP服务部署(接口池与全局池)、NAT转换(静态与动态)、静态路由、RIP与OSPF动态路由协议的配置,并介绍了策略路由和ACL访问控制列表的应用;最后简要说明了华为防火墙的安全区域划分与基本安全策略配置。; 适合人群:具备一定网络基础知识,从事网络工程、运维或相关技术岗位1-3年的技术人员,以及准备参加HCIA/CCNA等认证考试的学习者。; 使用场景及目标:①掌握企业网络中常见的交换与路由配置技能,提升实际操作能力;②理解VLAN、STP、OSPF、NAT、ACL等核心技术原理并能独立完成中小型网络搭建与调试;③通过命令示例熟悉华为设备CLI配置逻辑,为项目实施和故障排查提供参考。; 阅读建议:此笔记以实用配置为主,建议结合模拟器(如eNSP或Packet Tracer)动手实践每一条命令,对照拓扑理解数据流向,重点关注VLAN间通信、路由选择机制、安全策略控制等关键环节,并注意不同设备型号间的命令差异。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值