Commit bd33055318e799ef96b14eace29bdf2523f64dc5

Authored by liushiyu
1 parent 61bbbf6b

添加协议跳转

metaCode/Classes/Common/Base/CNLiveBaseViewController.swift
... ... @@ -205,7 +205,11 @@ class CNLiveBaseViewController: UIViewController {
205 205 }
206 206  
207 207 @objc func ClickBackBtn() {
208   - self.navigationController!.popViewController(animated: true)
  208 + if (self.presentingViewController != nil) {
  209 + self.dismiss(animated: true)
  210 + }else{
  211 + self.navigationController!.popViewController(animated: true)
  212 + }
209 213 }
210 214  
211 215 @objc func topNavViewTap() {
... ...
metaCode/Classes/Common/Util/CNLiveCommonQiniuTool.swift
... ... @@ -7,10 +7,16 @@
7 7  
8 8 import Foundation
9 9 import Qiniu
  10 +import YYCategories
  11 +import CNLiveRequestBastKit
10 12  
  13 +typealias ProgressBlcok = (String,CGFloat)
  14 +typealias SuccessBlock = (String,String)
11 15 class UploadManager: NSObject {
12 16  
13   - private let _qnUploadManager = QNUploadManager()
  17 + var successBlock: SuccessBlock?
  18 + var progressBlcok: ProgressBlcok?
  19 + private var _qnUploadManager = QNUploadManager()
14 20 static let shared = UploadManager()
15 21 private override init() {
16 22 super.init()
... ... @@ -20,9 +26,75 @@ class UploadManager: NSObject {
20 26 builder?.recorder = try QNFileRecorder(folder: "元码")
21 27 } catch {}
22 28 }
23   -// _qnUploadManager = QNUploadManager(configuration: config)
  29 + _qnUploadManager = QNUploadManager(configuration: config)
24 30 }
25 31  
26 32  
27 33  
  34 + static func uploadImage(imageData: NSData, progressBlock: ProgressBlcok, successBlock: SuccessBlock) {
  35 + let key = UploadManager.createImageFileName()
  36 + UploadManager.shared.successBlock = successBlock
  37 + UploadManager.shared.progressBlcok = progressBlock
  38 + UploadManager.uploadData(data: imageData, key: key)
  39 + }
  40 +
  41 +
  42 +
  43 + /// 上传图片
  44 + /// - Parameters:
  45 + /// - data: 上传数据
  46 + /// - key: key
  47 + /// - uploadProgress: 上传进度
  48 + /// - resultBlock: 结果
  49 + static private func uploadData(data: NSData, key: String) {
  50 +
  51 + CNLiveNetworking.setAllowRequestDefaultArgument(true)
  52 + CNLiveNetworking.setupShowDataResult(false)
  53 + CNLiveNetworking.requestNetwork(with: .POST, urlString: "\(CNLiveEnvironmentManager.shared.baseUrl_shop)/Api/Index3/getQiniuToken", param: [:], cacheType: .networkOnly) { task, result, error in
  54 + if (error == nil) {
  55 + let resp = result as! NSDictionary
  56 + let errorCode = "\(resp["code"] ?? 0)"
  57 + if (errorCode == "0") {
  58 + let data = resp["data"] as! Dictionary<String, Any>
  59 + let token = data["token"] as! String
  60 + if token.isNotBlank() {
  61 + var uploadModel = QiNiuUploadModel.init()
  62 + uploadModel.isCancel = false
  63 + uploadModel.key = key
  64 + let uploadOption = QNUploadOption.init(mime: nil, progressHandler: { key, percent in
  65 + DispatchQueue.main.async {
  66 +// UploadManager.shared.progressBlock
  67 + }
  68 + }, params: nil, checkCrc: false) {
  69 + return uploadModel.isCancel
  70 + }
  71 + }
  72 + } else {
  73 + showMessage(message: resp["message"] as! String)
  74 + }
  75 + } else {
  76 + showMessage(message: error!.localizedDescription)
  77 + }
  78 + }
  79 + }
  80 +
  81 + /// 设置图片名称
  82 + /// - Returns: 图片名
  83 + static private func createImageFileName() -> String {
  84 + let date = NSDate()
  85 + let currentTimeInterval = NSDate(timeIntervalSince1970: 0)
  86 + let imageName = "802/mateCode/img/\(date.string(withFormat: "yyyyMMdd") ?? "0000")/\(arc4random()%10).jpg"
  87 + return imageName
  88 + }
  89 +}
  90 +
  91 +class QiNiuUploadModel: BaseModel {
  92 +
  93 + required init() {
  94 + self.uploadOption = QNUploadOption.defaultOptions()
  95 + }
  96 + ///上传文件的key
  97 + var key:String = ""
  98 + var uploadOption:QNUploadOption
  99 + var isCancel:Bool = false
28 100 }
... ...
metaCode/Classes/Environment/CNLiveEnvironment.swift
... ... @@ -46,6 +46,7 @@ class CNLiveEnvironmentManager: NSObject{
46 46 var appKey: String
47 47 var baseUrl: String
48 48 var appSecret: String
  49 + var baseUrl_shop: String
49 50  
50 51 ///当前环境
51 52 var currentEnvironment: CNLiveEnvironment
... ... @@ -56,6 +57,7 @@ class CNLiveEnvironmentManager: NSObject{
56 57 self.appKey = ""
57 58 self.baseUrl = ""
58 59 self.appSecret = ""
  60 + self.baseUrl_shop = ""
59 61 self.currentEnvironment = .development
60 62 }
61 63 //重新copy 和 mutableCopy 方法
... ... @@ -88,6 +90,7 @@ class CNLiveEnvironmentManager: NSObject{
88 90 self.appKey = "ae3a7ad3e4b9beb7cfe2078db648ebb89aa249ca2e82ac"
89 91 self.appSecret = "3cc9f12db322a3d3656012ef929604cf6d6847471535f9"
90 92 self.baseUrl = "https://api.cnlive.com"
  93 + self.baseUrl_shop = "https://wjjshop.cnlive.com"
91 94 }
92 95 //testFlight 环境配置
93 96 func testFlightEnvironment(){
... ... @@ -95,6 +98,7 @@ class CNLiveEnvironmentManager: NSObject{
95 98 self.appKey = "ae3a7ad3e4b9beb7cfe2078db648ebb89aa249ca2e82ac"
96 99 self.appSecret = "3cc9f12db322a3d3656012ef929604cf6d6847471535f9"
97 100 self.baseUrl = "https://api.cnlive.com"
  101 + self.baseUrl_shop = "https://wjjshop.cnlive.com"
98 102 }
99 103 //production 生产环境配置
100 104 func productionEnvironment(){
... ... @@ -102,6 +106,7 @@ class CNLiveEnvironmentManager: NSObject{
102 106 self.appKey = "064f392f84dfe7bbe9f1eabeda53ea02044213019b0406"
103 107 self.appSecret = "68b5cc42fbdb466d56c2e22b00b1494feec8149f9dd32e"
104 108 self.baseUrl = "https://api.cnlive.com"
  109 + self.baseUrl_shop = "https://managemall.cnlive.com"
105 110 }
106 111  
107 112 }
... ...
metaCode/Classes/Main/LoginPage/Controller/CNLiveLoginViewController.swift
... ... @@ -69,7 +69,7 @@ class CNLiveLoginViewController : CNLiveBaseViewController, UITextViewDelegate {
69 69  
70 70  
71 71 override func viewDidAppear(_ animated: Bool) {
72   - LoginAuthInfoView.showAuthView()
  72 +
73 73 }
74 74  
75 75 override func viewDidLoad() {
... ... @@ -87,6 +87,8 @@ class CNLiveLoginViewController : CNLiveBaseViewController, UITextViewDelegate {
87 87 self.setupPhoneView()
88 88 self.setupVeriCodeView()
89 89 self.setupLoginButtonView()
  90 +
  91 + LoginAuthInfoView.showAuthView()
90 92 }
91 93  
92 94 deinit {
... ... @@ -289,11 +291,13 @@ extension CNLiveLoginViewController {
289 291 }
290 292  
291 293 @objc func pushAgreeActionMothod() {
292   - self.navigationController?.pushViewController(CNLiveInfoShowViewController.init(show_type: .service), animated: true)
  294 + self.present(CNLiveInfoShowViewController.init(show_type: .service, is_login: true), animated: true)
  295 +// navi.pushViewController(CNLiveInfoShowViewController.init(show_type: .service), animated: true)
293 296 }
294 297  
295 298 @objc func pushInfoActionMothod() {
296   - self.navigationController?.pushViewController(CNLiveInfoShowViewController.init(show_type: .privacy), animated: true)
  299 + self.present(CNLiveInfoShowViewController.init(show_type: .service, is_login: true), animated: true)
  300 +// navi.pushViewController(CNLiveInfoShowViewController.init(show_type: .privacy), animated: true)
297 301 }
298 302 }
299 303  
... ...
metaCode/Classes/Main/MinePage/Controller/CNLiveInfoShowViewController.swift
... ... @@ -17,14 +17,24 @@ enum ListShowInfoType {
17 17  
18 18 class CNLiveInfoShowViewController: CNLiveBaseViewController, WKNavigationDelegate, WKUIDelegate {
19 19  
  20 + var _is_login:Bool!
20 21 var _show_type:ListShowInfoType!
21   - init(show_type:ListShowInfoType) {
  22 + init(show_type:ListShowInfoType,is_login:Bool) {
22 23 super.init(nibName:nil, bundle:nil)
23 24 _show_type = show_type
  25 + _is_login = is_login
24 26 }
25 27  
26 28 override func viewWillAppear(_ animated: Bool) {
27   - navigationBarHidden = false
  29 + if _is_login {
  30 + if (self.presentingViewController != nil) {
  31 + //先设置一个默认返回按钮
  32 + let left_btn = UIButton.backItem(imageName: "mine_header_icon_close", target: self, action: #selector(changeCancelAction))
  33 + left_btn.backgroundColor = .white
  34 + let leftBtn_array : Array<UIButton> = [left_btn]
  35 + leftNavBtns = leftBtn_array
  36 + }
  37 + }
28 38 }
29 39  
30 40 required init?(coder: NSCoder) {
... ... @@ -43,6 +53,7 @@ class CNLiveInfoShowViewController: CNLiveBaseViewController, WKNavigationDelega
43 53  
44 54 override func viewDidLoad() {
45 55 super.viewDidLoad()
  56 + navigationBarHidden = false
46 57 var attrString = ""
47 58 switch _show_type {
48 59 case .service:
... ... @@ -65,9 +76,17 @@ class CNLiveInfoShowViewController: CNLiveBaseViewController, WKNavigationDelega
65 76 }
66 77  
67 78 webView.load(URLRequest(url: URL(string: attrString)!, cachePolicy: .returnCacheDataElseLoad))
  79 +
68 80 }
  81 +
69 82  
70   -
  83 + @objc func changeCancelAction() {
  84 + if (self.presentingViewController != nil) {
  85 + self.dismiss(animated: true)
  86 + }else{
  87 + self.navigationController!.popViewController(animated: true)
  88 + }
  89 + }
71 90 // override func viewDidLoad() {
72 91 // super.viewDidLoad()
73 92 // var attrString = ""
... ...
metaCode/Classes/Main/MinePage/Controller/CNLiveTypeFeedBackViewController.swift
... ... @@ -263,7 +263,7 @@ extension CNLiveTypeFeedBackViewController {
263 263 self.navigationController?.pushViewController(CNLiveTypeFeedBackViewController.init(show_type: .manager), animated: true)
264 264 }
265 265 if indexPath.section == 1 {
266   - self.navigationController?.pushViewController(CNLiveInfoShowViewController.init(show_type: .privacy), animated: true)
  266 + self.navigationController?.pushViewController(CNLiveInfoShowViewController.init(show_type: .privacy,is_login: false), animated: true)
267 267 }
268 268 }
269 269 if _show_type == .about {
... ... @@ -271,7 +271,7 @@ extension CNLiveTypeFeedBackViewController {
271 271 print("跳转app商店")
272 272 }
273 273 if indexPath.section == 1 {
274   - self.navigationController?.pushViewController(CNLiveInfoShowViewController.init(show_type: .service), animated: true)
  274 + self.navigationController?.pushViewController(CNLiveInfoShowViewController.init(show_type: .service,is_login: false), animated: true)
275 275 }
276 276 }
277 277 if _show_type == .info {
... ...
metaCode/Classes/Main/MinePage/ViewModel/CNLiveMineViewModel.swift
... ... @@ -120,7 +120,7 @@ class CNLiveMineViewModel: NSObject {
120 120 if CNLiveMineViewModel.timeStamp > NSNumber(string: UserInfoManager.shared.userInfo.expires_in)?.intValue ?? 0 {
121 121 let param = NSMutableDictionary.init()
122 122 param.setValue(APPId, forKey: "appId")
123   - param.setValue("3cc9f12db322a3d3656012ef929604cf6d6847471535f9", forKey: "secret")
  123 + param.setValue(APPSecret, forKey: "secret")
124 124 showLoading(message: "")
125 125 CNLiveNetworking.setAllowRequestDefaultArgument(false)
126 126 CNLiveNetworking.setupShowDataResult(false)
... ...
metaCode/Supporting Files/Assets.xcassets/MinePage/mine_header_icon_close.imageset/Contents.json 0 → 100644
  1 +{
  2 + "images" : [
  3 + {
  4 + "idiom" : "universal",
  5 + "scale" : "1x"
  6 + },
  7 + {
  8 + "filename" : "mine_header_icon_close@2x.png",
  9 + "idiom" : "universal",
  10 + "scale" : "2x"
  11 + },
  12 + {
  13 + "filename" : "mine_header_icon_close@3x.png",
  14 + "idiom" : "universal",
  15 + "scale" : "3x"
  16 + }
  17 + ],
  18 + "info" : {
  19 + "author" : "xcode",
  20 + "version" : 1
  21 + }
  22 +}
... ...
metaCode/Supporting Files/Assets.xcassets/MinePage/mine_header_icon_close.imageset/mine_header_icon_close@2x.png 0 → 100644

1.04 KB

metaCode/Supporting Files/Assets.xcassets/MinePage/mine_header_icon_close.imageset/mine_header_icon_close@3x.png 0 → 100644

1.75 KB