Commit 5870efa88920e724e969e4398d691acb6d1ce201

Authored by liushiyu
1 parent f89b8f7b

提示toast 添加修改头像逻辑

Showing 23 changed files with 557 additions and 290 deletions
... ... @@ -6,6 +6,7 @@ source 'https://cdn.cocoapods.org'
6 6  
7 7 source 'http://bj.gitlab.cnlive.com/ios-team/CNLiveRepos.git'
8 8 source 'http://bj.gitlab.cnlive.com/DSIOSTeam/DSSpecRepos.git'
  9 +use_frameworks!
9 10  
10 11 target 'metaCode' do
11 12 # Comment the next line if you don't want to use dynamic frameworks
... ... @@ -26,10 +27,10 @@ target 'metaCode' do
26 27 pod 'MBProgressHUD'
27 28 #模型转换工具
28 29 pod 'HandyJSON'
29   - #轻量级缓存工具
30   - pod 'SwiftyUserDefaults'
31 30 #图片视频选择器
32 31 pod 'HXPHPicker'
  32 + #七牛
  33 + pod 'Qiniu'
33 34 #加载GIF
34 35 pod 'SwiftGifOrigin', '~> 1.7.0'
35 36  
... ...
metaCode.xcodeproj/project.pbxproj
... ... @@ -20,10 +20,12 @@
20 20 790D01A52A2DF65E00C5978D /* CNLiveLoginPickerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 790D01A42A2DF65E00C5978D /* CNLiveLoginPickerView.swift */; };
21 21 790D01A72A2DF84C00C5978D /* countries.plist in Resources */ = {isa = PBXBuildFile; fileRef = 790D01A62A2DF84C00C5978D /* countries.plist */; };
22 22 79282A3C2A2EDC2500B5F8CF /* NSString+CNLiveExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 79282A3B2A2EDC2500B5F8CF /* NSString+CNLiveExtensions.swift */; };
23   - 79282A3E2A2EFDA000B5F8CF /* CNLiveLoginModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 79282A3D2A2EFDA000B5F8CF /* CNLiveLoginModel.swift */; };
24 23 79282A402A2F055100B5F8CF /* CNLiveConfigUserInfo.swift in Sources */ = {isa = PBXBuildFile; fileRef = 79282A3F2A2F055100B5F8CF /* CNLiveConfigUserInfo.swift */; };
25 24 79282A442A2F1C1E00B5F8CF /* CNLiveLoginAuthView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 79282A432A2F1C1E00B5F8CF /* CNLiveLoginAuthView.swift */; };
26 25 79282A462A2F457D00B5F8CF /* CNLiveMineViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 79282A452A2F457D00B5F8CF /* CNLiveMineViewController.swift */; };
  26 + 792E57D72A3AA2AC005834DB /* CNLiveCommonJsonUtil.swift in Sources */ = {isa = PBXBuildFile; fileRef = 792E57D62A3AA2AC005834DB /* CNLiveCommonJsonUtil.swift */; };
  27 + 792E57D92A3AA2F2005834DB /* CNLiveCommonBaseModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 792E57D82A3AA2F2005834DB /* CNLiveCommonBaseModel.swift */; };
  28 + 792E57DB2A3AE9F4005834DB /* CNLiveCommonQiniuTool.swift in Sources */ = {isa = PBXBuildFile; fileRef = 792E57DA2A3AE9F4005834DB /* CNLiveCommonQiniuTool.swift */; };
27 29 79396EED2A319F220053E1AF /* NSObject+CNLiveCurrentVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 79396EEC2A319F220053E1AF /* NSObject+CNLiveCurrentVC.swift */; };
28 30 79396EF12A31C21B0053E1AF /* CNLiveInfoShowViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 79396EF02A31C21B0053E1AF /* CNLiveInfoShowViewController.swift */; };
29 31 796398942A260C0100D045EB /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7963988D2A260C0100D045EB /* AppDelegate.swift */; };
... ... @@ -35,7 +37,6 @@
35 37 798A44EE2A305AAC00815935 /* CNLiveBaseNavigationController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 798A44ED2A305AAC00815935 /* CNLiveBaseNavigationController.swift */; };
36 38 798A44F02A305BC200815935 /* UIButton+CNLiveExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 798A44EF2A305BC200815935 /* UIButton+CNLiveExtension.swift */; };
37 39 798A44F22A30674200815935 /* CNLiveMineSubBodyListView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 798A44F12A30674200815935 /* CNLiveMineSubBodyListView.swift */; };
38   - 798A44F62A3077ED00815935 /* CNLiveTips.swift in Sources */ = {isa = PBXBuildFile; fileRef = 798A44F42A3077ED00815935 /* CNLiveTips.swift */; };
39 40 798A44F72A3077ED00815935 /* CNLiveHotButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 798A44F52A3077ED00815935 /* CNLiveHotButton.swift */; };
40 41 798A44F92A30835400815935 /* CNLiveHelpFeedBackViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 798A44F82A30835400815935 /* CNLiveHelpFeedBackViewController.swift */; };
41 42 798A44FB2A30999900815935 /* CNLiveAlertTool.swift in Sources */ = {isa = PBXBuildFile; fileRef = 798A44FA2A30999900815935 /* CNLiveAlertTool.swift */; };
... ... @@ -44,7 +45,6 @@
44 45 79A68C4A2A26E6CE00DC3B43 /* (null) in Sources */ = {isa = PBXBuildFile; };
45 46 79A68C4C2A26EA6000DC3B43 /* (null) in Sources */ = {isa = PBXBuildFile; };
46 47 79F4B1162A32B96B00993C03 /* CNLiveMineInfoViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 79F4B1152A32B96B00993C03 /* CNLiveMineInfoViewController.swift */; };
47   - 79F4B1182A32C5FA00993C03 /* CNLiveBaseMoel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 79F4B1172A32C5FA00993C03 /* CNLiveBaseMoel.swift */; };
48 48 79F4B11A2A32F21400993C03 /* CNLiveMineNickViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 79F4B1192A32F21400993C03 /* CNLiveMineNickViewController.swift */; };
49 49 79F4B11C2A33036E00993C03 /* CNLiveMineInfoAlertView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 79F4B11B2A33036E00993C03 /* CNLiveMineInfoAlertView.swift */; };
50 50 7C2703302A36CBE30061EC50 /* CNCertificationView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7C27032F2A36CBE30061EC50 /* CNCertificationView.swift */; };
... ... @@ -110,10 +110,12 @@
110 110 790D01A42A2DF65E00C5978D /* CNLiveLoginPickerView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNLiveLoginPickerView.swift; sourceTree = "<group>"; };
111 111 790D01A62A2DF84C00C5978D /* countries.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = countries.plist; sourceTree = "<group>"; };
112 112 79282A3B2A2EDC2500B5F8CF /* NSString+CNLiveExtensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "NSString+CNLiveExtensions.swift"; sourceTree = "<group>"; };
113   - 79282A3D2A2EFDA000B5F8CF /* CNLiveLoginModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNLiveLoginModel.swift; sourceTree = "<group>"; };
114 113 79282A3F2A2F055100B5F8CF /* CNLiveConfigUserInfo.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNLiveConfigUserInfo.swift; sourceTree = "<group>"; };
115 114 79282A432A2F1C1E00B5F8CF /* CNLiveLoginAuthView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNLiveLoginAuthView.swift; sourceTree = "<group>"; };
116 115 79282A452A2F457D00B5F8CF /* CNLiveMineViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNLiveMineViewController.swift; sourceTree = "<group>"; };
  116 + 792E57D62A3AA2AC005834DB /* CNLiveCommonJsonUtil.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNLiveCommonJsonUtil.swift; sourceTree = "<group>"; };
  117 + 792E57D82A3AA2F2005834DB /* CNLiveCommonBaseModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNLiveCommonBaseModel.swift; sourceTree = "<group>"; };
  118 + 792E57DA2A3AE9F4005834DB /* CNLiveCommonQiniuTool.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNLiveCommonQiniuTool.swift; sourceTree = "<group>"; };
117 119 79396EEC2A319F220053E1AF /* NSObject+CNLiveCurrentVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "NSObject+CNLiveCurrentVC.swift"; sourceTree = "<group>"; };
118 120 79396EF02A31C21B0053E1AF /* CNLiveInfoShowViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNLiveInfoShowViewController.swift; sourceTree = "<group>"; };
119 121 7963988D2A260C0100D045EB /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
... ... @@ -125,7 +127,6 @@
125 127 798A44ED2A305AAC00815935 /* CNLiveBaseNavigationController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNLiveBaseNavigationController.swift; sourceTree = "<group>"; };
126 128 798A44EF2A305BC200815935 /* UIButton+CNLiveExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIButton+CNLiveExtension.swift"; sourceTree = "<group>"; };
127 129 798A44F12A30674200815935 /* CNLiveMineSubBodyListView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNLiveMineSubBodyListView.swift; sourceTree = "<group>"; };
128   - 798A44F42A3077ED00815935 /* CNLiveTips.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CNLiveTips.swift; sourceTree = "<group>"; };
129 130 798A44F52A3077ED00815935 /* CNLiveHotButton.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CNLiveHotButton.swift; sourceTree = "<group>"; };
130 131 798A44F82A30835400815935 /* CNLiveHelpFeedBackViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNLiveHelpFeedBackViewController.swift; sourceTree = "<group>"; };
131 132 798A44FA2A30999900815935 /* CNLiveAlertTool.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNLiveAlertTool.swift; sourceTree = "<group>"; };
... ... @@ -133,7 +134,6 @@
133 134 798A44FE2A30A0A800815935 /* CNLiveInputFeedBackViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNLiveInputFeedBackViewController.swift; sourceTree = "<group>"; };
134 135 79A68C512A26F59C00DC3B43 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = metaCode/Info.plist; sourceTree = "<group>"; };
135 136 79F4B1152A32B96B00993C03 /* CNLiveMineInfoViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNLiveMineInfoViewController.swift; sourceTree = "<group>"; };
136   - 79F4B1172A32C5FA00993C03 /* CNLiveBaseMoel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNLiveBaseMoel.swift; sourceTree = "<group>"; };
137 137 79F4B1192A32F21400993C03 /* CNLiveMineNickViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNLiveMineNickViewController.swift; sourceTree = "<group>"; };
138 138 79F4B11B2A33036E00993C03 /* CNLiveMineInfoAlertView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNLiveMineInfoAlertView.swift; sourceTree = "<group>"; };
139 139 7C27032F2A36CBE30061EC50 /* CNCertificationView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNCertificationView.swift; sourceTree = "<group>"; };
... ... @@ -242,7 +242,6 @@
242 242 isa = PBXGroup;
243 243 children = (
244 244 790D019E2A2DD66E00C5978D /* CNLiveLoginViewModel.swift */,
245   - 79282A3D2A2EFDA000B5F8CF /* CNLiveLoginModel.swift */,
246 245 );
247 246 path = ViewModel;
248 247 sourceTree = "<group>";
... ... @@ -296,6 +295,16 @@
296 295 path = Controller;
297 296 sourceTree = "<group>";
298 297 };
  298 + 792E57D52A3AA28E005834DB /* Util */ = {
  299 + isa = PBXGroup;
  300 + children = (
  301 + 792E57D62A3AA2AC005834DB /* CNLiveCommonJsonUtil.swift */,
  302 + 792E57D82A3AA2F2005834DB /* CNLiveCommonBaseModel.swift */,
  303 + 792E57DA2A3AE9F4005834DB /* CNLiveCommonQiniuTool.swift */,
  304 + );
  305 + path = Util;
  306 + sourceTree = "<group>";
  307 + };
