Commit d5a5bd05 authored by guanghui.shi's avatar guanghui.shi

设置微信授权页面开发

parent 76da1e2e
......@@ -178,6 +178,7 @@
466175DC22D5DC740025437A /* QGAppAnalyticsEvent.m in Sources */ = {isa = PBXBuildFile; fileRef = 466175DB22D5DC740025437A /* QGAppAnalyticsEvent.m */; };
466175DF22D5DCBE0025437A /* QGAppBusinessStateEvent.m in Sources */ = {isa = PBXBuildFile; fileRef = 466175DE22D5DCBE0025437A /* QGAppBusinessStateEvent.m */; };
466175E222D5DD0A0025437A /* QGAppCoreModelClickEvent.m in Sources */ = {isa = PBXBuildFile; fileRef = 466175E122D5DD0A0025437A /* QGAppCoreModelClickEvent.m */; };
46743A88247CBD1300E46A9B /* QGSafeBindSmsVerifyViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 46743A87247CBD1300E46A9B /* QGSafeBindSmsVerifyViewController.m */; };
468CB58A23BF474400651684 /* QGBaseWebViewController+FaceSDK.m in Sources */ = {isa = PBXBuildFile; fileRef = 468CB58923BF474400651684 /* QGBaseWebViewController+FaceSDK.m */; };
46AB560C22F9163700DBC217 /* QGDependChainManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 46AB560822F9163600DBC217 /* QGDependChainManager.m */; };
46AB560D22F9163700DBC217 /* QGNetWorkResponse.m in Sources */ = {isa = PBXBuildFile; fileRef = 46AB560922F9163700DBC217 /* QGNetWorkResponse.m */; };
......@@ -1043,6 +1044,8 @@
466175DE22D5DCBE0025437A /* QGAppBusinessStateEvent.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = QGAppBusinessStateEvent.m; sourceTree = "<group>"; };
466175E022D5DD0A0025437A /* QGAppCoreModelClickEvent.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = QGAppCoreModelClickEvent.h; sourceTree = "<group>"; };
466175E122D5DD0A0025437A /* QGAppCoreModelClickEvent.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = QGAppCoreModelClickEvent.m; sourceTree = "<group>"; };
46743A86247CBD1300E46A9B /* QGSafeBindSmsVerifyViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = QGSafeBindSmsVerifyViewController.h; sourceTree = "<group>"; };
46743A87247CBD1300E46A9B /* QGSafeBindSmsVerifyViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = QGSafeBindSmsVerifyViewController.m; sourceTree = "<group>"; };
468CB58823BF474400651684 /* QGBaseWebViewController+FaceSDK.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "QGBaseWebViewController+FaceSDK.h"; sourceTree = "<group>"; };
468CB58923BF474400651684 /* QGBaseWebViewController+FaceSDK.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "QGBaseWebViewController+FaceSDK.m"; sourceTree = "<group>"; };
46AB560822F9163600DBC217 /* QGDependChainManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = QGDependChainManager.m; sourceTree = "<group>"; };
......@@ -3310,6 +3313,8 @@
children = (
7F58DCAB22C3831200F2A15F /* QGSafeCenterViewController.h */,
7F58DCAC22C3831200F2A15F /* QGSafeCenterViewController.m */,
46743A86247CBD1300E46A9B /* QGSafeBindSmsVerifyViewController.h */,
46743A87247CBD1300E46A9B /* QGSafeBindSmsVerifyViewController.m */,
);
path = SafeCenter;
sourceTree = "<group>";
......@@ -6390,6 +6395,7 @@
9EA5F8F324559797000AA6D3 /* QGMallGoodsDetailPromoterCell.m in Sources */,
9EBE243A2432DD74009C83A1 /* QGCardAccountBaseCell.m in Sources */,
465A6E93245AC9CF00BF924E /* SAJSONUtil.m in Sources */,
46743A88247CBD1300E46A9B /* QGSafeBindSmsVerifyViewController.m in Sources */,
9EE4095E229240B8008C1246 /* QGRotationCircleView.m in Sources */,
465A6EB2245AC9D000BF924E /* SAWeakPropertyContainer.m in Sources */,
465A6EAA245AC9D000BF924E /* SAVisualizedAbstractMessage.m in Sources */,
......
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "编组@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "编组@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
......@@ -129,7 +129,11 @@
self.centerY = controller.view.height / 2.0;
}
else{ // 其他一律放在右下,下面的位置偏下一点
self.bottom = controller.view.height - 70;
if (self.controller && self.controller.tabBarController.tabBar.isHidden){
self.bottom = controller.view.height - 20;
}else{
self.bottom = controller.view.height - 20 - [DeviceAdaptation getTabBarHeight];
}
}
}
......@@ -174,9 +178,17 @@
if (view.top < [DeviceAdaptation getNavBarAndStatusBarHeight]) {
view.top = [DeviceAdaptation getNavBarAndStatusBarHeight];
}
else if (view.bottom > self.controller.view.height)
{
view.bottom = self.controller.view.height;
if (self.controller && self.controller.tabBarController.tabBar.isHidden) {
if (view.bottom > self.controller.view.height)
{
view.bottom = self.controller.view.height;
}
}else{
if (view.bottom > self.controller.view.height - [DeviceAdaptation getTabBarHeight])
{
view.bottom = self.controller.view.height - [DeviceAdaptation getTabBarHeight];
}
}
//检测左右
......
......@@ -22,6 +22,8 @@
#import "QGDepositRequestApi.h"
#import "QGRepaymentReuestApi.h"
@interface QGDepositPwdManager()
......@@ -194,7 +196,7 @@
[param setObject:self.card.cardId forKey:@"cardId"];
[param setObject:pwd forKey:@"pwd"];
// [QGRepaymentReuestApi urlWithIndex:QGRepaymentRequestServerMethodRepay]
[networking POST:@"http://yapi.quantgroups.com/mock/305/vcc/repay" parameters:param success:^(id _Nonnull responseObject) {
[QGHUDManager hideHud];
if ([QGTalosNetwork checkBusinessCodeAndCodeWithResponseObjectObject:responseObject]) {
......
......@@ -12,8 +12,9 @@
#import "QGAlertView.h"
#import "QGDepositPwdManager.h"
#import "QGDepositeCardModel.h"
#import "QGRepaymentReuestApi.h"
#import "QGRepayResultViewController.h"
#import "CWWebViewController.h"
@interface QGRepaymentCommitViewController ()<UITableViewDelegate,UITableViewDataSource>
......@@ -29,8 +30,8 @@
/// 银行名字
@property (nonatomic, copy) NSString *bankName ;
/// 银行
@property (nonatomic, copy) NSString *bankCardNo ;
/// 银行
@property (nonatomic, copy) NSString *bankCardTailNo ;
/// 每单限额
@property (nonatomic, assign) CGFloat bankLimitAmtPerDay;
/// 每日限额
......@@ -124,6 +125,7 @@
{
QGTalosNetwork *networking = [QGTalosNetwork shareManager];
[QGHUDManager showHud:nil];
// [QGRepaymentReuestApi urlWithIndex:QGRepaymentRequestServerMethodRepayInfo];
[networking GET:@"http://yapi.quantgroups.com/mock/305/vcc/repay/page" parameters:nil success:^(id _Nonnull responseObject) {
[QGHUDManager hideHud];
if ([QGTalosNetwork checkBusinessCodeAndCodeWithResponseObjectObject:responseObject]) {
......@@ -131,7 +133,7 @@
self.amountLab.text = [NSString stringWithFormat:@"%.2f", [responseObject[@"data"][@"repayAmt"] floatValue]];
self.payDesLab.text = responseObject[@"data"][@"billTotalAmtContent"];
self.bankName = responseObject[@"data"][@"bankName"];
self.bankCardNo = responseObject[@"data"][@"bankCardNo"];
self.bankCardTailNo = responseObject[@"data"][@"bankCardTailNo"];
self.bankLimitAmtPerDay = [responseObject[@"data"][@"bankLimitAmtPerDay"] floatValue];
self.bankLimitAmtPerTrade = [responseObject[@"data"][@"bankLimitAmtPerTrade"] floatValue];
self.bankCardListH5Url = responseObject[@"data"][@"bankCardListH5Url"];
......@@ -190,7 +192,23 @@
{
[tableView deselectRowAtIndexPath:indexPath animated:YES];
if (self.bankCardListH5Url) {
[self navigationToWeb:self.bankCardListH5Url];
QGBaseWebViewController *webVC = [[QGBaseWebViewController alloc]init];
webVC.urlString = self.bankCardListH5Url;
webVC.callBackBlock = ^(NSString *tag, NSDictionary *params) {
/// H5选择的银行卡列表
if ([tag isEqualToString:kWebView_selectBankCardInfoKey]) {
NSDictionary *dic = params[kWebView_selectBankCardInfoKey];
if (dic) {
self.bankName = dic[@"bankName"];
self.cardId = dic[@"cardId"];
self.bankLimitAmtPerDay = [dic[@"dayLimit"] floatValue];
self.bankLimitAmtPerTrade = [dic[@"tradeLimit"] floatValue];
self.bankCardTailNo = dic[@"tailCardNo"];
[self.tableView reloadData];
}
}
};
[self.navigationController pushViewController:webVC animated:YES];
}
}
......@@ -210,10 +228,10 @@
QGDepositeCardModel *card = [[QGDepositeCardModel alloc]init];
card.bankName = self.bankName;
if (self.bankCardNo.length > 4) {
card.tailCardNo = [self.bankCardNo substringWithRange:NSMakeRange(self.bankCardNo.length - 4, 4)];
if (self.bankCardTailNo.length > 4) {
card.tailCardNo = [self.bankCardTailNo substringWithRange:NSMakeRange(self.bankCardTailNo.length - 4, 4)];
}else{
card.tailCardNo = self.bankCardNo;
card.tailCardNo = self.bankCardTailNo;
}
card.cardId = self.cardId;
card.minAmount = @"0.00";
......
......@@ -35,8 +35,12 @@ typedef NS_ENUM(NSInteger, QGLoginRequestServerMethod) {
QGLoginRequestServerMethodCheckAppleBinding,
///apple绑定手机号登陆
QGLoginRequestServerMethodLoginApple,
///获取微信,Apple,百川授权状态
QGLoginRequestServerMethodQueryStatus,
/// 根据unionId查询是否可以绑定
QGLoginRequestServerMethodBindAvailable,
/// 解绑微信
QGLoginRequestServerMethodUnBindWeChat
};
/*!
......
......@@ -55,6 +55,17 @@
case QGLoginRequestServerMethodLoginApple:
url = @"vcc/external/login/apple";
break;
//查询微信,Apple,百川是否授权状态
case QGLoginRequestServerMethodQueryStatus:
url = @"vcc/external/login/auth_status";
break;
// 查询当前unionId是否可用
case QGLoginRequestServerMethodBindAvailable:
url = @"vcc/external/login/auth_status/authId";
break;
case QGLoginRequestServerMethodUnBindWeChat:
url = @"vcc/external/login/weChat/unbind";
break;
default:
break;
}
......
//
// QGSafeBindSmsVerifyViewController.h
// VirtualPayment
//
// Created by silicn on 2020/5/26.
// Copyright © 2020 bo.zhang. All rights reserved.
//
#import "QGBaseViewController.h"
#import "ZHWeChatTool.h"
NS_ASSUME_NONNULL_BEGIN
typedef void(^WXBindSuccessBlock)(BOOL Success);
@interface QGSafeBindSmsVerifyViewController : QGBaseViewController
@property (nonatomic, strong) QGWechatLoginInfoModel *wxModel ;
@property (nonatomic, copy) WXBindSuccessBlock bindSuccessBlock ;
@end
NS_ASSUME_NONNULL_END
//
// QGSafeBindSmsVerifyViewController.m
// VirtualPayment
//
// Created by silicn on 2020/5/26.
// Copyright © 2020 bo.zhang. All rights reserved.
//
#import "QGSafeBindSmsVerifyViewController.h"
#import "QGGradientShadowButton.h"
#import "QGSendMessageCodeManger.h"
#import "QGCountDown.h"
#import "QGLoginRequestApi.h"
@interface QGSafeBindSmsVerifyViewController ()
@property (nonatomic, copy) NSString *phone ;
@property (nonatomic, strong) QGGradientShadowButton *commitBtn ;
///倒计时剩余时间
@property (nonatomic, assign)NSInteger residueTime;
///自定义定时器
@property (nonatomic, strong)QGCountDown *countDownTimer;
///获取短信验证码管理类
@property (nonatomic, strong)QGSendMessageCodeManger *sendVerifyCodeManger;
/// 获取验证码
@property (nonatomic, strong) UIButton *vCodeBtn ;
/// 验证码
@property (nonatomic, strong) UITextField *vCodeTF ;
@end
@implementation QGSafeBindSmsVerifyViewController
- (void)viewDidLoad {
[super viewDidLoad];
[self custemLeftDefaultBarButtonItem];
self.title = @"绑定微信";
[self setNavBarBottomLineHidden:YES];
self.view.backgroundColor = UIColor.whiteColor;
QGUserInfo *userInfo = QGUserInfo.sharedUserInfo;
if (userInfo.isLogin) {
self.phone = userInfo.userName;
}
[self initNomalUI];
//初始化定时器
self.residueTime = 60;
self.countDownTimer = [[QGCountDown alloc]init];
//初始化发送验证码管理类
self.sendVerifyCodeManger = [[QGSendMessageCodeManger alloc] init];
// Do any additional setup after loading the view.
}
- (void)initNomalUI
{
UIImageView *imageV = [UIImageView creatImageViewWithSuperView:self.view imageName:@"bindwxSms"];
[imageV mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.inset(40);
if (@available(iOS 11.0, *)) {
make.top.equalTo(self.view.mas_safeAreaLayoutGuideTop).inset(30);
} else {
make.top.equalTo(self.view.mas_top).inset(94);
}
}];
UILabel *label = [UILabel creatLabelWithSuperView:self.view title:@"为保护您的账号安全 请验证手机号" titleFontSize:[UIFont qg_lightFontOfSize:12.0f] textColor:UIColor.textColor3333 alignment:NSTextAlignmentLeft];
label.numberOfLines = 0;
[label mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(imageV.mas_top).offset(8);
make.left.equalTo(imageV.mas_right).offset(6);
make.right.inset(20);
}];
NSString *encryptPhone = @"";
if (self.phone.length > 7) {
encryptPhone = [self.phone stringByReplacingCharactersInRange:NSMakeRange(3, 4) withString:@"****"];
}else{
encryptPhone = self.phone;
}
UILabel *phoneLab = [UILabel creatLabelWithSuperView:self.view title:encryptPhone titleFontSize:[UIFont qg_numberFontOfSize:18.0f] textColor:UIColor.textColor3333 alignment:NSTextAlignmentLeft];
[phoneLab mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(label);
make.top.equalTo(label.mas_bottom).offset(6);
}];
UITextField *vCodeTF = [UITextField creatTextFieldWithSuperView:self.view placeholder:@"请输入验证码" titleFontSize:[UIFont qg_lightFontOfSize:18.0f] textColor:UIColor.textColor3333 tintColor:nil clearButtonMode:UITextFieldViewModeWhileEditing];
[vCodeTF mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.inset(40);
make.top.equalTo(imageV.mas_bottom).offset(36);
make.height.mas_equalTo(40);
}];
vCodeTF.keyboardType = UIKeyboardTypeNumberPad;
self.vCodeTF = vCodeTF;
[vCodeTF addTarget:self action:@selector(editChanged:) forControlEvents:UIControlEventEditingChanged];
UIButton *vCodeBtn = [UIButton creatButtonWithSuperView:self.view title:@"获取验证码" titleFont:[UIFont qg_lightFontOfSize:16.0f] textColor:UIColor.textColor3333];
[vCodeBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(vCodeTF.mas_right);
make.top.height.equalTo(vCodeTF);
make.right.inset(40);
make.width.equalTo(vCodeTF.mas_width).multipliedBy(1/2.0);
}];
self.vCodeBtn = vCodeBtn;
[vCodeBtn addTarget:self action:@selector(vCodeBtnAction:) forControlEvents:UIControlEventTouchUpInside];
UIView *lineV = [UIView creatViewWithSuperView:self.view backgroundColor:UIColor.lineSeparatorColorDCDC];
[lineV mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(vCodeTF.mas_right);
make.width.mas_equalTo(0.5);
make.height.mas_equalTo(30);
make.top.equalTo(vCodeTF.mas_top).offset(6);
}];
UIView *lineH = [UIView creatViewWithSuperView:self.view backgroundColor:UIColor.lineSeparatorColorDCDC];
[lineH mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(vCodeTF.mas_bottom).offset(10);
make.left.equalTo(vCodeTF);
make.right.equalTo(vCodeBtn);
make.height.mas_equalTo(0.5);
}];
self.commitBtn = [QGGradientShadowButton creatGradientColorButtonWithSuperView:self.view title:@"绑定" textFont:[UIFont qg_regularFontOfSize:17.0f]];
[self.commitBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.right.inset(40);
make.top.equalTo(lineH.mas_bottom).offset(50);
make.height.mas_equalTo(40);
}];
[self.commitBtn setGradientButtonIsClickEnabled:NO];
[self.commitBtn addTarget:self action:@selector(bindAction:) forControlEvents:UIControlEventTouchUpInside];
}
- (void)editChanged:(UITextField *)tf
{
if (tf.text.length > 6) {
tf.text = [tf.text substringToIndex:6];
}
if (tf.text.length != 0) {
[self.commitBtn setGradientButtonIsClickEnabled:YES];
}else{
[self.commitBtn setGradientButtonIsClickEnabled:NO];
}
}
#pragma mark - 确认绑定
- (void)bindAction:(UIButton *)btn
{
QGTalosNetwork *networking = [QGTalosNetwork shareManager];
NSMutableDictionary *param = [NSMutableDictionary dictionary];
if (!QGUserInfo.sharedUserInfo.isLogin) return;
if (self.vCodeTF.text.length == 0) return;
[param setObject:QGUserInfo.sharedUserInfo.userName forKey:@"loginName"];
[param setObject:self.vCodeTF.text forKey:@"smsCode"];
[param setObject:self.wxModel.openid forKey:@"openId"];
[param setObject:self.wxModel.unionid forKey:@"unionId"];
[param setObject:self.wxModel.headimgurl ? self.wxModel.headimgurl : @"" forKey:@"headImgUrl"];
[param setObject:self.wxModel.nickname ? self.wxModel.nickname :@"" forKey:@"nickName"];
NSString *sex = @"N";
if ([self.wxModel.sex isEqualToString:@"1"]) {
sex = @"M";
}else if([self.wxModel.sex isEqualToString:@"2"]){
sex = @"F";
}
[param setObject:sex forKey:@"sex"];
[param setObject:@"" forKey:@"userDesc"];
// [QGLoginRequestApi urlWithQGLoginRequestServerMethod:QGLoginRequestServerMethodLoginWechat];
[networking POST:@"http://yapi.quantgroups.com/mock/305/vcc/external/login/weChat" parameters:param success:^(id _Nonnull responseObject) {
if ([QGTalosNetwork checkBusinessCodeAndCodeWithResponseObjectObject:responseObject]) {
if (self.bindSuccessBlock) {
self.bindSuccessBlock(YES);
}
[self.navigationController popViewControllerAnimated:YES];
}else{
NSString *msg = responseObject[@"msg"]? responseObject[@"msg"]:@"授权失败";
[QGHUDManager showHud:msg];
}
} failure:^(NSURLSessionDataTask * _Nonnull task, NSError * _Nonnull error) {
[QGHUDManager showHud:@"网络错误,请稍后再试"];
}];
}
#pragma mark - 获取验证码
- (void)vCodeBtnAction:(UIButton *)btn
{
__weak typeof(self) weakSelf = self;
[self.sendVerifyCodeManger sendMessageCodeWithPhoneNumber:self.phone success:^{
[weakSelf fireTimer];
} fail:^{
weakSelf.vCodeBtn.userInteractionEnabled = YES;
}];
}
//启动定时器
-(void)fireTimer
{
[self.countDownTimer countDownWithPER_SECBlock:^{
self.residueTime--;
if (self.residueTime == 0) {
[self.countDownTimer destoryTimer];
self.residueTime = 60;
self.vCodeBtn.titleLabel.text = @"重新发送";
[self.vCodeBtn setTitle:@"重新发送" forState:UIControlStateNormal];
self.vCodeBtn.userInteractionEnabled = YES;
}else{
self.vCodeBtn.titleLabel.text = [NSString stringWithFormat:@"重新发送(%lds)",(long)self.residueTime];
[self.vCodeBtn setTitle:[NSString stringWithFormat:@"重新发送(%lds)",(long)self.residueTime] forState:UIControlStateNormal];
}
}];
}
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
{
[super touchesBegan:touches withEvent:event];
if ([self.vCodeTF isFirstResponder]) {
[self.vCodeTF resignFirstResponder];
}
}
/*
#pragma mark - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
}
*/
@end
......@@ -18,6 +18,16 @@
#import "QGMallRequestApi.h"
#import "QGThirdPlatformService.h"
#import "QGLoginRequestApi.h"
#import "QGSafeBindSmsVerifyViewController.h"
typedef NS_ENUM(NSInteger,QGAuthStatus){
QGAuthStatusUnknown, /// 未知授权状态
QGAuthStatusAuthed, /// 已授权
QGAuthStatusUnAuth /// 未授权
};
@interface QGSafeCenterViewController ()
///列表模型数组
......@@ -26,6 +36,10 @@
/// 修改交易密码
@property (nonatomic, strong) NSString * resetDealPwdUrl;
/// 微信授权状态
@property (nonatomic, assign) QGAuthStatus wxAuthStatus;
@end
@implementation QGSafeCenterViewController
......@@ -49,6 +63,36 @@
self.tableView.backgroundColor = [UIColor moduleSeparatorColorF7F7];
[self requestStatusShowhud:NO];
}
/// 查询当前授权状态
- (void)requestStatusShowhud:(BOOL)show
{
if (show) {
[QGHUDManager showHud:nil];
}
QGTalosNetwork *networking = [QGTalosNetwork shareManager];
// [QGLoginRequestApi urlWithQGLoginRequestServerMethod:QGLoginRequestServerMethodQueryStatus]
[networking GET:@"http://yapi.quantgroups.com/mock/305/vcc/external/login/auth_status" parameters:nil success:^(id _Nonnull responseObject) {
[QGHUDManager hideHud];
if ([QGTalosNetwork checkBusinessCodeAndCodeWithResponseObjectObject:responseObject]) {
NSDictionary *data = responseObject[@"data"];
NSArray *authList = data[@"authStatusList"];
for (NSDictionary *dic in authList) {
if ([dic[@"authType"] integerValue] == 1) {
bool auth = [dic[@"hadAuth"] boolValue];
self.wxAuthStatus = auth ? QGAuthStatusAuthed : QGAuthStatusUnAuth;
break;
}
}
/// 刷新数据
[self initData];
}
} failure:^(NSURLSessionDataTask * _Nonnull task, NSError * _Nonnull error) {
[QGHUDManager hideHud];
}];
}
- (void)taobaoAuthChanged
......@@ -56,6 +100,8 @@
[self initData];
}
#pragma mark - TableView Delegate & DataSource
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return self.dataArray.count;
......@@ -110,13 +156,29 @@
}];
[self.dataArray addObject:loginPassword];
QGMineModel *wxAuthModel = [[QGMineModel alloc]initWithTitle:@"微信授权" subtitle:@"未授权" clickAction:^(QGMineModel *model) {
NSString *wxSubTitle = @"";
if (self.wxAuthStatus == QGAuthStatusAuthed) {
wxSubTitle = @"已授权";
}else{
wxSubTitle = @"未授权";
}
QGMineModel *wxAuthModel = [[QGMineModel alloc]initWithTitle:@"微信授权" subtitle:wxSubTitle clickAction:^(QGMineModel *model) {
@strongify(self);
// if (alimamaAuth) {
// [self cancleTaoBaoAuth];
// }else{
// [[QGBaiChuanManager shareInstance] authAllAuthoritiesWithController:self.navigationController];
// }
/// 已授权,点击解除授权
if (self.wxAuthStatus == QGAuthStatusAuthed) {
[self unBindWxAuth];
}
/// 未授权,点击授权
else if(self.wxAuthStatus == QGAuthStatusUnAuth){
[self bindWxAuth];
}
/// 不知道授权状态,点击查询状态
else{
// 查询授权状态
[self requestStatusShowhud:YES];
}
}];
[self.dataArray addObject:wxAuthModel];
......@@ -137,18 +199,109 @@
}
#pragma mark - 微信授权相关
- (void)bindWxAuth
{
@weakify(self);
[[QGThirdPlatformService shareInstance] wxAuthWithSuccess:^(QGWechatLoginInfoModel *infoModel) {
@strongify(self);
/// 查询授权状态
[self queryAuthStatusWithOpenId:infoModel.unionid complete:^{
QGSafeBindSmsVerifyViewController *vc = [[QGSafeBindSmsVerifyViewController alloc]init];
vc.wxModel = infoModel;
/// 绑定完成
vc.bindSuccessBlock = ^(BOOL Success) {
self.wxAuthStatus = QGAuthStatusAuthed;
[self initData];
};
[self.navigationController pushViewController:vc animated:YES];
}];
}];
}
///解绑微信
- (void)unBindWxAuth
{
QGAlertView *alert = [[QGAlertView alloc]initWithTitle:nil message:@"解绑微信号后将无法继续使用它登录此真享生活账号哦" cancelButtonTitle:@"取消" sureButtonTitle:@"确认" clickBlock:^(NSInteger index) {
if (index == 1) {
[self requestUnBindWxAuth];
}
}];
[alert showInView:self.view];
}
- (void)requestUnBindWxAuth
{
QGTalosNetwork *networking = [QGTalosNetwork shareManager];
// [QGLoginRequestApi urlWithQGLoginRequestServerMethod:QGLoginRequestServerMethodUnBindWeChat]
[networking GET:@"http://yapi.quantgroups.com/mock/305/vcc/external/login/weChat/unbind" parameters:nil success:^(id _Nonnull responseObject) {
if ([QGTalosNetwork checkBusinessCodeAndCodeWithResponseObjectObject:responseObject]) {
/// 刷新页面
self.wxAuthStatus = QGAuthStatusUnAuth;
[self initData];
[QGHUDManager showHud:@""];
}else{
NSString *msg = responseObject[@"msg"]?responseObject[@"msg"]:@"解除授权错误";
[QGHUDManager showHud:msg];
}
} failure:^(NSURLSessionDataTask * _Nonnull task, NSError * _Nonnull error) {
[QGHUDManager showHud:@"网络错误,请稍后再试"];
}];
}
/// 查询当前的微信id是否可以被绑定
/// @param unionId 唯一id
/// @param completeBlock 可用完成回调
- (void)queryAuthStatusWithOpenId:(NSString *)unionId complete:(void(^)(void))completeBlock
{
if (unionId == nil) return;
QGTalosNetwork *networking = [QGTalosNetwork shareManager];
NSMutableDictionary *param = [NSMutableDictionary dictionary];
[param setObject:unionId forKey:@"authId"];
// 1:微信 2:apple 3:淘宝 4:百川
[param setObject:@(1) forKey:@"authType"];
[QGHUDManager showHud:nil];
// [QGLoginRequestApi urlWithQGLoginRequestServerMethod:QGLoginRequestServerMethodBindAvailable]
[networking GET:@"http://yapi.quantgroups.com/mock/305/vcc/external/login/auth_status/authId" parameters:param success:^(id _Nonnull responseObject) {
[QGHUDManager hideHud];
if ([QGTalosNetwork checkBusinessCodeAndCodeWithResponseObjectObject:responseObject]) {
if (completeBlock) {
completeBlock();
}
}else{
NSString *businessCode = responseObject[@"businessCode"];
/// 已被绑定,不可用
if ([businessCode isEqualToString:@"1012"]) {
QGAlertView *alert = [[QGAlertView alloc]initWithTitle:nil message:@"该微信已绑定其他真享生活账号,无法进行授权!" cancelButtonTitle:nil sureButtonTitle:@"知道了" clickBlock:NULL];
[alert showInView:self.view];
}else{
NSString *msg = responseObject[@"msg"] ? responseObject[@"msg"]:@"授权错误";
[QGHUDManager showHud:msg];
}
}
} failure:^(NSURLSessionDataTask * _Nonnull task, NSError * _Nonnull error) {
[QGHUDManager showHud:@"网络错误,请稍后再试"];
}];
}
/// 去短信验证绑定
- (void)toSMSverify
{
}
#pragma mark - 百川授权相关
- (void)cancleTaoBaoAuth
{
QGAlertView *alert = [[QGAlertView alloc] initWithTitle:nil message:@"确认取消淘宝授权?取消后将无法继续获得返现哦~" cancelButtonTitle:@"取消" sureButtonTitle:@"确认" clickBlock:^(NSInteger index) {
......
......@@ -11,6 +11,7 @@
///webView关闭当前页面并重新打开一个新的页面的回调
#define WebView_ReopenBrowserWithNewUrl @"WebView_ReopenBrowserWithNewUrl"
/// 选择银行卡回传
#define kWebView_selectBankCardInfoKey @"kWebView_selectBankCardInfoKey"
#endif /* QGWebViewTagFile_h */
......@@ -422,6 +422,8 @@
else if ([event isEqualToString:@"openNewUrl"])
{
[self openNewUrl:eventDic];
}else if ([event isEqualToString:@"selectBankCard"]){
[self selectBankCard:eventDic];
}
}
......@@ -686,6 +688,17 @@
}
}
/// 选择银行卡号信息
- (void)selectBankCard:(NSDictionary *)dic
{
NSDictionary *data = dic[@"data"];
if ([dic[@"data"] isKindOfClass:[NSDictionary class]]) {
if (self.callBackBlock) {
self.callBackBlock(kWebView_selectBankCardInfoKey, data);
}
}
}
- (void)dealloc {
//资源释放的时候,停止webView加载 并将webView的delegate置为nil 减少某些机型可能触发的bug
......
......@@ -9,7 +9,38 @@
#import <Foundation/Foundation.h>
#import "QGBaseModel.h"
@class QGWechatLoginInfoModel;
/// 微信登录信息模型
@interface QGWechatLoginInfoModel : QGBaseModel
/// 普通用户个人资料填写的城市
@property (nonatomic, strong) NSString * city;
/// 国家,如中国为 CN
@property (nonatomic, strong) NSString * country;
/// 普通用户个人资料填写的省份
@property (nonatomic, strong) NSString * province;
/// 用户头像,最后一个数值代表正方形头像大小(有 0、46、64、96、132 数值可选,0 代表 640*640 正方形头像),用户没有头像时该项为空
@property (nonatomic, strong) NSString * headimgurl;
/// 语言
@property (nonatomic, strong) NSString * language;
/// 昵称
@property (nonatomic, strong) NSString * nickname;
/// 普通用户的标识,对当前开发者帐号唯一
@property (nonatomic, strong) NSString * openid;
/// 普通用户性别,1 为男性,2 为女性
@property (nonatomic, strong) NSString * sex;
/// 用户统一标识。针对一个微信开放平台帐号下的应用,同一用户的 unionid 是唯一的。
@property (nonatomic, strong) NSString * unionid;
@end
//#import "WXApi.h"
///支付回调
......@@ -101,34 +132,3 @@ typedef void(^ZHWeChatAuthSuccessBlock)(QGWechatLoginInfoModel * infoModel);
/// 微信登录信息模型
@interface QGWechatLoginInfoModel : QGBaseModel
/// 普通用户个人资料填写的城市
@property (nonatomic, strong) NSString * city;
/// 国家,如中国为 CN
@property (nonatomic, strong) NSString * country;
/// 普通用户个人资料填写的省份
@property (nonatomic, strong) NSString * province;
/// 用户头像,最后一个数值代表正方形头像大小(有 0、46、64、96、132 数值可选,0 代表 640*640 正方形头像),用户没有头像时该项为空
@property (nonatomic, strong) NSString * headimgurl;
/// 语言
@property (nonatomic, strong) NSString * language;
/// 昵称
@property (nonatomic, strong) NSString * nickname;
/// 普通用户的标识,对当前开发者帐号唯一
@property (nonatomic, strong) NSString * openid;
/// 普通用户性别,1 为男性,2 为女性
@property (nonatomic, strong) NSString * sex;
/// 用户统一标识。针对一个微信开放平台帐号下的应用,同一用户的 unionid 是唯一的。
@property (nonatomic, strong) NSString * unionid;
@end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment