Commit 0cb042ba82b5d8277df11eb0c5dce526d3b2a8d5

Authored by iOS-Xiaowen
1 parent 809f0c69

no message

Showing 87 changed files with 4553 additions and 0 deletions

Too many changes to show.

To preserve performance only 87 of 108 files are displayed.

CNLiveBLoginModule.podspec 0 → 100644
  1 +#
  2 +# Be sure to run `pod lib lint CNLiveBLoginModule.podspec' to ensure this is a
  3 +# valid spec before submitting.
  4 +#
  5 +# Any lines starting with a # are optional, but their use is encouraged
  6 +# To learn more about a Podspec see https://guides.cocoapods.org/syntax/podspec.html
  7 +#
  8 +
  9 +Pod::Spec.new do |s|
  10 + s.name = 'CNLiveBLoginModule'
  11 + s.version = '0.0.1'
  12 + s.summary = 'CNLiveBLoginModule.'
  13 +
  14 +# This description is used to generate tags and improve search results.
  15 +# * Think: What does it do? Why did you write it? What is the focus?
  16 +# * Try to keep it short, snappy and to the point.
  17 +# * Write the description between the DESC delimiters below.
  18 +# * Finally, don't worry about the indent, CocoaPods strips it!
  19 +
  20 + s.description = <<-DESC
  21 +TODO: 网家家-登录模块.
  22 + DESC
  23 +
  24 + s.homepage = 'http://bj.gitlab.cnlive.com/ios-team/CNLiveBLoginModule'
  25 + # s.screenshots = 'www.example.com/screenshots_1', 'www.example.com/screenshots_2'
  26 + s.license = { :type => 'MIT', :file => 'LICENSE' }
  27 + s.author = { '153993236@qq.com' => 'zhangxiaowen@cnlive.com' }
  28 + s.source = { :git => 'http://bj.gitlab.cnlive.com/ios-team/CNLiveBLoginModule.git', :tag => s.version.to_s }
  29 + # s.social_media_url = 'https://twitter.com/<TWITTER_USERNAME>'
  30 +
  31 + s.ios.deployment_target = '9.0'
  32 +
  33 + # s.source_files = 'CNLiveBLoginModule/Classes/**/*'
  34 +
  35 + # Module
  36 + s.subspec 'Module' do |ss|
  37 + ss.source_files = 'CNLiveBLoginModule/Classes/Module/*.{h,m}'
  38 + ss.dependency 'CNLiveBLoginModule/Controller'
  39 + end
  40 +
  41 + # Controller
  42 + s.subspec 'Controller' do |ss|
  43 + ss.source_files = 'CNLiveBLoginModule/Classes/Controller/*.{h,m}'
  44 + ss.dependency 'CNLiveBLoginModule/View'
  45 + ss.dependency 'CNLiveBLoginModule/Model'
  46 + ss.dependency 'CNLiveBLoginModule/ThreeLogin'
  47 + end
  48 +
  49 + # View
  50 + s.subspec 'View' do |ss|
  51 + ss.source_files = 'CNLiveBLoginModule/Classes/View/*.{h,m}'
  52 + ss.dependency 'CNLiveBLoginModule/Model'
  53 + end
  54 +
  55 + # Model
  56 + s.subspec 'Model' do |ss|
  57 + ss.source_files = 'CNLiveBLoginModule/Classes/Model/*.{h,m}'
  58 + end
  59 +
  60 + s.subspec 'ThreeLogin' do |ss|
  61 + ss.source_files = 'CNLiveBLoginModule/Classes/ThreeLogin/*.{h,m}'
  62 + ss.dependency 'CNLiveBLoginModule/View'
  63 + end
  64 +
  65 + s.subspec 'BindingManage' do |ss|
  66 + ss.source_files = 'CNLiveBLoginModule/Classes/BindingManage/*.{h,m}'
  67 + end
  68 +
  69 + s.resource_bundles = {
  70 + 'CNLiveBLoginModule' => ['CNLiveBLoginModule/Assets/CNLiveBLoginModule.xcassets']
  71 + }
  72 +
  73 +# s.public_header_files = 'CNLiveBLoginModule/Classes/**/*.h'
  74 + # s.frameworks = 'UIKit', 'MapKit'
  75 +
  76 + # pod
  77 + s.dependency 'CNLiveSDKs/CNLiveUserSystemSDK', '~> 0.3.1.3' #GitHub所以指定版本号
  78 + s.dependency 'CNLiveTripartiteManagement/QMUIKit'
  79 + s.dependency 'CNLiveTripartiteManagement/YYKit'
  80 + s.dependency 'CNLiveTripartiteManagement/SDWebImage'
  81 + s.dependency 'CNLiveTripartiteManagement/Masonry'
  82 + s.dependency 'CNLiveTripartiteManagement/MJExtension'
  83 +
  84 + # 服务层
  85 + s.dependency 'CNLiveServices'
  86 +
  87 + # 切换成城市
  88 + s.dependency 'CNLiveChooseCountry'
  89 +
  90 + # 用户信息本地化
  91 + s.dependency 'CNLiveUserManagement'
  92 +
  93 + # 环境库
  94 + s.dependency 'CNLiveEnvironment'
  95 +
  96 + # 数据请求
  97 + s.dependency 'CNLiveRequestBastKit'
  98 +
  99 + # 用户协议
  100 + s.dependency 'CNLiveUserAgreementManager'
  101 +
  102 + # 管理类
  103 + s.dependency 'CNLiveManager'
  104 +
  105 + # 相册
  106 + s.dependency 'CNLiveImagePickerController'
  107 +
  108 + # 相机
  109 + s.dependency 'CNLiveAVCamera'
  110 +
  111 + #IM
  112 + s.dependency 'CNLiveIMBaseSDK'
  113 +
  114 + s.dependency 'tingyunApp', '~>2.14.0'
  115 +
  116 + # 分享
  117 +# s.dependency 'CNLiveShareToolKit'
  118 +
  119 + # 类别
  120 + s.dependency 'CNLiveCategory'
  121 +
  122 + # 自定义控件
  123 + s.dependency 'CNLiveCustomControl'
  124 +
  125 + s.dependency 'CNLiveBusinessBaseModule'
  126 +
  127 + s.static_framework = true
  128 +
  129 +end
CNLiveBLoginModule/Assets/.gitkeep 0 → 100644
CNLiveBLoginModule/Assets/CNLiveBLoginModule.xcassets/Contents.json 0 → 100644
  1 +{
  2 + "info" : {
  3 + "version" : 1,
  4 + "author" : "xcode"
  5 + }
  6 +}
0 \ No newline at end of file 7 \ No newline at end of file
CNLiveBLoginModule/Assets/CNLiveBLoginModule.xcassets/login_apple.imageset/Contents.json 0 → 100644
  1 +{
  2 + "images" : [
  3 + {
  4 + "idiom" : "universal",
  5 + "scale" : "1x"
  6 + },
  7 + {
  8 + "idiom" : "universal",
  9 + "filename" : "login_apple@2x.png",
  10 + "scale" : "2x"
  11 + },
  12 + {
  13 + "idiom" : "universal",
  14 + "filename" : "login_apple@3x.png",
  15 + "scale" : "3x"
  16 + }
  17 + ],
  18 + "info" : {
  19 + "version" : 1,
  20 + "author" : "xcode"
  21 + }
  22 +}
0 \ No newline at end of file 23 \ No newline at end of file
CNLiveBLoginModule/Assets/CNLiveBLoginModule.xcassets/login_apple.imageset/login_apple@2x.png 0 → 100644

5.16 KB

CNLiveBLoginModule/Assets/CNLiveBLoginModule.xcassets/login_apple.imageset/login_apple@3x.png 0 → 100644

11.4 KB

CNLiveBLoginModule/Assets/CNLiveBLoginModule.xcassets/login_apple_icon.imageset/Contents.json 0 → 100644
  1 +{
  2 + "images" : [
  3 + {
  4 + "idiom" : "universal",
  5 + "scale" : "1x"
  6 + },
  7 + {
  8 + "idiom" : "universal",
  9 + "filename" : "login_apple_icon@2x.png",
  10 + "scale" : "2x"
  11 + },
  12 + {
  13 + "idiom" : "universal",
  14 + "filename" : "login_apple_icon@3x.png",
  15 + "scale" : "3x"
  16 + }
  17 + ],
  18 + "info" : {
  19 + "version" : 1,
  20 + "author" : "xcode"
  21 + }
  22 +}
0 \ No newline at end of file 23 \ No newline at end of file
CNLiveBLoginModule/Assets/CNLiveBLoginModule.xcassets/login_apple_icon.imageset/login_apple_icon@2x.png 0 → 100644

3.09 KB

CNLiveBLoginModule/Assets/CNLiveBLoginModule.xcassets/login_apple_icon.imageset/login_apple_icon@3x.png 0 → 100644

5.8 KB

CNLiveBLoginModule/Assets/CNLiveBLoginModule.xcassets/login_camera.imageset/Contents.json 0 → 100644
  1 +{
  2 + "images" : [
  3 + {
  4 + "idiom" : "universal",
  5 + "scale" : "1x"
  6 + },
  7 + {
  8 + "idiom" : "universal",
  9 + "filename" : "login_camera@2x.png",
  10 + "scale" : "2x"
  11 + },
  12 + {
  13 + "idiom" : "universal",
  14 + "filename" : "login_camera@3x.png",
  15 + "scale" : "3x"
  16 + }
  17 + ],
  18 + "info" : {
  19 + "version" : 1,
  20 + "author" : "xcode"
  21 + }
  22 +}
0 \ No newline at end of file 23 \ No newline at end of file
CNLiveBLoginModule/Assets/CNLiveBLoginModule.xcassets/login_camera.imageset/login_camera@2x.png 0 → 100644

12.7 KB

CNLiveBLoginModule/Assets/CNLiveBLoginModule.xcassets/login_camera.imageset/login_camera@3x.png 0 → 100644

27.3 KB

CNLiveBLoginModule/Assets/CNLiveBLoginModule.xcassets/login_close.imageset/Contents.json 0 → 100644
  1 +{
  2 + "images" : [
  3 + {
  4 + "idiom" : "universal",
  5 + "scale" : "1x"
  6 + },
  7 + {
  8 + "idiom" : "universal",
  9 + "filename" : "login_close@2x.png",
  10 + "scale" : "2x"
  11 + },
  12 + {
  13 + "idiom" : "universal",
  14 + "filename" : "login_close@3x.png",
  15 + "scale" : "3x"
  16 + }
  17 + ],
  18 + "info" : {
  19 + "version" : 1,
  20 + "author" : "xcode"
  21 + }
  22 +}
0 \ No newline at end of file 23 \ No newline at end of file
CNLiveBLoginModule/Assets/CNLiveBLoginModule.xcassets/login_close.imageset/login_close@2x.png 0 → 100644

2.92 KB

CNLiveBLoginModule/Assets/CNLiveBLoginModule.xcassets/login_close.imageset/login_close@3x.png 0 → 100644

4.14 KB

CNLiveBLoginModule/Assets/CNLiveBLoginModule.xcassets/login_country.imageset/Contents.json 0 → 100644
  1 +{
  2 + "images" : [
  3 + {
  4 + "idiom" : "universal",
  5 + "scale" : "1x"
  6 + },
  7 + {
  8 + "idiom" : "universal",
  9 + "filename" : "login_country@2x.png",
  10 + "scale" : "2x"
  11 + },
  12 + {
  13 + "idiom" : "universal",
  14 + "filename" : "login_country@3x.png",
  15 + "scale" : "3x"
  16 + }
  17 + ],
  18 + "info" : {
  19 + "version" : 1,
  20 + "author" : "xcode"
  21 + }
  22 +}
0 \ No newline at end of file 23 \ No newline at end of file
CNLiveBLoginModule/Assets/CNLiveBLoginModule.xcassets/login_country.imageset/login_country@2x.png 0 → 100644

219 Bytes

CNLiveBLoginModule/Assets/CNLiveBLoginModule.xcassets/login_country.imageset/login_country@3x.png 0 → 100644

423 Bytes

CNLiveBLoginModule/Assets/CNLiveBLoginModule.xcassets/login_get_code.imageset/Contents.json 0 → 100644
  1 +{
  2 + "images" : [
  3 + {
  4 + "idiom" : "universal",
  5 + "scale" : "1x"
  6 + },
  7 + {
  8 + "idiom" : "universal",
  9 + "filename" : "login_get_code@2x.png",
  10 + "scale" : "2x"
  11 + },
  12 + {
  13 + "idiom" : "universal",
  14 + "filename" : "login_get_code@3x.png",
  15 + "scale" : "3x"
  16 + }
  17 + ],
  18 + "info" : {
  19 + "version" : 1,
  20 + "author" : "xcode"
  21 + }
  22 +}
0 \ No newline at end of file 23 \ No newline at end of file
CNLiveBLoginModule/Assets/CNLiveBLoginModule.xcassets/login_get_code.imageset/login_get_code@2x.png 0 → 100644

11 KB

CNLiveBLoginModule/Assets/CNLiveBLoginModule.xcassets/login_get_code.imageset/login_get_code@3x.png 0 → 100644

26 KB

CNLiveBLoginModule/Assets/CNLiveBLoginModule.xcassets/login_get_code_b.imageset/Contents.json 0 → 100644
  1 +{
  2 + "images" : [
  3 + {
  4 + "idiom" : "universal",
  5 + "scale" : "1x"
  6 + },
  7 + {
  8 + "filename" : "login_get_code_b@2x.png",
  9 + "idiom" : "universal",
  10 + "scale" : "2x"
  11 + },
  12 + {
  13 + "filename" : "login_get_code_b@3x.png",
  14 + "idiom" : "universal",
  15 + "scale" : "3x"
  16 + }
  17 + ],
  18 + "info" : {
  19 + "author" : "xcode",
  20 + "version" : 1
  21 + }
  22 +}
CNLiveBLoginModule/Assets/CNLiveBLoginModule.xcassets/login_get_code_b.imageset/login_get_code_b@2x.png 0 → 100644

7.27 KB

CNLiveBLoginModule/Assets/CNLiveBLoginModule.xcassets/login_get_code_b.imageset/login_get_code_b@3x.png 0 → 100644

17.9 KB

CNLiveBLoginModule/Assets/CNLiveBLoginModule.xcassets/login_logo.imageset/Contents.json 0 → 100644
  1 +{
  2 + "images" : [
  3 + {
  4 + "idiom" : "universal",
  5 + "scale" : "1x"
  6 + },
  7 + {
  8 + "idiom" : "universal",
  9 + "filename" : "login_logo@2x.png",
  10 + "scale" : "2x"
  11 + },
  12 + {
  13 + "idiom" : "universal",
  14 + "filename" : "login_logo@3x.png",
  15 + "scale" : "3x"
  16 + }
  17 + ],
  18 + "info" : {
  19 + "version" : 1,
  20 + "author" : "xcode"
  21 + }
  22 +}
0 \ No newline at end of file 23 \ No newline at end of file
CNLiveBLoginModule/Assets/CNLiveBLoginModule.xcassets/login_logo.imageset/login_logo@2x.png 0 → 100644

18.2 KB

CNLiveBLoginModule/Assets/CNLiveBLoginModule.xcassets/login_logo.imageset/login_logo@3x.png 0 → 100644

35.6 KB

CNLiveBLoginModule/Assets/CNLiveBLoginModule.xcassets/login_logo_b.imageset/Contents.json 0 → 100644
  1 +{
  2 + "images" : [
  3 + {
  4 + "idiom" : "universal",
  5 + "scale" : "1x"
  6 + },
  7 + {
  8 + "filename" : "login_logo_b@2x.png",
  9 + "idiom" : "universal",
  10 + "scale" : "2x"
  11 + },
  12 + {
  13 + "filename" : "login_logo_b@3x.png",
  14 + "idiom" : "universal",
  15 + "scale" : "3x"
  16 + }
  17 + ],
  18 + "info" : {
  19 + "author" : "xcode",
  20 + "version" : 1
  21 + }
  22 +}
CNLiveBLoginModule/Assets/CNLiveBLoginModule.xcassets/login_logo_b.imageset/login_logo_b@2x.png 0 → 100644

24.8 KB

CNLiveBLoginModule/Assets/CNLiveBLoginModule.xcassets/login_logo_b.imageset/login_logo_b@3x.png 0 → 100644

48.4 KB

CNLiveBLoginModule/Assets/CNLiveBLoginModule.xcassets/login_qq.imageset/Contents.json 0 → 100644
  1 +{
  2 + "images" : [
  3 + {
  4 + "idiom" : "universal",
  5 + "scale" : "1x"
  6 + },
  7 + {
  8 + "idiom" : "universal",
  9 + "filename" : "login_qq@2x.png",
  10 + "scale" : "2x"
  11 + },
  12 + {
  13 + "idiom" : "universal",
  14 + "filename" : "login_qq@3x.png",
  15 + "scale" : "3x"
  16 + }
  17 + ],
  18 + "info" : {
  19 + "version" : 1,
  20 + "author" : "xcode"
  21 + }
  22 +}
0 \ No newline at end of file 23 \ No newline at end of file
CNLiveBLoginModule/Assets/CNLiveBLoginModule.xcassets/login_qq.imageset/login_qq@2x.png 0 → 100644

3.25 KB

CNLiveBLoginModule/Assets/CNLiveBLoginModule.xcassets/login_qq.imageset/login_qq@3x.png 0 → 100644

6.58 KB

CNLiveBLoginModule/Assets/CNLiveBLoginModule.xcassets/login_sel.imageset/Contents.json 0 → 100644
  1 +{
  2 + "images" : [
  3 + {
  4 + "idiom" : "universal",
  5 + "scale" : "1x"
  6 + },
  7 + {
  8 + "idiom" : "universal",
  9 + "filename" : "login_sel@2x.png",
  10 + "scale" : "2x"
  11 + },
  12 + {
  13 + "idiom" : "universal",
  14 + "filename" : "login_sel@3x.png",
  15 + "scale" : "3x"
  16 + }
  17 + ],
  18 + "info" : {
  19 + "version" : 1,
  20 + "author" : "xcode"
  21 + }
  22 +}
0 \ No newline at end of file 23 \ No newline at end of file
CNLiveBLoginModule/Assets/CNLiveBLoginModule.xcassets/login_sel.imageset/login_sel@2x.png 0 → 100644

1.29 KB

CNLiveBLoginModule/Assets/CNLiveBLoginModule.xcassets/login_sel.imageset/login_sel@3x.png 0 → 100644

1.81 KB

CNLiveBLoginModule/Assets/CNLiveBLoginModule.xcassets/login_wechat.imageset/Contents.json 0 → 100644
  1 +{
  2 + "images" : [
  3 + {
  4 + "idiom" : "universal",
  5 + "scale" : "1x"
  6 + },
  7 + {
  8 + "idiom" : "universal",
  9 + "filename" : "login_wechat@2x.png",
  10 + "scale" : "2x"
  11 + },
  12 + {
  13 + "idiom" : "universal",
  14 + "filename" : "login_wechat@3x.png",
  15 + "scale" : "3x"
  16 + }
  17 + ],
  18 + "info" : {
  19 + "version" : 1,
  20 + "author" : "xcode"
  21 + }
  22 +}
0 \ No newline at end of file 23 \ No newline at end of file
CNLiveBLoginModule/Assets/CNLiveBLoginModule.xcassets/login_wechat.imageset/login_wechat@2x.png 0 → 100644

3.9 KB

CNLiveBLoginModule/Assets/CNLiveBLoginModule.xcassets/login_wechat.imageset/login_wechat@3x.png 0 → 100644

7.83 KB

CNLiveBLoginModule/Assets/CNLiveBLoginModule.xcassets/login_weibo.imageset/Contents.json 0 → 100644
  1 +{
  2 + "images" : [
  3 + {
  4 + "idiom" : "universal",
  5 + "scale" : "1x"
  6 + },
  7 + {
  8 + "idiom" : "universal",
  9 + "filename" : "login_weibo@2x.png",
  10 + "scale" : "2x"
  11 + },
  12 + {
  13 + "idiom" : "universal",
  14 + "filename" : "login_weibo@3x.png",
  15 + "scale" : "3x"
  16 + }
  17 + ],
  18 + "info" : {
  19 + "version" : 1,
  20 + "author" : "xcode"
  21 + }
  22 +}
0 \ No newline at end of file 23 \ No newline at end of file
CNLiveBLoginModule/Assets/CNLiveBLoginModule.xcassets/login_weibo.imageset/login_weibo@2x.png 0 → 100644

6.38 KB

CNLiveBLoginModule/Assets/CNLiveBLoginModule.xcassets/login_weibo.imageset/login_weibo@3x.png 0 → 100644

12.4 KB

CNLiveBLoginModule/Assets/CNLiveBLoginModule.xcassets/mine_back_black_b.imageset/Contents.json 0 → 100644
  1 +{
  2 + "images" : [
  3 + {
  4 + "idiom" : "universal",
  5 + "scale" : "1x"
  6 + },
  7 + {
  8 + "idiom" : "universal",
  9 + "filename" : "mine_back_black_b@2x.png",
  10 + "scale" : "2x"
  11 + },
  12 + {
  13 + "idiom" : "universal",
  14 + "filename" : "mine_back_black_b@3x.png",
  15 + "scale" : "3x"
  16 + }
  17 + ],
  18 + "info" : {
  19 + "version" : 1,
  20 + "author" : "xcode"
  21 + }
  22 +}
0 \ No newline at end of file 23 \ No newline at end of file
CNLiveBLoginModule/Assets/CNLiveBLoginModule.xcassets/mine_back_black_b.imageset/mine_back_black_b@2x.png 0 → 100644

1.49 KB

CNLiveBLoginModule/Assets/CNLiveBLoginModule.xcassets/mine_back_black_b.imageset/mine_back_black_b@3x.png 0 → 100644

1.79 KB

CNLiveBLoginModule/Classes/.gitkeep 0 → 100644
CNLiveBLoginModule/Classes/BindingManage/CNLiveBindingManageCell.h 0 → 100644
  1 +//
  2 +// CNLiveBindingManageCell.h
  3 +// CNLiveNetAdd
  4 +//
  5 +// Created by CNLive-zxw on 2019/9/10.
  6 +// Copyright © 2019 cnlive. All rights reserved.
  7 +//
  8 +
  9 +#import <UIKit/UIKit.h>
  10 +
  11 +NS_ASSUME_NONNULL_BEGIN
  12 +@class CNLiveBindingManageModel;
  13 +#define kCNLiveBindingManageCell @"CNLiveBindingManageCell"
  14 +
  15 +@class CNLiveBindingManageCell;
  16 +@protocol CNLiveBindingManageCellDelegate <NSObject>
  17 +//isBinding YES 绑定操作 NO 解除绑定操作
  18 +- (void)clickedBindingButton:(CNLiveBindingManageCell *)cell isBinding:(BOOL)isBinding;
  19 +
  20 +@end
  21 +
  22 +@interface CNLiveBindingManageCell : UITableViewCell
  23 +@property (nonatomic, strong) CNLiveBindingManageModel *model;
  24 +@property (nonatomic, weak) id<CNLiveBindingManageCellDelegate> delegate;
  25 +
  26 +@end
  27 +
  28 +NS_ASSUME_NONNULL_END
CNLiveBLoginModule/Classes/BindingManage/CNLiveBindingManageCell.m 0 → 100644
  1 +//
  2 +// CNLiveBindingManageCell.m
  3 +// CNLiveNetAdd
  4 +//
  5 +// Created by CNLive-zxw on 2019/9/10.
  6 +// Copyright © 2019 cnlive. All rights reserved.
  7 +//
  8 +
  9 +#import "CNLiveBindingManageCell.h"
  10 +#import <Masonry/Masonry.h>
  11 +#import "QMUIKit.h"
  12 +#import "CNLiveBaseKit.h"
  13 +#import <CNLiveRequestBastKit/CNLiveNetworking.h>
  14 +
  15 +#import "CNLiveBindingManageModel.h"
  16 +#import "CNLiveBindingManageRequest.h"
  17 +
  18 +@interface CNLiveBindingManageCell()
  19 +@property (nonatomic, strong) UIImageView *icon;
  20 +@property (nonatomic, strong) UILabel *title;
  21 +@property (nonatomic, strong) UILabel *desc;
  22 +@property (nonatomic, strong) UIButton *manage;
  23 +@property (nonatomic, strong) UIView *line;
  24 +
  25 +@end
  26 +@implementation CNLiveBindingManageCell
  27 +static NSInteger const margin = 15;
  28 +
  29 +- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
  30 + self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
  31 + if (self) {
  32 + self.contentView.backgroundColor = [UIColor whiteColor];
  33 + [self createSubViews];
  34 + }
  35 + return self;
  36 +}
  37 +- (void)setModel:(CNLiveBindingManageModel *)model{
  38 + _model = model;
  39 + _icon.image = [UIImage imageNamed:model.image];
  40 + _title.text = model.title;
  41 + _desc.text = model.desc;
  42 + if([model.isBinding isEqualToString:@"1"]){
  43 + _manage.backgroundColor = RGBOF(0xd9d9d9);
  44 + [_manage setTitle:@"已绑定" forState:UIControlStateNormal];
  45 +
  46 + }else{
  47 + _manage.backgroundColor = RGBOF(0x23d41e);
  48 + [_manage setTitle:@"未绑定" forState:UIControlStateNormal];
  49 +
  50 + }
  51 +
  52 +}
  53 +#pragma mark - setupUI
  54 +- (void)createSubViews {
  55 + [self.contentView addSubview:self.icon];
  56 + [self.contentView addSubview:self.title];
  57 + [self.contentView addSubview:self.desc];
  58 + [self.contentView addSubview:self.manage];
  59 + [self.contentView addSubview:self.line];
  60 +
  61 +}
  62 +
  63 +- (void)layoutSubviews {
  64 + [self.icon mas_makeConstraints:^(MASConstraintMaker *make) {
  65 + make.centerY.equalTo(self.contentView);
  66 + make.left.equalTo(self.contentView).offset(margin);
  67 + make.width.mas_equalTo(50);
  68 + make.height.mas_equalTo(50);
  69 + }];
  70 +
  71 + [self.manage mas_makeConstraints:^(MASConstraintMaker *make) {
  72 + make.centerY.equalTo(self.contentView);
  73 + make.right.equalTo(self.contentView.mas_right).offset(-margin);
  74 + make.width.mas_equalTo(70);
  75 + make.height.mas_equalTo(30);
  76 + }];
  77 +
  78 + [self.title mas_makeConstraints:^(MASConstraintMaker *make) {
  79 + make.top.equalTo(self.icon.mas_top);
  80 + make.left.equalTo(self.icon.mas_right).offset(margin);
  81 + make.right.equalTo(self.manage.mas_left).offset(-margin);
  82 + make.height.mas_equalTo(25);
  83 + }];
  84 +
  85 + [self.desc mas_makeConstraints:^(MASConstraintMaker *make) {
  86 + make.top.equalTo(self.title.mas_bottom);
  87 + make.left.equalTo(self.title.mas_left);
  88 + make.right.equalTo(self.title.mas_right);
  89 + make.height.mas_equalTo(25);
  90 + }];
  91 + [self.line mas_makeConstraints:^(MASConstraintMaker *make) {
  92 + make.bottom.equalTo(self.contentView.mas_bottom).offset(-0.5);
  93 + make.left.equalTo(self.contentView.mas_left);
  94 + make.right.equalTo(self.contentView.mas_right);
  95 + make.height.mas_equalTo(0.5);
  96 + }];
  97 +}
  98 +
  99 +- (void)awakeFromNib {
  100 + [super awakeFromNib];
  101 + // Initialization code
  102 +}
  103 +
  104 +- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  105 + [super setSelected:selected animated:animated];
  106 +
  107 + // Configure the view for the selected state
  108 +}
  109 +
  110 +#pragma mark - Lazy Loading
  111 +- (UIImageView *)icon {
  112 + if (!_icon) {
  113 + _icon = [[UIImageView alloc] init];
  114 + _icon.contentMode = UIViewContentModeScaleAspectFill;
  115 + _icon.layer.cornerRadius = 25;
  116 + _icon.layer.masksToBounds = YES;
  117 + }
  118 + return _icon;
  119 +}
  120 +- (UILabel *)title {
  121 + if (!_title) {
  122 + _title = [[UILabel alloc] init];
  123 + _title.textColor = RGBOF(0x333333);
  124 + _title.font = UIFontCNMake(16);//[UIFont fontWithName:@"PingFangSC-Regular" size:15];
  125 + _title.numberOfLines = 0;
  126 + }
  127 + return _title;
  128 +}
  129 +- (UILabel *)desc {
  130 + if (!_desc) {
  131 + _desc = [[UILabel alloc] init];
  132 + _desc.textColor = RGBOF(0x999999);
  133 + _desc.font = UIFontCNMake(12);//[UIFont fontWithName:@"PingFangSC-Regular" size:15];
  134 + _desc.numberOfLines = 0;
  135 + }
  136 + return _desc;
  137 +}
  138 +- (UIButton *)manage {
  139 + if (!_manage) {
  140 + _manage = [UIButton buttonWithType:UIButtonTypeCustom];
  141 + _manage.backgroundColor = RGBOF(0xd9d9d9);
  142 + [_manage setTitle:@"已绑定" forState:UIControlStateNormal];
  143 + [_manage setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
  144 + _manage.titleLabel.font = UIFontCNMake(14);
  145 + _manage.layer.cornerRadius = 15;
  146 + _manage.layer.masksToBounds = YES;
  147 + [_manage addTarget:self action:@selector(manageDidClicked:) forControlEvents:UIControlEventTouchUpInside];
  148 + }
  149 + return _manage;
  150 +}
  151 +
  152 +- (UIView *)line {
  153 + if (!_line) {
  154 + _line = [[UIView alloc] init];
  155 + _line.backgroundColor = RGBOF(0xeeeeee);
  156 + }
  157 + return _line;
  158 +}
  159 +
  160 +#pragma mark - Action
  161 +- (void)manageDidClicked:(UIButton *)btn{
  162 + if([self.model.thirdPartyPlat isEqualToString:@"10"]){
  163 + return;
  164 + }
  165 + if(![CNLiveNetworking isNetworking]){
  166 + [QMUITips showError:@"无法连接网络" inView:([UIApplication sharedApplication].delegate).window hideAfterDelay:1.5];
  167 + return ;
  168 + }
  169 + btn.userInteractionEnabled = NO;
  170 + if (self.delegate && [self.delegate respondsToSelector:@selector(clickedBindingButton:isBinding:)]) {
  171 + [self.delegate clickedBindingButton:self isBinding:![self.model.isBinding isEqualToString:@"1"]];
  172 + btn.userInteractionEnabled = YES;
  173 +
  174 + }
  175 +}
  176 +
  177 +
  178 +@end
CNLiveBLoginModule/Classes/BindingManage/CNLiveBindingManageController.h 0 → 100644
  1 +//
  2 +// CNLiveBindingManageController.h
  3 +// CNLiveNetAdd
  4 +//
  5 +// Created by CNLive-zxw on 2019/9/10.
  6 +// Copyright © 2019 cnlive. All rights reserved.
  7 +//
  8 +// 绑定管理
  9 +#import "CNCommonViewController.h"
  10 +
  11 +NS_ASSUME_NONNULL_BEGIN
  12 +
  13 +@interface CNLiveBindingManageController : CNCommonViewController
  14 +
  15 +@end
  16 +
  17 +NS_ASSUME_NONNULL_END
CNLiveBLoginModule/Classes/BindingManage/CNLiveBindingManageController.m 0 → 100644
  1 +//
  2 +// CNLiveBindingManageController.m
  3 +// CNLiveNetAdd
  4 +//
  5 +// Created by CNLive-zxw on 2019/9/10.
  6 +// Copyright © 2019 cnlive. All rights reserved.
  7 +//
  8 +
  9 +#import "CNLiveBindingManageController.h"
  10 +#import <Masonry/Masonry.h>
  11 +#import "CNLiveBaseKit.h"
  12 +
  13 +#import "CNLiveBindingManageHeaderView.h"
  14 +#import "CNLiveBindingManageCell.h"
  15 +#import "CNLiveBindingManageModel.h"
  16 +#import "CNLiveBindingManageRequest.h"
  17 +
  18 +@interface CNLiveBindingManageController ()<UITableViewDelegate, UITableViewDataSource,CNLiveBindingManageCellDelegate>
  19 +@property (nonatomic, strong) UITableView *tableView;
  20 +@property (nonatomic, strong) NSArray *bindingData;
  21 +@property (nonatomic, strong) NSArray *unBindingData;
  22 +
  23 +@end
  24 +
  25 +@implementation CNLiveBindingManageController
  26 +#pragma mark - CNLiveBindingManageCellDelegate
  27 +- (void)clickedBindingButton:(CNLiveBindingManageCell *)cell isBinding:(BOOL)isBinding{
  28 + if(isBinding){
  29 + //绑定操作
  30 + [self requestBindingManage:cell.model];
  31 +
  32 + }else{
  33 + //解除绑定操作
  34 + UIAlertController *actionAlert1 = [UIAlertController alertControllerWithTitle:@"确定解除绑定?" message:nil preferredStyle:UIAlertControllerStyleAlert];
  35 +
  36 + UIAlertAction *action1 = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleDefault handler:NULL];
  37 + __weak typeof(self) weakSelf = self;
  38 + UIAlertAction *action2 = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
  39 + __strong typeof(weakSelf) strongSelf = weakSelf;
  40 + if(!strongSelf) return;
  41 + [strongSelf requestBindingManage:cell.model];
  42 +
  43 + }];
  44 + [action1 setValue:RGBOF(0x23D41E) forKey:@"_titleTextColor"];
  45 + [action2 setValue:RGBOF(0x23D41E) forKey:@"_titleTextColor"];
  46 +
  47 + [actionAlert1 addAction:action1];
  48 + [actionAlert1 addAction:action2];
  49 + [self presentViewController:actionAlert1 animated:YES completion:nil];
  50 + }
  51 +
  52 +}
  53 +- (void)requestBindingManage:(CNLiveBindingManageModel *)model{
  54 +// switch (model.type) {
  55 +// case CNLiveSendAuthRespWX:
  56 +// {
  57 +// if(![WXApi isWXAppInstalled]){
  58 +// [QMUITips showWithText:@"未安装微信" inView:self.view hideAfterDelay:1.5];
  59 +// return;
  60 +// }
  61 +// }
  62 +// break;
  63 +// case CNLiveSendAuthRespQQ:
  64 +// {
  65 +// if(![TencentOAuth iphoneQQInstalled]){
  66 +// [QMUITips showWithText:@"未安装QQ" inView:self.view hideAfterDelay:1.5];
  67 +// return;
  68 +// }
  69 +// }
  70 +// break;
  71 +// case CNLiveSendAuthRespWB:
  72 +// {
  73 +// if(![WeiboSDK isWeiboAppInstalled]){
  74 +// [QMUITips showWithText:@"未安装微博" inView:self.view hideAfterDelay:1.5];
  75 +// return;
  76 +// }
  77 +// }
  78 +// break;
  79 +// case CNLiveSendAuthRespApple:
  80 +// {
  81 +// }
  82 +// break;
  83 +// }
  84 + __weak typeof(self) weakSelf = self;
  85 + [CNLiveBindingManageRequest requestModel:model block:^(BOOL isSuccess, CNLiveBindingManageModel * _Nullable model, BOOL isBinding) {
  86 + __strong typeof(weakSelf) strongSelf = weakSelf;
  87 + if(!strongSelf) return;
  88 + if(isSuccess){
  89 + [strongSelf loadData];
  90 +
  91 + }
  92 +
  93 + }];
  94 +}
  95 +#pragma mark - Data
  96 +- (void)loadData{
  97 + __weak typeof(self) weakSelf = self;
  98 + [CNLiveBindingManageRequest requestModels:^(NSArray * _Nullable bindingData, NSArray * _Nullable unBindingData) {
  99 + __strong typeof(weakSelf) strongSelf = weakSelf;
  100 + if(!strongSelf) return;
  101 + strongSelf.bindingData = bindingData;
  102 + strongSelf.unBindingData = unBindingData;
  103 + [strongSelf.tableView reloadData];
  104 + }];
  105 +
  106 +}
  107 +
  108 +- (void)viewDidLoad {
  109 + [super viewDidLoad];
  110 + // Do any additional setup after loading the view.
  111 + self.view.backgroundColor = RGBOF(0xf4f4f4);
  112 + self.title = @"绑定管理";
  113 + if (@available(iOS 11.0, *)) {
  114 + self.tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
  115 + } else {
  116 + self.automaticallyAdjustsScrollViewInsets = NO;
  117 + }
  118 + [self loadData];
  119 + [self createUI];
  120 +
  121 +}
  122 +
  123 +- (void)createUI{
  124 + [self.view addSubview:self.tableView];
  125 +
  126 +}
  127 +
  128 +- (void)viewDidLayoutSubviews {
  129 + [super viewDidLayoutSubviews];
  130 + [_tableView mas_makeConstraints:^(MASConstraintMaker *make) {
  131 + make.top.equalTo(self.view.mas_top).with.offset(kVerticalStatusHeight+44);
  132 + make.left.equalTo(self.view.mas_left).with.offset(0);
  133 + make.right.equalTo(self.view.mas_right).with.offset(-0);
  134 + make.bottom.equalTo(self.view.mas_bottom).with.offset(-0);
  135 +
  136 + }];
  137 +
  138 +}
  139 +
  140 +#pragma mark - UITableViewDataSource
  141 +- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
  142 + return 2;
  143 +
  144 +}
  145 +
  146 +- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  147 + if(section == 0){
  148 + return self.bindingData.count;
  149 +
  150 + }else if(section == 1){
  151 + return self.unBindingData.count;
  152 +
  153 + }else{
  154 + return 0;
  155 + }
  156 +
  157 +}
  158 +
  159 +- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
  160 + return 80;
  161 +
  162 +}
  163 +
  164 +- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  165 + CNLiveBindingManageCell *cell = [tableView dequeueReusableCellWithIdentifier:kCNLiveBindingManageCell forIndexPath:indexPath];
  166 + cell.selectionStyle = UITableViewCellSelectionStyleNone;
  167 + cell.delegate = self;
  168 + if(indexPath.section == 0){
  169 + if(self.bindingData.count > 0){
  170 + cell.model = self.bindingData[indexPath.row];
  171 + }
  172 +
  173 + }else if(indexPath.section == 1){
  174 + if(self.unBindingData.count > 0){
  175 + cell.model = self.unBindingData[indexPath.row];
  176 + }
  177 + }
  178 + return cell;
  179 +
  180 +}
  181 +
  182 +- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
  183 + return 40.0;
  184 +
  185 +}
  186 +- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
  187 + return 0.0000001f;
  188 +
  189 +}
  190 +
  191 +- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
  192 + NSArray *array = @[@"您已绑定网家家手机号账号", @"其他绑定方式"];
  193 + CNLiveBindingManageHeaderView *header = [tableView dequeueReusableHeaderFooterViewWithIdentifier:kCNLiveBindingManageHeaderView];
  194 + header.text = array[section];
  195 + return header;
  196 +
  197 +}
  198 +
  199 +- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
  200 +
  201 +
  202 +}
  203 +
  204 +/*
  205 + #pragma mark - Navigation
  206 +
  207 + // In a storyboard-based application, you will often want to do a little preparation before navigation
  208 + - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  209 + // Get the new view controller using [segue destinationViewController].
  210 + // Pass the selected object to the new view controller.
  211 + }
  212 + */
  213 +
  214 +#pragma mark - Lazy loading
  215 +- (UITableView *)tableView {
  216 + if (!_tableView) {
  217 + _tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStyleGrouped];
  218 + _tableView.backgroundColor = RGBOF(0xf4f4f4);
  219 + _tableView.delegate = self;
  220 + _tableView.dataSource = self;
  221 + _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
  222 + _tableView.showsVerticalScrollIndicator = NO;
  223 + _tableView.showsHorizontalScrollIndicator = NO;
  224 + _tableView.estimatedRowHeight = 0;
  225 + _tableView.estimatedSectionFooterHeight = 0;
  226 + _tableView.estimatedSectionHeaderHeight = 0;
  227 + [_tableView registerClass:[CNLiveBindingManageCell class] forCellReuseIdentifier:kCNLiveBindingManageCell];
  228 + [_tableView registerClass:[CNLiveBindingManageHeaderView class] forHeaderFooterViewReuseIdentifier:kCNLiveBindingManageHeaderView];
  229 +
  230 + }
  231 + return _tableView;
  232 +}
  233 +
  234 +@end
CNLiveBLoginModule/Classes/BindingManage/CNLiveBindingManageHeaderView.h 0 → 100644
  1 +//
  2 +// CNLiveBindingManageHeaderView.h
  3 +// CNLiveNetAdd
  4 +//
  5 +// Created by CNLive-zxw on 2019/9/10.
  6 +// Copyright © 2019 cnlive. All rights reserved.
  7 +//
  8 +
  9 +#import <UIKit/UIKit.h>
  10 +
  11 +NS_ASSUME_NONNULL_BEGIN
  12 +#define kCNLiveBindingManageHeaderView @"CNLiveBindingManageHeaderView"
  13 +
  14 +@interface CNLiveBindingManageHeaderView : UITableViewHeaderFooterView
  15 +@property (nonatomic, copy) NSString *text;
  16 +
  17 +@end
  18 +
  19 +NS_ASSUME_NONNULL_END
CNLiveBLoginModule/Classes/BindingManage/CNLiveBindingManageHeaderView.m 0 → 100644
  1 +//
  2 +// CNLiveBindingManageHeaderView.m
  3 +// CNLiveNetAdd
  4 +//
  5 +// Created by CNLive-zxw on 2019/9/10.
  6 +// Copyright © 2019 cnlive. All rights reserved.
  7 +//
  8 +
  9 +#import "CNLiveBindingManageHeaderView.h"
  10 +#import <Masonry/Masonry.h>
  11 +
  12 +@interface CNLiveBindingManageHeaderView()
  13 +@property (nonatomic, strong) UILabel *title;
  14 +
  15 +@end
  16 +@implementation CNLiveBindingManageHeaderView
  17 +static NSInteger const margin = 15;
  18 +
  19 +- (instancetype)initWithReuseIdentifier:(NSString *)reuseIdentifier {
  20 + if (self = [super initWithReuseIdentifier:reuseIdentifier]) {
  21 + //在这里向contentView添加控件
  22 + self.backgroundColor = [UIColor colorWithRed:244/255.0 green:244/255.0 blue:244/255.0 alpha:1.0];
  23 + [self createSubviews];
  24 + [self xw_layoutSubviews];
  25 +
  26 + }
  27 + return self;
  28 +}
  29 +- (void)setText:(NSString *)text{
  30 + _text = text;
  31 + _title.text = text;
  32 +}
  33 +
  34 +#pragma mark - setupUI
  35 +- (void)createSubviews {
  36 + [self.contentView addSubview:self.title];
  37 +
  38 +}
  39 +
  40 +- (void)xw_layoutSubviews {
  41 + [self.title mas_makeConstraints:^(MASConstraintMaker *make) {
  42 + make.top.equalTo(self.contentView);
  43 + make.left.equalTo(self.contentView.mas_left).offset(margin);
  44 + make.right.equalTo(self.contentView.mas_right).offset(-margin);
  45 + make.bottom.equalTo(self.contentView.mas_bottom);
  46 +
  47 + }];
  48 +
  49 +}
  50 +
  51 +/*
  52 +// Only override drawRect: if you perform custom drawing.
  53 +// An empty implementation adversely affects performance during animation.
  54 +- (void)drawRect:(CGRect)rect {
  55 + // Drawing code
  56 +}
  57 +*/
  58 +
  59 +#pragma mark - Lazy Loading
  60 +- (UILabel *)title {
  61 + if (!_title) {
  62 + _title = [[UILabel alloc] init];
  63 + _title.textColor = [UIColor colorWithRed:153/255.0 green:153/255.0 blue:153/255.0 alpha:1.0];
  64 + _title.font = [UIFont systemFontOfSize:14];
  65 + _title.numberOfLines = 0;
  66 + }
  67 + return _title;
  68 +}
  69 +
  70 +@end
CNLiveBLoginModule/Classes/BindingManage/CNLiveBindingManageModel.h 0 → 100644
  1 +//
  2 +// CNLiveBindingManageModel.h
  3 +// CNLiveNetAdd
  4 +//
  5 +// Created by CNLive-zxw on 2019/9/10.
  6 +// Copyright © 2019 cnlive. All rights reserved.
  7 +//
  8 +
  9 +#import <Foundation/Foundation.h>
  10 +//#import "CNLiveShareImageManager.h"
  11 +
  12 +NS_ASSUME_NONNULL_BEGIN
  13 +
  14 +@interface CNLiveBindingManageModel : NSObject
  15 +@property (nonatomic, copy) NSString *title;
  16 +@property (nonatomic, copy) NSString *desc;
  17 +@property (nonatomic, copy) NSString *image;
  18 +@property (nonatomic, copy) NSString *isBinding;//是否绑定
  19 +
  20 +@property (nonatomic, copy) NSString *thirdPartyPlat;
  21 +@property (nonatomic, copy) NSString *thirdPartyId;
  22 +//@property (nonatomic, assign) CNLiveSendAuthResp type;
  23 +
  24 +
  25 +@end
  26 +
  27 +NS_ASSUME_NONNULL_END
CNLiveBLoginModule/Classes/BindingManage/CNLiveBindingManageModel.m 0 → 100644
  1 +//
  2 +// CNLiveBindingManageModel.m
  3 +// CNLiveNetAdd
  4 +//
  5 +// Created by CNLive-zxw on 2019/9/10.
  6 +// Copyright © 2019 cnlive. All rights reserved.
  7 +//
  8 +
  9 +#import "CNLiveBindingManageModel.h"
  10 +
  11 +@implementation CNLiveBindingManageModel
  12 +//- (CNLiveSendAuthResp)type{
  13 +// CNLiveSendAuthResp type = CNLiveSendAuthRespWX;
  14 +//
  15 +// if([self.thirdPartyPlat isEqualToString:@"1"]){
  16 +// type = CNLiveSendAuthRespWB;
  17 +//
  18 +// }else if ([self.thirdPartyPlat isEqualToString:@"2"]){
  19 +// type = CNLiveSendAuthRespQQ;
  20 +//
  21 +// }else if([self.thirdPartyPlat isEqualToString:@"3"]){
  22 +// type = CNLiveSendAuthRespWX;
  23 +//
  24 +// }else if([self.thirdPartyPlat isEqualToString:@"5"]){
  25 +// type = CNLiveSendAuthRespApple;
  26 +//
  27 +// }
  28 +// return type;
  29 +//
  30 +//}
  31 +
  32 +@end
CNLiveBLoginModule/Classes/BindingManage/CNLiveBindingManageRequest.h 0 → 100644
  1 +//
  2 +// CNLiveBindingManageRequest.h
  3 +// CNLiveNetAdd
  4 +//
  5 +// Created by CNLive-zxw on 2019/9/10.
  6 +// Copyright © 2019 cnlive. All rights reserved.
  7 +//
  8 +
  9 +#import <Foundation/Foundation.h>
  10 +//#import "CNLiveShareImageManager.h"
  11 +
  12 +NS_ASSUME_NONNULL_BEGIN
  13 +@class CNLiveBindingManageModel;
  14 +@class CNThreeLoginModel;
  15 +
  16 +typedef void (^CNLiveBindingResponseBlock)(BOOL isSuccess, CNLiveBindingManageModel * _Nullable model, BOOL isBinding);
  17 +typedef void (^CNLiveBindingArrayBlock)(NSArray * _Nullable bindingData, NSArray * _Nullable unBindingData);
  18 +typedef void (^CNLiveLoginResponseBlock)(NSURLSessionTask *requestTask, id responseObject, NSError *error);
  19 +
  20 +@interface CNLiveBindingManageRequest : NSObject
  21 +/**
  22 + * @abstract 绑定/解除绑定
  23 + *
  24 + * @param model 模型
  25 + * @param block 回调
  26 + */
  27 ++ (void)requestModel:(CNLiveBindingManageModel *)model block:(CNLiveBindingResponseBlock)block;
  28 +
  29 +/**
  30 + * @abstract 获取绑定数据
  31 + *
  32 + * @param block 回调
  33 + */
  34 ++ (void)requestModels:(CNLiveBindingArrayBlock)block;
  35 +
  36 +/**
  37 + * @abstract 三方登录
  38 + *
  39 + * @param type 三方类型
  40 + * @param model 模型
  41 + * @param block 回调
  42 + */
  43 +//+ (void)thirdPartyLoginWithType:(CNLiveSendAuthResp)type model:(CNThreeLoginModel *)model block:(CNLoginResponseBlock)block;
  44 +
  45 +@end
  46 +
  47 +NS_ASSUME_NONNULL_END
CNLiveBLoginModule/Classes/BindingManage/CNLiveBindingManageRequest.m 0 → 100644
  1 +//
  2 +// CNLiveBindingManageRequest.m
  3 +// CNLiveNetAdd
  4 +//
  5 +// Created by CNLive-zxw on 2019/9/10.
  6 +// Copyright © 2019 cnlive. All rights reserved.
  7 +//
  8 +
  9 +#import "CNLiveBindingManageRequest.h"
  10 +#import "QMUIKit.h"
  11 +#import <CNLiveRequestBastKit/CNLiveNetworking.h>
  12 +#import "CNUserInfoManager.h"
  13 +
  14 +#import "CNLiveBindingManageModel.h"
  15 +
  16 +//#import "CNThreeLoginModel.h"
  17 +//#import "CNLiveShareImageManager.h"
  18 +
  19 +@implementation CNLiveBindingManageRequest
  20 ++ (void)requestModel:(CNLiveBindingManageModel *)model block:(CNLiveBindingResponseBlock)block{
  21 + if([model.isBinding isEqualToString:@"1"]){
  22 + //解除绑定操作
  23 + [CNLiveBindingManageRequest requestUnBindingModel:model block:^(BOOL isSuccess, CNLiveBindingManageModel * _Nullable model, BOOL isBinding) {
  24 + block?block(isSuccess, model, isBinding):@"";
  25 + }];
  26 + }
  27 + else{
  28 + //绑定操作
  29 + [CNLiveBindingManageRequest requestBindingModel:model block:^(BOOL isSuccess, CNLiveBindingManageModel * _Nullable model, BOOL isBinding) {
  30 + block?block(isSuccess, model, isBinding):@"";
  31 + }];
  32 + }
  33 +}
  34 +
  35 +//绑定操作
  36 ++ (void)requestBindingModel:(CNLiveBindingManageModel *)model block:(CNLiveBindingResponseBlock)block{
  37 + __weak typeof(self) weakSelf = self;
  38 + // 获取第三方id
  39 +// [CNLiveShareImageManager send:model.type authRespBlock:^(CNLiveSendAuthResp type, CNLiveThirdPartyModel *userInfo, NSError *error) {
  40 +// __strong typeof(weakSelf) strongSelf = weakSelf;
  41 +// if(!strongSelf) return;
  42 +// if(error){
  43 +// if(error.code == 10000){
  44 +// //用户取消
  45 +// }else{
  46 +// [QMUITips showWithText:@"绑定失败" inView:AppKeyWindow hideAfterDelay:1.5];
  47 +// }
  48 +// return ;
  49 +// }
  50 +// if(userInfo.thirdPartyId&&![userInfo.thirdPartyId isEqualToString:@""]){
  51 +// // 发起绑定请求
  52 +// model.thirdPartyId = userInfo.thirdPartyId;
  53 +// [strongSelf sendBindingModel:model block:block];
  54 +//
  55 +// }else{
  56 +// [QMUITips showWithText:@"绑定失败" inView:AppKeyWindow hideAfterDelay:1.5];
  57 +//
  58 +// }
  59 +//
  60 +// }];
  61 +
  62 +}
  63 +
  64 ++ (void)sendBindingModel:(CNLiveBindingManageModel *)model block:(CNLiveBindingResponseBlock)block{
  65 +// NSDictionary *params = @{
  66 +// @"uid":CNUserShareModel.uid?CNUserShareModel.uid:@"",
  67 +// @"thirdPartyPlat":model.thirdPartyPlat?model.thirdPartyPlat:@"",
  68 +// @"thirdPartyId":model.thirdPartyId?model.thirdPartyId:@"",
  69 +// @"token":CNUserShareModel.token?CNUserShareModel.token:@"",
  70 +// @"clientPlat":@"i"};
  71 +// [CNLiveNetworking setAllowRequestDefaultArgument:YES];
  72 +// [CNLiveNetworking setupShowDataResult:NO];
  73 +//
  74 +// __weak typeof(self) weakSelf = self;
  75 +// [CNLiveNetworking requestNetworkWithMethod:CNLiveRequestMethodPOST URLString:CNLoginBind3rdUrl Param:params CacheType:CNLiveNetworkCacheTypeNetworkOnly CompletionBlock:^(NSURLSessionTask *requestTask, id responseObject, NSError *error) {
  76 +// __strong typeof(weakSelf) strongSelf = weakSelf;
  77 +// if(!strongSelf) return;
  78 +//
  79 +// if ([responseObject isKindOfClass:[NSDictionary class]] && [responseObject[@"errorCode"] isEqualToString:@"0"]) {
  80 +// //绑定,并更新本地数据
  81 +// CNBindingManageModel *bindingModel = [strongSelf updateBindingModel:model isBinding:@"1"];
  82 +// block?block(YES, bindingModel, YES):@"";
  83 +// }
  84 +// else if([responseObject isKindOfClass:[NSDictionary class]]) {
  85 +// [QMUITips showWithText:responseObject[@"errorMessage"] inView:AppKeyWindow hideAfterDelay:1.5];
  86 +// block?block(NO, nil, NO):@"";
  87 +// }
  88 +// else{
  89 +// [QMUITips showWithText:@"绑定失败" inView:AppKeyWindow hideAfterDelay:1.5];
  90 +// block?block(NO, nil, NO):@"";
  91 +// }
  92 +//
  93 +// }];
  94 +}
  95 +
  96 +//解除绑定操作
  97 ++ (void)requestUnBindingModel:(CNLiveBindingManageModel *)model block:(CNLiveBindingResponseBlock)block{
  98 +// NSDictionary *params = @{
  99 +// @"uid":CNUserShareModel.uid?CNUserShareModel.uid:@"",
  100 +// @"thirdPartyPlat":model.thirdPartyPlat?model.thirdPartyPlat:@"",
  101 +// @"thirdPartyId":model.thirdPartyId?model.thirdPartyId:@"",
  102 +// @"token":CNUserShareModel.token?CNUserShareModel.token:@"",
  103 +// @"clientPlat":@"i"};
  104 +//
  105 +// [CNLiveNetworking setAllowRequestDefaultArgument:YES];
  106 +// [CNLiveNetworking setupShowDataResult:NO];
  107 +//
  108 +// __weak typeof(self) weakSelf = self;
  109 +// [CNLiveNetworking requestNetworkWithMethod:CNLiveRequestMethodPOST URLString:CNLoginUnBind3rdUrl Param:params CacheType:CNLiveNetworkCacheTypeNetworkOnly CompletionBlock:^(NSURLSessionTask *requestTask, id responseObject, NSError *error) {
  110 +// __strong typeof(weakSelf) strongSelf = weakSelf;
  111 +// if(!strongSelf) return;
  112 +//
  113 +// if ([responseObject isKindOfClass:[NSDictionary class]] && [responseObject[@"errorCode"] isEqualToString:@"0"]) {
  114 +// //解除绑定,并更新本地数据
  115 +// CNBindingManageModel *unbindingModel = [strongSelf updateBindingModel:model isBinding:@"0"];
  116 +// block?block(YES, unbindingModel, NO):@"";
  117 +// }
  118 +// else if ([responseObject isKindOfClass:[NSDictionary class]]) {
  119 +// [QMUITips showWithText:responseObject[@"errorMessage"] inView:AppKeyWindow hideAfterDelay:1.5];
  120 +// block?block(NO, nil, NO):@"";
  121 +// }
  122 +// else{
  123 +// [QMUITips showWithText:@"解除绑定失败" inView:AppKeyWindow hideAfterDelay:1.5];
  124 +// block?block(NO, nil, NO):@"";
  125 +// }
  126 +//
  127 +// }];
  128 +
  129 +}
  130 +
  131 +//改变绑定数据
  132 ++ (CNLiveBindingManageModel *)updateBindingModel:(CNLiveBindingManageModel *)model isBinding:(NSString *)isBinding{
  133 + if([isBinding isEqualToString:@"0"]){
  134 + //解除绑定
  135 + model.isBinding = @"0";
  136 + //微博
  137 + if([model.thirdPartyPlat isEqualToString:@"1"]){
  138 + CNUserShareModel.sinaUid = @"";
  139 +
  140 + }
  141 + //qq
  142 + else if([model.thirdPartyPlat isEqualToString:@"2"]){
  143 + CNUserShareModel.qqUid = @"";
  144 +
  145 + }
  146 + //微信
  147 + else if([model.thirdPartyPlat isEqualToString:@"3"]){
  148 + CNUserShareModel.wxUid = @"";
  149 +
  150 + }
  151 + //苹果
  152 + else if([model.thirdPartyPlat isEqualToString:@"5"]){
  153 + CNUserShareModel.appleUid = @"";
  154 +
  155 + }
  156 + [QMUITips showWithText:@"解除绑定成功" inView:([UIApplication sharedApplication].delegate).window hideAfterDelay:1.5];
  157 + return model;
  158 + }
  159 + else if ([isBinding isEqualToString:@"1"]){
  160 + //添加绑定
  161 + model.isBinding = @"1";
  162 + //微博
  163 + if([model.thirdPartyPlat isEqualToString:@"1"]){
  164 + CNUserShareModel.sinaUid = model.thirdPartyId;
  165 +
  166 + }
  167 + //qq
  168 + else if([model.thirdPartyPlat isEqualToString:@"2"]){
  169 + CNUserShareModel.qqUid = model.thirdPartyId;
  170 +
  171 + }
  172 + //微信
  173 + else if([model.thirdPartyPlat isEqualToString:@"3"]){
  174 + CNUserShareModel.wxUid = model.thirdPartyId;
  175 +
  176 + }
  177 + //苹果
  178 + else if([model.thirdPartyPlat isEqualToString:@"5"]){
  179 + CNUserShareModel.appleUid = model.thirdPartyId;
  180 +
  181 + }
  182 + [QMUITips showWithText:@"绑定成功" inView:([UIApplication sharedApplication].delegate).window hideAfterDelay:1.5];
  183 + return model;
  184 +
  185 + }
  186 + return nil;
  187 +
  188 +}
  189 +
  190 +//请求绑定数据
  191 ++ (void)requestModels:(CNLiveBindingArrayBlock)block{
  192 + NSMutableArray *bindingData = [[NSMutableArray alloc] init];
  193 + NSMutableArray *unBindingData = [[NSMutableArray alloc] init];
  194 + CNLiveBindingManageModel *tmodel = [[CNLiveBindingManageModel alloc]init];
  195 + tmodel.title = @"手机号";
  196 + tmodel.image = @"login_telephone";
  197 + NSString *mobile = [CNUserShareModel.mobile stringByReplacingCharactersInRange:NSMakeRange(3, 4) withString:@"****"];
  198 + tmodel.desc = mobile;
  199 + tmodel.isBinding = @"1";
  200 + tmodel.thirdPartyPlat = @"10";
  201 + tmodel.thirdPartyId = CNUserShareModel.uid;
  202 + [bindingData addObject:tmodel];
  203 +
  204 + CNLiveBindingManageModel *wmodel = [[CNLiveBindingManageModel alloc]init];
  205 + wmodel.title = @"微信";
  206 + wmodel.image = @"login_wechat";
  207 + wmodel.thirdPartyPlat = @"3";
  208 +
  209 + if(CNUserShareModel.wxUid&&![CNUserShareModel.wxUid isEqualToString:@""]){
  210 + wmodel.desc = @"已绑定微信";
  211 + wmodel.thirdPartyId = CNUserShareModel.wxUid;
  212 + wmodel.isBinding = @"1";
  213 + }else{
  214 + wmodel.desc = @"未绑定微信";
  215 + wmodel.isBinding = @"0";
  216 + }
  217 + [unBindingData addObject:wmodel];
  218 +
  219 + CNLiveBindingManageModel *qmodel = [[CNLiveBindingManageModel alloc]init];
  220 + qmodel.title = @"QQ";
  221 + qmodel.image = @"login_qq";
  222 + qmodel.thirdPartyPlat = @"2";
  223 + if(CNUserShareModel.qqUid&&![CNUserShareModel.qqUid isEqualToString:@""]){
  224 + qmodel.desc = @"已绑定QQ";
  225 + qmodel.thirdPartyId = CNUserShareModel.qqUid;
  226 + qmodel.isBinding = @"1";
  227 + }else{
  228 + qmodel.desc = @"未绑定QQ";
  229 + qmodel.isBinding = @"0";
  230 + }
  231 + [unBindingData addObject:qmodel];
  232 +
  233 + CNLiveBindingManageModel *smodel = [[CNLiveBindingManageModel alloc]init];
  234 + smodel.title = @"微博";
  235 + smodel.image = @"login_weibo";
  236 + smodel.thirdPartyPlat = @"1";
  237 + if(CNUserShareModel.sinaUid&&![CNUserShareModel.sinaUid isEqualToString:@""]){
  238 + smodel.desc = @"已绑定微博";
  239 + smodel.thirdPartyId = CNUserShareModel.sinaUid;
  240 + smodel.isBinding = @"1";
  241 + }else{
  242 + smodel.desc = @"未绑定微博";
  243 + smodel.isBinding = @"0";
  244 + }
  245 + [unBindingData addObject:smodel];
  246 +
  247 + CNLiveBindingManageModel *amodel = [[CNLiveBindingManageModel alloc]init];
  248 + amodel.title = @"苹果账号";
  249 + amodel.image = @"login_apple_icon";
  250 + amodel.thirdPartyPlat = @"5";
  251 + if(CNUserShareModel.appleUid&&![CNUserShareModel.appleUid isEqualToString:@""]){
  252 + amodel.desc = @"已绑定苹果账号";
  253 + amodel.thirdPartyId = CNUserShareModel.appleUid;
  254 + amodel.isBinding = @"1";
  255 + }else{
  256 + amodel.desc = @"未绑定苹果账号";
  257 + amodel.isBinding = @"0";
  258 + }
  259 + [unBindingData addObject:amodel];
  260 +
  261 + block?block(bindingData,unBindingData):@"";
  262 +}
  263 +
  264 +//三方登录
  265 +//+ (void)thirdPartyLoginWithType:(CNLiveSendAuthResp)type model:(CNThreeLoginModel *)model block:(CNLoginResponseBlock)block{
  266 +// NSDictionary *params = @{@"thirdPartyPlat":model.thirdPartyPlat?model.thirdPartyPlat:@"",
  267 +// @"thirdPartyId":model.thirdPartyId?model.thirdPartyId:@"",
  268 +// @"frmId":model.frmId?model.frmId:@"",
  269 +// @"clientPlat":@"i"};
  270 +// [CNLiveNetworking setAllowRequestDefaultArgument:YES];
  271 +// [CNLiveNetworking setupShowDataResult:NO];
  272 +//
  273 +// [CNLiveNetworking requestNetworkWithMethod:CNLiveRequestMethodPOST URLString:CNLoginIn3rdForWJJUrl Param:params CacheType:CNLiveNetworkCacheTypeNetworkOnly CompletionBlock:^(NSURLSessionTask *requestTask, id responseObject, NSError *error) {
  274 +// block?block(requestTask, responseObject, error):@"";
  275 +//
  276 +// }];
  277 +//
  278 +//
  279 +//}
  280 +
  281 +@end
CNLiveBLoginModule/Classes/Controller/CNLiveCompleteInfoController.h 0 → 100644
  1 +//
  2 +// CNLiveCompleteInfoController.h
  3 +// CNLiveLoginModule
  4 +//
  5 +// Created by 153993236@qq.com on 11/12/2019.
  6 +// Copyright (c) 2019 153993236@qq.com. All rights reserved.
  7 +//
  8 +
  9 +#import <UIKit/UIKit.h>
  10 +
  11 +NS_ASSUME_NONNULL_BEGIN
  12 +
  13 +@interface CNLiveCompleteInfoController : UIViewController
  14 +@property (nonatomic, assign) BOOL isShow;
  15 +
  16 +@end
  17 +
  18 +NS_ASSUME_NONNULL_END
CNLiveBLoginModule/Classes/Controller/CNLiveCompleteInfoController.m 0 → 100644
  1 +//
  2 +// CNLiveCompleteInfoController.m
  3 +// CNLiveLoginModule
  4 +//
  5 +// Created by 153993236@qq.com on 11/12/2019.
  6 +// Copyright (c) 2019 153993236@qq.com. All rights reserved.
  7 +//
  8 +
  9 +#import "CNLiveCompleteInfoController.h"
  10 +
  11 +#import "MJExtension.h"
  12 +#import "QMUIKit.h"
  13 +#import "YYKit.h"
  14 +
  15 +#import "CNLiveNavigationBar.h"
  16 +#import "CNLiveCompleteInfoView.h"
  17 +
  18 +@interface CNLiveCompleteInfoController()<CNLiveCompleteInfoViewDelegate>
  19 +@property (nonatomic, strong) CNLiveCompleteInfoView *infoView;
  20 +@property (nonatomic, strong) CNLiveNavigationBar *navigationBar;
  21 +
  22 +@end
  23 +
  24 +@implementation CNLiveCompleteInfoController
  25 +#pragma mark - 生命周期
  26 +- (void)viewWillAppear:(BOOL)animated{
  27 + [super viewWillAppear:animated];
  28 + self.navigationController.navigationBarHidden = YES;
  29 +}
  30 +
  31 +- (void)viewDidLoad {
  32 + [super viewDidLoad];
  33 + // Do any additional setup after loading the view.
  34 + self.automaticallyAdjustsScrollViewInsets = NO;
  35 + self.view.backgroundColor = [UIColor whiteColor];
  36 + [self createUI];
  37 +}
  38 +
  39 +- (void)createUI{
  40 + [self.view addSubview:self.navigationBar];
  41 + [self.view addSubview:self.infoView];
  42 +}
  43 +
  44 +- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
  45 + [self.view endEditing:YES];
  46 +}
  47 +
  48 +#pragma mark - CNLiveCompleteInfoViewDelegate
  49 +- (void)loginSuccess:(CNLiveCompleteInfoView *)view result:(id _Nonnull)result{
  50 + // 进入tabbar
  51 +
  52 +}
  53 +
  54 +/*
  55 +#pragma mark - Navigation
  56 +
  57 +// In a storyboard-based application, you will often want to do a little preparation before navigation
  58 +- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  59 + // Get the new view controller using [segue destinationViewController].
  60 + // Pass the selected object to the new view controller.
  61 +}
  62 +*/
  63 +
  64 +#pragma mark - 懒加载
  65 +- (CNLiveNavigationBar *)navigationBar {
  66 + if (!_navigationBar) {
  67 + _navigationBar = [CNLiveNavigationBar navigationBar];
  68 + _navigationBar.backgroundColor = [UIColor whiteColor];
  69 + _navigationBar.title.text = @"完善信息";
  70 + __weak typeof(self) weakSelf = self;
  71 + _navigationBar.onClickLeftButton = ^{
  72 + [weakSelf.navigationController popViewControllerAnimated:YES];
  73 + };
  74 + _navigationBar.right = nil;
  75 + }
  76 + return _navigationBar;
  77 +}
  78 +
  79 +- (CNLiveCompleteInfoView *)infoView{
  80 + if(!_infoView){
  81 + _infoView = [[CNLiveCompleteInfoView alloc] initWithFrame:CGRectMake(self.view.frame.size.width/8.0, NavigationContentTop+40, self.view.frame.size.width*3/4.0, 250)];
  82 + _infoView.center = CGPointMake(self.view.center.x, self.view.center.y-50);
  83 + _infoView.delegate = self;
  84 + }
  85 + return _infoView;
  86 +}
  87 +
  88 +@end
CNLiveBLoginModule/Classes/Controller/CNLiveLoginController.h 0 → 100644
  1 +//
  2 +// CNLiveLoginController.h
  3 +// CNLiveLoginModule
  4 +//
  5 +// Created by 153993236@qq.com on 11/12/2019.
  6 +// Copyright (c) 2019 153993236@qq.com. All rights reserved.
  7 +//
  8 +
  9 +#import <UIKit/UIKit.h>
  10 +
  11 +NS_ASSUME_NONNULL_BEGIN
  12 +
  13 +@interface CNLiveLoginController : UIViewController
  14 +@property (nonatomic, assign) BOOL isShowClose;
  15 +
  16 +@end
  17 +
  18 +NS_ASSUME_NONNULL_END
CNLiveBLoginModule/Classes/Controller/CNLiveLoginController.m 0 → 100644
  1 +//
  2 +// CNLiveLoginController.m
  3 +// CNLiveLoginModule
  4 +//
  5 +// Created by 153993236@qq.com on 11/12/2019.
  6 +// Copyright (c) 2019 153993236@qq.com. All rights reserved.
  7 +//
  8 +
  9 +#import "CNLiveLoginController.h"
  10 +
  11 +#import "MJExtension.h"
  12 +#import "QMUIKit.h"
  13 +#import "YYKit.h"
  14 +
  15 +#import "CNLiveUserAgreementManager.h"
  16 +#import "CNLiveCategory.h"
  17 +#import "CNUserInfoManager.h"
  18 +#import "CNLiveEnvironment.h"
  19 +
  20 +#import "CNLiveLoginView.h"
  21 +#import "CNLiveThreeLoginView.h"
  22 +#import "CNLiveBindingTelController.h"//绑定手机号
  23 +#import "CNLiveCompleteInfoController.h"//修改昵称
  24 +#import "CNLiveLoginRequest.h"
  25 +
  26 +@interface CNLiveLoginController()<CNLiveLoginViewDelegate, CNLiveThreeLoginViewDelegate>
  27 +@property (nonatomic, weak) CNLiveLoginView *loginView;
  28 +@property (nonatomic, weak) CNLiveThreeLoginView *threeLoginView;
  29 +@property (nonatomic, weak) YYLabel *protocol;
  30 +@property (nonatomic, strong) UIButton *close;
  31 +
  32 +@end
  33 +
  34 +@implementation CNLiveLoginController
  35 +
  36 +#pragma mark - 生命周期
  37 +- (void)viewWillAppear:(BOOL)animated{
  38 + [super viewWillAppear:animated];
  39 + self.navigationController.navigationBarHidden = YES;
  40 +}
  41 +
  42 +- (void)viewDidLoad {
  43 + [super viewDidLoad];
  44 + // Do any additional setup after loading the view.
  45 + self.automaticallyAdjustsScrollViewInsets = NO;
  46 + self.view.backgroundColor = [UIColor whiteColor];
  47 + [self createUI];
  48 +}
  49 +
  50 +- (void)createUI{
  51 +
  52 + [self.view addSubview:self.close];
  53 +
  54 + CNLiveLoginView *loginView = [[CNLiveLoginView alloc] initWithFrame:CGRectMake(SCREEN_WIDTH/8.0, NavigationContentTop+20, SCREEN_WIDTH*3/4.0, 380)];
  55 + loginView.delegate = self;
  56 + [self.view addSubview:loginView];
  57 + self.loginView = loginView;
  58 +
  59 + YYLabel *protocol = [[YYLabel alloc] initWithFrame:CGRectMake(0, SCREEN_HEIGHT-30-SafeAreaInsetsConstantForDeviceWithNotch.bottom, SCREEN_WIDTH, 30)];
  60 + protocol.textAlignment = NSTextAlignmentCenter;
  61 + protocol.textColor = [UIColor colorWithRed:173/255.0 green:173/255.0 blue:173/255.0 alpha:1.0];
  62 + protocol.font = [UIFont systemFontOfSize:14.0];
  63 + NSMutableAttributedString *text = [[NSMutableAttributedString alloc] initWithString:@"登录即代表阅读并同意《用户协议》及《隐私政策》"];
  64 + NSMutableParagraphStyle *style = [[NSParagraphStyle defaultParagraphStyle] mutableCopy];
  65 + style.alignment = NSTextAlignmentCenter;//对齐方式
  66 + [text addAttribute:NSParagraphStyleAttributeName value:style range:NSMakeRange(0, text.length)];
  67 + text.color = [UIColor colorWithRed:173/255.0 green:173/255.0 blue:173/255.0 alpha:1.0];
  68 + text.font = [UIFont systemFontOfSize:14.0];
  69 + __weak typeof(self) weakSelf = self;
  70 + UIColor *color = Business?[UIColor colorWithRed:72/255.0 green:168/255.0 blue:249/255.0 alpha:1.0]:[UIColor colorWithRed:35/255.0 green:212/255.0 blue:30/255.0 alpha:1.0];
  71 + [text setTextHighlightRange:NSMakeRange(11, 4) color:color backgroundColor:[UIColor clearColor] tapAction:^(UIView * _Nonnull containerView, NSAttributedString * _Nonnull text, NSRange range, CGRect rect) {
  72 + [weakSelf.view endEditing:YES];
  73 + [CNLiveUserAgreementManager jumpToAgreementH5WithType:CNLiveUserAgreementUser];
  74 + }];
  75 + [text setTextHighlightRange:NSMakeRange(text.length-5, 4) color:color backgroundColor:[UIColor clearColor] tapAction:^(UIView * _Nonnull containerView, NSAttributedString * _Nonnull text, NSRange range, CGRect rect) {
  76 + [weakSelf.view endEditing:YES];
  77 + [CNLiveUserAgreementManager jumpToAgreementH5WithType:CNLiveUserAgreementPrivacy];
  78 + }];
  79 + protocol.attributedText = text;
  80 + [self.view addSubview:protocol];
  81 + self.protocol = protocol;
  82 +
  83 + CNLiveThreeLoginView *threeLoginView = [[CNLiveThreeLoginView alloc] initWithFrame:CGRectMake(20, SCREEN_HEIGHT-30-SafeAreaInsetsConstantForDeviceWithNotch.bottom-80-10, SCREEN_WIDTH-40, 80)];
  84 + threeLoginView.delegate = self;
  85 + [self.view addSubview:threeLoginView];
  86 + self.threeLoginView = threeLoginView;
  87 +
  88 +}
  89 +
  90 +- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
  91 + [self.view endEditing:YES];
  92 +
  93 +}
  94 +
  95 +#pragma mark - CNLiveLoginViewDelegate
  96 +- (void)loginSuccess:(CNLiveLoginView *)view isNewUser:(BOOL)isNewUser result:(id _Nonnull)result{
  97 + if (!isNewUser) {
  98 + // 新用户 -> 设置昵称和头像
  99 + CNLiveCompleteInfoController *vc = [[CNLiveCompleteInfoController alloc]init];
  100 + vc.hidesBottomBarWhenPushed = YES;
  101 + [self.navigationController pushViewController:vc animated:YES];
  102 +
  103 + }else{
  104 + // 老用户 -> home
  105 + [[CNLiveLoginRequest manager] loginTIM:CNUserShareModel.uid success:^{
  106 + // 进入tabbar
  107 +
  108 + } failed:^(int code, NSString * _Nonnull msg) {
  109 + // 错误逻辑
  110 +
  111 + }];
  112 +
  113 + }
  114 +
  115 +}
  116 +
  117 +#pragma mark - CNLiveThreeLoginViewDelegate
  118 +- (void)clickedButton:(CNLiveThreeLoginView *)view type:(CNLiveThreeLoginType)type{
  119 + // 1.请求三方平台
  120 +
  121 + // 2.绑定手机号
  122 + [self jumpToBindingTelController:type];
  123 +
  124 +}
  125 +
  126 +- (void)jumpToBindingTelController:(CNLiveThreeLoginType)type{
  127 + CNLiveBindingTelController *vc = [[CNLiveBindingTelController alloc]initWithType:type];
  128 + [self.navigationController pushViewController:vc animated:YES];
  129 +
  130 +}
  131 +
  132 +/*
  133 +#pragma mark - Navigation
  134 +
  135 +// In a storyboard-based application, you will often want to do a little preparation before navigation
  136 +- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  137 + // Get the new view controller using [segue destinationViewController].
  138 + // Pass the selected object to the new view controller.
  139 +}
  140 +*/
  141 +#pragma mark - 响应事件
  142 +- (void)closeDidSelected:(UIButton *)btn{
  143 + if (self.navigationController.topViewController == self) {
  144 + [self.navigationController popViewControllerAnimated:YES];
  145 + }else{
  146 + [self dismissViewControllerAnimated:YES completion:nil];
  147 + }
  148 +}
  149 +
  150 +#pragma mark - 懒加载
  151 +- (UIButton *)close{
  152 + if (!_close) {
  153 + _close = [UIButton buttonWithType:UIButtonTypeCustom];
  154 + _close.frame = CGRectMake(SCREEN_WIDTH-NavigationBarHeight-10, StatusBarHeight, NavigationBarHeight, NavigationBarHeight);
  155 + _close.hidden = !self.isShowClose;
  156 + UIImage *image = [self getImageWithImageName:@"login_close" bundleName:@"CNLiveBLoginModule" targetClass:[self class]];
  157 + [_close setImage:image forState:UIControlStateNormal];
  158 + [_close addTarget:self action:@selector(closeDidSelected:) forControlEvents:UIControlEventTouchUpInside];
  159 + _close.adjustsImageWhenHighlighted = NO;
  160 + }
  161 + return _close;
  162 +
  163 +}
  164 +
  165 +@end
CNLiveBLoginModule/Classes/Model/CNLiveClassifyOffsetManager.h 0 → 100644
  1 +//
  2 +// CNLiveClassifyOffsetManager.h
  3 +// CNLiveLoginModule
  4 +//
  5 +// Created by CNLive-zxw on 2019/3/27.
  6 +// Copyright © 2019年 cnlive. All rights reserved.
  7 +//
  8 +
  9 +#import <Foundation/Foundation.h>
  10 +
  11 +NS_ASSUME_NONNULL_BEGIN
  12 +
  13 +@interface CNLiveClassifyOffsetManager : NSObject
  14 ++ (instancetype)manager;
  15 +
  16 +
  17 +@end
  18 +
  19 +NS_ASSUME_NONNULL_END
CNLiveBLoginModule/Classes/Model/CNLiveClassifyOffsetManager.m 0 → 100644
  1 +//
  2 +// CNLiveClassifyOffsetManager.m
  3 +// CNLiveLoginModule
  4 +//
  5 +// Created by CNLive-zxw on 2019/3/27.
  6 +// Copyright © 2019年 cnlive. All rights reserved.
  7 +//
  8 +
  9 +#import "CNLiveClassifyOffsetManager.h"
  10 +
  11 +@interface CNLiveClassifyOffsetManager ()
  12 +
  13 +@end
  14 +
  15 +@implementation CNLiveClassifyOffsetManager
  16 +#pragma mark - 单例
  17 ++ (instancetype)manager {
  18 + static CNLiveClassifyOffsetManager *_singleton = nil;
  19 + static dispatch_once_t onceToken;
  20 + dispatch_once(&onceToken, ^{
  21 + //不能再使用alloc方法
  22 + //因为已经重写了allocWithZone方法,所以这里要调用父类的分配空间的方法
  23 + _singleton = [[super allocWithZone:NULL] init];
  24 + });
  25 + return _singleton;
  26 +
  27 +}
  28 +
  29 +// 防止外部调用alloc 或者 new
  30 ++ (instancetype)allocWithZone:(struct _NSZone *)zone {
  31 + return [CNLiveClassifyOffsetManager manager];
  32 +
  33 +}
  34 +
  35 +// 防止外部调用copy
  36 +- (id)copyWithZone:(nullable NSZone *)zone {
  37 + return [CNLiveClassifyOffsetManager manager];
  38 +
  39 +}
  40 +
  41 +// 防止外部调用mutableCopy
  42 +- (id)mutableCopyWithZone:(nullable NSZone *)zone {
  43 + return [CNLiveClassifyOffsetManager manager];
  44 +
  45 +}
  46 +
  47 +@end
CNLiveBLoginModule/Classes/Model/CNLiveLoginModel.h 0 → 100644
  1 +//
  2 +// CNLiveLoginModel.h
  3 +// CNLiveLoginModule
  4 +//
  5 +// Created by 153993236@qq.com on 11/12/2019.
  6 +// Copyright (c) 2019 153993236@qq.com. All rights reserved.
  7 +//
  8 +
  9 +#import <Foundation/Foundation.h>
  10 +
  11 +NS_ASSUME_NONNULL_BEGIN
  12 +
  13 +@interface CNLiveLoginModel : NSObject
  14 +
  15 +
  16 +@end
  17 +
  18 +NS_ASSUME_NONNULL_END
CNLiveBLoginModule/Classes/Model/CNLiveLoginModel.m 0 → 100644
  1 +//
  2 +// CNLiveLoginModel.m
  3 +// CNLiveLoginModule
  4 +//
  5 +// Created by 153993236@qq.com on 11/12/2019.
  6 +// Copyright (c) 2019 153993236@qq.com. All rights reserved.
  7 +//
  8 +
  9 +#import "CNLiveLoginModel.h"
  10 +
  11 +@implementation CNLiveLoginModel
  12 +
  13 +@end
CNLiveBLoginModule/Classes/Model/CNLiveLoginRequest.h 0 → 100644
  1 +//
  2 +// CNLiveLoginRequest.h
  3 +// CNLiveLoginModule
  4 +//
  5 +// Created by 153993236@qq.com on 11/12/2019.
  6 +// Copyright (c) 2019 153993236@qq.com. All rights reserved.
  7 +//
  8 +
  9 +#import <Foundation/Foundation.h>
  10 +
  11 +NS_ASSUME_NONNULL_BEGIN
  12 +
  13 +@interface CNLiveLoginRequest : NSObject
  14 +
  15 ++ (instancetype)manager;
  16 +
  17 +- (void)getTIMLoginToken:(NSString *)identifier success:(void (^)(NSString * token))success failed:(void (^)(int code, NSString * msg))failed;
  18 +
  19 +
  20 +- (void)loginTIM:(NSString *)uid success:(void (^)(void))success failed:(void (^)(int code, NSString * msg))failed;
  21 +
  22 +- (void)resumeLogin;
  23 +
  24 +@end
  25 +
  26 +NS_ASSUME_NONNULL_END
CNLiveBLoginModule/Classes/Model/CNLiveLoginRequest.m 0 → 100644
  1 +//
  2 +// CNLiveLoginRequest.m
  3 +// CNLiveLoginModule
  4 +//
  5 +// Created by 153993236@qq.com on 11/12/2019.
  6 +// Copyright (c) 2019 153993236@qq.com. All rights reserved.
  7 +//
  8 +
  9 +#import "CNLiveLoginRequest.h"
  10 +#import <UIKit/UIKit.h>
  11 +#import "QMUIKit.h"
  12 +
  13 +#import "CNLiveEnvironment.h"
  14 +#import <CNLiveRequestBastKit/CNLiveNetworking.h>
  15 +#import "TIMAdapter.h"
  16 +#import "CommonLibrary.h"
  17 +
  18 +#import "NBSAppAgent.h"
  19 +#import "CNLiveBusinessTools.h"
  20 +
  21 +@interface CNLiveLoginRequest()
  22 +@property (nonatomic, strong) IMALoginParam *loginParam;
  23 +
  24 +@end
  25 +
  26 +@implementation CNLiveLoginRequest
  27 +static const NSInteger timeValue = 1.5;
  28 +#define XWKeyWindow [UIApplication sharedApplication].keyWindow
  29 +#pragma mark - 单例
  30 ++ (instancetype)manager {
  31 + static CNLiveLoginRequest *_singleton = nil;
  32 + static dispatch_once_t onceToken;
  33 + dispatch_once(&onceToken, ^{
  34 + _singleton = [[super allocWithZone:NULL] init];
  35 + BOOL isAutoLogin = [IMAPlatform isAutoLogin];
  36 +
  37 + if (isAutoLogin) {
  38 + _singleton.loginParam = [IMALoginParam loadFromLocal];
  39 +
  40 + } else {
  41 + _singleton.loginParam = [[IMALoginParam alloc] init];
  42 +
  43 + }
  44 + [IMAPlatform configWith:_singleton.loginParam.config];
  45 +
  46 + });
  47 + return _singleton;
  48 +
  49 +}
  50 +
  51 +// 防止外部调用alloc 或者 new
  52 ++ (instancetype)allocWithZone:(struct _NSZone *)zone {
  53 + return [CNLiveLoginRequest manager];
  54 +}
  55 +
  56 +// 防止外部调用copy
  57 +- (id)copyWithZone:(nullable NSZone *)zone {
  58 + return [CNLiveLoginRequest manager];
  59 +}
  60 +
  61 +// 防止外部调用mutableCopy
  62 +- (id)mutableCopyWithZone:(nullable NSZone *)zone {
  63 + return [CNLiveLoginRequest manager];
  64 +}
  65 +
  66 +// 获取token
  67 +- (void)getTIMLoginToken:(NSString *)identifier success:(void (^)(NSString * token))success failed:(void (^)(int code, NSString * msg))failed{
  68 + NSDictionary *params = @{@"appId":AppId,
  69 + @"plat":@"i",
  70 + @"sdkAppId":SdkAppId,
  71 + @"identifier":identifier};
  72 + [CNLiveNetworking setupShowDataResult:NO];
  73 + [CNLiveNetworking setAllowRequestDefaultArgument:YES];
  74 + [CNLiveNetworking requestNetworkWithMethod:CNLiveRequestMethodPOST URLString:TIM_GetTokenUrl Param:params CacheType:CNLiveNetworkCacheTypeNetworkOnly CompletionBlock:^(NSURLSessionTask *requestTask, id responseObject, NSError *error) {
  75 + if (!error) {
  76 + if (responseObject && [responseObject isKindOfClass:[NSDictionary class]] && [[responseObject allKeys] containsObject:@"data"] && [[responseObject objectForKey:@"data"] isKindOfClass:[NSDictionary class]]) {
  77 + NSNumber *code = responseObject[@"errorCode"];
  78 + if (code && code.intValue == 0) {
  79 + if (success) {
  80 + success(responseObject[@"data"][@"token"]);
  81 + }
  82 + } else {
  83 + if (failed) {
  84 + failed(31012, @"获取token失败");
  85 + }
  86 + }
  87 + }
  88 + }else{
  89 + if (failed) failed(31012, @"获取token失败");
  90 + }
  91 + }];
  92 +
  93 +}
  94 +
  95 +// 登录IM
  96 +- (void)loginTIM:(NSString *)uid success:(void (^)(void))success failed:(void (^)(int code, NSString * msg))failed{
  97 + [QMUITips showLoading:@"正在连接服务器..." inView:XWKeyWindow];
  98 + // 1.获取token
  99 + [self getTIMLoginToken:uid success:^(NSString * _Nonnull token) {
  100 +
  101 + self.loginParam.identifier = uid;
  102 + self.loginParam.userSig = token;
  103 + self.loginParam.tokenTime = [[NSDate date] timeIntervalSince1970];
  104 +
  105 + // 2.登录im
  106 + [[IMAPlatform sharedInstance] login:self.loginParam succ:^{
  107 + [QMUITips hideAllToastInView:XWKeyWindow animated:YES];
  108 +
  109 + [self.loginParam saveToLocal];
  110 +
  111 + [[IMAPlatform sharedInstance].contactMgr asyncUpdateContact];
  112 + [[IMAPlatform sharedInstance].contactMgr saveGroupIdList:YES];
  113 + [[IMAPlatform sharedInstance] configHost:self.loginParam];
  114 + [IMAPlatform sharedInstance].didConnectSuccess = YES;
  115 +
  116 + // 听云
  117 + [NBSAppAgent setUserIdentifier:[CNLiveBusinessTools getSidIdfv]];
  118 +
  119 + // 设置电商sdk
  120 +// [[DSCnliveShopSDKManager sharedManager] loginUser:uid];
  121 +
  122 + //设置APP已活跃
  123 + [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"is_Active_Application"];
  124 + [[NSUserDefaults standardUserDefaults] synchronize];
  125 +
  126 + [QMUITips showSucceed:@"登录成功" inView:XWKeyWindow hideAfterDelay:timeValue];
  127 + success?success():@"";
  128 +
  129 + // 3.im配置信息
  130 + [[IMAPlatform sharedInstance].host asyncSetAllowType:TIM_FRIEND_NEED_CONFIRM succ:^{
  131 + NSLog(@"asyncSetAllowType Suc");
  132 + [self.loginParam saveToLocal];
  133 +
  134 + } fail:^(int code, NSString *msg) {
  135 + NSLog(@"asyncSetAllowType failed : %@", msg);
  136 +
  137 + }];
  138 +
  139 + } fail:^(int code, NSString *msg) {
  140 + NSLog(@"login failed : %@", msg);
  141 + [QMUITips hideAllToastInView:XWKeyWindow animated:YES];
  142 + if (code == 6208) {
  143 + // 离线被踢下线重新登录
  144 + [self resumeLogin];
  145 + }
  146 + else{
  147 + [QMUITips showError:msg inView:XWKeyWindow hideAfterDelay:timeValue];
  148 + failed?failed(code, msg):@"";
  149 + }
  150 + }];
  151 +
  152 + } failed:^(int code, NSString * _Nonnull msg) {
  153 + NSLog(@"token code:%d msg:%@", code, msg);
  154 + [QMUITips hideAllToastInView:XWKeyWindow animated:YES];
  155 + [QMUITips showError:msg inView:XWKeyWindow hideAfterDelay:timeValue];
  156 + failed?failed(code, msg):@"";
  157 +
  158 + }];
  159 +
  160 +}
  161 +
  162 +// 如果遇到离线被踢下线重新登录
  163 +- (void)resumeLogin {
  164 + __weak typeof(self)weakSelf = self;
  165 + [[IMAPlatform sharedInstance] login:self.loginParam succ:^{
  166 + [QMUITips hideAllToastInView:XWKeyWindow animated:YES];
  167 + [QMUITips showSucceed:@"登录成功" inView:XWKeyWindow hideAfterDelay:timeValue];
  168 + [self.loginParam saveToLocal];
  169 +
  170 + [[IMAPlatform sharedInstance] configHost:self.loginParam];
  171 + [IMAPlatform sharedInstance].didConnectSuccess = YES;
  172 +
  173 + [[IMAPlatform sharedInstance].host asyncSetAllowType:TIM_FRIEND_NEED_CONFIRM succ:^{
  174 + NSLog(@"asyncSetAllowType Suc");
  175 + [self.loginParam saveToLocal];
  176 +
  177 + } fail:^(int code, NSString *msg) {
  178 + NSLog(@"asyncSetAllowType failed : %@", msg);
  179 + }];
  180 +
  181 + } fail:^(int code, NSString *msg) {
  182 + NSLog(@"tokenCode login failed : %@", msg);
  183 + if (code == 6028) {
  184 + dispatch_async(dispatch_get_main_queue(), ^{
  185 + QMUIAlertAction *action = [QMUIAlertAction actionWithTitle:@"重试" style:QMUIAlertActionStyleDefault handler:^(__kindof QMUIAlertController *aAlertController, QMUIAlertAction *action) {
  186 + [weakSelf resumeLogin];
  187 + }];
  188 + QMUIAlertController *alertController = [QMUIAlertController alertControllerWithTitle:@"连接服务器失败,请点击重试" message:@"" preferredStyle:QMUIAlertControllerStyleActionSheet];
  189 + [alertController addAction:action];
  190 +
  191 + NSMutableDictionary *titleAttributs = [[NSMutableDictionary alloc] initWithDictionary:alertController.alertTitleAttributes];
  192 +
  193 + titleAttributs[NSForegroundColorAttributeName] = [UIColor colorWithRed:35/255.0 green:212/255.0 blue:30/255.0 alpha:1.0];
  194 +
  195 + action.buttonAttributes = titleAttributs;
  196 + [alertController showWithAnimated:YES];
  197 +
  198 + });
  199 + }
  200 + }];
  201 +}
  202 +
  203 +@end
CNLiveBLoginModule/Classes/Module/CNLiveLoginModule.h 0 → 100644
  1 +//
  2 +// CNLiveLoginModule.h
  3 +// CNLiveLoginModule
  4 +//
  5 +// Created by 153993236@qq.com on 11/12/2019.
  6 +// Copyright (c) 2019 153993236@qq.com. All rights reserved.
  7 +//
  8 +
  9 +#import <Foundation/Foundation.h>
  10 +
  11 +NS_ASSUME_NONNULL_BEGIN
  12 +
  13 +@interface CNLiveLoginModule : NSObject
  14 +
  15 +@end
  16 +
  17 +NS_ASSUME_NONNULL_END
CNLiveBLoginModule/Classes/Module/CNLiveLoginModule.m 0 → 100644
  1 +//
  2 +// CNLiveLoginModule.m
  3 +// CNLiveLoginModule
  4 +//
  5 +// Created by 153993236@qq.com on 11/12/2019.
  6 +// Copyright (c) 2019 153993236@qq.com. All rights reserved.
  7 +//
  8 +
  9 +#import "CNLiveLoginModule.h"
  10 +#import "CNLiveServices.h"
  11 +
  12 +@BeeHiveMod(CNLiveLoginModule)
  13 +@interface CNLiveLoginModule()<BHModuleProtocol>
  14 +
  15 +@end
  16 +
  17 +@implementation CNLiveLoginModule
  18 +- (id)init {
  19 + if (self = [super init]) {
  20 +
  21 + }
  22 + return self;
  23 +
  24 +}
  25 +
  26 +- (NSUInteger)moduleLevel {
  27 + return 0;
  28 +
  29 +}
  30 +
  31 +- (void)modSetUp:(BHContext *)context {
  32 + switch (context.env) {
  33 + case BHEnvironmentDev:
  34 + //....初始化开发环境
  35 + break;
  36 + case BHEnvironmentProd:
  37 + //....初始化生产环境
  38 + default:
  39 + break;
  40 + }
  41 +
  42 +}
  43 +
  44 +- (void)modInit:(BHContext *)context {
  45 +
  46 +}
  47 +
  48 +@end
CNLiveBLoginModule/Classes/Module/CNLiveLoginService.h 0 → 100644
  1 +//
  2 +// CNLiveLoginService.h
  3 +// CNLiveLoginModule
  4 +//
  5 +// Created by 153993236@qq.com on 11/12/2019.
  6 +// Copyright (c) 2019 153993236@qq.com. All rights reserved.
  7 +//
  8 +
  9 +#import <Foundation/Foundation.h>
  10 +
  11 +NS_ASSUME_NONNULL_BEGIN
  12 +
  13 +@interface CNLiveLoginService : NSObject
  14 +
  15 +@end
  16 +
  17 +NS_ASSUME_NONNULL_END
CNLiveBLoginModule/Classes/Module/CNLiveLoginService.m 0 → 100644
  1 +//
  2 +// CNLiveLoginService.m
  3 +// CNLiveLoginModule
  4 +//
  5 +// Created by 153993236@qq.com on 11/12/2019.
  6 +// Copyright (c) 2019 153993236@qq.com. All rights reserved.
  7 +//
  8 +
  9 +#import "CNLiveLoginService.h"
  10 +#import "CNLiveServices.h"
  11 +#import "CNLiveManager.h"
  12 +#import "CNUserInfoManager.h"
  13 +
  14 +#import "CNLiveLoginController.h"
  15 +
  16 +@BeeHiveService(CNLiveLoginServiceProtocol,CNLiveLoginService)
  17 +@interface CNLiveLoginService ()<CNLiveLoginServiceProtocol>
  18 +
  19 +@end
  20 +
  21 +@implementation CNLiveLoginService
  22 +
  23 +- (UIViewController *)getLoginViewController{
  24 + return [CNLiveLoginController new];
  25 +}
  26 +
  27 +- (void)pushToLoginViewController{
  28 + [self pushToLoginViewController:NO];
  29 +}
  30 +
  31 +- (void)pushToLoginViewController:(BOOL)isShowClose{
  32 + CNLiveLoginController *vc = [[CNLiveLoginController alloc]init];
  33 + vc.isShowClose = isShowClose;
  34 + vc.modalPresentationStyle = UIModalPresentationOverFullScreen;
  35 + vc.hidesBottomBarWhenPushed = YES;
  36 + [CNLivePageJumpManager pushViewController:vc];
  37 +}
  38 +
  39 +- (void)presentToLoginViewController{
  40 + [self presentToLoginViewController:NO];
  41 +}
  42 +
  43 +- (void)presentToLoginViewController:(BOOL)isShowClose{
  44 + CNLiveLoginController *vc = [[CNLiveLoginController alloc]init];
  45 + vc.isShowClose = isShowClose;
  46 + vc.modalPresentationStyle = UIModalPresentationOverFullScreen;
  47 + vc.hidesBottomBarWhenPushed = YES;
  48 + [CNLivePageJumpManager presentViewController:vc];
  49 +}
  50 +
  51 +- (void)loginIfNeedWithCompleteBlock:(void (^)(BOOL))completeBlock{
  52 + if(CNUserShareManager.isLogin){
  53 + completeBlock(YES);
  54 + }else{
  55 + [self presentToLoginViewController:YES];
  56 + }
  57 +}
  58 +
  59 +@end
CNLiveBLoginModule/Classes/ThreeLogin/CNLiveBindingTelController.h 0 → 100644
  1 +//
  2 +// CNLiveBindingTelController.h
  3 +// CNLiveLoginModule
  4 +//
  5 +// Created by CNLive-zxw on 2019/9/9.
  6 +// Copyright © 2019 153993236@qq.com. All rights reserved.
  7 +//
  8 +
  9 +#import <UIKit/UIKit.h>
  10 +#import "CNLiveThreeLoginType.h"
  11 +
  12 +NS_ASSUME_NONNULL_BEGIN
  13 +
  14 +@interface CNLiveBindingTelController : UIViewController
  15 +- (instancetype)initWithType:(CNLiveThreeLoginType)type;
  16 +
  17 +
  18 +@end
  19 +
  20 +NS_ASSUME_NONNULL_END
CNLiveBLoginModule/Classes/ThreeLogin/CNLiveBindingTelController.m 0 → 100644
  1 +//
  2 +// CNLiveBindingTelController.m
  3 +// CNLiveLoginModule
  4 +//
  5 +// Created by CNLive-zxw on 2019/9/9.
  6 +// Copyright © 2019 153993236@qq.com. All rights reserved.
  7 +//
  8 +
  9 +#import "CNLiveBindingTelController.h"
  10 +
  11 +#import "YYKit.h"
  12 +#import "NSAttributedString+YYText.h"
  13 +#import "QMUIKit.h"
  14 +#import "CNLiveEnvironment.h"
  15 +#import "CNLiveUserAgreementManager.h"
  16 +
  17 +#import "CNLiveNavigationBar.h"
  18 +#import "CNLiveBindingTelView.h"
  19 +
  20 +@interface CNLiveBindingTelController()<CNLiveBindingTelViewDelegate>
  21 +@property (nonatomic, assign) CNLiveThreeLoginType type;
  22 +@property (nonatomic, strong) CNLiveNavigationBar *navigationBar;
  23 +
  24 +@property (nonatomic, strong) CNLiveBindingTelView *bindingTelView;
  25 +@property (nonatomic, strong) YYLabel *protocol;
  26 +
  27 +@end
  28 +
  29 +@implementation CNLiveBindingTelController
  30 +- (instancetype)initWithType:(CNLiveThreeLoginType)type{
  31 + self = [super init];
  32 + if (self) {
  33 + self.type = type;
  34 + }
  35 + return self;
  36 +
  37 +}
  38 +#pragma mark - 生命周期
  39 +- (void)viewWillAppear:(BOOL)animated{
  40 + [super viewWillAppear:animated];
  41 + self.navigationController.navigationBarHidden = YES;
  42 +}
  43 +
  44 +- (void)viewDidLoad {
  45 + [super viewDidLoad];
  46 + // Do any additional setup after loading the view.
  47 + self.automaticallyAdjustsScrollViewInsets = NO;
  48 + self.navigationController.navigationBar.translucent = NO;
  49 + self.extendedLayoutIncludesOpaqueBars = YES;
  50 + self.edgesForExtendedLayout = UIRectEdgeBottom;
  51 + self.view.backgroundColor = [UIColor whiteColor];
  52 +
  53 + [self.view addSubview:self.navigationBar];
  54 + [self.view addSubview:self.bindingTelView];
  55 + [self.view addSubview:self.protocol];
  56 +
  57 +}
  58 +
  59 +- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
  60 + [self.view endEditing:YES];
  61 +
  62 +}
  63 +
  64 +#pragma mark - CNLiveBindingTelViewDelegate
  65 +- (void)bindingSuccess:(CNLiveBindingTelView *)view type:(CNLiveThreeLoginType)type{
  66 +
  67 +}
  68 +
  69 +/*
  70 +#pragma mark - Navigation
  71 +
  72 +// In a storyboard-based application, you will often want to do a little preparation before navigation
  73 +- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  74 + // Get the new view controller using [segue destinationViewController].
  75 + // Pass the selected object to the new view controller.
  76 +}
  77 +*/
  78 +#pragma mark - 懒加载
  79 +- (CNLiveNavigationBar *)navigationBar {
  80 + if (!_navigationBar) {
  81 + _navigationBar = [CNLiveNavigationBar navigationBar];
  82 + _navigationBar.backgroundColor = [UIColor whiteColor];
  83 + _navigationBar.title.text = @"绑定手机号";
  84 + __weak typeof(self) weakSelf = self;
  85 + _navigationBar.onClickLeftButton = ^{
  86 + [weakSelf.navigationController popViewControllerAnimated:YES];
  87 + };
  88 + _navigationBar.right = nil;
  89 + }
  90 + return _navigationBar;
  91 +}
  92 +
  93 +- (CNLiveBindingTelView *)bindingTelView {
  94 + if (!_bindingTelView) {
  95 + _bindingTelView = [[CNLiveBindingTelView alloc] initWithFrame:CGRectMake(self.view.frame.size.width/8.0, NavigationContentTop, self.view.frame.size.width*3/4.0, 400) type:self.type];
  96 + _bindingTelView.delegate = self;
  97 + }
  98 + return _bindingTelView;
  99 +}
  100 +
  101 +- (YYLabel *)protocol {
  102 + if (!_protocol) {
  103 + _protocol = [[YYLabel alloc] initWithFrame:CGRectMake(0, self.view.frame.size.height-30-NavigationContentTop-SafeAreaInsetsConstantForDeviceWithNotch.bottom, self.view.frame.size.width, 30)];
  104 + _protocol.textAlignment = NSTextAlignmentCenter;
  105 + _protocol.textColor = [UIColor colorWithRed:173/255.0 green:173/255.0 blue:173/255.0 alpha:1.0];
  106 + _protocol.font = [UIFont systemFontOfSize:14.0];
  107 + NSMutableAttributedString *text = [[NSMutableAttributedString alloc] initWithString:@"已阅读并同意《账户绑定确认书(网家家)》"];
  108 + NSMutableParagraphStyle *style = [[NSParagraphStyle defaultParagraphStyle] mutableCopy];
  109 + style.alignment = NSTextAlignmentCenter;//对齐方式
  110 + [text addAttribute:NSParagraphStyleAttributeName value:style range:NSMakeRange(0, text.length)];
  111 + text.color = [UIColor colorWithRed:173/255.0 green:173/255.0 blue:173/255.0 alpha:1.0];
  112 + text.font = [UIFont systemFontOfSize:14.0];
  113 + __weak typeof(self) weakSelf = self;
  114 + UIColor *color = Business?[UIColor colorWithRed:72/255.0 green:168/255.0 blue:249/255.0 alpha:1.0]:[UIColor colorWithRed:35/255.0 green:212/255.0 blue:30/255.0 alpha:1.0];
  115 + [text setTextHighlightRange:NSMakeRange(7, 12) color:color backgroundColor:[UIColor clearColor] tapAction:^(UIView * _Nonnull containerView, NSAttributedString * _Nonnull text, NSRange range, CGRect rect) {
  116 + __strong typeof(weakSelf) strongSelf = weakSelf;
  117 + if(!strongSelf) return;
  118 + [strongSelf.view endEditing:YES];
  119 + [CNLiveUserAgreementManager jumpToAgreementH5WithType:CNLiveUserAgreementUser];
  120 +
  121 + }];
  122 + _protocol.attributedText = text;
  123 +
  124 + }
  125 + return _protocol;
  126 +}
  127 +
  128 +@end
CNLiveBLoginModule/Classes/ThreeLogin/CNLiveBindingTelView.h 0 → 100644
  1 +//
  2 +// CNLiveBindingTelView.h
  3 +// CNLiveLoginModule
  4 +//
  5 +// Created by CNLive-zxw on 2019/9/6.
  6 +// Copyright © 2019 153993236@qq.com. All rights reserved.
  7 +//
  8 +
  9 +#import <UIKit/UIKit.h>
  10 +#import "CNLiveThreeLoginType.h"
  11 +
  12 +NS_ASSUME_NONNULL_BEGIN
  13 +
  14 +@class CNLiveBindingTelView;
  15 +@protocol CNLiveBindingTelViewDelegate <NSObject>
  16 +- (void)bindingSuccess:(CNLiveBindingTelView *)view type:(CNLiveThreeLoginType)type;
  17 +
  18 +@end
  19 +
  20 +@interface CNLiveBindingTelView : UIView
  21 +@property (nonatomic, weak) id<CNLiveBindingTelViewDelegate> delegate;
  22 +- (instancetype)initWithFrame:(CGRect)frame type:(CNLiveThreeLoginType)type;
  23 +
  24 +@end
  25 +
  26 +NS_ASSUME_NONNULL_END
CNLiveBLoginModule/Classes/ThreeLogin/CNLiveBindingTelView.m 0 → 100644
  1 +//
  2 +// CNLiveBindingTelView.m
  3 +// CNLiveLoginModule
  4 +//
  5 +// Created by CNLive-zxw on 2019/9/6.
  6 +// Copyright © 2019 153993236@qq.com. All rights reserved.
  7 +//
  8 +
  9 +#import "CNLiveBindingTelView.h"
  10 +#import "YYKit.h"
  11 +#import "QMUIKit.h"
  12 +#import <CNLiveRequestBastKit/CNLiveNetworking.h>
  13 +
  14 +#import "CNLiveCategory.h"
  15 +#import "CNLiveEnvironment.h"
  16 +#import <CNLiveUserSystemSDK/CNLiveUserSystemCenter.h>
  17 +#import <CNLiveUserSystemSDK/CNLiveUserSystemTypeDef.h>
  18 +#import "CNUserInfoManager.h"
  19 +
  20 +#import "CNLiveLoginCountryView.h"
  21 +#import "CNLiveLoginTextField.h"
  22 +#import "CNLiveCountDownButton.h"
  23 +
  24 +@interface CNLiveBindingTelView()<UITextFieldDelegate,CNLiveCountDownButtonDataSource, CNLiveCountDownButtonDelegate>
  25 +{
  26 + NSString *_countryCode; // 国家Code
  27 + NSString *_verificationCode; // 验证码
  28 +}
  29 +
  30 +@property (nonatomic, weak) CNLiveLoginTextField *account;
  31 +@property (nonatomic, weak) CNLiveLoginTextField *code;
  32 +@property (nonatomic, strong) CNLiveCountDownButton *countDown;
  33 +@property (nonatomic, weak) UIButton *binding;
  34 +@property (nonatomic, assign) CNLiveThreeLoginType type;
  35 +
  36 +@end
  37 +
  38 +@implementation CNLiveBindingTelView
  39 +#define XWKeyWindow [UIApplication sharedApplication].keyWindow
  40 +static NSInteger const rowHeight = 40;
  41 +static NSInteger const space = 40;
  42 +static const NSInteger timeValue = 1.5;
  43 +
  44 +- (instancetype)initWithFrame:(CGRect)frame type:(CNLiveThreeLoginType)type{
  45 +
  46 + self = [super initWithFrame:frame];
  47 + if (self) {
  48 + self.userInteractionEnabled = YES;
  49 + _countryCode = @"86";
  50 + self.type = type;
  51 + [self createSubviews:frame];
  52 +
  53 + }
  54 + return self;
  55 +
  56 +}
  57 +- (void)createSubviews:(CGRect)frame{
  58 +
  59 + CNLiveLoginTextField *account = [[CNLiveLoginTextField alloc] initWithFrame:CGRectMake(0, 0, frame.size.width, rowHeight)];
  60 + account.keyboardType = UIKeyboardTypeNumberPad;
  61 + account.placeholder = @"请输入手机号";
  62 + account.textColor = [UIColor colorWithRed:51/255.0 green:51/255.0 blue:51/255.0 alpha:1.0];
  63 + account.placeholderColor = [UIColor colorWithRed:173/255.0 green:173/255.0 blue:173/255.0 alpha:1.0];
  64 + account.font = [UIFont systemFontOfSize:16];
  65 + account.textAlignment = NSTextAlignmentLeft;
  66 + [account addTarget:self action:@selector(textFieldDidChange:) forControlEvents:UIControlEventEditingChanged];
  67 + account.clearButtonMode = UITextFieldViewModeWhileEditing;
  68 + account.delegate = self;
  69 + [self addSubview:account];
  70 + self.account = account;
  71 +
  72 + CNLiveLoginTextField *code = [[CNLiveLoginTextField alloc] initWithFrame:CGRectMake(account.left, account.bottom+space, frame.size.width/2.0, rowHeight)];
  73 + code.keyboardType = UIKeyboardTypeNumberPad;
  74 + code.placeholder = @"请输入验证码";
  75 + code.textColor = [UIColor colorWithRed:51/255.0 green:51/255.0 blue:51/255.0 alpha:1.0];
  76 + code.placeholderColor = [UIColor colorWithRed:173/255.0 green:173/255.0 blue:173/255.0 alpha:1.0];
  77 + code.font = [UIFont systemFontOfSize:16];
  78 + code.textAlignment = NSTextAlignmentLeft;
  79 + [code addTarget:self action:@selector(textFieldDidChange:) forControlEvents:UIControlEventEditingChanged];
  80 + code.clearButtonMode = UITextFieldViewModeWhileEditing;
  81 + code.delegate = self;
  82 + [self addSubview:code];
  83 + self.code = code;
  84 +
  85 + CNLiveCountDownButton *countDown = [CNLiveCountDownButton buttonWithType:UIButtonTypeCustom];
  86 + countDown.dataSource = self;
  87 + countDown.delegate = self;
  88 + countDown.frame = CGRectMake(frame.size.width-80, account.bottom+space+10, 80, rowHeight-10);
  89 + UIImage *image2 = [self getImageWithImageName:Business?@"login_get_code_b":@"login_get_code" bundleName:@"CNLiveBLoginModule" targetClass:[self class]];
  90 + [countDown setImage:image2 forState:UIControlStateNormal];
  91 + countDown.adjustsImageWhenHighlighted = NO;
  92 + [countDown setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
  93 + countDown.titleLabel.font = [UIFont systemFontOfSize:12.0];
  94 + countDown.layer.cornerRadius = 15;
  95 + countDown.layer.masksToBounds = YES;
  96 + [self addSubview:countDown];
  97 + self.countDown = countDown;
  98 +
  99 + UIButton *binding = [UIButton buttonWithType:UIButtonTypeCustom];
  100 + binding.frame = CGRectMake(5, code.bottom+space, frame.size.width-10, rowHeight);
  101 + [binding setTitle:@"确认手机绑定并同意协议" forState:UIControlStateNormal];
  102 + [binding setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
  103 + binding.titleLabel.font = [UIFont systemFontOfSize:15.0];
  104 + UIColor *color = Business?[UIColor colorWithRed:72/255.0 green:168/255.0 blue:249/255.0 alpha:1.0]:[UIColor colorWithRed:35/255.0 green:212/255.0 blue:30/255.0 alpha:1.0];
  105 + binding.backgroundColor = color;
  106 + binding.layer.cornerRadius = 20;
  107 + binding.layer.masksToBounds = YES;
  108 + binding.adjustsImageWhenHighlighted = NO;
  109 + [binding addTarget:self action:@selector(bindingDidClicked:) forControlEvents:UIControlEventTouchUpInside];
  110 + [self addSubview:binding];
  111 + self.binding = binding;
  112 +
  113 +}
  114 +
  115 +#pragma mark - UITextFieldDelegate
  116 +- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField{
  117 + if ([textField isEqual:_account] || [textField isEqual:_code]) {
  118 + return YES;
  119 + }
  120 + else {
  121 + return YES;
  122 +
  123 + }
  124 +}
  125 +
  126 +- (void)textFieldDidChange:(UITextField *)textField {
  127 + if (![_account.text isEqualToString:@""] && ![_code.text isEqualToString:@""]) {
  128 + _binding.enabled = YES;
  129 +
  130 + }
  131 + else {
  132 + _binding.enabled = NO;
  133 +
  134 + }
  135 +
  136 +}
  137 +
  138 +- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {
  139 + if ([textField isEqual:_account]) {
  140 + NSInteger maxTextLength = 20;
  141 + if(string.length == 0) {
  142 + //判断是不是删除键
  143 + return YES;
  144 + }
  145 + else if(textField.text.length >= maxTextLength) {
  146 + NSLog(@"输入的字符个数大于20,忽略输入");
  147 + return NO;
  148 + }
  149 + else if (![self isNum:string]) {
  150 + return NO;
  151 + }
  152 + else if (textField.text.length + string.length > maxTextLength){
  153 + NSInteger length = textField.text.length;
  154 + NSInteger needLen = maxTextLength - length;
  155 + textField.text = [textField.text stringByAppendingString:[string substringToIndex:needLen]];
  156 + return NO;
  157 + }
  158 + else{
  159 + return YES;
  160 + }
  161 + }
  162 + else if ([textField isEqual:self.code]){
  163 + NSInteger maxTextLength = 6;
  164 + if(string.length == 0) {
  165 + //判断是不是删除键
  166 + return YES;
  167 + }
  168 + else if(textField.text.length >= maxTextLength) {
  169 + NSLog(@"输入的字符个数大于6,忽略输入");
  170 + return NO;
  171 + }
  172 + else if (![self isNum:string]) {
  173 + return NO;
  174 + }
  175 + else if (textField.text.length + string.length > maxTextLength){
  176 + NSInteger length = textField.text.length;
  177 + NSInteger needLen = maxTextLength - length;
  178 + textField.text = [textField.text stringByAppendingString:[string substringToIndex:needLen]];
  179 + return NO;
  180 + }
  181 + else{
  182 + return YES;
  183 + }
  184 + }
  185 + else{
  186 + return YES;
  187 + }
  188 +}
  189 +
  190 +/** 判断是否为纯数字 */
  191 +- (BOOL)isNum:(NSString *)checkedNumString {
  192 + checkedNumString = [checkedNumString stringByTrimmingCharactersInSet:[NSCharacterSet decimalDigitCharacterSet]];
  193 + if(checkedNumString.length > 0) {
  194 + return NO;
  195 + }
  196 + return YES;
  197 +}
  198 +
  199 +/*
  200 + // Only override drawRect: if you perform custom drawing.
  201 + // An empty implementation adversely affects performance during animation.
  202 + - (void)drawRect:(CGRect)rect {
  203 + // Drawing code
  204 + }
  205 + */
  206 +
  207 +#pragma mark - CNLiveCountdownButton DataSource
  208 +// 设置倒计时总秒数
  209 +- (NSInteger)startCountDownNumOfCountDownButton:(CNLiveCountDownButton *)countdownButton {
  210 + return 60;
  211 +}
  212 +
  213 +#pragma mark - CNLiveCountdownButton Delegate
  214 +// 倒计时按钮点击
  215 +- (void)countDownButtonDidClick:(CNLiveCountDownButton *)button {
  216 + //获取验证码
  217 + if ([_account.text isEqualToString:@""]) {
  218 + [QMUITips showWithText:@"请输入手机号"];
  219 + return;
  220 + }
  221 + if(![CNLiveNetworking isNetworking]){
  222 + [QMUITips showError:@"无法连接网络" inView:XWKeyWindow hideAfterDelay:timeValue];
  223 + return ;
  224 + }
  225 + _code.text = @"";
  226 + [_code becomeFirstResponder];
  227 +
  228 + button.userInteractionEnabled = NO;
  229 + [QMUITips showLoadingInView:XWKeyWindow];
  230 +
  231 + [CNLiveUserSystemCenter verificationCodeType:VerificationCodeTypeShortcutLogin mobile:_account.text countryCode:@"86" success:^(id result) {
  232 + [QMUITips hideAllToastInView:XWKeyWindow animated:YES];
  233 + [QMUITips showWithText:@"验证码已发送"];
  234 +
  235 +// button.backgroundColor = HexColor(0xdedede);
  236 + button.frame = CGRectMake(self.frame.size.width-110, self.account.bottom+space+10, 110, rowHeight-10);
  237 + [button setImage:nil forState:UIControlStateNormal];
  238 + NSString *title = [NSString stringWithFormat:@"%d秒后重新发送", 60];
  239 + [button setTitle:title forState:UIControlStateNormal];
  240 + [button startCountDown];
  241 +
  242 +
  243 + } failure:^(NSDictionary *errorDic) {
  244 + [QMUITips hideAllToastInView:XWKeyWindow animated:YES];
  245 + if ([errorDic[@"errorCode"] integerValue] == 408) {
  246 + [QMUITips showWithText:@"请输入正确的手机号"];
  247 + }
  248 + else{
  249 + [QMUITips showWithText:errorDic[@"errorMessage"]];
  250 + }
  251 + button.userInteractionEnabled = YES;
  252 +
  253 + }];
  254 +
  255 +}
  256 +
  257 +// 倒计时进行中
  258 +- (void)countDownButtonDidCountDown:(CNLiveCountDownButton *)button countDownNum:(NSInteger)countDownNum {
  259 + if(button.frame.size.width != 110){
  260 + button.frame = CGRectMake(self.frame.size.width-110, self.account.bottom+space+10, 110, rowHeight-10);
  261 + }
  262 + NSString *title = [NSString stringWithFormat:@"%ld秒后重新发送", countDownNum];
  263 + [button setTitle:title forState:UIControlStateNormal];
  264 +
  265 +}
  266 +
  267 +// 倒计时结束
  268 +- (void)countDownButtonDidEndCountDown:(CNLiveCountDownButton *)button {
  269 + button.frame = CGRectMake(self.frame.size.width-80, self.account.bottom+space+10, 80, rowHeight-10);
  270 + button.backgroundColor = [UIColor whiteColor];
  271 + button.userInteractionEnabled = YES;
  272 + [button setTitle:@"" forState:UIControlStateNormal];
  273 + UIImage *image2 = [self getImageWithImageName:Business?@"login_get_code_b":@"login_get_code" bundleName:@"CNLiveBLoginModule" targetClass:[self class]];
  274 + [button setImage:image2 forState:UIControlStateNormal];
  275 +}
  276 +
  277 +#pragma mark - Action
  278 +- (void)bindingDidClicked:(UIButton *)btn{
  279 + if ([self.account.text isEqualToString:@""]) {
  280 + [QMUITips showWithText:@"请输入手机号" inView:XWKeyWindow hideAfterDelay:1.5];
  281 + return;
  282 + }
  283 + if ([self.code.text isEqualToString:@""]) {
  284 + [QMUITips showWithText:@"请输入验证码" inView:XWKeyWindow hideAfterDelay:1.5];
  285 + return;
  286 + }
  287 + [self endEditing:YES];
  288 + if(![CNLiveNetworking isNetworking]){
  289 + [QMUITips showError:@"无法连接网络" inView:XWKeyWindow hideAfterDelay:1.5];
  290 + return ;
  291 + }
  292 + btn.userInteractionEnabled = NO;
  293 + // 绑定手机号请求登录
  294 + [self thirdPartyLoginBindingTel];
  295 +
  296 +}
  297 +
  298 +// 绑定手机号请求登录
  299 +- (void)thirdPartyLoginBindingTel{
  300 + NSDictionary *params = @{
  301 + @"mobile":self.account.text,
  302 +// @"countryCode":self.model.countryCode?self.model.countryCode:@"",
  303 +// @"verificationCode":self.code.text,
  304 +// @"thirdPartyPlat":self.model.thirdPartyPlat?self.model.thirdPartyPlat:@"",
  305 +// @"thirdPartyId":self.model.thirdPartyId?self.model.thirdPartyId:@"",
  306 +// @"frmId":self.model.frmId?self.model.frmId:@"",
  307 +// @"clientPlat":@"i",
  308 +// @"nickName":self.model.nickName?self.model.nickName:@"",
  309 +// @"gender":self.model.gender?self.model.gender:@"",
  310 +// @"location":self.model.location?self.model.location:@"",
  311 +// @"faceUrl":self.model.faceUrl?self.model.faceUrl:@""
  312 + };
  313 + [CNLiveNetworking setAllowRequestDefaultArgument:YES];
  314 + [CNLiveNetworking setupShowDataResult:NO];
  315 +
  316 + [QMUITips showLoadingInView:XWKeyWindow];
  317 + __weak typeof(self) weakSelf = self;
  318 + [CNLiveNetworking requestNetworkWithMethod:CNLiveRequestMethodPOST URLString:CNLoginIn3rdAndMobileForWJJUrl Param:params CacheType:CNLiveNetworkCacheTypeNetworkOnly CompletionBlock:^(NSURLSessionTask *requestTask, id responseObject, NSError *error) {
  319 + __strong typeof(weakSelf) strongSelf = weakSelf;
  320 + if(!strongSelf) return;
  321 + [QMUITips hideAllToastInView:XWKeyWindow animated:YES];
  322 + strongSelf.binding.userInteractionEnabled = YES;
  323 + if (error.code == -1001 || error.code == -1009) {
  324 + [QMUITips showError:@"无法连接网络" inView:XWKeyWindow hideAfterDelay:1.5];
  325 + return ;
  326 + }
  327 + if ([responseObject isKindOfClass:[NSDictionary class]] && [responseObject[@"errorCode"] isEqualToString:@"0"]) {
  328 +
  329 + // 给用户库使用
  330 + NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
  331 + [userDefaults setObject:responseObject[@"data"][@"token"] forKey:@"CNLiveAuthToken"];
  332 + [userDefaults setObject:responseObject[@"data"][@"uid"] forKey:@"CNLiveUserSid"];
  333 + [userDefaults synchronize];
  334 +
  335 + //登录成功,连接IM
  336 + [strongSelf connectionIM:responseObject[@"data"]];
  337 + }
  338 + else if ([responseObject isKindOfClass:[NSDictionary class]]) {
  339 + [QMUITips showError:responseObject[@"errorMessage"] inView:XWKeyWindow hideAfterDelay:1.5];
  340 + }
  341 + else{
  342 + [QMUITips showError:@"登录失败" inView:XWKeyWindow hideAfterDelay:1.5];
  343 + }
  344 +
  345 + }];
  346 +
  347 +}
  348 +- (void)connectionIM:(id)result{
  349 + NSMutableDictionary *dic = [NSMutableDictionary dictionaryWithDictionary:result[@"data"]];
  350 + NSString *faceUrl = [dic objectForKey:@"faceUrl"];
  351 + if ([faceUrl containsString:@"/mobile/images/mobilehead/default/"]) {
  352 + //网家家默认头像地址
  353 + [dic setValue:CNLiveNetAddDefaultHead forKey:@"faceUrl"];
  354 + }
  355 + [CNUserInfoManager saveUserinfoDic:dic];
  356 + if (self.delegate && [self.delegate respondsToSelector:@selector(bindingSuccess:type:)]) {
  357 + [self.delegate bindingSuccess:self type:self.type];
  358 + }
  359 +}
  360 +
  361 +@end
CNLiveBLoginModule/Classes/ThreeLogin/CNLiveThreeLoginType.h 0 → 100644
  1 +//
  2 +// CNLiveThreeLoginType.h
  3 +// CNLiveLoginModule
  4 +//
  5 +// Created by CNLive-zxw on 2019/9/9.
  6 +// Copyright © 2019 153993236@qq.com. All rights reserved.
  7 +//
  8 +
  9 +#ifndef CNLiveThreeLoginType_h
  10 +#define CNLiveThreeLoginType_h
  11 +
  12 +typedef NS_ENUM(NSInteger,CNLiveThreeLoginType)
  13 +{
  14 + CNLiveThreeLoginType_UnKnown = -2,
  15 + //预定义的平台
  16 + CNLiveThreeLoginType_Predefine_Begin = -1,
  17 + CNLiveThreeLoginType_Sina = 0, //新浪
  18 + CNLiveThreeLoginType_WechatSession = 1, //微信聊天
  19 + CNLiveThreeLoginType_WechatTimeLine = 2, //微信朋友圈
  20 + CNLiveThreeLoginType_WechatFavorite = 3, //微信收藏
  21 + CNLiveThreeLoginType_QQ = 4, //QQ聊天页面
  22 + CNLiveThreeLoginType_Qzone = 5, //qq空间
  23 +};
  24 +
  25 +#endif /* CNLiveThreeLoginType_h */
CNLiveBLoginModule/Classes/ThreeLogin/CNLiveThreeLoginView.h 0 → 100644
  1 +//
  2 +// CNLiveThreeLoginView.h
  3 +// CNLiveLoginModule
  4 +//
  5 +// Created by CNLive-zxw on 2019/9/6.
  6 +// Copyright © 2019 153993236@qq.com. All rights reserved.
  7 +//
  8 +
  9 +#import <UIKit/UIKit.h>
  10 +//#import "CNLiveShareImageManager.h"
  11 +
  12 +NS_ASSUME_NONNULL_BEGIN
  13 +
  14 +@class CNLiveThreeLoginView;
  15 +@protocol CNLiveThreeLoginViewDelegate <NSObject>
  16 +//- (void)clickedButton:(CNLiveThreeLoginView *)view type:(CNLiveSendAuthResp)type;
  17 +
  18 +@end
  19 +@interface CNLiveThreeLoginView : UIView
  20 +@property (nonatomic, weak) id<CNLiveThreeLoginViewDelegate> delegate;
  21 +
  22 +@end
  23 +
  24 +NS_ASSUME_NONNULL_END
CNLiveBLoginModule/Classes/ThreeLogin/CNLiveThreeLoginView.m 0 → 100644
  1 +//
  2 +// CNLiveThreeLoginView.m
  3 +// CNLiveLoginModule
  4 +//
  5 +// Created by CNLive-zxw on 2019/9/6.
  6 +// Copyright © 2019 153993236@qq.com. All rights reserved.
  7 +//
  8 +
  9 +#import "CNLiveThreeLoginView.h"
  10 +#import "YYKit.h"
  11 +#import "CNLiveCategory.h"
  12 +//#import "CNLiveShareManager.h"
  13 +//#import "WXApi.h"
  14 +
  15 +@interface CNLiveThreeLoginView()
  16 +
  17 +@end
  18 +@implementation CNLiveThreeLoginView
  19 +static NSInteger const rowHeight = 60;
  20 +//- (instancetype)initWithFrame:(CGRect)frame{
  21 +// self = [super initWithFrame:frame];
  22 +// if (self) {
  23 +// [self createSubviews:frame];
  24 +//
  25 +// }
  26 +// return self;
  27 +//
  28 +//}
  29 +//- (void)createSubviews:(CGRect)frame{
  30 +// CGFloat width = frame.size.width;
  31 +// CGFloat nameWidth = width/3.0;
  32 +// CGFloat lineLeft = 15;
  33 +// CGFloat lineWidth = nameWidth - lineLeft*2;
  34 +//
  35 +// UIView *leftLine = [[UIView alloc] initWithFrame:CGRectMake(lineLeft, (rowHeight/3.0-1)/2.0, lineWidth, 1)];
  36 +// leftLine.backgroundColor = [UIColor colorWithRed:173/255.0 green:173/255.0 blue:173/255.0 alpha:1.0];
  37 +// [self addSubview:leftLine];
  38 +//
  39 +// UILabel *name = [[UILabel alloc] initWithFrame:CGRectMake(nameWidth, 0, nameWidth, rowHeight/3.0)];
  40 +// name.textColor = [UIColor colorWithRed:173/255.0 green:173/255.0 blue:173/255.0 alpha:1.0];
  41 +// name.font = [UIFont systemFontOfSize:14];
  42 +// name.textAlignment = NSTextAlignmentCenter;
  43 +// name.text = @"第三方账号登录";
  44 +// [self addSubview:name];
  45 +//
  46 +// UILabel *rightLine = [[UILabel alloc] initWithFrame:CGRectMake(name.right+15, leftLine.top, leftLine.width, 1)];
  47 +// rightLine.backgroundColor = [UIColor colorWithRed:173/255.0 green:173/255.0 blue:173/255.0 alpha:1.0];
  48 +// [self addSubview:rightLine];
  49 +//
  50 +// NSMutableArray *pics = [NSMutableArray arrayWithArray:@[@"login_qq",@"login_weibo"]];
  51 +// if([WXApi isWXAppInstalled]||[[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"wechat://"]]){
  52 +// [pics insertObject:@"login_wechat" atIndex:0];
  53 +// }
  54 +// NSUInteger number = pics.count;
  55 +// if (@available(iOS 13, *)) {
  56 +// [pics addObject:@"login_apple"];
  57 +// number = pics.count + 1;
  58 +// }
  59 +// CGFloat btnWidth = width/number*1.0;
  60 +//
  61 +// for(int i = 0; i < pics.count; i++){
  62 +// UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
  63 +// btn.tag = 10000+i;
  64 +// btn.frame = CGRectMake(btnWidth*i, name.bottom, btnWidth, rowHeight);
  65 +// if (@available(iOS 13, *)) {
  66 +// if (i == pics.count-1) {
  67 +// btn.frame = CGRectMake(btnWidth*i, name.bottom, 2*btnWidth, rowHeight);
  68 +// }
  69 +// }
  70 +// UIImage *image = [self getImageWithImageName:pics[i] bundleName:@"CNLiveBLoginModule" targetClass:[self class]];
  71 +// [btn setImage:image forState:UIControlStateNormal];
  72 +// btn.adjustsImageWhenHighlighted = NO;
  73 +// [btn addTarget:self action:@selector(btnDidClicked:) forControlEvents:UIControlEventTouchUpInside];
  74 +// [self addSubview:btn];
  75 +//
  76 +// }
  77 +//
  78 +//}
  79 +//- (void)btnDidClicked:(UIButton *)btn{
  80 +// if([WXApi isWXAppInstalled]||[[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"wechat://"]]){
  81 +// if (self.delegate && [self.delegate respondsToSelector:@selector(clickedButton:type:)]) {
  82 +// if(btn.tag == 10000){
  83 +// [self.delegate clickedButton:self type:CNLiveSendAuthRespWX];
  84 +//
  85 +// }else if (btn.tag == 10001){
  86 +// [self.delegate clickedButton:self type:CNLiveSendAuthRespQQ];
  87 +//
  88 +// }else if(btn.tag == 10002){
  89 +// [self.delegate clickedButton:self type:CNLiveSendAuthRespWB];
  90 +//
  91 +// }else if(btn.tag == 10003){
  92 +// [self.delegate clickedButton:self type:CNLiveSendAuthRespApple];
  93 +//
  94 +// }
  95 +// }
  96 +// }else{
  97 +// if (self.delegate && [self.delegate respondsToSelector:@selector(clickedButton:type:)]) {
  98 +// if(btn.tag == 10000){
  99 +// [self.delegate clickedButton:self type:CNLiveSendAuthRespQQ];
  100 +//
  101 +// }else if(btn.tag == 10001){
  102 +// [self.delegate clickedButton:self type:CNLiveSendAuthRespWB];
  103 +//
  104 +// }else if(btn.tag == 10002){
  105 +// [self.delegate clickedButton:self type:CNLiveSendAuthRespApple];
  106 +//
  107 +// }
  108 +// }
  109 +// }
  110 +//
  111 +//}
  112 +
  113 +/*
  114 +// Only override drawRect: if you perform custom drawing.
  115 +// An empty implementation adversely affects performance during animation.
  116 +- (void)drawRect:(CGRect)rect {
  117 + // Drawing code
  118 +}
  119 +*/
  120 +
  121 +@end
CNLiveBLoginModule/Classes/View/CNLiveCompleteInfoView.h 0 → 100644
  1 +//
  2 +// CNLiveCompleteInfoView.h
  3 +// CNLiveLoginModule
  4 +//
  5 +// Created by 153993236@qq.com on 11/12/2019.
  6 +// Copyright (c) 2019 153993236@qq.com. All rights reserved.
  7 +//
  8 +
  9 +#import <UIKit/UIKit.h>
  10 +
  11 +NS_ASSUME_NONNULL_BEGIN
  12 +@class CNLiveCompleteInfoView;
  13 +@protocol CNLiveCompleteInfoViewDelegate <NSObject>
  14 +- (void)loginSuccess:(CNLiveCompleteInfoView *)view result:(id _Nonnull)result;
  15 +
  16 +@end
  17 +@interface CNLiveCompleteInfoView : UIView
  18 +@property (nonatomic, weak) id<CNLiveCompleteInfoViewDelegate> delegate;
  19 +
  20 +@end
  21 +
  22 +NS_ASSUME_NONNULL_END
CNLiveBLoginModule/Classes/View/CNLiveCompleteInfoView.m 0 → 100644
  1 +//
  2 +// CNLiveCompleteInfoView.m
  3 +// CNLiveLoginModule
  4 +//
  5 +// Created by 153993236@qq.com on 11/12/2019.
  6 +// Copyright (c) 2019 153993236@qq.com. All rights reserved.
  7 +//
  8 +
  9 +#import "CNLiveCompleteInfoView.h"
  10 +#import "CNLiveLoginTextField.h"
  11 +#import "YYKit.h"
  12 +#import "QMUIKit.h"
  13 +
  14 +#import <CNLiveUserSystemSDK/CNLiveUserSystemCenter.h>
  15 +#import <CNLiveUserSystemSDK/CNLiveUserSystemTypeDef.h>
  16 +#import "CNUserInfoManager.h"
  17 +#import "CNLiveEnvironment.h"
  18 +#import "CNLiveManager.h"
  19 +#import <AVFoundation/AVCaptureDevice.h>
  20 +#import <AVFoundation/AVMediaFormat.h>
  21 +#import "XFCameraController.h"
  22 +#import "TZImagePickerController.h"
  23 +
  24 +#import "TIMAdapter.h"
  25 +#import "CommonLibrary.h"
  26 +#import "CNLiveCategory.h"
  27 +
  28 +#import "CNLiveLoginRequest.h"
  29 +
  30 +@interface CNLiveCompleteInfoView()<UITextFieldDelegate,UIImagePickerControllerDelegate,UINavigationControllerDelegate,TZImagePickerControllerDelegate,QMUIAlertControllerDelegate>{
  31 + UIImage *_image;
  32 +}
  33 +
  34 +@property (nonatomic, weak) UIButton *head;
  35 +@property (nonatomic, weak) CNLiveLoginTextField *nickname;
  36 +@property (nonatomic, weak) UIButton *next;
  37 +@property (nonatomic, strong) IMALoginParam *loginParam;
  38 +
  39 +@end
  40 +@implementation CNLiveCompleteInfoView
  41 +
  42 +static NSInteger const rowHeight = 40;
  43 +static NSInteger const space = 40;
  44 +static const NSInteger timeValue = 1.5;
  45 +
  46 +- (instancetype)initWithFrame:(CGRect)frame{
  47 + self = [super initWithFrame:frame];
  48 + if (self) {
  49 + self.userInteractionEnabled = YES;
  50 + [self createSubviews:frame];
  51 + _loginParam = [[IMALoginParam alloc] init];
  52 + _image = nil;
  53 + }
  54 + return self;
  55 +
  56 +}
  57 +
  58 +- (void)createSubviews:(CGRect)frame{
  59 + UIButton *head = [UIButton buttonWithType:UIButtonTypeCustom];
  60 + head.frame = CGRectMake((frame.size.width-80)/2.0, 0, 80, 80);
  61 + head.layer.cornerRadius = 40;
  62 + head.layer.masksToBounds = YES;
  63 + head.adjustsImageWhenHighlighted = NO;
  64 + UIImage *image = [self getImageWithImageName:@"login_camera" bundleName:@"CNLiveBLoginModule" targetClass:[self class]];
  65 + [head setImage:image forState:UIControlStateNormal];
  66 + [head addTarget:self action:@selector(headDidClicked:) forControlEvents:UIControlEventTouchUpInside];
  67 + [self addSubview:head];
  68 + self.head = head;
  69 +
  70 + CNLiveLoginTextField *nickname = [[CNLiveLoginTextField alloc] initWithFrame:CGRectMake(0, head.bottom+space, frame.size.width, rowHeight)];
  71 + nickname.keyboardType = UIKeyboardTypeNumberPad;
  72 + if(CNUserShareManager.isLogin&&CNUserShareModel.mobile.length >= 11){
  73 + nickname.text = [CNUserShareModel.mobile stringByReplacingCharactersInRange:NSMakeRange(3, 4) withString:@"****"];
  74 + }
  75 +
  76 + nickname.placeholder = @"请输入昵称";
  77 + nickname.textColor = [UIColor colorWithRed:51/255.0 green:51/255.0 blue:51/255.0 alpha:1.0];
  78 + nickname.placeholderColor = [UIColor colorWithRed:173/255.0 green:173/255.0 blue:173/255.0 alpha:1.0];
  79 + nickname.font = [UIFont systemFontOfSize:16];
  80 + nickname.textAlignment = NSTextAlignmentLeft;
  81 + [nickname addTarget:self action:@selector(textFieldDidChange:) forControlEvents:UIControlEventEditingChanged];
  82 + nickname.clearButtonMode = UITextFieldViewModeWhileEditing;
  83 + nickname.delegate = self;
  84 + [self addSubview:nickname];
  85 + self.nickname = nickname;
  86 +
  87 + UIButton *next = [UIButton buttonWithType:UIButtonTypeCustom];
  88 + next.frame = CGRectMake(nickname.left, nickname.bottom+space, nickname.width, rowHeight);
  89 + [next setTitle:@"下一步" forState:UIControlStateNormal];
  90 + [next setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
  91 + next.titleLabel.font = [UIFont systemFontOfSize:15.0];
  92 + UIColor *color = Business?[UIColor colorWithRed:72/255.0 green:168/255.0 blue:249/255.0 alpha:1.0]:[UIColor colorWithRed:35/255.0 green:212/255.0 blue:30/255.0 alpha:1.0];
  93 + next.backgroundColor = color;
  94 + next.layer.cornerRadius = 20;
  95 + next.layer.masksToBounds = YES;
  96 + next.adjustsImageWhenHighlighted = NO;
  97 + [next addTarget:self action:@selector(nextDidClicked:) forControlEvents:UIControlEventTouchUpInside];
  98 + [self addSubview:next];
  99 + self.next = next;
  100 +
  101 +}
  102 +
  103 +- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
  104 + [self endEditing:YES];
  105 +
  106 +}
  107 +
  108 +#pragma mark - UITextFieldDelegate
  109 +- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField{
  110 + if ([textField isEqual:_nickname]) {
  111 + return YES;
  112 + }
  113 + else {
  114 + return YES;
  115 + }
  116 +}
  117 +
  118 +- (void)textFieldDidChange:(UITextField *)textField {
  119 + if (![_nickname.text isEqualToString:@""]) {
  120 + _next.enabled = YES;
  121 + }
  122 + else {
  123 + _next.enabled = NO;
  124 + }
  125 +
  126 +}
  127 +
  128 +- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {
  129 + if ([textField isEqual:_nickname]) {
  130 + NSInteger maxTextLength = 20;
  131 + if(string.length == 0) {
  132 + //判断是不是删除键
  133 + return YES;
  134 + }
  135 + else if(textField.text.length >= maxTextLength) {
  136 + NSLog(@"输入的字符个数大于20,忽略输入");
  137 + return NO;
  138 + }
  139 + else if (textField.text.length + string.length > maxTextLength){
  140 + NSInteger length = textField.text.length;
  141 + NSInteger needLen = maxTextLength - length;
  142 + textField.text = [textField.text stringByAppendingString:[string substringToIndex:needLen]];
  143 + return NO;
  144 + }
  145 + else{
  146 + return YES;
  147 + }
  148 + }
  149 + else{
  150 + return YES;
  151 + }
  152 +}
  153 +
  154 +#pragma mark - Action
  155 +- (void)headDidClicked:(UIButton *)btn{
  156 + btn.userInteractionEnabled = NO;
  157 + __weak typeof(self) weakSelf = self;
  158 + QMUIAlertAction *action1 = [QMUIAlertAction actionWithTitle:@"拍照" style:QMUIAlertActionStyleDefault handler:^(__kindof QMUIAlertController *aAlertController, QMUIAlertAction *action) {
  159 + btn.userInteractionEnabled = YES;
  160 + __strong typeof(weakSelf) strongSelf = weakSelf;
  161 + if(!strongSelf) return ;
  162 + __strong typeof(strongSelf) weakSelf = strongSelf;
  163 + [CNLiveAuthorizationManager getAVAuthorizationStatus:^{
  164 + __strong typeof(weakSelf) strongSelf = weakSelf;
  165 + if(!strongSelf) return ;
  166 + XFCameraController *cameraController = [[XFCameraController alloc] init];
  167 + cameraController.isCanShootVideo = NO;
  168 + cameraController.modalPresentationStyle = UIModalPresentationFullScreen;
  169 + __weak XFCameraController *weakCameraController = cameraController;
  170 + __weak typeof(strongSelf) weakSelf = strongSelf;
  171 + cameraController.takePhotosCompletionBlock = ^(UIImage *image, NSError *error) {
  172 + __strong typeof(weakSelf) strongSelf = weakSelf;
  173 + if(!strongSelf) return ;
  174 + strongSelf->_image = image;
  175 + [strongSelf.head setImage:strongSelf->_image forState:UIControlStateNormal];
  176 + dispatch_async(dispatch_get_main_queue(), ^{
  177 + [weakCameraController dismissViewControllerAnimated:YES completion:nil];
  178 + });
  179 + };
  180 + [(UIViewController *)self.delegate presentViewController:cameraController animated:YES completion:nil];
  181 + }];
  182 +
  183 + }];
  184 + QMUIAlertAction *action2 = [QMUIAlertAction actionWithTitle:@"从手机相册中选择" style:QMUIAlertActionStyleDefault handler:^(__kindof QMUIAlertController *aAlertController, QMUIAlertAction *action) {
  185 + btn.userInteractionEnabled = YES;
  186 + __strong typeof(weakSelf) strongSelf = weakSelf;
  187 + if(!strongSelf) return ;
  188 + __strong typeof(strongSelf) weakSelf = strongSelf;
  189 + [CNLiveAuthorizationManager getPHAuthorizationStatus:^{
  190 + __strong typeof(weakSelf) strongSelf = weakSelf;
  191 + if(!strongSelf) return ;
  192 + TZImagePickerController *picker = [[TZImagePickerController alloc] initWithMaxImagesCount:1 delegate:strongSelf];
  193 + picker.modalPresentationStyle = UIModalPresentationFullScreen;
  194 + picker.allowPickingVideo = NO;
  195 + picker.allowPreview = NO;
  196 + __weak typeof(strongSelf) weakSelf = strongSelf;
  197 + [picker setDidFinishPickingPhotosHandle:^(NSArray<UIImage *> *photos, NSArray *assets, BOOL isSelectOriginalPhoto) {
  198 + __strong typeof(weakSelf) strongSelf = weakSelf;
  199 + if(!strongSelf) return ;
  200 + strongSelf->_image = [photos firstObject];
  201 + [strongSelf.head setImage:strongSelf->_image forState:UIControlStateNormal];
  202 + }];
  203 + [(UIViewController *)strongSelf.delegate presentViewController:picker animated:YES completion:nil];
  204 + }];
  205 +
  206 + }];
  207 + QMUIAlertAction *cancel = [QMUIAlertAction actionWithTitle:@"取消" style:QMUIAlertActionStyleCancel handler:^(__kindof QMUIAlertController *aAlertController, QMUIAlertAction *action) {
  208 + __strong typeof(weakSelf) strongSelf = weakSelf;
  209 + if(!strongSelf) return ;
  210 +
  211 + }];
  212 +
  213 + QMUIAlertController *alertController = [QMUIAlertController alertControllerWithTitle:@"" message:@"" preferredStyle:QMUIAlertControllerStyleActionSheet];
  214 + alertController.delegate = self;
  215 + [alertController addAction:action1];
  216 + [alertController addAction:action2];
  217 + [alertController addAction:cancel];
  218 +
  219 + NSMutableDictionary *titleAttributs = [[NSMutableDictionary alloc] initWithDictionary:alertController.alertTitleAttributes];
  220 + UIColor *color = Business?[UIColor colorWithRed:72/255.0 green:168/255.0 blue:249/255.0 alpha:1.0]:[UIColor colorWithRed:35/255.0 green:212/255.0 blue:30/255.0 alpha:1.0];
  221 +
  222 + titleAttributs[NSForegroundColorAttributeName] = color;
  223 +
  224 + NSMutableDictionary *cancelAttributs = [[NSMutableDictionary alloc] initWithDictionary:alertController.alertTitleAttributes];
  225 + cancelAttributs[NSForegroundColorAttributeName] = [UIColor colorWithRed:51/255.0 green:51/255.0 blue:51/255.0 alpha:1.0];
  226 +
  227 + action1.buttonAttributes = titleAttributs;
  228 + action2.buttonAttributes = titleAttributs;
  229 + cancel.buttonAttributes = cancelAttributs;
  230 +
  231 + [alertController showWithAnimated:YES];
  232 +
  233 +}
  234 +
  235 +- (void)didHideAlertController:(QMUIAlertController *)alertController{
  236 + self.head.userInteractionEnabled = YES;
  237 +}
  238 +
  239 +#pragma mark - 响应方法
  240 +- (void)nextDidClicked:(UIButton *)btn{
  241 + [_nickname resignFirstResponder];
  242 + if ([_nickname.text isEqualToString:@""]) {
  243 + [QMUITips showError:@"请输入昵称" inView:self.superview hideAfterDelay:timeValue];
  244 + return;
  245 + }
  246 + self.next.userInteractionEnabled = NO;
  247 + [self.superview endEditing:YES];
  248 + [self modifyNickName];
  249 +}
  250 +
  251 +// 修改名字
  252 +- (void)modifyNickName {
  253 + [QMUITips showLoading:@"修改中" inView:self.superview];
  254 + __weak typeof(self) weakSelf = self;
  255 + [CNLiveUserSystemCenter modifyUserInfoType:UserInfoTypeNickName uid:CNUserShareModel.uid modifyInfo:_nickname.text success:^(id result) {
  256 + __strong typeof(weakSelf) strongSelf = weakSelf;
  257 + if(!strongSelf) return;
  258 + strongSelf.next.userInteractionEnabled = YES;
  259 + CNUserShareModel.nickname = strongSelf.nickname.text;
  260 + [QMUITips hideAllToastInView:strongSelf.superview animated:YES];
  261 +
  262 + if (!strongSelf->_image) {
  263 + [strongSelf connectionIM:result];
  264 +
  265 + }else{
  266 + [strongSelf modifyIcon];
  267 + }
  268 +
  269 + } failure:^(NSDictionary *errorDic) {
  270 + __strong typeof(weakSelf) strongSelf = weakSelf;
  271 + if(!strongSelf) return;
  272 + strongSelf.next.userInteractionEnabled = YES;
  273 + [QMUITips hideAllToastInView:strongSelf.superview animated:YES];
  274 + [QMUITips showError:[errorDic objectForKey:@"errorMessage"] inView:strongSelf.superview hideAfterDelay:timeValue];
  275 + }];
  276 +
  277 +}
  278 +
  279 +// 修改头像
  280 +- (void)modifyIcon {
  281 + [QMUITips showLoading:@"修改中" inView:self.superview];
  282 + __weak typeof(self) weakSelf = self;
  283 + [CNLiveUserSystemCenter uploadIconWithUid:CNUserShareModel.uid icon:_image success:^(id result) {
  284 + __strong typeof(weakSelf) strongSelf = weakSelf;
  285 + if(!strongSelf) return;
  286 + strongSelf.next.userInteractionEnabled = YES;
  287 + [QMUITips hideAllToastInView:strongSelf.superview animated:YES];
  288 + NSLog(@"result:%@",result);
  289 + NSString *deFaceUrl = result[@"data"][@"faceUrl"];
  290 + NSString *faceUrl = @"";
  291 + if ([deFaceUrl containsString:@"/mobile/images/mobilehead/default/"]) {
  292 + faceUrl = CNLiveNetAddDefaultHead;
  293 + }else{
  294 + faceUrl = deFaceUrl;
  295 + }
  296 + CNUserShareModel.faceUrl = faceUrl;
  297 + [strongSelf connectionIM:result];
  298 +
  299 + } failure:^(NSDictionary *errorDic) {
  300 + __strong typeof(weakSelf) strongSelf = weakSelf;
  301 + if(!strongSelf) return;
  302 + strongSelf.next.userInteractionEnabled = YES;
  303 + [QMUITips hideAllToastInView:strongSelf.superview animated:YES];
  304 + [QMUITips showError:errorDic[@"errorMessage"] inView:strongSelf.superview hideAfterDelay:timeValue];
  305 + }];
  306 +
  307 +}
  308 +
  309 +// 连接IM
  310 +- (void)connectionIM:(id)result{
  311 + NSMutableDictionary *dic = [NSMutableDictionary dictionaryWithDictionary:result[@"data"]];
  312 + NSString *faceUrl = [dic objectForKey:@"faceUrl"];
  313 + if ([faceUrl containsString:@"/mobile/images/mobilehead/default/"]) {
  314 + //网家家默认头像地址
  315 + [dic setValue:CNLiveNetAddDefaultHead forKey:@"faceUrl"];
  316 + }
  317 + [CNUserInfoManager saveUserinfoDic:dic];
  318 +
  319 + __weak typeof(self) weakSelf = self;
  320 + [[CNLiveLoginRequest manager] loginTIM:CNUserShareModel.uid success:^{
  321 + __strong typeof(weakSelf) strongSelf = weakSelf;
  322 + if(!strongSelf) return;
  323 + // 进入tabbar
  324 + if (strongSelf.delegate && [strongSelf.delegate respondsToSelector:@selector(loginSuccess:result:)]) {
  325 + [strongSelf.delegate loginSuccess:strongSelf result:result];
  326 + }
  327 +
  328 + } failed:^(int code, NSString * _Nonnull msg) {
  329 + __strong typeof(weakSelf) strongSelf = weakSelf;
  330 + if(!strongSelf) return;
  331 + // 错误逻辑
  332 + [QMUITips showError:msg inView:strongSelf.superview hideAfterDelay:timeValue];
  333 +
  334 + }];
  335 +
  336 +}
  337 +
  338 +/*
  339 +// Only override drawRect: if you perform custom drawing.
  340 +// An empty implementation adversely affects performance during animation.
  341 +- (void)drawRect:(CGRect)rect {
  342 + // Drawing code
  343 +}
  344 +*/
  345 +
  346 +@end
CNLiveBLoginModule/Classes/View/CNLiveLoginCountryView.h 0 → 100644
  1 +//
  2 +// CNLiveLoginCountryView.h
  3 +// CNLiveLoginModule
  4 +//
  5 +// Created by 153993236@qq.com on 11/12/2019.
  6 +// Copyright (c) 2019 153993236@qq.com. All rights reserved.
  7 +//
  8 +
  9 +#import <UIKit/UIKit.h>
  10 +
  11 +NS_ASSUME_NONNULL_BEGIN
  12 +@protocol CNLiveLoginCountryViewDelegate <NSObject>
  13 +- (void)chooseCountryName:(NSString *)countryName countryCode:(NSString *)countryCode;
  14 +
  15 +@end
  16 +@interface CNLiveLoginCountryView : UIView
  17 +@property (nonatomic, weak) id<CNLiveLoginCountryViewDelegate> delegate;
  18 +
  19 +@end
  20 +
  21 +NS_ASSUME_NONNULL_END
CNLiveBLoginModule/Classes/View/CNLiveLoginCountryView.m 0 → 100644
  1 +//
  2 +// CNLiveLoginCountryView.m
  3 +// CNLiveLoginModule
  4 +//
  5 +// Created by 153993236@qq.com on 11/12/2019.
  6 +// Copyright (c) 2019 153993236@qq.com. All rights reserved.
  7 +//
  8 +
  9 +#import "CNLiveLoginCountryView.h"
  10 +#import "YYKit.h"
  11 +#import "CNLiveCategory.h"
  12 +
  13 +#import "CNLiveChooseCountryController.h"
  14 +
  15 +@interface CNLiveLoginCountryView()<ChooseCountriesDelegate>
  16 +{
  17 + NSString *_countryName;
  18 + NSString *_countryCode;
  19 +}
  20 +@property (nonatomic, weak) UILabel *name;
  21 +@property (nonatomic, weak) UIButton *code;
  22 +
  23 +@end
  24 +@implementation CNLiveLoginCountryView
  25 +
  26 +- (instancetype)initWithFrame:(CGRect)frame{
  27 + self = [super initWithFrame:frame];
  28 + if (self) {
  29 + _countryName = @"中国大陆";
  30 + _countryCode = @"86";
  31 + [self createSubviews:frame];
  32 + }
  33 + return self;
  34 +
  35 +}
  36 +- (void)createSubviews:(CGRect)frame{
  37 + UILabel *name = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, frame.size.width-70, frame.size.height)];
  38 + name.textColor = [UIColor colorWithRed:173/255.0 green:173/255.0 blue:173/255.0 alpha:1.0];
  39 + name.font = [UIFont systemFontOfSize:16];
  40 + name.textAlignment = NSTextAlignmentLeft;
  41 + name.text = _countryName;
  42 + [self addSubview:name];
  43 + self.name = name;
  44 +
  45 + UIButton *code = [UIButton buttonWithType:UIButtonTypeCustom];
  46 + code.frame = CGRectMake(name.right, 0, 70, frame.size.height);
  47 + [code setTitle:[NSString stringWithFormat:@"+%@",_countryCode] forState:UIControlStateNormal];
  48 + [code setTitleColor:[UIColor colorWithRed:51/255.0 green:51/255.0 blue:51/255.0 alpha:1.0] forState:UIControlStateNormal];
  49 + code.titleLabel.font = [UIFont systemFontOfSize:14];
  50 + UIImage *image = [self getImageWithImageName:@"login_country" bundleName:@"CNLiveBLoginModule" targetClass:[self class]];
  51 + [code setImage:image forState:UIControlStateNormal];
  52 + code.adjustsImageWhenHighlighted = NO;
  53 + //button图片的偏移量,距上左下右分别(0, 0, 0, 0)像素点
  54 + code.imageEdgeInsets = UIEdgeInsetsMake(0, 60, 0, 0);
  55 + //button标题的偏移量,这个偏移量是相对于图片的
  56 + code.titleEdgeInsets = UIEdgeInsetsMake(0, 0, 0, 10);
  57 + [code addTarget:self action:@selector(countryCodeDidClicked:) forControlEvents:UIControlEventTouchUpInside];
  58 + [self addSubview:code];
  59 + self.code = code;
  60 +
  61 +}
  62 +
  63 +/*
  64 +// Only override drawRect: if you perform custom drawing.
  65 +// An empty implementation adversely affects performance during animation.
  66 +- (void)drawRect:(CGRect)rect {
  67 + // Drawing code
  68 +}
  69 +*/
  70 +#pragma mark - Action
  71 +- (void)countryCodeDidClicked:(UIButton *)btn{
  72 + UIViewController *root = [UIApplication sharedApplication].delegate.window.rootViewController;
  73 + CNLiveChooseCountryController *vc = [[CNLiveChooseCountryController alloc] init];
  74 + vc.delegate = self;
  75 + vc.modalPresentationStyle = UIModalPresentationFullScreen;
  76 + [root presentViewController:vc animated:YES completion:nil];
  77 +}
  78 +
  79 +#pragma mark - CNLiveSelectCountryViewDelegate
  80 +- (void)chooseViewController:(CNLiveChooseCountryController *)controller countryName:(NSString *)countryName countryCode:(NSString *)countryCode{
  81 + if(![_countryName isEqualToString:countryName]&&![_countryCode isEqualToString:countryCode]){
  82 + _countryName = countryName;
  83 + _countryCode = countryCode;
  84 + _name.text = countryName;
  85 + [_code setTitle:[NSString stringWithFormat:@"+%@",countryCode] forState:UIControlStateNormal];
  86 + }
  87 + if (self.delegate && [self.delegate respondsToSelector:@selector(chooseCountryName:countryCode:)]) {
  88 + [self.delegate chooseCountryName:countryName countryCode:countryCode];
  89 + }
  90 +}
  91 +
  92 +@end
CNLiveBLoginModule/Classes/View/CNLiveLoginTextField.h 0 → 100644
  1 +//
  2 +// CNLiveLoginTextField.h
  3 +// CNLiveLoginModule
  4 +//
  5 +// Created by 153993236@qq.com on 11/12/2019.
  6 +// Copyright (c) 2019 153993236@qq.com. All rights reserved.
  7 +//
  8 +
  9 +#import <UIKit/UIKit.h>
  10 +
  11 +NS_ASSUME_NONNULL_BEGIN
  12 +
  13 +@interface CNLiveLoginTextField : UITextField
  14 +@property (nonatomic, strong) UIColor *lineColor;
  15 +@property (nonatomic, strong) UIColor *placeholderColor;
  16 +
  17 +@end
  18 +
  19 +NS_ASSUME_NONNULL_END
CNLiveBLoginModule/Classes/View/CNLiveLoginTextField.m 0 → 100644
  1 +//
  2 +// XWLoginTextField.m
  3 +// CNLiveLoginModule
  4 +//
  5 +// Created by 153993236@qq.com on 11/12/2019.
  6 +// Copyright (c) 2019 153993236@qq.com. All rights reserved.
  7 +//
  8 +
  9 +#import "CNLiveLoginTextField.h"
  10 +#import <objc/runtime.h>
  11 +//#import "XWColorHeader.h"
  12 +
  13 +@interface CNLiveLoginTextField()
  14 +@property (nonatomic, weak) UIView *line;
  15 +@property (nonatomic, strong) UIColor *color;
  16 +
  17 +@end
  18 +
  19 +@implementation CNLiveLoginTextField
  20 +static NSString * const CNLivePlaceholderTextColor = @"_placeholderLabel.textColor";
  21 +
  22 +- (instancetype)initWithFrame:(CGRect)frame{
  23 +
  24 + self = [super initWithFrame:frame];
  25 + if (self) {
  26 + [self createSubviews:frame];
  27 +
  28 + }
  29 + return self;
  30 +
  31 +}
  32 +- (void)createSubviews:(CGRect)frame{
  33 + UIView *line = [[UIView alloc] initWithFrame:CGRectMake(0, frame.size.height-1, frame.size.width, 0.5)];
  34 + line.backgroundColor = [UIColor colorWithRed:173/255.0 green:173/255.0 blue:173/255.0 alpha:1.0];
  35 + [self addSubview:line];
  36 + self.line = line;
  37 +}
  38 +- (void)setLineColor:(UIColor *)lineColor{
  39 + _lineColor = lineColor;
  40 + self.line.backgroundColor = lineColor;
  41 +}
  42 +/*
  43 +// Only override drawRect: if you perform custom drawing.
  44 +// An empty implementation adversely affects performance during animation.
  45 +- (void)drawRect:(CGRect)rect {
  46 + // Drawing code
  47 +}
  48 +*/
  49 +
  50 ++ (void)initialize {
  51 + if (@available(iOS 13.0, *)) {
  52 +
  53 + }else{
  54 + [self getIvars];
  55 + }
  56 +}
  57 +
  58 +// 获取私有变量名称
  59 ++ (void)getIvars {
  60 + unsigned int count = 0;
  61 + Ivar *ivars = class_copyIvarList([UITextField class], &count);
  62 + for (int i = 0; i < count; i++) {
  63 + Ivar ivar = ivars[i];
  64 + NSLog(@"%s----%s", ivar_getName(ivar), ivar_getTypeEncoding(ivar));
  65 + }
  66 +
  67 +}
  68 +
  69 +- (void)awakeFromNib {
  70 + // 设置光标的颜色
  71 + self.tintColor = self.textColor;
  72 + [super awakeFromNib];
  73 +}
  74 +
  75 +// 获取到焦点
  76 +- (BOOL)becomeFirstResponder {
  77 + if (@available(iOS 13.0, *)) {
  78 +
  79 + }else{
  80 + // 利用运行时获取key,设置占位文字的颜色
  81 + [self setValue:self.textColor forKeyPath:CNLivePlaceholderTextColor];
  82 +
  83 + }
  84 + return [super becomeFirstResponder];
  85 +}
  86 +
  87 +// 失去焦点
  88 +- (BOOL)resignFirstResponder {
  89 + if (@available(iOS 13.0, *)) {
  90 + }else{
  91 + // 利用运行时获取key,设置占位文字的颜色
  92 + [self setValue:self.color forKeyPath:CNLivePlaceholderTextColor];
  93 + }
  94 + return [super resignFirstResponder];
  95 +
  96 +}
  97 +- (void)setPlaceholderColor:(UIColor *)placeholderColor{
  98 + _color = placeholderColor;
  99 + if (_color) {
  100 + _color = placeholderColor;
  101 + } else {
  102 + _color = [UIColor whiteColor];
  103 + }
  104 + if (@available(iOS 13.0, *)) {
  105 + self.attributedPlaceholder = [[NSAttributedString alloc] initWithString:self.placeholder attributes:@{NSFontAttributeName:self.font, NSForegroundColorAttributeName:_color}];
  106 +
  107 + }else{
  108 + [self setValue:_color forKeyPath:CNLivePlaceholderTextColor];
  109 + }
  110 +
  111 +}
  112 +
  113 +- (UIColor *)placeholderColor{
  114 + return [self valueForKeyPath:CNLivePlaceholderTextColor];
  115 +
  116 +}
  117 +
  118 +@end
CNLiveBLoginModule/Classes/View/CNLiveLoginTipsView.h 0 → 100644
  1 +//
  2 +// CNLiveLoginTipsView.h
  3 +// CNLiveLoginModule
  4 +//
  5 +// Created by CNLive-zxw on 2019/11/11.
  6 +// Copyright © 2019 cnlive. All rights reserved.
  7 +//
  8 +
  9 +#import <UIKit/UIKit.h>
  10 +
  11 +NS_ASSUME_NONNULL_BEGIN
  12 +
  13 +@interface CNLiveLoginTipsView : UIView
  14 +
  15 ++ (void)showCenterLoginViewWithVC:(UIViewController *)controller;
  16 ++ (void)hide;
  17 +
  18 +@end
  19 +
  20 +NS_ASSUME_NONNULL_END
CNLiveBLoginModule/Classes/View/CNLiveLoginTipsView.m 0 → 100644
  1 +//
  2 +// CNLiveLoginTipsView.m
  3 +// CNLiveLoginModule
  4 +//
  5 +// Created by CNLive-zxw on 2019/11/11.
  6 +// Copyright © 2019 cnlive. All rights reserved.
  7 +//
  8 +
  9 +#import "CNLiveLoginTipsView.h"
  10 +#import "CNLiveLoginTextField.h"
  11 +#import "NSString+CNLiveExtension.h"
  12 +#import "NSString+Category.h"
  13 +#import "CNLiveUserAgreementManager.h"
  14 +#import "CNLiveCategory.h"
  15 +
  16 +#import "MJExtension.h"
  17 +#import "QMUIKit.h"
  18 +#import "YYKit.h"
  19 +#import "TIMAdapter.h"
  20 +#import "CommonLibrary.h"
  21 +#import <Masonry/Masonry.h>
  22 +
  23 +//#import "CNNavigationController.h"
  24 +#import "CNLiveChooseCountryController.h"
  25 +#import <CNLiveUserSystemSDK/CNLiveUserSystemCenter.h>
  26 +#import <CNLiveUserSystemSDK/CNLiveUserSystemTypeDef.h>
  27 +#import "CNUserInfoManager.h"
  28 +#import "CNLiveEnvironment.h"
  29 +
  30 +
  31 +#import "CNLiveThreeLoginView.h"
  32 +
  33 +
  34 +//三方登录
  35 +//#import "CNThreeLoginViewController.h"
  36 +//#import "CNLiveShareImageManager.h"
  37 +//#import "CNThreeLoginModel.h"
  38 +//#import "CNBindingManageRequest.h"
  39 +//#import "NSObject+TransformModel.h"
  40 +//#import "CNShareExtensionGroup.h"
  41 +//#import "CNLoginIUsernfoViewController.h"
  42 +
  43 +@interface CNLiveLoginTipsView()<UITextFieldDelegate,ChooseCountriesDelegate,CNLiveThreeLoginViewDelegate>{
  44 + dispatch_source_t _timer;
  45 + NSString * _codeStr;
  46 + NSString * _countryStr;
  47 +}
  48 +@property (nonatomic, strong) IMALoginParam *loginParam;
  49 +
  50 +@property (nonatomic, strong) UIImageView *whiteView;
  51 +@property (nonatomic, strong) UIButton *close;
  52 +
  53 +@property (nonatomic, strong) QMUILabel *countryLbl;
  54 +@property (nonatomic, strong) UIButton *countryBtn;
  55 +@property (nonatomic, strong) UIView *line;
  56 +
  57 +@property (nonatomic, strong) CNLiveLoginTextField *telTF;
  58 +@property (nonatomic, strong) CNLiveLoginTextField *codeTF;
  59 +@property (nonatomic, strong) UIButton *codeBtn;
  60 +@property (nonatomic, strong) YYLabel *protocolLab;
  61 +@property (nonatomic, strong) UIButton *login;
  62 +@property (nonatomic, strong) CNLiveThreeLoginView *threeLoginView;
  63 +@property (nonatomic, strong) CNLiveLoginTipsView *loginView;
  64 +
  65 +@end
  66 +
  67 +@implementation CNLiveLoginTipsView
  68 +#define XWKeyWindow [UIApplication sharedApplication].keyWindow
  69 +
  70 +static const CGFloat rowHeight = 30;
  71 +static const CGFloat margin = 15;
  72 +
  73 +#pragma mark - 单例
  74 ++ (instancetype)manager {
  75 + static CNLiveLoginTipsView *_singleton = nil;
  76 + static dispatch_once_t onceToken;
  77 + dispatch_once(&onceToken, ^{
  78 + //不能再使用alloc方法
  79 + //因为已经重写了allocWithZone方法,所以这里要调用父类的分配空间的方法
  80 + _singleton = [[super allocWithZone:NULL] init];
  81 + });
  82 + return _singleton;
  83 +
  84 +}
  85 +
  86 ++ (void)showCenterLoginViewWithVC:(UIViewController *)controller {
  87 + [CNLiveLoginTipsView manager].loginView = [[CNLiveLoginTipsView alloc] initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height)];
  88 + [CNLiveLoginTipsView manager].loginView.backgroundColor = [UIColor colorWithWhite:0.2f alpha:0.4f];
  89 + [controller.view addSubview:[CNLiveLoginTipsView manager].loginView];
  90 +}
  91 +
  92 +#pragma mark - Init
  93 +- (instancetype)initWithFrame:(CGRect)frame{
  94 + if(self = [super initWithFrame:frame]){
  95 + _codeStr = @"86";
  96 + _countryStr = @"中国大陆";
  97 +
  98 + BOOL isAutoLogin = [IMAPlatform isAutoLogin];
  99 + if (isAutoLogin) {
  100 + _loginParam = [IMALoginParam loadFromLocal];
  101 +
  102 + } else {
  103 + _loginParam = [[IMALoginParam alloc] init];
  104 +
  105 + }
  106 +
  107 + [IMAPlatform configWith:_loginParam.config];
  108 + [self setUpUI];
  109 +// UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(closeBtn:)];
  110 +// [self addGestureRecognizer:tap];
  111 +
  112 + }
  113 + return self;
  114 +
  115 +}
  116 +#pragma mark - UI
  117 +- (void)setUpUI{
  118 + [self addSubview:self.whiteView];
  119 + [self addSubview:self.close];
  120 +
  121 + [self addSubview:self.countryLbl];
  122 + [self addSubview:self.countryBtn];
  123 + [self addSubview:self.line];
  124 +
  125 + [self addSubview:self.telTF];
  126 + [self addSubview:self.codeTF];
  127 + [self addSubview:self.codeBtn];
  128 +
  129 + [self addSubview:self.login];
  130 + [self addSubview:self.threeLoginView];
  131 + [self addSubview:self.protocolLab];
  132 + [self.protocolLab mas_makeConstraints:^(MASConstraintMaker *make) {
  133 + make.top.mas_equalTo(self.threeLoginView.mas_bottom).mas_offset(0);
  134 + make.bottom.mas_equalTo(self.whiteView.mas_bottom).mas_offset(-0);
  135 + make.left.mas_equalTo(self.countryLbl.mas_left).mas_offset(0);
  136 + make.right.mas_equalTo(self.countryBtn.mas_right).mas_offset(-0);
  137 +
  138 + }];
  139 +
  140 +}
  141 +- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
  142 + [self endEditing:YES];
  143 +}
  144 +
  145 +#pragma mark - UITextFieldDelegate
  146 +- (void)textFieldDidChange:(UITextField *)textField {
  147 + if (![NSString isEmpty:_telTF.text] && ![NSString isEmpty:_codeTF.text]) {
  148 + _login.enabled = YES;
  149 +
  150 + }
  151 + else {
  152 + _login.enabled = NO;
  153 +
  154 + }
  155 +
  156 +}
  157 +
  158 +- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {
  159 + if ([textField isEqual:self.telTF]) {
  160 + NSInteger maxTextLength = 20;
  161 + if(string.length == 0) {
  162 + //判断是不是删除键
  163 + return YES;
  164 + }
  165 + else if(textField.text.length >= maxTextLength) {
  166 + //输入的字符个数大于11,则无法继续输入,返回NO表示禁止输入
  167 + NSLog(@"输入的字符个数大于20,忽略输入");
  168 + return NO;
  169 + }
  170 +// else if (!CNLiveStringIsNumber(string)) {
  171 +// //string复制的可能为特殊字符,过滤
  172 +// return NO;
  173 +// }
  174 + else if (textField.text.length + string.length > maxTextLength){
  175 + NSInteger length = textField.text.length;
  176 + NSInteger needLen = maxTextLength - length;
  177 + textField.text = [textField.text stringByAppendingString:[string substringToIndex:needLen]];
  178 + return NO;
  179 + }
  180 + else{
  181 + return YES;
  182 + }
  183 + }else if ([textField isEqual:self.codeTF]){
  184 + NSInteger maxTextLength = 6;
  185 + if(string.length == 0) {
  186 + //判断是不是删除键
  187 + return YES;
  188 + }
  189 + else if(textField.text.length >= maxTextLength) {
  190 + //输入的字符个数大于6,则无法继续输入,返回NO表示禁止输入
  191 + return NO;
  192 + }
  193 +// else if (!CNLiveStringIsNumber(string)) {
  194 +// //string复制的可能为特殊字符,过滤
  195 +// return NO;
  196 +// }
  197 + else if (textField.text.length + string.length > maxTextLength){
  198 + //如果textF.text + string > 6 截取6位
  199 +#warning 有个问题,光标没有及时更新到最后一位
  200 + NSInteger length = textField.text.length;
  201 + NSInteger needLen = maxTextLength - length;
  202 + textField.text = [textField.text stringByAppendingString:[string substringToIndex:needLen]];
  203 + return NO;
  204 + }
  205 + else{
  206 + return YES;
  207 + }
  208 + }else
  209 + {
  210 + return YES;
  211 + }
  212 +}
  213 +/*
  214 +// Only override drawRect: if you perform custom drawing.
  215 +// An empty implementation adversely affects performance during animation.
  216 +- (void)drawRect:(CGRect)rect {
  217 + // Drawing code
  218 +}
  219 +*/
  220 +#pragma mark - Lazy Loading
  221 +- (UIImageView *)whiteView{
  222 + if (!_whiteView) {
  223 + _whiteView = [[UIImageView alloc] initWithFrame:CGRectMake(([UIScreen mainScreen].bounds.size.width-287)/2.0, ([UIScreen mainScreen].bounds.size.height-396)/2.0, 287, 396)];
  224 + _whiteView.image = [UIImage imageNamed:@"tourists_login_bg"];
  225 + }
  226 + return _whiteView;
  227 +}
  228 +
  229 +- (UIButton *)close{
  230 + if (!_close) {
  231 + _close = [[UIButton alloc]initWithFrame:CGRectMake(CGRectGetMaxX(_whiteView.frame)-25-10, CGRectGetMinY(_whiteView.frame)+10, 25, 25)];
  232 + [_close setImage:[UIImage imageNamed:@"tourists_login_close"] forState:UIControlStateNormal];
  233 + [_close addTarget:self action:@selector(closeBtn:) forControlEvents:UIControlEventTouchUpInside];
  234 + }
  235 + return _close;
  236 +}
  237 +
  238 +- (QMUILabel *)countryLbl{
  239 + if (!_countryLbl){
  240 + _countryLbl = [[QMUILabel alloc] initWithFrame:CGRectMake(_whiteView.left+margin, _whiteView.top+100, 80, rowHeight)];
  241 + [_countryLbl setFont:UIFontMake(13)];
  242 + _countryLbl.textColor = [UIColor colorWithRed:49/255.0 green:49/255.0 blue:49/255.0 alpha:1.0];
  243 + _countryLbl.text = _countryStr;
  244 + _countryLbl.userInteractionEnabled = YES;
  245 + }
  246 + return _countryLbl;
  247 +}
  248 +
  249 +- (UIButton *)countryBtn{
  250 + if (!_countryBtn){
  251 + _countryBtn = [[UIButton alloc]initWithFrame:CGRectMake(kScreenWidth-_whiteView.left-15-70, _countryLbl.top, 70, _countryLbl.height)];
  252 + _countryBtn.titleLabel.font = UIFontMake(13);
  253 + [_countryBtn setTitleColor:[UIColor colorWithRed:49/255.0 green:49/255.0 blue:49/255.0 alpha:1.0] forState:UIControlStateNormal];
  254 + [_countryBtn setTitle:[NSString stringWithFormat:@"+%@", _codeStr] forState:UIControlStateNormal];
  255 + UIImage *image = [self getImageWithImageName:@"login_country" bundleName:@"CNLiveBLoginModule" targetClass:[self class]];
  256 + [_countryBtn setImage:image forState:UIControlStateNormal];
  257 + [_countryBtn addTarget:self action:@selector(countryBtn:) forControlEvents:UIControlEventTouchUpInside];
  258 + _countryBtn.userInteractionEnabled = YES;
  259 + //button图片的偏移量,距上左下右分别(0, 0, 0, 0)像素点
  260 + _countryBtn.imageEdgeInsets = UIEdgeInsetsMake(0, 60, 0, 0);
  261 + //button标题的偏移量,这个偏移量是相对于图片的
  262 + _countryBtn.titleEdgeInsets = UIEdgeInsetsMake(0, 0, 0, 10);
  263 + }
  264 + return _countryBtn;
  265 +}
  266 +- (UIView *)line{
  267 + if(!_line){
  268 + _line = [[UIView alloc] initWithFrame:CGRectMake(_countryLbl.left, _countryBtn.bottom, KScreenWidth - (2*_countryLbl.left), 0.5)];
  269 + _line.backgroundColor = [UIColor colorWithRed:235/255.0 green:235/255.0 blue:235/255.0 alpha:1.0];
  270 + }
  271 + return _line;
  272 +}
  273 +- (CNLiveLoginTextField *)telTF{
  274 + if (!_telTF) {
  275 + _telTF = [[CNLiveLoginTextField alloc] initWithFrame:CGRectMake(_countryLbl.left, _countryLbl.bottom + margin, KScreenWidth - (2*_countryLbl.left), rowHeight)];
  276 + _telTF.placeholderColor = KGray173Color;
  277 + _telTF.textColor = [UIColor blackColor];
  278 + _telTF.keyboardType = UIKeyboardTypeNumberPad;
  279 + _telTF.placeholder = @"请输入手机号号码";
  280 + _telTF.font = UIFontMake(13);
  281 + _telTF.clearButtonMode = UITextFieldViewModeAlways;
  282 + _telTF.textAlignment = NSTextAlignmentLeft;
  283 + [_telTF addTarget:self action:@selector(textFieldDidChange:) forControlEvents:UIControlEventEditingChanged];
  284 + _telTF.delegate = self;
  285 + }
  286 + return _telTF;
  287 +}
  288 +- (CNLiveLoginTextField *)codeTF {
  289 + if (!_codeTF) {
  290 + _codeTF = [[CNLiveLoginTextField alloc] initWithFrame:CGRectMake(_telTF.left, _telTF.bottom + margin, 120, _telTF.height)];
  291 + _codeTF.keyboardType = UIKeyboardTypeNumberPad;
  292 + _codeTF.placeholder = @"请输入验证码";
  293 + _codeTF.textColor = [UIColor blackColor];
  294 + _codeTF.placeholderColor = KGray173Color;
  295 + _codeTF.font = UIFontMake(13);
  296 + _codeTF.textAlignment = NSTextAlignmentLeft;
  297 + [_codeTF addTarget:self action:@selector(textFieldDidChange:) forControlEvents:UIControlEventEditingChanged];
  298 + _codeTF.clearButtonMode = UITextFieldViewModeWhileEditing;
  299 + _codeTF.delegate = self;
  300 + }
  301 + return _codeTF;
  302 +}
  303 +- (UIButton *)codeBtn{
  304 + if (!_codeBtn) {
  305 + _codeBtn = [[UIButton alloc]initWithFrame:CGRectMake(kScreenWidth-_whiteView.left-margin-58, _codeTF.top+(rowHeight-22)/2.0, 58, 22)];
  306 + _codeBtn.titleLabel.font = [UIFont systemFontOfSize:10.0];
  307 + [_codeBtn setBackgroundImage:[UIImage imageNamed:@"dl_yzman"] forState:UIControlStateNormal];
  308 + [_codeBtn setTitleColor:[UIColor colorWithRed:35/255.0 green:212/255.0 blue:30/255.0 alpha:1.0] forState:UIControlStateNormal];
  309 + [_codeBtn setBackgroundImage:nil forState:UIControlStateSelected];
  310 + [_codeBtn setTitleColor:[UIColor colorWithRed:35/255.0 green:212/255.0 blue:30/255.0 alpha:1.0] forState:UIControlStateSelected];
  311 + [_codeBtn addTarget:self action:@selector(codeBtn:) forControlEvents:UIControlEventTouchUpInside];
  312 + [_codeBtn setAdjustsImageWhenHighlighted:NO];
  313 + }
  314 + return _codeBtn;
  315 +}
  316 +- (UIButton *)login{
  317 + if (!_login) {
  318 + _login = [[UIButton alloc]initWithFrame:CGRectMake(([UIScreen mainScreen].bounds.size.width-180)/2.0, _codeTF.bottom + margin, 180, rowHeight)];
  319 + _login.backgroundColor = [UIColor colorWithRed:35/255.0 green:212/255.0 blue:30/255.0 alpha:1.0];
  320 + _login.titleLabel.font = [UIFont systemFontOfSize:14.0];
  321 + _login.layer.cornerRadius = 15;
  322 + _login.layer.masksToBounds = YES;
  323 + [_login setTitle:@"登录" forState:UIControlStateNormal];
  324 + [_login setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
  325 + [_login addTarget:self action:@selector(loginBtn:) forControlEvents:UIControlEventTouchUpInside];
  326 + }
  327 + return _login;
  328 +}
  329 +
  330 +- (CNLiveThreeLoginView *)threeLoginView{
  331 + if (!_threeLoginView) {
  332 + _threeLoginView = [[CNLiveThreeLoginView alloc]initWithFrame:CGRectMake(_whiteView.left, _login.bottom+margin, _whiteView.width, 80)];
  333 + _threeLoginView.delegate = self;
  334 + }
  335 + return _threeLoginView;
  336 +}
  337 +
  338 +- (YYLabel *)protocolLab {
  339 + if (!_protocolLab) {
  340 + _protocolLab = [[YYLabel alloc] init];
  341 + _protocolLab.textAlignment = NSTextAlignmentCenter;
  342 +
  343 + NSMutableAttributedString *text = [[NSMutableAttributedString alloc] initWithString:@"登录即代表阅读并同意《用户协议》及《隐私政策》"];
  344 + NSMutableParagraphStyle *style = [[NSParagraphStyle defaultParagraphStyle] mutableCopy];
  345 + style.alignment = NSTextAlignmentCenter;//对齐方式
  346 + [text addAttribute:NSParagraphStyleAttributeName value:style range:NSMakeRange(0, text.length)];
  347 +
  348 + text.color = UIColorMake(201, 202, 203);
  349 + text.font = UIFontMake(10);
  350 +
  351 + __weak typeof(self) weakSelf = self;
  352 + [text setTextHighlightRange:NSMakeRange(11, 4) color:[UIColor colorWithRed:35/255.0 green:212/255.0 blue:30/255.0 alpha:1.0] backgroundColor:[UIColor clearColor] tapAction:^(UIView * _Nonnull containerView, NSAttributedString * _Nonnull text, NSRange range, CGRect rect) {
  353 + [weakSelf endEditing:YES];
  354 + [CNLiveUserAgreementManager jumpToAgreementH5WithType:CNLiveUserAgreementUser];
  355 + }];
  356 + [text setTextHighlightRange:NSMakeRange(text.length-5, 4) color:[UIColor colorWithRed:35/255.0 green:212/255.0 blue:30/255.0 alpha:1.0] backgroundColor:[UIColor clearColor] tapAction:^(UIView * _Nonnull containerView, NSAttributedString * _Nonnull text, NSRange range, CGRect rect) {
  357 + [weakSelf endEditing:YES];
  358 + [CNLiveUserAgreementManager jumpToAgreementH5WithType:CNLiveUserAgreementPrivacy];
  359 + }];
  360 +
  361 + _protocolLab.attributedText = text;
  362 +
  363 + }
  364 +
  365 +
  366 + return _protocolLab;
  367 +}
  368 +
  369 +
  370 +#pragma mark - Action
  371 +//点击✘按钮调用方法
  372 +- (void)closeBtn:(UIButton *)btn {
  373 + [[CNLiveLoginTipsView manager].loginView removeFromSuperview];
  374 +}
  375 +
  376 ++ (void)hide {
  377 + [[CNLiveLoginTipsView manager].loginView removeFromSuperview];
  378 +}
  379 +- (void)codeBtn:(UIButton *)btn {
  380 +// [CNTools setFrmId];
  381 + if ([self.telTF.text isEqualToString:@""]) {
  382 + [QMUITips showWithText:@"请输入手机号" inView:XWKeyWindow hideAfterDelay:1.5];
  383 + [self cancelVerBtnChange];
  384 + return;
  385 + }
  386 +
  387 + [_codeTF becomeFirstResponder];
  388 + _codeTF.text = nil;
  389 + _codeBtn.userInteractionEnabled = NO;
  390 + [QMUITips showLoadingInView:XWKeyWindow];
  391 + [CNLiveUserSystemCenter verificationCodeType:VerificationCodeTypeShortcutLogin mobile:_telTF.text countryCode:_codeStr success:^(id result) {
  392 + _codeBtn.selected = YES;
  393 + [self startTimer];//倒计时结束,打开交互性
  394 + [QMUITips hideAllToastInView:XWKeyWindow animated:YES];
  395 + [QMUITips showWithText:@"验证码已发送" inView:XWKeyWindow hideAfterDelay:1.5];
  396 +
  397 + } failure:^(NSDictionary *errorDic) {
  398 + [QMUITips hideAllToastInView:XWKeyWindow animated:YES];
  399 + if ([errorDic[@"errorCode"] integerValue] == 408) {
  400 + [QMUITips showError:@"请输入正确的手机号" inView:XWKeyWindow hideAfterDelay:1.5];
  401 +
  402 + }else{
  403 + [QMUITips showError:errorDic[@"errorMessage"] inView:XWKeyWindow hideAfterDelay:1.5];
  404 + }
  405 + [self cancelVerBtnChange];//请求失败,复原按钮,打开交互性
  406 +
  407 + }];
  408 +
  409 +}
  410 +#pragma mark - 倒计时
  411 +//恢复原状
  412 +- (void)cancelVerBtnChange {
  413 + dispatch_async(dispatch_get_main_queue(), ^{
  414 + _codeBtn.selected = NO;
  415 + [_codeBtn setTitle:@"" forState:UIControlStateNormal];
  416 + [_codeBtn setBackgroundImage:[UIImage imageNamed:@"dl_yzman"] forState:UIControlStateNormal];
  417 + //设置界面的按钮显示
  418 + _codeBtn.layer.borderWidth = 0;
  419 + _codeBtn.userInteractionEnabled = YES;
  420 + });
  421 + if (_timer) {
  422 + dispatch_source_cancel(_timer);//取消定时器
  423 + }
  424 +}
  425 +
  426 +//开始倒计时
  427 +- (void)startTimer {
  428 + __block int timeout = 60; //倒计时时间
  429 +
  430 + dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
  431 +
  432 + _timer = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0,queue);
  433 +
  434 + dispatch_source_set_timer(_timer,dispatch_walltime(NULL, 0),1.0*NSEC_PER_SEC, 0); //每秒执行
  435 +
  436 + dispatch_source_set_event_handler(_timer, ^{
  437 +
  438 + if(timeout<=0){ //倒计时结束,关闭
  439 +
  440 + dispatch_source_cancel(_timer);
  441 +
  442 + dispatch_async(dispatch_get_main_queue(), ^{
  443 + _codeBtn.selected = NO;
  444 + [_codeBtn setTitle:@"" forState:UIControlStateNormal];
  445 + [_codeBtn setBackgroundImage:[UIImage imageNamed:@"dl_yzman"] forState:UIControlStateNormal];
  446 + //设置界面的按钮显示 根据自己需求设置
  447 + _codeBtn.layer.borderWidth = 0;
  448 + _codeBtn.userInteractionEnabled = YES;
  449 +
  450 + });
  451 +
  452 + }else{
  453 +
  454 + int seconds = timeout % 60;
  455 + NSString *strTime = [NSString stringWithFormat:@"%.2d", seconds];
  456 +
  457 + if(seconds == 0)strTime = [NSString stringWithFormat:@"%d",timeout];
  458 + dispatch_async(dispatch_get_main_queue(), ^{
  459 + //设置界面的按钮显示 根据自己需求设置
  460 + _codeBtn.selected = YES;
  461 + [_codeBtn setBackgroundImage:nil forState:UIControlStateNormal];
  462 + [_codeBtn setTitle:[NSString stringWithFormat:@"%@s",strTime] forState:UIControlStateSelected];
  463 + _codeBtn.layer.borderColor = UIColorMake(89, 210, 75).CGColor;
  464 + _codeBtn.layer.borderWidth = 1;
  465 + _codeBtn.layer.masksToBounds = YES;
  466 + _codeBtn.layer.cornerRadius = 11.0;
  467 + _codeBtn.userInteractionEnabled = NO;
  468 + });
  469 + timeout--;
  470 +
  471 + }
  472 + });
  473 +
  474 + dispatch_resume(_timer);
  475 +}
  476 +
  477 +- (void)countryBtn:(UIButton *)btn {
  478 + UIViewController *root = [UIApplication sharedApplication].delegate.window.rootViewController;
  479 + CNLiveChooseCountryController *vc = [[CNLiveChooseCountryController alloc] init];
  480 + vc.delegate = self;
  481 + vc.modalPresentationStyle = UIModalPresentationFullScreen;
  482 + [root presentViewController:vc animated:YES completion:nil];
  483 +
  484 +}
  485 +#pragma mark - CNLiveSelectCountryViewDelegate
  486 +- (void)chooseViewController:(CNLiveChooseCountryController *)controller countryName:(NSString *)countryName countryCode:(NSString *)countryCode{
  487 + _countryLbl.text = countryName;
  488 + _countryStr = countryName;
  489 + [_countryBtn setTitle:[NSString stringWithFormat:@"+%@",countryCode] forState:UIControlStateNormal];
  490 + _codeStr = countryCode;
  491 + NSLog(@"%@---%@",countryName,countryCode);
  492 +
  493 +}
  494 +
  495 +- (void)loginBtn:(UIButton *)btn {
  496 + if ([_telTF.text isEqualToString:@""]) {
  497 + [QMUITips showWithText:@"请输入手机号" inView:XWKeyWindow hideAfterDelay:1.5];
  498 + return;
  499 + }
  500 +
  501 + if ([_codeTF.text isEqualToString:@""]) {
  502 + [QMUITips showWithText:@"请输入验证码" inView:XWKeyWindow hideAfterDelay:1.5];
  503 + return;
  504 + }
  505 +
  506 + [self endEditing:YES];
  507 +
  508 + [QMUITips showLoading:@"登录中" inView:XWKeyWindow];
  509 +
  510 + __weak typeof(self) weakSelf = self;
  511 +// [CNLiveUserSystemCenter shortcutLoginWithUserName:_telTF.text countryCode:_codeStr verificationCode:_codeTF.text frmId:[CNTools getFrmId] success:^(id result) {
  512 +// __strong typeof(weakSelf) strongSelf = weakSelf;
  513 +// if(!strongSelf) return;
  514 +// // 连接IM
  515 +// [strongSelf connectionIM:result];
  516 +//
  517 +// } failure:^(NSDictionary *errorDic) {
  518 +// [QMUITips hideAllToastInView:AppKeyWindow animated:YES];
  519 +// [QMUITips showError:[errorDic objectForKey:@"errorMessage"] inView:AppKeyWindow hideAfterDelay:1.5];
  520 +//
  521 +// }];
  522 +
  523 +}
  524 +
  525 +#pragma mark - CNLiveThreeLoginViewDelegate
  526 +//- (void)clickedButton:(CNLiveThreeLoginView *)view type:(CNLiveSendAuthResp)type{
  527 +// if(![CNLiveNetworking isNetworking]){
  528 +// [QMUITips showError:@"无法连接网络" inView:AppKeyWindow hideAfterDelay:1.5];
  529 +// return ;
  530 +// }
  531 +// [self endEditing:YES];
  532 +// __weak typeof(self) weakSelf = self;
  533 +// [CNLiveShareImageManager send:type authRespBlock:^(CNLiveSendAuthResp type, CNLiveThirdPartyModel *userInfo, NSError *error) {
  534 +// __strong typeof(weakSelf) strongSelf = weakSelf;
  535 +// if(!strongSelf) return;
  536 +// if(error){
  537 +// [QMUITips hideAllToastInView:AppKeyWindow animated:YES];
  538 +// if(error.code == 10000){
  539 +// //用户取消
  540 +// }else{
  541 +// [QMUITips showError:@"登录失败" inView:AppKeyWindow hideAfterDelay:1.5];
  542 +// }
  543 +// return ;
  544 +// }
  545 +// CNThreeLoginModel *model = [CNThreeLoginModel cn_transformModelFromModel:userInfo];
  546 +// model.countryName = strongSelf->_countryStr;
  547 +// model.countryCode = strongSelf->_codeStr;
  548 +// model.frmId = [CNTools getFrmId];
  549 +// switch (type) {
  550 +// case CNLiveSendAuthRespWX:
  551 +// {
  552 +// model.thirdPartyPlat = @"3";
  553 +// }
  554 +// break;
  555 +// case CNLiveSendAuthRespQQ:
  556 +// {
  557 +// model.thirdPartyPlat = @"2";
  558 +// }
  559 +// break;
  560 +// case CNLiveSendAuthRespWB:
  561 +// {
  562 +// model.thirdPartyPlat = @"1";
  563 +// }
  564 +// break;
  565 +// }
  566 +// [strongSelf thirdPartyLoginWithType:type model:model];
  567 +//
  568 +// }];
  569 +//
  570 +//}
  571 +
  572 +//- (void)thirdPartyLoginWithType:(CNLiveSendAuthResp)type model:(CNThreeLoginModel *)model{
  573 +// [QMUITips showLoadingInView:AppKeyWindow];
  574 +// __weak typeof(self) weakSelf = self;
  575 +// [CNBindingManageRequest thirdPartyLoginWithType:type model:model block:^(NSURLSessionTask * _Nonnull requestTask, id _Nonnull responseObject, NSError * _Nonnull error) {
  576 +// __strong typeof(weakSelf) strongSelf = weakSelf;
  577 +// if(!strongSelf) return;
  578 +// [QMUITips hideAllToastInView:AppKeyWindow animated:YES];
  579 +// if ([responseObject isKindOfClass:[NSDictionary class]] && [responseObject[@"errorCode"] isEqualToString:@"42013"]) {
  580 +// //未注册
  581 +// CNThreeLoginViewController *vc = [[CNThreeLoginViewController alloc]initWithModel:model];
  582 +// __weak typeof(strongSelf) weakSelf = strongSelf;
  583 +// vc.block = ^(NSString * _Nonnull countryName, NSString * _Nonnull countryCode) {
  584 +// __strong typeof(weakSelf) strongSelf = weakSelf;
  585 +// if(!strongSelf) return;
  586 +// strongSelf->_countryLbl.text = countryName;
  587 +// strongSelf->_countryStr = countryName;
  588 +// strongSelf->_countryLbl.text = [NSString stringWithFormat:@"+%@",countryCode];
  589 +// strongSelf->_codeStr = countryCode;
  590 +// };
  591 +// vc.hidesBottomBarWhenPushed = YES;
  592 +// CNNavigationController *nav = [[CNNavigationController alloc] initWithRootViewController:vc];
  593 +// [[AppDelegate sharedAppDelegate].topViewController presentViewController:nav animated:YES completion:^{
  594 +//
  595 +// }];
  596 +//
  597 +// }
  598 +// else if ([responseObject isKindOfClass:[NSDictionary class]] && [responseObject[@"errorCode"] isEqualToString:@"0"]) {
  599 +// //登录成功
  600 +// // 连接IM
  601 +// [strongSelf connectionIM:responseObject];
  602 +// }
  603 +// else if ([responseObject isKindOfClass:[NSDictionary class]] ) {
  604 +// [QMUITips showError:responseObject[@"errorMessage"] inView:AppKeyWindow hideAfterDelay:1.5];
  605 +// }
  606 +// else{
  607 +// [QMUITips hideAllToastInView:AppKeyWindow animated:YES];
  608 +// [QMUITips showError:@"登录失败" inView:AppKeyWindow hideAfterDelay:1.5];
  609 +// }
  610 +// }];
  611 +//
  612 +//}
  613 +//- (void)connectionIM:(id)result{
  614 +// weakself
  615 +// NSLog(@"result:%@",result);
  616 +//
  617 +// NSMutableDictionary *resDic = [NSMutableDictionary dictionaryWithDictionary:result[@"data"]];
  618 +// NSString *deFaceUrl = [resDic objectForKey:@"faceUrl"];
  619 +// NSString *faceUrl = @"";
  620 +// if ([deFaceUrl containsString:@"/mobile/images/mobilehead/default/"]) {
  621 +// faceUrl = CNLiveNetAddDefaultHead;//网家家默认头像地址
  622 +// [resDic setValue:faceUrl forKey:@"faceUrl"];
  623 +// }
  624 +// [CNUserInfoManager saveUserinfoDic:resDic];
  625 +// [CNShareExtensionGroup writeMyInfoToShareGroup];
  626 +// //连接IM
  627 +// [_loginParam getTIMLoginToken:CNUserShareModel.uid successBlock:^(NSString *token) {
  628 +//
  629 +// _loginParam.identifier = CNUserShareModel.uid;
  630 +// _loginParam.userSig = token;
  631 +// _loginParam.tokenTime = [[NSDate date] timeIntervalSince1970];
  632 +//
  633 +// [[IMAPlatform sharedInstance] login:_loginParam succ:^{
  634 +// [NBSAppAgent setUserIdentifier:[CNLiveBusinessTools getSidIdfv]];
  635 +// [QMUITips hideAllToastInView:AppKeyWindow animated:YES];
  636 +// [AppDelegate sharedAppDelegate].loginPrepositionUrl = @"judgeGiftUrl";
  637 +// [QMUITips showSucceed:@"登录成功" inView:AppKeyWindow hideAfterDelay:1.5];
  638 +// [_loginParam saveToLocal];
  639 +// [[AppDelegate sharedAppDelegate] registNotification];
  640 +// [[IMAPlatform sharedInstance] configHost:_loginParam];
  641 +// [IMAPlatform sharedInstance].didConnectSuccess = YES;
  642 +// //电商
  643 +// NSString *userID = CNUserShareModel.uid;
  644 +// [[DSCnliveShopSDKManager sharedManager] loginUser:userID];
  645 +// //设置APP已活跃
  646 +// [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"is_Active_Application"];
  647 +// [[NSUserDefaults standardUserDefaults] synchronize];
  648 +//
  649 +//
  650 +// [AppDelegate sharedAppDelegate].loginAlert = YES;
  651 +// if ([result[@"data"][@"isNewUser"] intValue] == 0) {
  652 +// //老用户
  653 +// [[AppDelegate sharedAppDelegate] enterMainUI];
  654 +// [[AppDelegate sharedAppDelegate] registNotification];
  655 +//
  656 +// }
  657 +// else {
  658 +// //新用户
  659 +// [OpenInstallSDK reportRegister];
  660 +// CNLoginIUsernfoViewController *vc = [[CNLoginIUsernfoViewController alloc] init];
  661 +// NSString *tel = _telTF.text;
  662 +// if(_telTF.text.length == 11){
  663 +// tel = [_telTF.text stringByReplacingCharactersInRange:NSMakeRange(3, 4) withString:@"XXXX"];
  664 +// }
  665 +// NSLog(@"tel:%@",tel);
  666 +// vc.mobileStr = tel;
  667 +// [[AppDelegate sharedAppDelegate] presentViewController:vc animated:NO completion:NULL];
  668 +// }
  669 +// [[NSNotificationCenter defaultCenter] postNotificationName:kCNLive_LoginSuccess object:nil];
  670 +//
  671 +// [CNDSShopActionViewModel networkParamAction];
  672 +//
  673 +// [[IMAPlatform sharedInstance].host asyncSetAllowType:TIM_FRIEND_NEED_CONFIRM succ:^{
  674 +// NSLog(@"asyncSetAllowType Suc");
  675 +// [_loginParam saveToLocal];
  676 +//
  677 +// } fail:^(int code, NSString *msg) {
  678 +// NSLog(@"asyncSetAllowType failed : %@", msg);
  679 +// }];
  680 +//
  681 +// } fail:^(int code, NSString *msg) {
  682 +// NSLog(@"login failed : %@", msg);
  683 +// if (code == 6208) {
  684 +// //离线被踢下线重新登录
  685 +//// [weakSelf resumeLogin];
  686 +// }
  687 +// else
  688 +// [QMUITips showError:msg inView:AppKeyWindow hideAfterDelay:1.5];
  689 +// [QMUITips hideAllToastInView:AppKeyWindow animated:YES];
  690 +// }];
  691 +//
  692 +// } failedBlock:^(int code, NSString *errorMsg) {
  693 +// [QMUITips hideAllToastInView:AppKeyWindow animated:YES];
  694 +//
  695 +// }];
  696 +//}
  697 +
  698 +@end