299 308 7963988A2A260B3300D045EB /* Classes */ = {
300 309 isa = PBXGroup;
301 310 children = (
... ... @@ -359,6 +368,7 @@
359 368 796398912A260C0100D045EB /* Common */ = {
360 369 isa = PBXGroup;
361 370 children = (
  371 + 792E57D52A3AA28E005834DB /* Util */,
362 372 7963989B2A260E6200D045EB /* Base */,
363 373 );
364 374 path = Common;
... ... @@ -391,7 +401,6 @@
391 401 7963989C2A260E6200D045EB /* CNLiveBaseViewController.swift */,
392 402 7C4931282A2D8BA8000E44B4 /* CNLiveBaseTabBarViewController.swift */,
393 403 798A44ED2A305AAC00815935 /* CNLiveBaseNavigationController.swift */,
394   - 79F4B1172A32C5FA00993C03 /* CNLiveBaseMoel.swift */,
395 404 );
396 405 path = Base;
397 406 sourceTree = "<group>";
... ... @@ -418,7 +427,6 @@
418 427 798A44F32A3077ED00815935 /* CustomView */ = {
419 428 isa = PBXGroup;
420 429 children = (
421   - 798A44F42A3077ED00815935 /* CNLiveTips.swift */,
422 430 798A44F52A3077ED00815935 /* CNLiveHotButton.swift */,
423 431 798A44FA2A30999900815935 /* CNLiveAlertTool.swift */,
424 432 );
... ... @@ -798,20 +806,21 @@
798 806 7C4931382A307BDB000E44B4 /* CNHomePageGuideView.swift in Sources */,
799 807 7CD6753E2A2740B0008354C1 /* CNPayMoneyCodeView.swift in Sources */,
800 808 7CD675402A2740B0008354C1 /* CNCollectMoneyCodeView.swift in Sources */,
  809 + 792E57D92A3AA2F2005834DB /* CNLiveCommonBaseModel.swift in Sources */,
801 810 798A44FD2A309EBA00815935 /* CNLiveTypeFeedBackViewController.swift in Sources */,
802 811 7CD6754F2A2840B9008354C1 /* CNMetaCodeHomePageController.swift in Sources */,
  812 + 792E57DB2A3AE9F4005834DB /* CNLiveCommonQiniuTool.swift in Sources */,
803 813 7CD675472A274167008354C1 /* NewPagedFlowView.m in Sources */,
804   - 798A44F62A3077ED00815935 /* CNLiveTips.swift in Sources */,
805 814 79F4B11A2A32F21400993C03 /* CNLiveMineNickViewController.swift in Sources */,
806 815 798A44FF2A30A0A800815935 /* CNLiveInputFeedBackViewController.swift in Sources */,
807 816 79282A442A2F1C1E00B5F8CF /* CNLiveLoginAuthView.swift in Sources */,
808 817 7C2703302A36CBE30061EC50 /* CNCertificationView.swift in Sources */,
  818 + 792E57D72A3AA2AC005834DB /* CNLiveCommonJsonUtil.swift in Sources */,
809 819 790D01A32A2DDBA300C5978D /* CNLiveConfigManager.swift in Sources */,
810 820 7C2703332A36CC660061EC50 /* CNLiveGlobalBlock.swift in Sources */,
811 821 798A44EA2A30135D00815935 /* CNLiveMineBodyListView.swift in Sources */,
812 822 798A44F92A30835400815935 /* CNLiveHelpFeedBackViewController.swift in Sources */,
813 823 79A68C4A2A26E6CE00DC3B43 /* (null) in Sources */,
814   - 79282A3E2A2EFDA000B5F8CF /* CNLiveLoginModel.swift in Sources */,
815 824 790D01852A2D89E100C5978D /* UIColor+CNHexColor.swift in Sources */,
816 825 79396EED2A319F220053E1AF /* NSObject+CNLiveCurrentVC.swift in Sources */,
817 826 7C4931312A2F142F000E44B4 /* CNHomePageBackgroupView.swift in Sources */,
... ... @@ -824,7 +833,6 @@
824 833 798A44EE2A305AAC00815935 /* CNLiveBaseNavigationController.swift in Sources */,
825 834 7CD675422A2740F8008354C1 /* CNCustomIndexView.swift in Sources */,
826 835 7C4931292A2D8BA8000E44B4 /* CNLiveBaseTabBarViewController.swift in Sources */,
827   - 79F4B1182A32C5FA00993C03 /* CNLiveBaseMoel.swift in Sources */,
828 836 79F4B1162A32B96B00993C03 /* CNLiveMineInfoViewController.swift in Sources */,
829 837 7CD6753F2A2740B0008354C1 /* CNTopCollectMoneyRemindView.swift in Sources */,
830 838 7CD6753C2A2740B0008354C1 /* CNBottomPayMoneyRemindView.swift in Sources */,
... ...
metaCode/Classes/Common/Base/CNLiveBaseTabBarViewController.swift
... ... @@ -39,12 +39,10 @@ class CNLiveBaseTabBarViewController: UITabBarController
39 39  
40 40 override func viewWillAppear(_ animated: Bool) {
41 41 super.viewWillAppear(animated)
42   -
43 42 }
44 43 override func viewDidAppear(_ animated: Bool) {
45 44 super.viewDidAppear(animated)
46   -
47   -
  45 + print("获取用户用户数据=====>\(UserInfoManager.shared.userInfo.uid)")
48 46 }
49 47 // MARK: - 控制器的信息
50 48 func setUpTabBar() {
... ...
metaCode/Classes/Common/Base/CNLiveBaseMoel.swift renamed to metaCode/Classes/Common/Util/CNLiveCommonBaseModel.swift
1 1 //
2   -// CNLiveBaseMoel.swift
  2 +// CNLiveCommonBaseModel.swift
3 3 // metaCode
4 4 //
5   -// Created by open on 2023/6/9.
  5 +// Created by open on 2023/6/15.
6 6 //
7 7  
8 8 import Foundation
  9 +import UIKit
9 10 import HandyJSON
10 11  
11 12 class BaseModel: HandyJSON {
12 13  
13 14 required init() {}
14   -
  15 +
15 16 func mapping(mapper: HelpingMapper) {
16 17  
17 18 }
... ...
metaCode/Classes/Common/Util/CNLiveCommonJsonUtil.swift 0 → 100644
  1 +//
  2 +// CNLiveCommonJsonUtil.swift
  3 +// metaCode
  4 +//
  5 +// Created by open on 2023/6/15.
  6 +//
  7 +
  8 +import Foundation
  9 +
  10 +import UIKit
  11 +import HandyJSON
  12 +
  13 +class JsonUtil: NSObject {
  14 + /**
  15 + * Json转对象
  16 + */
  17 + static func jsonToModel(_ jsonStr:String,_ modelType:HandyJSON.Type) -> BaseModel {
  18 + if jsonStr == "" || jsonStr.count == 0 {
  19 + #if DEBUG
  20 + print("jsonoModel:字符串为空")
  21 + #endif
  22 + return BaseModel()
  23 + }
  24 + return modelType.deserialize(from: jsonStr) as! BaseModel
  25 +
  26 + }
  27 +
  28 + /**
  29 + * Json转数组对象
  30 + */
  31 + static func jsonArrayToModel(_ jsonArrayStr:String, _ modelType:HandyJSON.Type) ->[BaseModel] {
  32 + if jsonArrayStr == "" || jsonArrayStr.count == 0 {
  33 + #if DEBUG
  34 + print("jsonToModelArray:字符串为空")
  35 + #endif
  36 + return []
  37 + }
  38 + var modelArray:[BaseModel] = []
  39 + let data = jsonArrayStr.data(using: String.Encoding.utf8)
  40 + let peoplesArray = try! JSONSerialization.jsonObject(with:data!, options: JSONSerialization.ReadingOptions()) as? [AnyObject]
  41 + for people in peoplesArray! {
  42 + modelArray.append(dictionaryToModel(people as! [String : Any], modelType))
  43 + }
  44 + return modelArray
  45 +
  46 + }
  47 +
  48 + /**
  49 + * 字典转对象
  50 + */
  51 + static func dictionaryToModel(_ dictionStr:[String:Any],_ modelType:HandyJSON.Type) -> BaseModel {
  52 + if dictionStr.count == 0 {
  53 + #if DEBUG
  54 + print("dictionaryToModel:字符串为空")
  55 + #endif
  56 + return BaseModel()
  57 + }
  58 + return modelType.deserialize(from: dictionStr) as! BaseModel
  59 + }
  60 +
  61 + /**
  62 + * 对象转JSON
  63 + */
  64 + static func modelToJson(_ model:BaseModel?) -> String {
  65 + if model == nil {
  66 + #if DEBUG
  67 + print("modelToJson:model为空")
  68 + #endif
  69 + return ""
  70 + }
  71 + return (model?.toJSONString())!
  72 + }
  73 +
  74 + /**
  75 + * 对象转字典
  76 + */
  77 + static func modelToDictionary(_ model:BaseModel?) -> [String:Any] {
  78 + if model == nil {
  79 + #if DEBUG
  80 + print("modelToJson:model为空")
  81 + #endif
  82 + return [:]
  83 + }
  84 + return (model?.toJSON())!
  85 + }
  86 +}
... ...
metaCode/Classes/Common/Util/CNLiveCommonQiniuTool.swift 0 → 100644
  1 +//
  2 +// CNLiveCommonQiniuTool.swift
  3 +// metaCode
  4 +//
  5 +// Created by open on 2023/6/15.
  6 +//
  7 +
  8 +import Foundation
  9 +import Qiniu
  10 +
  11 +class UploadManager: NSObject {
  12 +
  13 + private let _qnUploadManager = QNUploadManager()
  14 + static let shared = UploadManager()
  15 + private override init() {
  16 + super.init()
  17 + let config = QNConfiguration.build { builder in
  18 + builder?.useHttps = true;
  19 + do {
  20 + builder?.recorder = try QNFileRecorder(folder: "元码")
  21 + } catch {}
  22 + }
  23 +// _qnUploadManager = QNUploadManager(configuration: config)
  24 + }
  25 +
  26 +
  27 +
  28 +}
... ...
metaCode/Classes/Config/CNLiveConfigUserInfo.swift
... ... @@ -6,62 +6,113 @@
6 6 //
7 7  
8 8 import Foundation
9   -import SwiftyUserDefaults
  9 +import UIKit
  10 +import HandyJSON
10 11  
11   -extension DefaultsKeys {
  12 +class UserInfoModel: BaseModel {
12 13  
13   - var userInfoKey: DefaultsKey<CNLiveLoginModel?>{
14   - DefaultsKey.init("userInfo")
15   - }
  14 + required init() {}
  15 +
  16 + var appId:String = ""
  17 + var appleUid:String = ""
  18 + var bigFaceUrl:String = ""
  19 + var birthday:String = ""
  20 + var countryCode:String = ""
  21 + var email:String = ""
  22 + var extInfo:String = ""
  23 + var faceUrl:String = ""
  24 + var frmId:String = ""
  25 + var gender:String = ""
  26 + var hUid:String = ""
  27 + var isNewUser:String = ""
  28 + var location:String = ""
  29 + var mobile:String = ""
  30 + var newAccount:String = ""
  31 + var nickName:String = ""
  32 + var platformId:String = ""
  33 + var qqUid:String = ""
  34 + var renrenUid:String = ""
  35 + var sinaUid:String = ""
  36 + var token:String = ""
  37 + var uid:String = ""
  38 + var wxUid:String = ""
  39 + var access_token:String = ""
  40 + var expires_in:String = ""//过期时间
16 41  
  42 + override func mapping(mapper: HelpingMapper) {
  43 +
  44 + mapper <<<
  45 + self.gender <-- TransformOf(fromJSON: { (rawString) -> String? in
  46 +
  47 + if let _str = rawString {
  48 +
  49 + if _str == "m" || _str == "男" {
  50 + return "男"
  51 + }
  52 + if _str == "f" || _str == "女" {
  53 + return "女"
  54 + }
  55 + }
  56 + return "未知"
  57 + }, toJSON: { (srcString) -> String? in
  58 + return srcString
  59 + })
  60 + }
17 61 }
18 62  
19 63 class UserInfoManager: NSObject {
20 64  
21 65 static let shared = UserInfoManager()
22 66  
23   - public var is_login: Bool {
24   - get {
25   - return userInfo.uid.lengthOfBytes(using: .utf8) > 0
26   - }
27   - }
28   -
29   - fileprivate var _userInfo : CNLiveLoginModel?
30   - private(set) var userInfo: CNLiveLoginModel {
  67 + fileprivate var _userInfo : UserInfoModel?
  68 + private(set) var userInfo: UserInfoModel {
31 69  
32 70 set {
33 71 _userInfo = newValue
34 72 }
35 73  
36 74 get {
37   - if (_userInfo != nil && (_userInfo?.uid.lengthOfBytes(using: .utf8))! > 0) {
  75 + if _userInfo != nil && (_userInfo?.uid.count)! > 0 {
38 76 return _userInfo!
39 77 }
40   - return readUserInfo()
  78 + return UserInfoManager.readUserInfo()
41 79 }
42 80 }
43 81  
44 82 private override init() {}
45 83  
46 84 /// 缓存用户数据
47   - /// - Parameter userInfo: 用户数据
48   - public func cacheUserInfo(userInfo: CNLiveLoginModel) {
49   - _userInfo = userInfo
50   - Defaults[\.userInfoKey] = userInfo
  85 + /// - Parameter userInfo: 用户数据 存储字符串
  86 + static public func cacheUserInfo(userInfo: UserInfoModel) {
  87 + UserInfoManager.clearUserInfo()
  88 + UserInfoManager.shared._userInfo = userInfo
  89 + //JsonUtil.modelToJson(userInfo)
  90 + UserDefaults.standard.set(userInfo.toJSONString(), forKey: "mateCode_userInfo")
  91 + if UserDefaults.standard.synchronize() {
  92 + print("用户信息存储成功")
  93 + }
51 94 }
52 95  
53 96 /// 读取用户数据
54 97 /// - Returns: 用户数据
55   - public func readUserInfo() -> CNLiveLoginModel {
56   - if (Defaults.hasKey(\.userInfoKey)) {
57   - return Defaults[\.userInfoKey]!
58   - }else{
59   - return CNLiveLoginModel()
  98 + static public func readUserInfo() -> UserInfoModel {
  99 + let user_info = UserDefaults.standard.object(forKey: "mateCode_userInfo")
  100 + if user_info == nil && (user_info as! String).count == 0 {
  101 + print("获取用户信息失败")
  102 + return UserInfoModel()
60 103 }
  104 + let userInfo = JsonUtil.jsonToModel(user_info as! String, UserInfoModel.self) as! UserInfoModel
  105 + UserInfoManager.shared._userInfo = userInfo
  106 + return userInfo
61 107 }
62 108  
63   - public func clearUserInfo() {
64   - _userInfo = nil
65   - Defaults.remove(\.userInfoKey)
  109 + static public func clearUserInfo() {
  110 + UserDefaults.standard.removeObject(forKey: "mateCode_userInfo")
  111 + UserInfoManager.shared._userInfo = nil
  112 + if UserDefaults.standard.synchronize() {
  113 + print("用户信息删除成功")
  114 + }
66 115 }
67 116 }
  117 +
  118 +
... ...
metaCode/Classes/CustomView/CNLiveTips.swift deleted 100644 → 0
1   -//
2   -// CNLiveTips.swift
3   -// metaCode
4   -//
5   -// Created by open on 2023/6/5.
6   -//
7   -
8   -import Foundation
9   -import UIKit
10   -import YYCategories
11   -import MBProgressHUD
12   -
13   -class tip {
14   -
15   - static func showMessage(message : String) {
16   -
17   - if !message.isNotBlank() {
18   - return
19   - }
20   -
21   - let delegate = UIApplication.shared.delegate as! AppDelegate
22   -
23   - let bgView = UIView.init()
24   - bgView.backgroundColor = UIColor(white: 0.1, alpha: 0.7)
25   - bgView.layer.cornerRadius = 8.0
26   - bgView.clipsToBounds = true
27   - delegate.window?.addSubview(bgView)
28   -
29   - let remindLab = UILabel.init()
30   - remindLab.textColor = .white
31   - remindLab.font = Font_15_Fit
32   - remindLab.textAlignment = .center
33   - remindLab.numberOfLines = 1
34   - remindLab.backgroundColor = .clear
35   - remindLab.text = message
36   - bgView.addSubview(remindLab)
37   -
38   - var width = message.boundingRect(with: CGSize(width: CGFloat(MAXFLOAT), height: delegate.window?.bounds.size.height ?? 0), options:.usesLineFragmentOrigin, attributes: [NSAttributedString.Key.font:Font_15_Fit], context: nil).size.width
39   - if width > (delegate.window?.bounds.size.width ?? 0)/4.0 * 3.0 {
40   - width = (delegate.window?.bounds.size.width ?? 0)/4.0 * 3.0
41   - }
42   -
43   - let height = message.boundingRect(with: CGSize(width: width, height: CGFloat(MAXFLOAT)), options: .usesLineFragmentOrigin, attributes: [NSAttributedString.Key.font:Font_15_Fit], context: nil).size.height
44   -
45   - bgView.bounds = CGRect(x: 0, y: 0, width: width + 20, height: height + 20)
46   - bgView.layer.position = CGPoint(x: (delegate.window?.bounds.size.width ?? 0) / 2.0, y: ( (delegate.window?.bounds.size.height ?? 0) - CNLiveConfigManager.shared.keyboardDisplayHeight) / 2.0)
47   -
48   - remindLab.bounds = CGRect(x: 0, y: 0, width: width, height: height)
49   - remindLab.layer.position = CGPoint(x: bgView.bounds.size.width / 2, y: bgView.bounds.size.height / 2)
50   -
51   - UIView.animate(withDuration: 1, delay: 1, options: .curveEaseOut) {
52   - bgView.alpha = 0
53   - } completion: { finish in
54   - bgView.removeFromSuperview()
55   - }
56   - }
57   -
58   - static func showLoading(message: String) {
59   -
60   - let delegate = UIApplication.shared.delegate as! AppDelegate
61   -
62   - delegate.window?.subviews.forEach({ view in
63   - if view.isKind(of: MBProgressHUD.layerClass) {
64   - let hub = view as! MBProgressHUD
65   - hub.removeFromSuperview()
66   - }
67   - })
68   -
69   - let hub = MBProgressHUD.showAdded(to: delegate.window!, animated: true)
70   - hub.mode = .indeterminate
71   - hub.animationType = .fade
72   - hub.contentColor = .white
73   - hub.bezelView.backgroundColor = .black
74   - hub.label.textColor = .white
75   - if message.isNotBlank() {
76   - hub.label.text = message
77   - }
78   - }
79   -
80   - static func hiddenLoading() {
81   - let delegate = UIApplication.shared.delegate as! AppDelegate
82   - MBProgressHUD.hide(for: delegate.window!, animated: true)
83   - }
84   -
85   -}
86   -
metaCode/Classes/Extensions/NSObject+CNLiveCurrentVC.swift
... ... @@ -6,6 +6,7 @@
6 6 //
7 7  
8 8 import Foundation
  9 +import MBProgressHUD
9 10  
10 11 func currentViewController() -> (UIViewController?) {
11 12 var window = UIApplication.shared.keyWindow
... ... @@ -42,3 +43,77 @@ private func currentVC(_ vc :UIViewController?) -&gt; UIViewController? {
42 43 return vc
43 44 }
44 45 }
  46 +
  47 +
  48 +/// 弹框提示
  49 +/// - Parameter message: 内容提示
  50 +func showMessage(message: String) {
  51 + if !message.isNotBlank() {
  52 + return
  53 + }
  54 +
  55 + let delegate = UIApplication.shared.delegate as! AppDelegate
  56 +
  57 + let bgView = UIView.init()
  58 + bgView.backgroundColor = UIColor(white: 0.1, alpha: 0.7)
  59 + bgView.layer.cornerRadius = 8.0
  60 + bgView.clipsToBounds = true
  61 + delegate.window?.addSubview(bgView)
  62 +
  63 + let remindLab = UILabel.init()
  64 + remindLab.textColor = .white
  65 + remindLab.font = Font_15_Fit
  66 + remindLab.textAlignment = .center
  67 + remindLab.numberOfLines = 1
  68 + remindLab.backgroundColor = .clear
  69 + remindLab.text = message
  70 + bgView.addSubview(remindLab)
  71 +
  72 + var width = message.boundingRect(with: CGSize(width: CGFloat(MAXFLOAT), height: delegate.window?.bounds.size.height ?? 0), options:.usesLineFragmentOrigin, attributes: [NSAttributedString.Key.font:Font_15_Fit], context: nil).size.width
  73 + if width > (delegate.window?.bounds.size.width ?? 0)/4.0 * 3.0 {
  74 + width = (delegate.window?.bounds.size.width ?? 0)/4.0 * 3.0
  75 + }
  76 +
  77 + let height = message.boundingRect(with: CGSize(width: width, height: CGFloat(MAXFLOAT)), options: .usesLineFragmentOrigin, attributes: [NSAttributedString.Key.font:Font_15_Fit], context: nil).size.height
  78 +
  79 + bgView.bounds = CGRect(x: 0, y: 0, width: width + 20, height: height + 20)
  80 + bgView.layer.position = CGPoint(x: (delegate.window?.bounds.size.width ?? 0) / 2.0, y: ( (delegate.window?.bounds.size.height ?? 0) - CNLiveConfigManager.shared.keyboardDisplayHeight) / 2.0)
  81 +
  82 + remindLab.bounds = CGRect(x: 0, y: 0, width: width, height: height)
  83 + remindLab.layer.position = CGPoint(x: bgView.bounds.size.width / 2, y: bgView.bounds.size.height / 2)
  84 +
  85 + UIView.animate(withDuration: 1, delay: 1, options: .curveEaseOut) {
  86 + bgView.alpha = 0
  87 + } completion: { finish in
  88 + bgView.removeFromSuperview()
  89 + }
  90 +}
  91 +
  92 +/// 展示等待框
  93 +/// - Parameter message: 提示词
  94 +func showLoading(message: String) {
  95 + let delegate = UIApplication.shared.delegate as! AppDelegate
  96 +
  97 + delegate.window?.subviews.forEach({ view in
  98 + if view.isKind(of: MBProgressHUD.layerClass) {
  99 + let hub = view as! MBProgressHUD
  100 + hub.removeFromSuperview()
  101 + }
  102 + })
  103 +
  104 + let hub = MBProgressHUD.showAdded(to: delegate.window!, animated: true)
  105 + hub.mode = .indeterminate
  106 + hub.animationType = .fade
  107 + hub.contentColor = .white
  108 + hub.bezelView.backgroundColor = .black
  109 + hub.label.textColor = .white
  110 + if message.isNotBlank() {
  111 + hub.label.text = message
  112 + }
  113 +}
  114 +
  115 +/// 隐藏提示词
  116 +func hiddenLoading() {
  117 + let delegate = UIApplication.shared.delegate as! AppDelegate
  118 + MBProgressHUD.hide(for: delegate.window!, animated: true)
  119 +}
... ...
metaCode/Classes/Extensions/UIButton+CNLiveExtension.swift
... ... @@ -9,12 +9,12 @@ import Foundation
9 9  
10 10 extension UIButton {
11 11  
12   - /// 根据图片生成UIBarButtonItem
  12 + /// 根据图片生成UIButton
13 13 static func imageItem(imageName:String,target:AnyObject,action:Selector) -> UIButton {
14 14 return customItem(title: "", titleColor: UIColor.white, imageName: imageName, target: target, action: action,contentHorizontalAlignment: .center)
15 15 }
16 16  
17   - /// 根据文字生成UIBarButtonItem
  17 + /// 根据文字生成UIButton
18 18 static func textItem(title:String,titleColor:UIColor,target:AnyObject,action:Selector) -> UIButton {
19 19 return customItem(title: title, titleColor: titleColor, imageName: "", target: target, action: action,contentHorizontalAlignment: .center)
20 20 }
... ... @@ -24,7 +24,7 @@ extension UIButton {
24 24 return customItem(title: "", titleColor: UIColor.white, imageName: imageName, target: target, action: action,contentHorizontalAlignment: .left,isBack: true)
25 25 }
26 26  
27   - /// 快速初始化一个UIBarButtonItem,内部是按钮
  27 + /// 快速初始化一个UIButton,内部是按钮
28 28 static func customItem(title:String,titleColor:UIColor,imageName:String,target:AnyObject,action:Selector,
29 29 contentHorizontalAlignment:UIControl.ContentHorizontalAlignment,isBack:Bool=false) -> UIButton {
30 30 let button = UIButton()
... ...
metaCode/Classes/Main/LoginPage/Controller/CNLiveLoginViewController.swift
... ... @@ -15,7 +15,7 @@ class CNLiveLoginViewController : CNLiveBaseViewController, UITextViewDelegate {
15 15 lazy var headerView : UIImageView = {
16 16 let headerView = UIImageView()
17 17 headerView.backgroundColor = .white
18   - headerView.contentMode = .scaleAspectFit
  18 + headerView.contentMode = .scaleToFill
19 19 headerView.image = UIImage(named: "Login_page_header_icon")
20 20 return headerView
21 21 }()
... ... @@ -25,7 +25,7 @@ class CNLiveLoginViewController : CNLiveBaseViewController, UITextViewDelegate {
25 25 areaButton.backgroundColor = .white
26 26 areaButton.setTitle("+86", for: .normal)
27 27 areaButton.setTitle("+86", for: .highlighted)
28   - areaButton.titleLabel?.font = BoldFont_16_Fit
  28 + areaButton.titleLabel?.font = BoldFont_16
29 29 areaButton.setTitleColor(HexColor("#333333"), for: .normal)
30 30 areaButton.setTitleColor(HexColor("#333333"), for: .highlighted)
31 31 areaButton.addTarget(self, action: #selector(changeCityNumberMothod), for: .touchUpInside)
... ... @@ -112,7 +112,7 @@ class CNLiveLoginViewController : CNLiveBaseViewController, UITextViewDelegate {
112 112 areaButton.snp.makeConstraints { make in
113 113 make.centerY.equalTo(phoneV)
114 114 make.left.equalTo(phoneV.left).offset(40)
115   - make.width.lessThanOrEqualTo(45)
  115 + make.width.lessThanOrEqualTo(50)
116 116 }
117 117  
118 118 let v_line = UILabel.init()
... ... @@ -169,7 +169,7 @@ class CNLiveLoginViewController : CNLiveBaseViewController, UITextViewDelegate {
169 169 codeButton.backgroundColor = .white
170 170 codeButton.setTitle("获取验证码", for: .normal)
171 171 codeButton.setTitle("获取验证码", for: .highlighted)
172   - codeButton.titleLabel?.font = Font_16_Fit
  172 + codeButton.titleLabel?.font = Font_16
173 173 codeButton.setTitleColor(HexColor("#0066FE"), for: .normal)
174 174 codeButton.setTitleColor(HexColor("#0066FE"), for: .highlighted)
175 175 codeButton.addTarget(self, action: #selector(sendVerifiCodeMothod), for: .touchUpInside)
... ... @@ -278,23 +278,22 @@ extension CNLiveLoginViewController {
278 278  
279 279 @objc func sendLoginActionMothod(sender : UIButton) {
280 280 if !is_agree {
281   - tip.showMessage(message: "请先阅读并同意协议")
  281 + showMessage(message: "请先阅读并同意协议")
282 282 return
283 283 }
284 284 view.endEditing(true)
285 285 CNLiveLoginViewModel.requestLoginAction(userName: phoneText.text ?? "", countryCode: country, verCode: veriText.text ?? "") {
286   - UserInfoManager.shared.clearUserInfo()
287 286 let window = UIApplication.shared.delegate?.window
288 287 window??.rootViewController = CNLiveBaseTabBarViewController.init()
289 288 }
290 289 }
291 290  
292 291 @objc func pushAgreeActionMothod() {
293   - tip.showMessage(message: "APP用户服务协议")
  292 + self.navigationController?.pushViewController(CNLiveInfoShowViewController.init(show_type: .service), animated: true)
294 293 }
295 294  
296 295 @objc func pushInfoActionMothod() {
297   - tip.showMessage(message: "个人信息保护政策")
  296 + self.navigationController?.pushViewController(CNLiveInfoShowViewController.init(show_type: .privacy), animated: true)
298 297 }
299 298 }
300 299  
... ...
metaCode/Classes/Main/LoginPage/View/CNLiveLoginPickerView.swift
... ... @@ -163,12 +163,14 @@ extension CNLiveLoginPickerView {
163 163 }
164 164  
165 165 func pickerView(_ pickerView: UIPickerView, titleForRow row: Int, forComponent component: Int) -> String? {
166   - let param = country_array[row] as! NSMutableDictionary
167   - return param["name"] as? String
  166 + let param = country_array[row] as! NSDictionary
  167 + let name = param["name"] as? String
  168 + let code = param["code"] as? String
  169 + return "\(name ?? "")"+"(+\(code ?? ""))"
168 170 }
169 171  
170 172 func pickerView(_ pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int) {
171   - let param = country_array[row] as! NSMutableDictionary
  173 + let param = country_array[row] as! NSDictionary
172 174 result_string = param["code"] as! String
173 175 }
174 176 }
... ...
metaCode/Classes/Main/LoginPage/ViewModel/CNLiveLoginModel.swift deleted 100644 → 0
1   -//
2   -// CNLiveLoginModel.swift
3   -// metaCode
4   -//
5   -// Created by open on 2023/6/6.
6   -//
7   -
8   -import Foundation
9   -import SwiftyUserDefaults
10   -import HandyJSON
11   -
12   -class CNLiveLoginModel : BaseModel, DefaultsSerializable, Codable {
13   -
14   -
15   - required init() {}
16   -
17   - var appId:String = ""
18   - var appleUid:String = ""
19   - var bigFaceUrl:String = ""
20   - var birthday:String = ""
21   - var countryCode:String = ""
22   - var email:String = ""
23   - var extInfo:String = ""
24   - var faceUrl:String = ""
25   - var frmId:String = ""
26   - var gender:String = ""
27   - var hUid:String = ""
28   - var isNewUser:String = ""
29   - var location:String = ""
30   - var mobile:String = ""
31   - var newAccount:String = ""
32   - var nickName:String = ""
33   - var platformId:String = ""
34   - var qqUid:String = ""
35   - var renrenUid:String = ""
36   - var sinaUid:String = ""
37   - var token:String = ""
38   - var uid:String = ""
39   - var wxUid:String = ""
40   -
41   - override func mapping(mapper: HelpingMapper) {
42   - mapper.specify(property: &gender) { rawString -> String in
43   - var g = "未知"
44   - if rawString == "m" {
45   - g = "男"
46   - } else {
47   - g = "女"
48   - }
49   - return g
50   - }
51   - }
52   -
53   -}
metaCode/Classes/Main/LoginPage/ViewModel/CNLiveLoginViewModel.swift
... ... @@ -7,9 +7,10 @@
7 7  
8 8 import Foundation
9 9 import YYCategories
10   -import HandyJSON
11 10 import CNLiveRequestBastKit
12   -import SwiftyUserDefaults
  11 +import HandyJSON
  12 +
  13 +import MJExtension
13 14  
14 15 //验证码发送成功回调
15 16 typealias resultCodeBlock = () -> Void
... ... @@ -21,84 +22,105 @@ class CNLiveLoginViewModel : NSObject {
21 22 static func requestVerCodeAction(phone: String, code: String, resultBlock: @escaping resultCodeBlock) {
22 23  
23 24 if !phone.isNotBlank() {
24   - tip.showMessage(message: "请输入手机号")
  25 + showMessage(message: "请输入手机号")
25 26 return
26 27 }
27 28 if phone.lengthOfBytes(using: .utf8) >= 20 {
28   - tip.showMessage(message: "手机号格式不正确")
  29 + showMessage(message: "手机号格式不正确")
29 30 return
30 31 }
31 32 if !phone.isPurnInt() {
32   - tip.showMessage(message: "手机号格式不正确")
  33 + showMessage(message: "手机号格式不正确")
33 34 return
34 35 }
35   - tip.showLoading(message: "")
  36 + showLoading(message: "")
36 37 let param = ["mobile":phone,"countryCode":code]
37 38 CNLiveNetworking.setAllowRequestDefaultArgument(true)
38 39 CNLiveNetworking.setupShowDataResult(false)
39 40 CNLiveNetworking.requestNetwork(with: .POST, urlString: "/open/api2/user/sendVerifyCode", param: param, cacheType: .networkOnly) { task, result, error in
40   - tip.hiddenLoading()
  41 + hiddenLoading()
41 42 if (error == nil) {
42 43 let resp = result as! NSDictionary
43 44 let errorCode = resp["errorCode"]
44 45 if (errorCode as! String == "0") {
45   - tip.showMessage(message: "验证码已发送")
  46 + showMessage(message: "验证码已发送")
46 47 resultBlock()
47 48 } else {
48   - tip.showMessage(message: resp["errorMessage"] as! String)
  49 + showMessage(message: resp["errorMessage"] as! String)
49 50 }
50 51 } else{
51   - tip.showMessage(message: "获取验证码失败")
  52 + showMessage(message: "获取验证码失败")
52 53 }
53 54 }
54 55 }
55 56  
56 57 static func requestLoginAction(userName: String, countryCode: String, verCode: String, resultBlock: @escaping resultLoginBlock) {
57 58 if !userName.isNotBlank() {
58   - tip.showMessage(message: "请输入手机号")
  59 + showMessage(message: "请输入手机号")
59 60 return
60 61 }
61 62 if userName.lengthOfBytes(using: .utf8) >= 20 {
62   - tip.showMessage(message: "手机号格式不正确")
  63 + showMessage(message: "手机号格式不正确")
63 64 return
64 65 }
65 66 if !userName.isPurnInt() {
66   - tip.showMessage(message: "手机号格式不正确")
  67 + showMessage(message: "手机号格式不正确")
67 68 return
68 69 }
69 70 if !verCode.isNotBlank() {
70   - tip.showMessage(message: "请输入验证码")
  71 + showMessage(message: "请输入验证码")
71 72 return
72 73 }
73 74 if verCode.lengthOfBytes(using: .utf8) >= 20 {
74   - tip.showMessage(message: "验证码格式不正确")
  75 + showMessage(message: "验证码格式不正确")
75 76 return
76 77 }
77 78 if !verCode.isPurnInt() {
78   - tip.showMessage(message: "验证码格式不正确")
  79 + showMessage(message: "验证码格式不正确")
79 80 return
80 81 }
81 82  
82   - tip.showLoading(message: "")
  83 + showLoading(message: "")
83 84 let param = ["userName":userName,"countryCode":countryCode,"verificationCode":verCode,"inviterId":""]
84 85 CNLiveNetworking.setAllowRequestDefaultArgument(true)
85 86 CNLiveNetworking.setupShowDataResult(false)
86 87 CNLiveNetworking.requestNetwork(with: .POST, urlString: "/open/api2/user/loginInMetaCode", param: param, cacheType: .networkOnly) { task, result, error in
87   - tip.hiddenLoading()
  88 + hiddenLoading()
88 89 if (error == nil) {
89 90 let resp = result as! NSDictionary
90 91 let errorCode = resp["errorCode"]
91 92 if (errorCode as! String == "0") {
92   - if let res = JSONDeserializer<CNLiveLoginModel>.deserializeFrom(dict: resp, designatedPath: "data") {
93   - Defaults.userInfoKey = res
  93 + if resp.allKeys.contains(where: { item in
  94 + return item as! String == "data"
  95 + }) {
  96 + let userInfoModel = JsonUtil.dictionaryToModel(resp["data"] as! [String : Any], UserInfoModel.self)
  97 + UserInfoManager.cacheUserInfo(userInfo: userInfoModel as! UserInfoModel)
  98 + UserDefaults.standard.set(true,forKey: "is_login")
94 99 resultBlock()
95 100 }
96 101 } else {
97   - tip.showMessage(message: resp["errorMessage"] as! String)
  102 + showMessage(message: resp["errorMessage"] as! String)
98 103 }
99 104 } else {
100   - tip.showMessage(message: "登陆失败")
  105 + showMessage(message: "登陆失败")
101 106 }
102 107 }
  108 +// DispatchQueue.main.asyncAfter(deadline: .now()+0.5, execute: {
  109 +// hiddenLoading()
  110 +// let resp = CNLiveLoginViewModel.dict() as NSDictionary
  111 +// let errorCode = resp["errorCode"]
  112 +// if (errorCode as! String == "0") {
  113 +// if resp.allKeys.contains(where: { item in
  114 +// return item as! String == "data"
  115 +// }) {
  116 +// let userInfoModel = JsonUtil.dictionaryToModel(resp["data"] as! [String : Any], UserInfoModel.self)
  117 +// UserInfoManager.cacheUserInfo(userInfo: userInfoModel as! UserInfoModel)
  118 +// UserDefaults.standard.set(true,forKey: "is_login")
  119 +// resultBlock()
  120 +// }
  121 +// } else {
  122 +// showMessage(message: resp["errorMessage"] as! String)
  123 +// }
  124 +// })
103 125 }
104 126 }
... ...
metaCode/Classes/Main/MinePage/Controller/CNLiveInfoShowViewController.swift
... ... @@ -7,13 +7,15 @@
7 7  
8 8 import Foundation
9 9 import YYCategories
  10 +import WebKit
10 11  
11 12 enum ListShowInfoType {
12 13 case service
13 14 case privacy
  15 + case yinsi
14 16 }
15 17  
16   -class CNLiveInfoShowViewController: CNLiveBaseViewController {
  18 +class CNLiveInfoShowViewController: CNLiveBaseViewController, WKNavigationDelegate, WKUIDelegate {
17 19  
18 20 var _show_type:ListShowInfoType!
19 21 init(show_type:ListShowInfoType) {
... ... @@ -29,42 +31,79 @@ class CNLiveInfoShowViewController: CNLiveBaseViewController {
29 31 fatalError("init(coder:) has not been implemented")
30 32 }
31 33  
  34 + lazy var webView: WKWebView = {
  35 + let config = WKWebViewConfiguration()
  36 + let webView = WKWebView.init(frame: .zero, configuration: config)
  37 + webView.backgroundColor = .white
  38 + webView.allowsBackForwardNavigationGestures = true
  39 + webView.navigationDelegate = self
  40 + webView.uiDelegate = self
  41 + return webView
  42 + }()
  43 +
32 44 override func viewDidLoad() {
33 45 super.viewDidLoad()
34 46 var attrString = ""
35 47 switch _show_type {
36   - case .service:
37   - titleName = "APP用户服务协议"
38   - attrString = "欢迎您使用元码,我们非常重视您的个人信息保护,并采取了有效措施保障您的信息安全,请您充分了解: \n为保障APP账号安全,元码APP需向您申请获取电话状态权限。 \n请您务必阅读APP《个人信息保护政策》,以充分了解我们如何处理您的个人信息。"
39   - case .privacy:
40   - titleName = "个人信息保护政策"
41   - attrString = "欢迎您使用元码,我们非常重视您的个人信息保护,并采取了有效措施保障您的信息安全,请您充分了解: \n为保障APP账号安全,元码APP需向您申请获取电话状态权限 \n请您务必阅读APP《个人信息保护政策》,以充分了解我们如何处理您的个人信息。"
42   - case .none:
43   - break
44   - }
  48 + case .service:
  49 + titleName = "APP用户服务协议"
  50 + attrString = "https://wjjh5.cnlive.com/yuanmaYhxy.html"
  51 + case .privacy:
  52 + titleName = "个人信息保护政策"
  53 + attrString = "https://wjjh5.cnlive.com/yuanmaYszc.html"
  54 + case .yinsi:
  55 + titleName = "隐私协议"
  56 + attrString = "https://wjjh5.cnlive.com/yuanmaYszc.html"
  57 + case .none:
  58 + break
  59 + }
45 60  
46   - let paraph = NSMutableParagraphStyle()
47   - paraph.lineSpacing = 10
48   - let attributes = [NSAttributedString.Key.font:Font_16_Fit,
49   - NSAttributedString.Key.paragraphStyle: paraph]
50   - let h = attrString.boundingRect(with: CGSize(width: KSreenWidth - 40, height: CGFloat(MAXFLOAT)), options: .usesLineFragmentOrigin, attributes: attributes, context: nil).size.height + 40
51   - let textView = UITextView.init()
52   - textView.attributedText = NSAttributedString(string: attrString, attributes: attributes)
53   - textView.textColor = HexColor("#666666")
54   - textView.layer.cornerRadius = 10
55   - textView.layer.masksToBounds = true
56   - textView.textAlignment = .left
57   - textView.contentMode = .scaleAspectFill
58   - textView.contentInset = UIEdgeInsets(top: 10, left: 10, bottom: 10, right: 10)
59   - textView.sizeToFit()
60   - view.addSubview(textView)
61   - textView.snp.makeConstraints { make in
62   - make.centerX.equalToSuperview()
63   - make.top.equalToSuperview().offset(get_system_nav_height() + 10)
64   - make.left.equalToSuperview().offset(10)
65   - make.right.equalToSuperview().offset(-10)
66   - make.height.equalTo(h)
  61 + view.addSubview(webView)
  62 + webView.snp.makeConstraints { make in
  63 + make.top.equalToSuperview().offset(get_system_nav_height())
  64 + make.left.right.bottom.equalToSuperview()
67 65 }
  66 +
  67 + webView.load(URLRequest(url: URL(string: attrString)!, cachePolicy: .returnCacheDataElseLoad))
68 68 }
69 69  
  70 +
  71 +// override func viewDidLoad() {
  72 +// super.viewDidLoad()
  73 +// var attrString = ""
  74 +// switch _show_type {
  75 +// case .service:
  76 +// titleName = "APP用户服务协议"
  77 +// attrString = "欢迎您使用元码,我们非常重视您的个人信息保护,并采取了有效措施保障您的信息安全,请您充分了解: \n为保障APP账号安全,元码APP需向您申请获取电话状态权限。 \n请您务必阅读APP《个人信息保护政策》,以充分了解我们如何处理您的个人信息。"
  78 +// case .privacy:
  79 +// titleName = "个人信息保护政策"
  80 +// attrString = "欢迎您使用元码,我们非常重视您的个人信息保护,并采取了有效措施保障您的信息安全,请您充分了解: \n为保障APP账号安全,元码APP需向您申请获取电话状态权限 \n请您务必阅读APP《个人信息保护政策》,以充分了解我们如何处理您的个人信息。"
  81 +// case .none:
  82 +// break
  83 +// }
  84 +//
  85 +// let paraph = NSMutableParagraphStyle()
  86 +// paraph.lineSpacing = 10
  87 +// let attributes = [NSAttributedString.Key.font:Font_16_Fit,
  88 +// NSAttributedString.Key.paragraphStyle: paraph]
  89 +// let h = attrString.boundingRect(with: CGSize(width: KSreenWidth - 40, height: CGFloat(MAXFLOAT)), options: .usesLineFragmentOrigin, attributes: attributes, context: nil).size.height + 40
  90 +// let textView = UITextView.init()
  91 +// textView.attributedText = NSAttributedString(string: attrString, attributes: attributes)
  92 +// textView.textColor = HexColor("#666666")
  93 +// textView.layer.cornerRadius = 10
  94 +// textView.layer.masksToBounds = true
  95 +// textView.textAlignment = .left
  96 +// textView.contentMode = .scaleAspectFill
  97 +// textView.contentInset = UIEdgeInsets(top: 10, left: 10, bottom: 10, right: 10)
  98 +// textView.sizeToFit()
  99 +// view.addSubview(textView)
  100 +// textView.snp.makeConstraints { make in
  101 +// make.centerX.equalToSuperview()
  102 +// make.top.equalToSuperview().offset(get_system_nav_height() + 10)
  103 +// make.left.equalToSuperview().offset(10)
  104 +// make.right.equalToSuperview().offset(-10)
  105 +// make.height.equalTo(h)
  106 +// }
  107 +// }
  108 +
70 109 }
... ...
metaCode/Classes/Main/MinePage/Controller/CNLiveMineInfoViewController.swift
... ... @@ -17,7 +17,8 @@ class CNLiveMineInfoViewController: CNLiveBaseViewController, PhotoPickerControl
17 17 imageView.backgroundColor = .clear
18 18 imageView.contentMode = .scaleToFill
19 19 imageView.image = UIImage(named: "mine_header_icon_defult_ava")
20   - imageView.image = _image
  20 + imageView.kf.indicatorType = .activity
  21 + imageView.kf.setImage(with: URL(string: UserInfoManager.shared.userInfo.bigFaceUrl), placeholder: UIImage(named: "mine_header_icon_defult_ava"))
21 22 return imageView
22 23 }()
23 24  
... ... @@ -57,12 +58,10 @@ class CNLiveMineInfoViewController: CNLiveBaseViewController, PhotoPickerControl
57 58 }()
58 59  
59 60 var _select_image: UIImage!
60   - var _image:UIImage!
61 61 var reslut: ClickInfoResultBlock
62   - init(image:UIImage, result: @escaping ClickInfoResultBlock) {
  62 + init(result: @escaping ClickInfoResultBlock) {
63 63 self.reslut = result
64 64 super.init(nibName:nil, bundle:nil)
65   - _image = image
66 65 }
67 66  
68 67 required init?(coder: NSCoder) {
... ... @@ -106,10 +105,12 @@ class CNLiveMineInfoViewController: CNLiveBaseViewController, PhotoPickerControl
106 105 make.width.equalTo((KSreenWidth - 60)*0.65)
107 106 }
108 107 sendBtn.setGradient(colors: [UIColor(red: 103/255.0, green: 197/255.0, blue: 255/255.0, alpha: 1),UIColor(red: 96/255.0, green: 154/255.0, blue: 255/255.0, alpha: 1)], startPoint: CGPoint(x: 0, y: 0.5), endPoint: CGPoint(x: 1, y: 0.5))
  108 +
109 109 }
110 110  
111 111 override var preferredStatusBarStyle: UIStatusBarStyle {
112   - return .lightContent
  112 +
  113 + return .lightContent
113 114 }
114 115  
115 116 @objc func changeCancelAction() {
... ... @@ -117,8 +118,11 @@ class CNLiveMineInfoViewController: CNLiveBaseViewController, PhotoPickerControl
117 118 }
118 119  
119 120 @objc func changeSendAction() {
120   - self.reslut(_select_image)
121   - self.navigationController?.popViewController(animated: true)
  121 + CNLiveMineViewModel.requestUploadIconAction(_select_image) { [self] in
  122 + //再这里进行图片上传
  123 + self.reslut(_select_image)
  124 + self.navigationController?.popViewController(animated: true)
  125 + }
122 126 }
123 127  
124 128 @objc func changeAvatarAction() {
... ...
metaCode/Classes/Main/MinePage/Controller/CNLiveMineNickViewController.swift
... ... @@ -89,7 +89,7 @@ class CNLiveMineNickViewController: CNLiveBaseViewController, UITextFieldDelegat
89 89 CNLiveMineViewModel.requestUpdateUserInfoAction(type: .nickName, value: nickField.text ?? "", resultBlock: { [self] in
90 90 let userInfo = UserInfoManager.shared.userInfo
91 91 userInfo.nickName = nickField.text ?? ""
92   - UserInfoManager.shared.cacheUserInfo(userInfo: userInfo)
  92 + UserInfoManager.cacheUserInfo(userInfo: userInfo)
93 93 })
94 94 }
95 95  
... ...
metaCode/Classes/Main/MinePage/Controller/CNLiveMineViewController.swift
... ... @@ -39,11 +39,16 @@ class CNLiveMineViewController : CNLiveBaseViewController, UITableViewDelegate,
39 39 let array01 : [Dictionary] = [["name":"添加身份","icon":"mine_list_icon_add_identity"]]
40 40 dataArray.add(array01)
41 41 let array02 : [Dictionary] = [["name":"帮助与反馈","icon":"mine_list_icon_help_feedback"],
42   - ["name":"更多设置","icon":"mine_list_icon_set_more"]]
  42 + ["name":"更多设置","icon":"mine_list_icon_set_more"]]
43 43 dataArray.add(array02)
44 44 return dataArray
45 45 }()
46 46  
  47 + lazy var headerView: MineHeaderView = {
  48 + let headerView = MineHeaderView.init(frame: CGRect(x: 0, y: 0, width: KSreenWidth, height: 80))
  49 + return headerView
  50 + }()
  51 +
47 52 override func viewDidLoad() {
48 53 super.viewDidLoad()
49 54 view.backgroundColor = HexColor("#f9f9f9")
... ... @@ -61,6 +66,12 @@ class CNLiveMineViewController : CNLiveBaseViewController, UITableViewDelegate,
61 66 }
62 67 }
63 68  
  69 + override func viewWillAppear(_ animated: Bool) {
  70 + super.viewWillAppear(animated)
  71 + headerView.updateHeaderView()
  72 + tableView.reloadData()
  73 + }
  74 +
64 75 override var preferredStatusBarStyle: UIStatusBarStyle {
65 76 return .lightContent
66 77 }
... ... @@ -124,7 +135,6 @@ extension CNLiveMineViewController {
124 135  
125 136 func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
126 137 if section == 0 {
127   - let headerView = MineHeaderView.init(frame: CGRect(x: 0, y: 0, width: KSreenWidth, height: 80))
128 138 return headerView
129 139 }
130 140 return UIView.init()
... ...
metaCode/Classes/Main/MinePage/Controller/CNLiveTypeFeedBackViewController.swift
... ... @@ -187,7 +187,8 @@ class CNLiveTypeFeedBackViewController : CNLiveBaseViewController, UITableViewDe
187 187 @objc func logoutAction() -> Void {
188 188 AlertTool.systemActionSheet(title: nil, message: nil, actionTitles: ["退出登录"]) { index in
189 189 if index == 1 {
190   - UserInfoManager.shared.clearUserInfo()
  190 + UserDefaults.standard.set(false,forKey: "is_login")
  191 + UserInfoManager.clearUserInfo()
191 192 let window = UIApplication.shared.delegate?.window
192 193 window??.rootViewController = CNLiveLoginViewController.init()
193 194 }
... ... @@ -276,9 +277,9 @@ extension CNLiveTypeFeedBackViewController {
276 277 if _show_type == .info {
277 278 if indexPath.section == 0 {
278 279 let cell = tableView.cellForRow(at: indexPath) as! MineBodyTwoListViewCell
279   - let vc = CNLiveMineInfoViewController.init(image: cell.avatarView.image!) { image in
  280 + let vc = CNLiveMineInfoViewController.init(result: { image in
280 281 cell.avatarView.image = image
281   - }
  282 + })
282 283 self.navigationController?.pushViewController(vc, animated: true)
283 284 }
284 285 if indexPath.section == 1 {
... ... @@ -286,13 +287,11 @@ extension CNLiveTypeFeedBackViewController {
286 287 self.navigationController?.pushViewController(mineInfoVC, animated: true)
287 288 }
288 289 if indexPath.section == 2 {
289   - let cell = tableView.cellForRow(at: indexPath) as! MineBodyTwoListViewCell
290 290 MineInfoAlertView.showSelectView(showType: .gender) { [self] text in
291 291 updateWithDataSource()
292 292 }
293 293 }
294 294 if indexPath.section == 3 {
295   - let cell = tableView.cellForRow(at: indexPath) as! MineBodyTwoListViewCell
296 295 MineInfoAlertView.showSelectView(showType: .birthday) { [self] text in
297 296 updateWithDataSource()
298 297 }
... ...
metaCode/Classes/Main/MinePage/View/CNLiveMineHeaderView.swift
... ... @@ -62,7 +62,10 @@ class MineHeaderView : UIView {
62 62 make.right.equalToSuperview().offset(-15)
63 63 make.size.equalTo(30)
64 64 }
65   -
  65 + updateHeaderView()
  66 + }
  67 +
  68 + public func updateHeaderView() {
66 69 iconView.kf.indicatorType = .activity
67 70 iconView.kf.setImage(with: URL(string: UserInfoManager.shared.userInfo.bigFaceUrl), placeholder: UIImage(named: "mine_header_icon_defult_ava"))
68 71 nameLabel.text = UserInfoManager.shared.userInfo.nickName
... ...
metaCode/Classes/Main/MinePage/View/CNLiveMineInfoAlertView.swift
... ... @@ -171,9 +171,11 @@ class MineInfoAlertView: UIView {
171 171  
172 172 wBtn.isSelected = UserInfoManager.shared.userInfo.gender == "男"
173 173 mBtn.isSelected = UserInfoManager.shared.userInfo.gender == "女"
174   - mView.isHidden = UserInfoManager.shared.userInfo.gender == "男"
175   - wView.isHidden = UserInfoManager.shared.userInfo.gender == "女"
176   -
  174 + if UserInfoManager.shared.userInfo.gender != "未知" {
  175 + mView.isHidden = UserInfoManager.shared.userInfo.gender == "男"
  176 + wView.isHidden = UserInfoManager.shared.userInfo.gender == "女"
  177 + }
  178 +
177 179 setConstraints()
178 180 }
179 181  
... ... @@ -311,17 +313,12 @@ class MineInfoAlertView: UIView {
311 313 CNLiveMineViewModel.requestUpdateUserInfoAction(type: type!, value: value) { [self] in
312 314 let userInfo = UserInfoManager.shared.userInfo
313 315 if type == .gender {
314   - if (value == "m") {
315   - userInfo.gender = "男"
316   - }
317   - if (value == "f") {
318   - userInfo.gender = "女"
319   - }
  316 + userInfo.gender = (value == "m" ? "男" : "女")
320 317 }
321 318 if type == .birthday {
322 319 userInfo.birthday = value
323 320 }
324   - UserInfoManager.shared.cacheUserInfo(userInfo: userInfo)
  321 + UserInfoManager.cacheUserInfo(userInfo: userInfo)
325 322 result!(value)
326 323 }
327 324 }
... ...
metaCode/Classes/Main/MinePage/ViewModel/CNLiveMineViewModel.swift
... ... @@ -15,13 +15,11 @@ enum CNLiveMineRequestType {
15 15 case location
16 16 case birthday
17 17 }
18   -// 修改用户信息成功
  18 +// 成功
19 19 typealias resultSuccessBlock = () -> Void
20 20  
21 21 class CNLiveMineViewModel: NSObject {
22 22  
23   -
24   -
25 23 /// 提交更新用户单项数据
26 24 /// - Parameters:
27 25 /// - type: nickName-昵称,gender-性别,email-邮箱, location-联系方式,birthday-生日yyyy-MM-dd
... ... @@ -52,23 +50,109 @@ class CNLiveMineViewModel: NSObject {
52 50 }
53 51 param.setValue(UserInfoManager.shared.userInfo.uid, forKey: "uid")
54 52 param.setValue(UserInfoManager.shared.userInfo.token, forKey: "token")
55   - tip.showLoading(message: "")
  53 + showLoading(message: "")
56 54 CNLiveNetworking.setAllowRequestDefaultArgument(true)
57 55 CNLiveNetworking.setupShowDataResult(false)
58 56 CNLiveNetworking.requestNetwork(with: .POST, urlString: "/open/api2/user/updateUserById", param: param as! [String : Any], cacheType: .networkOnly) { task, result, error in
59   - tip.hiddenLoading()
  57 + hiddenLoading()
60 58 if (error == nil) {
61 59 let resp = result as! NSDictionary
62 60 let errorCode = resp["errorCode"]
63 61 if (errorCode as! String == "0") {
64   - tip.showMessage(message: "更改成功")
  62 + showMessage(message: "更改成功")
65 63 resultBlock()
66 64 } else {
67   - tip.showMessage(message: resp["errorMessage"] as! String)
  65 + showMessage(message: resp["errorMessage"] as! String)
68 66 }
69 67 } else {
70   - tip.showMessage(message: "修改信息失败")
  68 + showMessage(message: "修改信息失败")
  69 + }
  70 + }
  71 + }
  72 +
  73 +
  74 + /// 上传并修改头像
  75 + /// - Parameters:
  76 + /// - image: 头像
  77 + /// - resultBlock: 返回
  78 + static func requestUploadIconAction(_ image: UIImage,resultBlock: @escaping resultSuccessBlock) {
  79 +
  80 + CNLiveMineViewModel.requestAccessTokenAction() {
  81 + let param = NSMutableDictionary.init()
  82 + param.setValue(UserInfoManager.shared.userInfo.uid, forKey: "uid")
  83 + param.setValue(UserInfoManager.shared.userInfo.token, forKey: "token")
  84 + param.setValue(UserInfoManager.shared.userInfo.access_token, forKey: "access_token")
  85 + showLoading(message: "修改头像中...")
  86 + CNLiveNetworking.setAllowRequestDefaultArgument(true)
  87 + CNLiveNetworking.setupShowDataResult(false)
  88 + CNLiveNetworking.uploadNetwork(withURLString: "/open/api2/user/updateUserFaceById", param: param as? [AnyHashable : Any]) { formData in
  89 + let imageData = image.jpegData(compressionQuality: 1.0)
  90 + formData?.appendPart(withFileData: imageData! as Data, name: "face", fileName: ".jpg", mimeType: "image/jpg")
  91 + } progressBlock: { progress in
  92 + print("已上传==>\(progress!.fractionCompleted*100)")
  93 + } completionBlock: { task, result, error in
  94 + hiddenLoading()
  95 + if (error == nil) {
  96 + let resp = result as! NSDictionary
  97 + let errorCode = resp["errorCode"]
  98 + if (errorCode as! String == "0") {
  99 + showMessage(message: "头像更改成功")
  100 + let data = resp["data"] as! Dictionary<String, Any>
  101 + let userInfo = UserInfoManager.shared.userInfo
  102 + userInfo.faceUrl = data["faceUrl"] as! String
  103 + userInfo.bigFaceUrl = data["bigFaceUrl"] as! String
  104 + UserInfoManager.cacheUserInfo(userInfo: userInfo)
  105 + resultBlock()
  106 + } else {
  107 + showMessage(message: resp["errorMessage"] as! String)
  108 + }
  109 + } else {
  110 + showMessage(message: "头像更改成功")
  111 + }
71 112 }
72 113 }
73 114 }
  115 +
  116 + /// 获取access_token
  117 + /// - Parameter resultBlock: 结果返回
  118 + static func requestAccessTokenAction(resultBlock: @escaping resultSuccessBlock) {
  119 + //当前时间大于最大允许时间则表明当前access_token已经过期需要重新请求
  120 + if CNLiveMineViewModel.timeStamp > NSNumber(string: UserInfoManager.shared.userInfo.expires_in)?.intValue ?? 0 {
  121 + let param = NSMutableDictionary.init()
  122 + param.setValue("802_li40qhp922", forKey: "appId")
  123 + param.setValue("3cc9f12db322a3d3656012ef929604cf6d6847471535f9", forKey: "secret")
  124 + showLoading(message: "")
  125 + CNLiveNetworking.setAllowRequestDefaultArgument(false)
  126 + CNLiveNetworking.setupShowDataResult(false)
  127 + CNLiveNetworking.requestNetwork(with: .POST, urlString: "/open/api2/token", param: (param as! [AnyHashable : Any]), cacheType: .networkOnly) { task, result, error in
  128 + hiddenLoading()
  129 + if (error == nil) {
  130 + let resp = result as! NSDictionary
  131 + let errorCode = "\(resp["errorCode"] ?? 0)"
  132 + if (errorCode == "0") {
  133 + let data = resp["data"] as! Dictionary<String, Any>
  134 + let userInfo = UserInfoManager.shared.userInfo
  135 + userInfo.access_token = data["access_token"] as! String
  136 + let expires_in = data["expires_in"] as! NSNumber
  137 + userInfo.expires_in = "\(expires_in.intValue+CNLiveMineViewModel.timeStamp)"
  138 + UserInfoManager.cacheUserInfo(userInfo: userInfo)
  139 + resultBlock()
  140 + } else {
  141 + showMessage(message: resp["errorMessage"] as! String)
  142 + }
  143 + } else {
  144 + showMessage(message: "修改头像失败")
  145 + }
  146 + }
  147 + } else {
  148 + resultBlock()
  149 + }
  150 + }
  151 +
  152 + /// 获取十位时间戳
  153 + static var timeStamp: Int {
  154 + let timeInterval: TimeInterval = NSDate().timeIntervalSince1970
  155 + let timeStamp = Int(timeInterval)
  156 + return timeStamp
  157 + }
74 158 }
... ...
metaCode/Classes/Other/AppDelegate.swift
... ... @@ -8,7 +8,6 @@
8 8 import UIKit
9 9 import CNLiveRequestBastKit
10 10 import IQKeyboardManagerSwift
11   -import SwiftyUserDefaults
12 11  
13 12 @main
14 13 class AppDelegate: UIResponder, UIApplicationDelegate {
... ... @@ -21,8 +20,8 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
21 20  
22 21 window = UIWindow.init(frame: UIScreen.main.bounds)
23 22 window?.backgroundColor = KVCBackgroupColor
24   - window?.rootViewController = UserInfoManager.shared.is_login ? CNLiveBaseTabBarViewController.init() : CNLiveLoginViewController.init()
25   -// window?.rootViewController = CNLiveBaseTabBarViewController.init()
  23 + let is_login = UserDefaults.standard.bool(forKey: "is_login")
  24 + window?.rootViewController = is_login ? CNLiveBaseTabBarViewController.init() : CNLiveLoginViewController.init()
26 25 window?.makeKeyAndVisible()
27 26  
28 27  
... ...