123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606 |
- //
- // JXRechargeViewController.m
- // shiku_im
- //
- // Created by 1 on 17/10/30.
- // Copyright © 2017年 Reese. All rights reserved.
- //
- #import "JXRechargeViewController.h"
- #import "JXRechargeCell.h"
- #import "UIImage+Color.h"
- #import <AlipaySDK/AlipaySDK.h>
- #import "JXQRCodeViewController.h"
- @interface JXRechargeViewController ()<UIAlertViewDelegate,UITextFieldDelegate>
- @property (nonatomic, assign) NSInteger checkIndex;
- @property (atomic, assign) NSInteger payType;
- //@property (nonatomic, strong) NSArray * rechargeArray;
- @property (nonatomic, strong) NSArray * rechargeMoneyArray;
- @property (nonatomic, strong) UILabel * totalMoney;
- @property (nonatomic, strong) UIButton * wxPayBtn;
- @property (nonatomic, strong) UIButton * aliPayBtn;
- @property (atomic, assign) NSInteger btnIndex;
- @property (nonatomic, strong) UIView *baseView;
- @property (nonatomic, strong) UITextField *moneyTextField;
- @end
- static NSString * JXRechargeCellID = @"JXRechargeCellID";
- @implementation JXRechargeViewController
- -(instancetype)init{
- if (self = [super init]) {
- self.heightHeader = JX_SCREEN_TOP;
- self.heightFooter = 0;
- self.isGotoBack = YES;
- self.title = Localized(@"JXLiveVC_Recharge");
- self.rechargeMoneyArray = @[@10,
- @20,
- @50,
- @100,
- @200,
- @500];
- _checkIndex = -1;
-
- [g_notify addObserver:self selector:@selector(receiveWXPayFinishNotification:) name:kWxPayFinishNotification object:nil];
- [g_notify addObserver:self selector:@selector(receiveAliPayFinishNotification:) name:kWCMessageTypeOpenPaySuccessRefresh object:nil];
- }
- return self;
- }
- - (void)viewDidLoad {
- [super viewDidLoad];
- [self createHeadAndFoot];
-
- self.baseView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, JX_SCREEN_WIDTH,56*2)];
- [self.tableBody addSubview:self.baseView];
-
- [self setupViews];
-
-
- UIView *line = [[UIView alloc] initWithFrame:CGRectMake(15, CGRectGetMaxY(self.baseView.frame)+20, JX_SCREEN_WIDTH-30, LINE_WH)];
- line.backgroundColor = THE_LINE_COLOR;
- [self.tableBody addSubview:line];
-
- UILabel *tinLabel = [[UILabel alloc] initWithFrame:CGRectMake(15, CGRectGetMaxY(line.frame)+20, 130, 14)];
- tinLabel.textColor = HEXCOLOR(0x999999);
- tinLabel.font = SYSFONT(14);
- tinLabel.text = @"请选择充值方式";
- [self.tableBody addSubview:tinLabel];
-
-
- UILabel *leftLab = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 48, 16)];
- leftLab.font = SYSFONT(16);
- leftLab.text = @"合计: ";
-
- UILabel *rigLab = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 24, 24)];
- rigLab.font = SYSFONT(24);
- rigLab.textColor = THEMECOLOR;
- rigLab.text = @"元";
- self.moneyTextField = [[UITextField alloc] initWithFrame:CGRectMake(15, CGRectGetMaxY(tinLabel.frame)+24, JX_SCREEN_WIDTH-30, 24)];
- self.moneyTextField.placeholder = @"请输入金额";
- self.moneyTextField.textColor = THEMECOLOR;
- self.moneyTextField.font = SYSFONT(24);
- self.moneyTextField.leftView = leftLab;
- self.moneyTextField.leftViewMode = UITextFieldViewModeAlways;
- self.moneyTextField.rightView = rigLab;
- self.moneyTextField.rightViewMode = UITextFieldViewModeAlways;
- self.moneyTextField.delegate = self;
- self.moneyTextField.keyboardType = UIKeyboardTypeDecimalPad;
- self.moneyTextField.text = [NSString stringWithFormat:@"%.2f",[self.rechargeMoneyArray[self.btnIndex] doubleValue]];
- [self.moneyTextField addTarget:self action:@selector(textFieldDidChange:) forControlEvents:UIControlEventEditingChanged];
- [self.tableBody addSubview:self.moneyTextField];
-
- [self setTextFieldWidth:self.moneyTextField.text];
-
- // self.wxPayBtn = [self payTypeBtn:CGRectMake(0, CGRectGetMaxY(self.moneyTextField.frame)+30, JX_SCREEN_WIDTH, 56) title:@"微信支付" image:@"weixin_logo" drawTop:NO drawBottom:YES action:@selector(wxPayBtnAction:)];
-
- // self.aliPayBtn = [self payTypeBtn:CGRectMake(0, CGRectGetMaxY(self.wxPayBtn.frame), JX_SCREEN_WIDTH, 56) title:@"支付宝支付" image:@"aliPay_logo" drawTop:NO drawBottom:NO action:@selector(aliPayBtnAction:)];
- self.aliPayBtn = [self payTypeBtn:CGRectMake(0, CGRectGetMaxY(self.moneyTextField.frame)+30, JX_SCREEN_WIDTH, 56) title:@"支付宝支付" image:@"aliPay_logo" drawTop:NO drawBottom:NO action:@selector(aliPayBtnAction:)];
- UILabel *tipsLabel = [[UILabel alloc] initWithFrame:CGRectMake(15, CGRectGetMaxY(self.aliPayBtn.frame)+20, JX_SCREEN_WIDTH - 15, 14)];
- tipsLabel.textColor = [UIColor redColor];
- tipsLabel.font = SYSFONT(14);
- tipsLabel.text = @"提醒:请根据界面操作,请勿修改金额和重复扫码";
- [self.tableBody addSubview:tipsLabel];
- // self.isShowHeaderPull = NO;
- // self.isShowFooterPull = NO;
- // _table.backgroundColor = HEXCOLOR(0xefeff4);
- // [_table registerClass:[JXRechargeCell class] forCellReuseIdentifier:JXRechargeCellID];
- // _table.showsVerticalScrollIndicator = NO;
- // _table.separatorStyle = UITableViewCellSeparatorStyleSingleLine;
- }
- - (void)textFieldDidChange:(UITextField *)textField {
- if (textField == self.moneyTextField) {
- if ([textField.text doubleValue] >= 10000) {
- textField.text = @"10000";
- }
- }
- [self setTextFieldWidth:textField.text];
- }
- - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {
- NSString * toBeString = [textField.text stringByReplacingCharactersInRange:range withString:string];
- if (textField == self.moneyTextField) {
- // 首位不能输入 .
- if (IsStringNull(textField.text) && [string isEqualToString:@"."]) {
- return NO;
- }
- //限制.后面最多有两位,且不能再输入.
- if ([textField.text rangeOfString:@"."].location != NSNotFound) {
- //有.了 且.后面输入了两位 停止输入
- if (toBeString.length > [toBeString rangeOfString:@"."].location+3) {
- return NO;
- }
- //有.了,不允许再输入.
- if ([string isEqualToString:@"."]) {
- return NO;
- }
- }
- //限制首位0,后面只能输入. 和 删除
- if ([textField.text isEqualToString:@"0"]) {
- if (![string isEqualToString:@"."] && ![string isEqualToString:@""]) {
- return NO;
- }
- }
- //限制只能输入:1234567890.
- NSCharacterSet * characterSet = [[NSCharacterSet characterSetWithCharactersInString:@"1234567890."] invertedSet];
- NSString * filtered = [[string componentsSeparatedByCharactersInSet:characterSet] componentsJoinedByString:@""];
- return [string isEqualToString:filtered];
- }
- return YES;
- }
- - (void)setupViews {
- UIButton *btn;
- CGFloat w = 89;
- int inset = (JX_SCREEN_WIDTH-w*3)/4;
- for (int i = 0; i < self.rechargeMoneyArray.count; i++) {
- CGFloat x = (w+inset)*(i % 3)+inset;
- int m = i / 3;
- btn = [self createButtonWihtFrame:CGRectMake(x, m*41+(15 * (m +1)), w, 41) title:[NSString stringWithFormat:@"%.2f元",[self.rechargeMoneyArray[i] doubleValue]] index:i];
- }
- }
- - (void)onDidMoney:(UIButton *)button {
- if ([self.moneyTextField isFirstResponder]) {
- [self.moneyTextField resignFirstResponder];
- }
- self.btnIndex = button.tag;
-
- self.moneyTextField.text = [NSString stringWithFormat:@"%.2f",[self.rechargeMoneyArray[self.btnIndex] doubleValue]];
- [self setTextFieldWidth:self.moneyTextField.text];
-
- for (UIView *view in self.baseView.subviews) {
- [view removeFromSuperview];
- }
- [self setupViews];
- }
- - (BOOL)textFieldShouldBeginEditing:(UITextField *)textField {
- self.btnIndex = self.rechargeMoneyArray.count+1;
- textField.text = @"";
- [self setTextFieldWidth:textField.text];
-
- for (UIView *view in self.baseView.subviews) {
- [view removeFromSuperview];
- }
- [self setupViews];
- return YES;
- }
- - (void)setTextFieldWidth:(NSString *)s {
- CGSize size = [s sizeWithAttributes:@{NSFontAttributeName:SYSFONT(24)}];
-
- CGRect frame = self.moneyTextField.frame;
- if (s.length > 0) {
- frame.size.width = size.width+48+24;
- }else {
- frame.size.width = 130+48+24;
- }
- self.moneyTextField.frame = frame;
- }
- - (BOOL)textFieldShouldEndEditing:(UITextField *)textField {
- if ([textField.text doubleValue] > 0) {
- self.moneyTextField.text = [NSString stringWithFormat:@"%.2f元",[textField.text doubleValue]];
- }
- return YES;
- }
- -(void)dealloc{
- [g_notify removeObserver:self];
- }
- //-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
- // return _rechargeMoneyArray.count;
- //}
- //
- //-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
- // return 65;
- //}
- //
- //-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
- // JXRechargeCell * cell = [tableView dequeueReusableCellWithIdentifier:JXRechargeCellID forIndexPath:indexPath];
- // NSString * money = [NSString stringWithFormat:@"%@%@",_rechargeMoneyArray[indexPath.row],Localized(@"JX_ChinaMoney")];
- // cell.textLabel.text = money;
- // if(_checkIndex == indexPath.row){
- // cell.checkButton.selected = YES;
- // }
- // return cell;
- //}
- //
- //-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
- // _checkIndex = indexPath.row;
- // NSString * money = [NSString stringWithFormat:@"%@",_rechargeMoneyArray[indexPath.row]];
- // [self setTotalMoneyText:money];
- // NSArray * cellArray = [tableView visibleCells];
- // for (JXRechargeCell * cell in cellArray) {
- // cell.checkButton.selected = NO;
- // }
- //
- // JXRechargeCell * selCell = [tableView cellForRowAtIndexPath:indexPath];
- // selCell.checkButton.selected = YES;
- //}
- //
- //-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
- // return 200;
- //}
- //
- //-(UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
- // UIView * paySelView = [[UIView alloc] init];
- // paySelView.backgroundColor = HEXCOLOR(0xefeff4);
- // UILabel * payStyleLabel = [UIFactory createLabelWith:CGRectMake(20, 0, JX_SCREEN_WIDTH-20*2, 40) text:Localized(@"JXMoney_choosePayType") font:g_factory.font14 textColor:[UIColor lightGrayColor] backgroundColor:[UIColor clearColor]];
- // [paySelView addSubview:payStyleLabel];
- //
- // UIView * whiteView = [[UIView alloc] init];
- // whiteView.backgroundColor = [UIColor whiteColor];
- // whiteView.frame = CGRectMake(0, CGRectGetMaxY(payStyleLabel.frame), JX_SCREEN_WIDTH, 200-CGRectGetMaxY(payStyleLabel.frame));
- // [paySelView addSubview:whiteView];
- //
- // UILabel * totalTitle = [UIFactory createLabelWith:CGRectZero text:nil font:g_factory.font14 textColor:[UIColor lightGrayColor] backgroundColor:[UIColor clearColor]];
- // NSString * totalStr = Localized(@"JXMoney_total");
- // CGFloat totalWidth = [totalStr sizeWithAttributes:@{NSFontAttributeName:totalTitle.font}].width;
- // totalTitle.frame = CGRectMake(20, 20, totalWidth+5, 18);
- // totalTitle.text = totalStr;
- // [whiteView addSubview:totalTitle];
- //
- //
- // _totalMoney = [UIFactory createLabelWith:CGRectZero text:nil font:g_factory.font20 textColor:[UIColor lightGrayColor] backgroundColor:[UIColor clearColor]];
- // NSString * totalMoneyStr = @"¥--";
- // CGFloat moneyWidth = [totalMoneyStr sizeWithAttributes:@{NSFontAttributeName:_totalMoney.font}].width;
- // _totalMoney.frame = CGRectMake(CGRectGetMaxX(totalTitle.frame), 20, moneyWidth+5, 18);
- // _totalMoney.text = totalMoneyStr;
- // _totalMoney.textColor = [UIColor redColor];
- // [whiteView addSubview:_totalMoney];
- //
- // _wxPayBtn = [UIFactory createButtonWithRect:CGRectZero title:Localized(@"JXMoney_wxPay") titleFont:g_factory.font17 titleColor:[UIColor whiteColor] normal:nil selected:nil selector:@selector(wxPayBtnAction:) target:self];
- // _wxPayBtn.frame = CGRectMake(20, CGRectGetMaxY(_totalMoney.frame)+20, JX_SCREEN_WIDTH-20*2, 40);
- // [_wxPayBtn setBackgroundImage:[UIImage createImageWithColor:HEXCOLOR(0x1aad19)] forState:UIControlStateNormal];
- // [_wxPayBtn setBackgroundImage:[UIImage createImageWithColor:HEXCOLOR(0xa2dea3)] forState:UIControlStateDisabled];
- // _wxPayBtn.layer.cornerRadius = 5;
- // _wxPayBtn.clipsToBounds = YES;
- // [whiteView addSubview:_wxPayBtn];
- //
- //
- // _aliPayBtn = [UIFactory createButtonWithRect:CGRectZero title:Localized(@"JXMoney_aliPay") titleFont:g_factory.font17 titleColor:[UIColor whiteColor] normal:nil selected:nil selector:@selector(aliPayBtnAction:) target:self];
- // _aliPayBtn.frame = CGRectMake(20, CGRectGetMaxY(_wxPayBtn.frame)+15, JX_SCREEN_WIDTH-20*2, 40);
- // [_aliPayBtn setBackgroundImage:[UIImage createImageWithColor:HEXCOLOR(0x1aad19)] forState:UIControlStateNormal];
- // [_aliPayBtn setBackgroundImage:[UIImage createImageWithColor:HEXCOLOR(0xa2dea3)] forState:UIControlStateDisabled];
- // _aliPayBtn.layer.cornerRadius = 5;
- // _aliPayBtn.clipsToBounds = YES;
- // [whiteView addSubview:_aliPayBtn];
- //
- //
- // return paySelView;
- //}
- -(void)setTotalMoneyText:(NSString *)money{
- NSString * totalMoneyStr = [NSString stringWithFormat:@"¥%@",money];
- CGFloat moneyWidth = [totalMoneyStr sizeWithAttributes:@{NSFontAttributeName:_totalMoney.font}].width;
- CGRect frame = _totalMoney.frame;
- frame.size.width = moneyWidth;
- _totalMoney.frame = frame;
- _totalMoney.text = totalMoneyStr;
- }
- - (void)didReceiveMemoryWarning {
- [super didReceiveMemoryWarning];
- // Dispose of any resources that can be recreated.
- }
- #pragma mark Action
- -(void)wxPayBtnAction:(UIButton *)button{
- // if (_checkIndex >=0 && _checkIndex <_rechargeMoneyArray.count) {
- // NSString * money = [NSString stringWithFormat:@"%@",_rechargeMoneyArray[_checkIndex]];
- // _payType = 2;
- // [g_server getSign:money payType:2 toView:self];
- // }
- if ([self.moneyTextField.text doubleValue] > 0) {
- _payType = 2;
- [g_server getSign:self.moneyTextField.text payType:2 toView:self];
- }
- }
- -(void)aliPayBtnAction:(UIButton *)button{
- // if (_checkIndex >=0 && _checkIndex <_rechargeMoneyArray.count) {
- // NSString * money = [NSString stringWithFormat:@"%@",_rechargeMoneyArray[_checkIndex]];
- // _payType = 1;
- // [g_server getSign:money payType:1 toView:self];
- // }
- if ([self.moneyTextField.text doubleValue] > 0) {
- _payType = 1;
- // [g_server getSign:self.moneyTextField.text payType:1 toView:self];
- [g_server paymentByThirdAmount:self.moneyTextField.text type:@"1" ToView:self];
- }
- }
- -(void)tuningWxWith:(NSDictionary *)dict{
- PayReq *req = [[PayReq alloc] init];
- req.partnerId = [dict objectForKey:@"partnerId"];
- req.prepayId = [dict objectForKey:@"prepayId"];
- req.nonceStr = [dict objectForKey:@"nonceStr"];
- req.timeStamp = [[dict objectForKey:@"timeStamp"] intValue];
- req.package = @"Sign=WXPay";//[dict objectForKey:@"package"];
- req.sign = [dict objectForKey:@"sign"];
- [WXApi sendReq:req];
- }
- - (void)tuningAlipayWithOrder:(NSString *)signedString {
- // NOTE: 如果加签成功,则继续执行支付
- if (signedString != nil) {
- //应用注册scheme,在AliSDKDemo-Info.plist定义URL types
- NSString *appScheme = @"shikuimapp";
- // NOTE: 调用支付结果开始支付
- [[AlipaySDK defaultService] payOrder:signedString fromScheme:appScheme callback:^(NSDictionary *resultDic) {
-
- SBJsonParser * resultParser = [[SBJsonParser alloc] init] ;
- NSDictionary *resultObject = [resultParser objectWithString:resultDic[@"result"]];
- NSDictionary *response = [resultObject objectForKey:@"alipay_trade_app_pay_response"];
- if ([response[@"msg"] isEqualToString:@"Success"]) {
-
- [g_App showAlert:@"充值成功" delegate:self tag:1001 onlyConfirm:YES];
- }else {
-
- [g_App showAlert:@"充值失败" delegate:self tag:1001 onlyConfirm:YES];
- }
- [self actionQuit];
- NSLog(@"reslut = %@",resultDic);
- }];
- }
- }
- -(void)receiveWXPayFinishNotification:(NSNotification *)notifi{
- PayResp *resp = notifi.object;
- switch (resp.errCode) {
- case WXSuccess:{
- [g_App showAlert:Localized(@"JXMoney_PaySuccess") delegate:self tag:1001 onlyConfirm:YES];
- if (self.rechargeDelegate && [self.rechargeDelegate respondsToSelector:@selector(rechargeSuccessed)]) {
- [self.rechargeDelegate performSelector:@selector(rechargeSuccessed)];
- }
- if (_isQuitAfterSuccess) {
- [self actionQuit];
- }
- break;
- }
- case WXErrCodeUserCancel:{
- //取消了支付
- break;
- }
- default:{
- //支付错误
- UIAlertView *alert = [[UIAlertView alloc] initWithTitle:[NSString stringWithFormat:@"支付失败!retcode = %d, retstr = %@", resp.errCode,resp.errStr] message:nil delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
- [alert show];
- break;
- }
- }
-
- }
- - (void)receiveAliPayFinishNotification:(NSNotification *)notifi {
- // JXMessageObject *msg = notifi.object;
- // msg.content;
- // SBJsonParser * resultParser = [[SBJsonParser alloc] init] ;
- //
- // NSDictionary *response = [self dictionaryWithJsonString: msg.content];
- // int status = (int)response[@"status"];
- // if (status == 1) {
- // [g_App showAlert:@"充值成功" delegate:self tag:1001 onlyConfirm:YES];
- // }else {
- //
- // [g_App showAlert:@"充值失败" delegate:self tag:1001 onlyConfirm:YES];
- // }
- // [self actionQuit];
-
- }
- //json格式字符串转字典:
- - (NSDictionary *)dictionaryWithJsonString:(NSString *)jsonString {
-
- if (jsonString == nil) {
-
- return nil;
-
- }
-
- NSData *jsonData = [jsonString dataUsingEncoding:NSUTF8StringEncoding];
-
- NSError *err;
-
- NSDictionary *dic = [NSJSONSerialization JSONObjectWithData:jsonData
-
- options:NSJSONReadingMutableContainers
-
- error:&err];
-
- if(err) {
-
- NSLog(@"json解析失败:%@",err);
-
- return nil;
-
- }
-
- return dic;
-
- }
- -(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
- if (alertView.tag == 1001) {
- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.6 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
- [g_server getUserMoenyToView:self];
- });
- }
- }
- - (void)didServerResultSucces:(JXConnection *)aDownload dict:(NSDictionary *)dict array:(NSArray *)array1{
- [_wait stop];
- if ([aDownload.action isEqualToString:act_getSign]) {
- if ([[dict objectForKey:@"package"] isEqualToString:@"Sign=WXPay"]) {
- [self tuningWxWith:dict];
- }else {
- [self tuningAlipayWithOrder:[dict objectForKey:@"orderInfo"]];
- }
- }else if ([aDownload.action isEqualToString:act_getUserMoeny]) {
- g_App.myMoney = [dict[@"balance"] doubleValue];
- [g_notify postNotificationName:kUpdateUserNotifaction object:nil];
- [self actionQuit];
- }
-
- if ([aDownload.action isEqualToString:act_paymentByThird]) {
- if (dict == nil) {
- return;
- }
- NSString *qrString = dict[@"data"][@"codeOriginal"];
-
- // 显示二维码
- JXQRCodeViewController * qrVC = [[JXQRCodeViewController alloc] init];
- qrVC.type = QRAliPayType;
- qrVC.qrString = qrString;
- qrVC.nickName = [NSString stringWithFormat:@"支付金额: %@元",self.moneyTextField.text];
- qrVC.amount = self.moneyTextField.text;
- // qrVC.qrString =
- // qrVC.userId = user.userId;
- // qrVC.account = user.account;
- // qrVC.nickName = user.userNickname;
- // qrVC.sex = user.sex;
- // [g_window addSubview:qrVC.view];
- [g_navigation pushViewController:qrVC animated:YES];
- }
-
- }
- - (int)didServerResultFailed:(JXConnection *)aDownload dict:(NSDictionary *)dict{
- [_wait stop];
- // if ([aDownload.action isEqualToString:]) {
- // return hide_error
- // }
- // [self tuningAlipayWithOrder:[dict objectForKey:@"resultMsg"][@"data"][@""]];
-
- return show_error;
- }
- - (int)didServerConnectError:(JXConnection *)aDownload error:(NSError *)error{
- [_wait stop];
- // if ([aDownload.action isEqualToString:]) {
- // [self refreshAfterConnectError];
- // }
- return hide_error;
- }
- -(void) didServerConnectStart:(JXConnection*)aDownload{
- [_wait start];
- }
- - (UIButton *)createButtonWihtFrame:(CGRect)frame title:(NSString *)title index:(NSInteger)index {
- UIButton *btn = [[UIButton alloc] initWithFrame:frame];
- [btn setTag:index];
- UIImageView *imgV = [[UIImageView alloc] initWithFrame:btn.bounds];
- imgV.image = [[UIImage imageNamed:@"Recharge_normal"] imageWithTintColor:THEMECOLOR];
- [btn addSubview:imgV];
-
- UILabel *label = [[UILabel alloc] initWithFrame:btn.bounds];
- label.text = title;
- label.backgroundColor = [UIColor clearColor];
- label.textColor = THEMECOLOR;
- label.textAlignment = NSTextAlignmentCenter;
- label.font = SYSFONT(14);
- [btn addSubview:label];
- if (self.btnIndex == index) {
- imgV.image = [[UIImage imageNamed:@"Recharge_seleted"] imageWithTintColor:THEMECOLOR];
- label.textColor = [UIColor whiteColor];
- }
- [btn addTarget:self action:@selector(onDidMoney:) forControlEvents:UIControlEventTouchUpInside];
-
- [self.baseView addSubview:btn];
-
- return btn;
- }
- - (UIButton *)payTypeBtn:(CGRect)frame title:(NSString *)title image:(NSString *)image drawTop:(BOOL)drawTop drawBottom:(BOOL)drawBottom action:(SEL)action {
- UIButton *btn = [[UIButton alloc] initWithFrame:frame];
-
- UIImageView *imgV = [[UIImageView alloc] initWithFrame:CGRectMake(frame.size.width-19-36, (frame.size.height-19)/2, 19, 19)];
- imgV.image = [UIImage imageNamed:image];
- [btn addSubview:imgV];
- if (action == @selector(wxPayBtnAction:)) {
- imgV.frame = CGRectMake(frame.size.width-20-36, (frame.size.height-16)/2, 20, 16);
- }
- UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(15, 0, 100, frame.size.height)];
- label.text = title;
- label.backgroundColor = [UIColor clearColor];
- label.textColor = HEXCOLOR(0x222222);
- label.font = SYSFONT(16);
- [btn addSubview:label];
-
- [btn addTarget:self action:action forControlEvents:UIControlEventTouchUpInside];
-
- [self.tableBody addSubview:btn];
-
- if(drawTop){
- UIView* line = [[UIView alloc] initWithFrame:CGRectMake(15,0,JX_SCREEN_WIDTH-15,LINE_WH)];
- line.backgroundColor = THE_LINE_COLOR;
- [btn addSubview:line];
- }
-
- if(drawBottom){
- UIView* line = [[UIView alloc]initWithFrame:CGRectMake(15, frame.size.height-LINE_WH,JX_SCREEN_WIDTH-15,LINE_WH)];
- line.backgroundColor = THE_LINE_COLOR;
- [btn addSubview:line];
- }
-
- UIImageView *iv = [[UIImageView alloc] initWithFrame:CGRectMake(JX_SCREEN_WIDTH-15-7, frame.size.height/2-13/2, 7, 13)];
- iv.image = [UIImage imageNamed:@"new_icon_>"];
- [btn addSubview:iv];
-
- return btn;
- }
- @end
|