CNLiveBLoginModule/Classes/View/CNLiveLoginView.h 0 → 100644
  1 +//
  2 +// CNLiveLoginView.h
  3 +// CNLiveLoginModule
  4 +//
  5 +// Created by 153993236@qq.com on 11/12/2019.
  6 +// Copyright (c) 2019 153993236@qq.com. All rights reserved.
  7 +//
  8 +
  9 +#import <UIKit/UIKit.h>
  10 +
  11 +NS_ASSUME_NONNULL_BEGIN
  12 +@class CNLiveLoginView;
  13 +@protocol CNLiveLoginViewDelegate <NSObject>
  14 +- (void)loginSuccess:(CNLiveLoginView *)view isNewUser:(BOOL)isNewUser result:(id _Nonnull)result;
  15 +
  16 +@end
  17 +@interface CNLiveLoginView : UIView
  18 +@property (nonatomic, weak) id<CNLiveLoginViewDelegate> delegate;
  19 +
  20 +@end
  21 +
  22 +NS_ASSUME_NONNULL_END
CNLiveBLoginModule/Classes/View/CNLiveLoginView.m 0 → 100644
  1 +//
  2 +// CNLiveLoginView.m
  3 +// CNLiveLoginModule
  4 +//
  5 +// Created by 153993236@qq.com on 11/12/2019.
  6 +// Copyright (c) 2019 153993236@qq.com. All rights reserved.
  7 +//
  8 +
  9 +#import "CNLiveLoginView.h"
  10 +
  11 +#import "YYKit.h"
  12 +#import "QMUIKit.h"
  13 +
  14 +#import <CNLiveUserSystemSDK/CNLiveUserSystemCenter.h>
  15 +#import <CNLiveUserSystemSDK/CNLiveUserSystemTypeDef.h>
  16 +#import "CNUserInfoManager.h"
  17 +#import "CNLiveEnvironment.h"
  18 +#import "CNLiveCategory.h"
  19 +#import "TIMAdapter.h"
  20 +#import "CommonLibrary.h"
  21 +
  22 +#import "CNLiveLoginRequest.h"
  23 +
  24 +#import "CNLiveLoginCountryView.h"
  25 +#import "CNLiveLoginTextField.h"
  26 +#import "CNLiveCountDownButton.h"
  27 +//#import "XWLoginNotification.h"
  28 +
  29 +@interface CNLiveLoginView()<UITextFieldDelegate, CNLiveLoginCountryViewDelegate,CNLiveCountDownButtonDataSource, CNLiveCountDownButtonDelegate>
  30 +{
  31 + NSString *_countryCode; // 国家Code
  32 + NSString *_verificationCode; // 验证码
  33 +}
  34 +@property (nonatomic, weak) UIImageView *logo;
  35 +@property (nonatomic, weak) CNLiveLoginCountryView *country;
  36 +@property (nonatomic, weak) CNLiveLoginTextField *account;
  37 +@property (nonatomic, weak) CNLiveLoginTextField *code;
  38 +@property (nonatomic, strong) CNLiveCountDownButton *countDown;
  39 +
  40 +@property (nonatomic, weak) UILabel *tips;
  41 +@property (nonatomic, weak) UIButton *login;
  42 +
  43 +@end
  44 +
  45 +@implementation CNLiveLoginView
  46 +#define XWKeyWindow [UIApplication sharedApplication].keyWindow
  47 +
  48 +static NSInteger const rowHeight = 40;
  49 +static NSInteger const space = 16;
  50 +static const NSInteger timeValue = 1.5;
  51 +
  52 +- (instancetype)initWithFrame:(CGRect)frame{
  53 +
  54 + self = [super initWithFrame:frame];
  55 + if (self) {
  56 + self.userInteractionEnabled = YES;
  57 + _countryCode = @"86";
  58 + [self createSubviews:frame];
  59 +
  60 + }
  61 + return self;
  62 +
  63 +}
  64 +- (void)createSubviews:(CGRect)frame{
  65 + UIImageView *logo = [[UIImageView alloc] initWithFrame:CGRectMake((frame.size.width-75)/2.0, 0, 75, 100)];
  66 + UIImage *image = [self getImageWithImageName:Business?@"login_logo_b":@"login_logo" bundleName:@"CNLiveBLoginModule" targetClass:[self class]];
  67 + logo.image = image;
  68 + [self addSubview:logo];
  69 + self.logo = logo;
  70 +
  71 + CNLiveLoginCountryView *country = [[CNLiveLoginCountryView alloc] initWithFrame:CGRectMake(0, logo.bottom+space, frame.size.width, rowHeight)];
  72 + country.delegate = self;
  73 + [self addSubview:country];
  74 + self.country = country;
  75 +
  76 + CNLiveLoginTextField *account = [[CNLiveLoginTextField alloc] initWithFrame:CGRectMake(country.left, country.bottom+space, frame.size.width, rowHeight)];
  77 + account.keyboardType = UIKeyboardTypeNumberPad;
  78 + account.placeholder = @"请输入手机号";
  79 + account.textColor = [UIColor colorWithRed:51/255.0 green:51/255.0 blue:51/255.0 alpha:1.0];
  80 + account.placeholderColor = [UIColor colorWithRed:173/255.0 green:173/255.0 blue:173/255.0 alpha:1.0];
  81 + account.font = [UIFont systemFontOfSize:14];
  82 + account.textAlignment = NSTextAlignmentLeft;
  83 + [account addTarget:self action:@selector(textFieldDidChange:) forControlEvents:UIControlEventEditingChanged];
  84 + account.clearButtonMode = UITextFieldViewModeWhileEditing;
  85 + account.delegate = self;
  86 + [self addSubview:account];
  87 + self.account = account;
  88 +
  89 + CNLiveLoginTextField *code = [[CNLiveLoginTextField alloc] initWithFrame:CGRectMake(country.left, account.bottom+space, frame.size.width/2.0, rowHeight)];
  90 + code.keyboardType = UIKeyboardTypeNumberPad;
  91 + code.placeholder = @"请输入验证码";
  92 + code.textColor = [UIColor colorWithRed:51/255.0 green:51/255.0 blue:51/255.0 alpha:1.0];
  93 + code.placeholderColor = [UIColor colorWithRed:173/255.0 green:173/255.0 blue:173/255.0 alpha:1.0];
  94 + code.font = [UIFont systemFontOfSize:14];
  95 + code.textAlignment = NSTextAlignmentLeft;
  96 + [code addTarget:self action:@selector(textFieldDidChange:) forControlEvents:UIControlEventEditingChanged];
  97 + code.clearButtonMode = UITextFieldViewModeWhileEditing;
  98 + code.delegate = self;
  99 + [self addSubview:code];
  100 + self.code = code;
  101 +
  102 + CNLiveCountDownButton *countDown = [CNLiveCountDownButton buttonWithType:UIButtonTypeCustom];
  103 + countDown.dataSource = self;
  104 + countDown.delegate = self;
  105 + countDown.frame = CGRectMake(frame.size.width-80, account.bottom+space+10, 80, rowHeight-10);
  106 + UIImage *image2 = [self getImageWithImageName:Business?@"login_get_code_b":@"login_get_code" bundleName:@"CNLiveBLoginModule" targetClass:[self class]];
  107 + [countDown setImage:image2 forState:UIControlStateNormal];
  108 + countDown.adjustsImageWhenHighlighted = NO;
  109 + [countDown setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
  110 + countDown.titleLabel.font = [UIFont systemFontOfSize:12.0];
  111 + countDown.layer.cornerRadius = 15;
  112 + countDown.layer.masksToBounds = YES;
  113 + [self addSubview:countDown];
  114 + self.countDown = countDown;
  115 +
  116 + UILabel *tips = [[UILabel alloc] initWithFrame:CGRectMake(0, code.bottom+space, frame.size.width, rowHeight/4.0)];
  117 + tips.textColor = [UIColor colorWithRed:153/255.0 green:153/255.0 blue:153/255.0 alpha:1.0];
  118 + tips.font = [UIFont systemFontOfSize:10];
  119 + tips.textAlignment = NSTextAlignmentCenter;
  120 + tips.text = @"为了保证您的支付安全及个人信息隐私,请使用手机号码登录";
  121 + [self addSubview:tips];
  122 + self.tips = tips;
  123 +
  124 + UIButton *login = [UIButton buttonWithType:UIButtonTypeCustom];
  125 + login.frame = CGRectMake(5, tips.bottom+space, frame.size.width-10, rowHeight);
  126 + [login setTitle:@"登录" forState:UIControlStateNormal];
  127 + [login setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
  128 + login.titleLabel.font = [UIFont systemFontOfSize:15.0];
  129 + UIColor *color = Business?[UIColor colorWithRed:72/255.0 green:168/255.0 blue:249/255.0 alpha:1.0]:[UIColor colorWithRed:35/255.0 green:212/255.0 blue:30/255.0 alpha:1.0];
  130 + login.backgroundColor = color;
  131 + login.layer.cornerRadius = 20;
  132 + login.layer.masksToBounds = YES;
  133 + login.adjustsImageWhenHighlighted = NO;
  134 + [login addTarget:self action:@selector(loginDidClicked:) forControlEvents:UIControlEventTouchUpInside];
  135 + [self addSubview:login];
  136 + self.login = login;
  137 +
  138 +}
  139 +
  140 +#pragma mark - UITextFieldDelegate
  141 +- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField{
  142 + if ([textField isEqual:_account] || [textField isEqual:_code]) {
  143 + return YES;
  144 + }
  145 + else {
  146 + return YES;
  147 + }
  148 +}
  149 +
  150 +- (void)textFieldDidChange:(UITextField *)textField {
  151 + if (![_account.text isEqualToString:@""] && ![_code.text isEqualToString:@""]) {
  152 + _login.enabled = YES;
  153 + }
  154 + else {
  155 + _login.enabled = NO;
  156 + }
  157 +}
  158 +
  159 +- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {
  160 + if ([textField isEqual:_account]) {
  161 + NSInteger maxTextLength = 20;
  162 + if(string.length == 0) {
  163 + //判断是不是删除键
  164 + return YES;
  165 + }
  166 + else if(textField.text.length >= maxTextLength) {
  167 + NSLog(@"输入的字符个数大于20,忽略输入");
  168 + return NO;
  169 + }
  170 + else if (![self isNum:string]) {
  171 + return NO;
  172 + }
  173 + else if (textField.text.length + string.length > maxTextLength){
  174 + NSInteger length = textField.text.length;
  175 + NSInteger needLen = maxTextLength - length;
  176 + textField.text = [textField.text stringByAppendingString:[string substringToIndex:needLen]];
  177 + return NO;
  178 + }
  179 + else{
  180 + return YES;
  181 + }
  182 + }
  183 + else if ([textField isEqual:self.code]){
  184 + NSInteger maxTextLength = 6;
  185 + if(string.length == 0) {
  186 + //判断是不是删除键
  187 + return YES;
  188 + }
  189 + else if(textField.text.length >= maxTextLength) {
  190 + NSLog(@"输入的字符个数大于6,忽略输入");
  191 + return NO;
  192 + }
  193 + else if (![self isNum:string]) {
  194 + return NO;
  195 + }
  196 + else if (textField.text.length + string.length > maxTextLength){
  197 + NSInteger length = textField.text.length;
  198 + NSInteger needLen = maxTextLength - length;
  199 + textField.text = [textField.text stringByAppendingString:[string substringToIndex:needLen]];
  200 + return NO;
  201 + }
  202 + else{
  203 + return YES;
  204 + }
  205 + }
  206 + else{
  207 + return YES;
  208 + }
  209 +}
  210 +
  211 +/** 判断是否为纯数字 */
  212 +- (BOOL)isNum:(NSString *)checkedNumString {
  213 + checkedNumString = [checkedNumString stringByTrimmingCharactersInSet:[NSCharacterSet decimalDigitCharacterSet]];
  214 + if(checkedNumString.length > 0) {
  215 + return NO;
  216 + }
  217 + return YES;
  218 +}
  219 +
  220 +/*
  221 +// Only override drawRect: if you perform custom drawing.
  222 +// An empty implementation adversely affects performance during animation.
  223 +- (void)drawRect:(CGRect)rect {
  224 + // Drawing code
  225 +}
  226 +*/
  227 +
  228 +#pragma mark - CNLiveLoginCountryViewDelegate
  229 +- (void)chooseCountryName:(NSString *)countryName countryCode:(NSString *)countryCode{
  230 + [_account resignFirstResponder];
  231 + [_code resignFirstResponder];
  232 + if(![_countryCode isEqualToString:countryCode]){
  233 + _countryCode = countryCode;
  234 + }
  235 +}
  236 +#pragma mark - CNLiveCountDownButton DataSource
  237 +// 设置倒计时总秒数
  238 +- (NSInteger)startCountDownNumOfCountDownButton:(CNLiveCountDownButton *)countdownButton {
  239 + return 60;
  240 +}
  241 +
  242 +#pragma mark - CNLiveCountDownButton Delegate
  243 +// 倒计时按钮点击
  244 +- (void)countDownButtonDidClick:(CNLiveCountDownButton *)button {
  245 + [_account resignFirstResponder];
  246 + [_code resignFirstResponder];
  247 + //获取验证码
  248 + if ([_account.text isEqualToString:@""]) {
  249 + [QMUITips showError:@"请输入手机号" inView:XWKeyWindow hideAfterDelay:timeValue];
  250 + return;
  251 + }
  252 + // 按钮点击后将enabled设置为NO
  253 + button.userInteractionEnabled = NO;
  254 +
  255 + __weak typeof(self) weakSelf = self;
  256 + [QMUITips showLoadingInView:XWKeyWindow];
  257 + [CNLiveUserSystemCenter verificationCodeType:VerificationCodeTypeShortcutLogin mobile:_account.text countryCode:_countryCode success:^(id result) {
  258 + button.userInteractionEnabled = YES;
  259 + __strong typeof(weakSelf) strongSelf = weakSelf;
  260 + if(!strongSelf) return;
  261 + [QMUITips hideAllToastInView:XWKeyWindow animated:YES];
  262 + [QMUITips showSucceed:@"验证码已发送" inView:XWKeyWindow hideAfterDelay:timeValue];
  263 + button.backgroundColor = [UIColor colorWithRed:222/255.0 green:222/255.0 blue:222/255.0 alpha:1.0];
  264 + button.frame = CGRectMake(self.frame.size.width-110, self.account.bottom+space+10, 110, rowHeight-10);
  265 + [button setImage:nil forState:UIControlStateNormal];
  266 + [button setTitle:[NSString stringWithFormat:@"%d秒后重新发送", 60] forState:UIControlStateNormal];
  267 + [button startCountDown];
  268 +
  269 + } failure:^(NSDictionary *errorDic) {
  270 + button.userInteractionEnabled = YES;
  271 + __strong typeof(weakSelf) strongSelf = weakSelf;
  272 + if(!strongSelf) return;
  273 + [QMUITips hideAllToastInView:XWKeyWindow animated:YES];
  274 + if ([errorDic[@"errorCode"] integerValue] == 408) {
  275 + [QMUITips showError:@"请输入正确的手机号" inView:XWKeyWindow hideAfterDelay:timeValue];
  276 + }else{
  277 + [QMUITips showError:[errorDic objectForKey:@"errorMessage"] inView:XWKeyWindow hideAfterDelay:timeValue];
  278 + }
  279 +
  280 + }];
  281 +
  282 +}
  283 +
  284 +// 倒计时进行中
  285 +- (void)countDownButtonDidCountDown:(CNLiveCountDownButton *)button countDownNum:(NSInteger)countDownNum {
  286 + if(button.frame.size.width != 110){
  287 + button.frame = CGRectMake(self.frame.size.width-110, self.account.bottom+space+10, 110, rowHeight-10);
  288 + }
  289 + NSString *title = [NSString stringWithFormat:@"%ld秒后重新发送", countDownNum];
  290 + [button setTitle:title forState:UIControlStateNormal];
  291 +
  292 +}
  293 +
  294 +// 倒计时结束
  295 +- (void)countDownButtonDidEndCountDown:(CNLiveCountDownButton *)button {
  296 + button.frame = CGRectMake(self.frame.size.width-80, self.account.bottom+space+10, 80, rowHeight-10);
  297 + button.backgroundColor = [UIColor whiteColor];
  298 + button.userInteractionEnabled = YES;
  299 + [button setTitle:@"" forState:UIControlStateNormal];
  300 + UIImage *image2 = [self getImageWithImageName:Business?@"login_get_code_b":@"login_get_code" bundleName:@"CNLiveBLoginModule" targetClass:[self class]];
  301 + [button setImage:image2 forState:UIControlStateNormal];
  302 +}
  303 +
  304 +#pragma mark - Action
  305 +- (void)loginDidClicked:(UIButton *)btn{
  306 + [_account resignFirstResponder];
  307 + [_code resignFirstResponder];
  308 + //登录
  309 + if ([_account.text isEqualToString:@""]) {
  310 + [QMUITips showError:@"请输入手机号" inView:XWKeyWindow hideAfterDelay:timeValue];
  311 + return;
  312 + }
  313 + if ([_code.text isEqualToString:@""]) {
  314 + [QMUITips showError:@"请输入验证码" inView:XWKeyWindow hideAfterDelay:timeValue];
  315 + return;
  316 + }
  317 + btn.userInteractionEnabled = NO;
  318 + // 隐藏键盘
  319 + [self.superview endEditing:YES];
  320 +
  321 + [QMUITips showLoading:@"登录中" inView:XWKeyWindow];
  322 +
  323 + __weak typeof(self) weakSelf = self;
  324 + [CNLiveUserSystemCenter shortcutLoginWithUserName:_account.text countryCode:_countryCode verificationCode:_code.text frmId:@"apple" success:^(id result) {
  325 + btn.userInteractionEnabled = YES;
  326 + __strong typeof(weakSelf) strongSelf = weakSelf;
  327 + if(!strongSelf) return;
  328 + [QMUITips hideAllToastInView:XWKeyWindow animated:YES];
  329 + // 连接IM
  330 + [strongSelf connectionIM:result];
  331 +
  332 + } failure:^(NSDictionary *errorDic) {
  333 + btn.userInteractionEnabled = YES;
  334 + __strong typeof(weakSelf) strongSelf = weakSelf;
  335 + if(!strongSelf) return;
  336 + [QMUITips hideAllToastInView:XWKeyWindow animated:YES];
  337 + [QMUITips showError:[errorDic objectForKey:@"errorMessage"] inView:XWKeyWindow hideAfterDelay:timeValue];
  338 + }];
  339 +}
  340 +
  341 +#pragma mark - 连接IM
  342 +- (void)connectionIM:(id)result{
  343 + NSMutableDictionary *dic = [NSMutableDictionary dictionaryWithDictionary:result[@"data"]];
  344 + NSString *faceUrl = [dic objectForKey:@"faceUrl"];
  345 + if ([faceUrl containsString:@"/mobile/images/mobilehead/default/"]) {
  346 + //网家家默认头像地址
  347 + [dic setValue:CNLiveNetAddDefaultHead forKey:@"faceUrl"];
  348 + }
  349 + [CNUserInfoManager saveUserinfoDic:dic];
  350 +
  351 + // YES 新用户 NO 老用户
  352 + BOOL isNewUser = [dic[@"isNewUser"] intValue] != 0;
  353 + if (self.delegate && [self.delegate respondsToSelector:@selector(loginSuccess:isNewUser:result:)]) {
  354 + [self.delegate loginSuccess:self isNewUser:isNewUser result:result];
  355 + }
  356 +}
  357 +
  358 +@end