Commit b3173611024e86b3a81301ce1ddf45120aa4630c

Authored by liushiyu
2 parents 86105f9d cc7ae3b3
... ... @@ -67,6 +67,7 @@ target 'metaCode' do
67 67 # pod 'QMUIKit'
68 68 pod 'YYWebImage', :git => 'https://gitee.com/mirrors/YYWebImage.git'
69 69  
  70 + #网页交互
70 71 pod 'WebViewJavascriptBridge'
71 72  
72 73 #依赖三方私有库,如果里面有.a的时候加上这个
... ...
metaCode/Classes/Common/Base/CNLiveBaseViewController.swift
... ... @@ -108,7 +108,9 @@ class CNLiveBaseViewController: UIViewController {
108 108 btn.frame = CGRect(x: lastBtn != nil ? (lastBtn!.origin.x - btn.width) : (topNavView.width - CNLiveBaseViewController.kTopNavLeftRightOffset - btn.width), y: topNavViewHeight - btn.height, width: btn.width, height: btn.height)
109 109 lastBtn = btn
110 110 }
111   - rightNavSpace = CGRectGetMaxX(lastBtn!.frame)
  111 + if _rightNavBtns.count > 0{
  112 + rightNavSpace = CGRectGetMaxX(lastBtn!.frame)
  113 + }
112 114 viewWillLayoutSubviews()
113 115 }
114 116 }
... ...
metaCode/Classes/Extensions/String+Extension.swift
... ... @@ -7,7 +7,7 @@
7 7  
8 8  
9 9 import UIKit
10   -
  10 +import CommonCrypto
11 11  
12 12 extension String {
13 13 /// Calculate text's height from `width` and `front`.
... ... @@ -25,5 +25,63 @@ extension String {
25 25 let substring = self[startIndex..<endIndex]
26 26 return String(substring)
27 27 }
  28 +
  29 + //DES加密
  30 + func crypt(operation:CCOperation, key: String) -> String? {
  31 +
  32 + if let keyData = key.data(using: .utf8) {
  33 +
  34 + var cryptData: Data?
  35 +
  36 + if operation == kCCEncrypt {
  37 + cryptData = self.data(using: .utf8)
  38 + } else {
  39 + cryptData = Data(base64Encoded: self, options: .ignoreUnknownCharacters)
  40 + }
  41 +
  42 + if cryptData == nil {
  43 + return nil
  44 + }
  45 +
  46 + let algoritm: CCAlgorithm = CCAlgorithm(kCCAlgorithmDES)
  47 + let option: CCOptions = CCOptions(kCCOptionPKCS7Padding)
  48 +
  49 + let keyBytes = [UInt8](keyData)
  50 + let keyLength = kCCKeySizeDES
  51 +
  52 + let dataIn = [UInt8](cryptData!)
  53 + let dataInlength = cryptData!.count
  54 +
  55 + let dataOutAvailable = Int(dataInlength + kCCBlockSizeDES)
  56 + let dataOut = UnsafeMutablePointer<UInt8>.allocate(capacity: dataOutAvailable)
  57 + let dataOutMoved = UnsafeMutablePointer<Int>.allocate(capacity: 1)
  58 +
  59 + dataOutMoved.initialize(to: 0)
  60 +
  61 + let cryptStatus = CCCrypt(operation, algoritm, option, keyBytes, keyLength, keyBytes, dataIn, dataInlength, dataOut, dataOutAvailable, dataOutMoved)
  62 +
  63 + var data: Data?
  64 +
  65 + if CCStatus(cryptStatus) == CCStatus(kCCSuccess) {
  66 + data = Data(bytesNoCopy: dataOut, count: dataOutMoved.pointee, deallocator: .none)
  67 + }
  68 +
  69 + dataOutMoved.deallocate()
  70 + dataOut.deallocate()
  71 +
  72 + if data == nil {
  73 + return nil
  74 + }
  75 +
  76 + if operation == kCCEncrypt {
  77 + data = data!.base64EncodedData(options: .lineLength64Characters)
  78 + }
  79 +
  80 + return String(data: data!, encoding: .utf8)
  81 + }
  82 +
  83 + return nil
  84 +
  85 + }
28 86  
29 87 }
... ...
metaCode/Classes/Main/HomePage/Controller/DownSlideController/CNUpSlideDetailViewController.swift
... ... @@ -20,6 +20,8 @@ enum CNLiveHomePageCellType {
20 20 case playletToCourse
21 21 }
22 22  
  23 +let allCourseCellHeight:CGFloat = 75
  24 +
23 25 class CNUpSlideDetailViewController: CNLiveBaseViewController,UITableViewDataSource, UITableViewDelegate,EmptyDataSetSource, EmptyDataSetDelegate {
24 26  
25 27 //slideModel
... ... @@ -96,8 +98,9 @@ class CNUpSlideDetailViewController: CNLiveBaseViewController,UITableViewDataSou
96 98  
97 99 private func setupUI() {
98 100 self.view.layer.masksToBounds = true
  101 + self.view.backgroundColor = .white
99 102 self.view.addSubview(self.tableView)
100   - self.tableView.frame = CGRect(x: 0, y: 0, width: KSreenWidth, height: KSreenHeight)
  103 + self.tableView.frame = CGRect(x: 0, y: KStatusBarHeight, width: KSreenWidth, height: KSreenHeight-KStatusBarHeight)
101 104 view.addSubview(closeBtn)
102 105 view.addGestureRecognizer(dismissPanGesture)
103 106 }
... ... @@ -266,7 +269,7 @@ class CNUpSlideDetailViewController: CNLiveBaseViewController,UITableViewDataSou
266 269 }else if self.cellType == .course || self.cellType == .playletToCourse{
267 270 if self.slideModel?.type == SlideModelTypeAllCourse12{
268 271 //全部课程
269   - return 75
  272 + return allCourseCellHeight
270 273 }else if self.slideModel?.type == SlideModelTypeOneCourse75{
271 274 //大图课程
272 275 return KSreenWidth*(KSreenWidth/DownSlideSingleCourseW)
... ...
metaCode/Classes/Main/HomePage/Controller/WebController/CNWebViewController.swift
... ... @@ -7,17 +7,46 @@
7 7  
8 8 import Foundation
9 9 import WebKit
  10 +import WebViewJavascriptBridge
  11 +import CNLiveShareToolKit
  12 +import CommonCrypto
  13 +import CNLiveBusinessTools
  14 +
  15 +
  16 +let WjjH5 = "wjjh5.cnlive.com"
10 17  
11 18 class CNWebViewController:CNLiveBaseViewController ,WKNavigationDelegate{
12 19  
  20 + var bridge:WKWebViewJavascriptBridge?
  21 + var currentUrl:String = ""//当前网页的url
  22 +
13 23 lazy var webView: WKWebView = {
14   - let webView = WKWebView.init(frame: CGRectMake(0, 0, Width, Height))
  24 + let configuration = WKWebViewConfiguration()
  25 + configuration.allowsInlineMediaPlayback = true
  26 + let preferences = WKPreferences()
  27 + preferences.javaScriptCanOpenWindowsAutomatically = true
  28 + preferences.javaScriptEnabled = true
  29 + configuration.preferences.minimumFontSize = 0.0
  30 + configuration.preferences = preferences
  31 + configuration.userContentController = WKUserContentController()
  32 +
  33 + let webView = WKWebView(frame: CGRectMake(0, 0, Width, Height), configuration: configuration)
15 34 webView.scrollView.showsVerticalScrollIndicator = false
16 35 webView.scrollView.showsHorizontalScrollIndicator = false
17   - webView.navigationDelegate = self
  36 +// webView.navigationDelegate = self
18 37 return webView
19 38 }()
20 39  
  40 + lazy var moreNavBtn: UIButton = {
  41 + let moreNavBtn = UIButton(type: .custom)
  42 + moreNavBtn.frame = CGRect(x: 0, y: KStatusBarHeight, width: KNavigationHeight-KStatusBarHeight, height: KNavigationHeight-KStatusBarHeight)
  43 + moreNavBtn.backgroundColor = .clear
  44 + moreNavBtn.setImage(UIImage(named: "web_more"), for: .normal)
  45 + moreNavBtn.addTarget(self, action: #selector(moreNavBtnAction), for: .touchUpInside)
  46 + return moreNavBtn
  47 + }()
  48 +
  49 +
21 50 var _url:URL?
22 51 var url:URL? {
23 52 get{
... ... @@ -25,19 +54,6 @@ class CNWebViewController:CNLiveBaseViewController ,WKNavigationDelegate{
25 54 }
26 55 set{
27 56 _url = newValue!
28   - if (_url != nil){
29   - let webUrl: URL! = _url!
30   - webView.evaluateJavaScript("navigator.userAgent") { [self] result, error in
31   - let userAgent = result as! String
32   - if error == nil && userAgent.count > 0 {
33   - if !userAgent.contains(CNLiveMCEnvironmentManager.shared.base_web_UA) {
34   - let newUserAgent = userAgent + CNLiveMCEnvironmentManager.shared.base_web_UA
35   - webView.customUserAgent = newUserAgent
36   - }
37   - }
38   - webView.load(URLRequest.init(url:webUrl))
39   - }
40   - }
41 57 }
42 58 }
43 59  
... ... @@ -49,42 +65,197 @@ class CNWebViewController:CNLiveBaseViewController ,WKNavigationDelegate{
49 65 make.top.equalTo(get_system_nav_height())
50 66 make.left.right.bottom.equalToSuperview()
51 67 }
52   -
  68 + webView.evaluateJavaScript("navigator.userAgent") { [self] result, error in
  69 + let userAgent = result as! String
  70 + if error == nil && userAgent.count > 0 {
  71 + if !userAgent.contains(CNLiveMCEnvironmentManager.shared.base_web_UA) {
  72 + let newUserAgent = userAgent + CNLiveMCEnvironmentManager.shared.base_web_UA
  73 + webView.customUserAgent = newUserAgent
  74 +
  75 + if (_url != nil){
  76 + let urlStr = self.checkURLWithStr(urlStr: _url!.absoluteString)
  77 + self.currentUrl = urlStr
  78 +
  79 + webView.load(URLRequest.init(url:URL(string: urlStr)!))
  80 + }
  81 + self.configBridge()
  82 + self.configBridgeRegister()
  83 + }
  84 + }
  85 + }
  86 + }
  87 +
  88 + func configBridge(){
  89 + WKWebViewJavascriptBridge.enableLogging()
  90 + self.bridge = WKWebViewJavascriptBridge(for: self.webView)
  91 + self.bridge?.setWebViewDelegate(self)
  92 + }
  93 + //h5拉起原生分享 js call oc
  94 + func configBridgeRegister() -> Void {
  95 + self.bridge?.registerHandler("wjjylzgVideoShare", handler: { data, responseCallback in
  96 +// print("js call oc\(data)")
  97 + let dic = data as! Dictionary<String, String>
  98 + CNLiveShareManager.showShareViewWithParam(forShareTitle: dic["title"], shareUrl: dic["shareUrl"], shareDesc: dic["subTitle"], shareImage: dic["cover"], screenFull: false, hiddenWjj: true, hiddenQQ: false, hiddenWB: true, hiddenLifeCircle: true, hiddenWechatCircle: false, hiddenWechat: false, hiddenSafari: true, formVC: self, topImage: [], topTitles: [], platformType: .all) { title in
  99 +
  100 + } completerBlock: { resultType, platformType, typeString in
  101 + if resultType == .succ{
  102 +
  103 + }
  104 + }
  105 +
  106 + })
  107 + }
  108 +
  109 + //点击...分享获取h5参数oc call js
  110 + func configBridgeCallHander() -> Void {
  111 + self.bridge?.callHandler("wjjClientGetShareParaFromJS", data: ["":""], responseCallback: { data in
  112 +// print("js call oc\(data)")
  113 + let dic = data as! Dictionary<String, String>
  114 +// let shareType = dic["shareType"]
  115 +// let contentIdStr = dic["activityId"]
  116 + let title = dic["title"]
  117 + let desc = dic["desc"]
  118 + let shareImg = dic["shareImg"]
  119 +
  120 + var shareUrl = ""
  121 + if let tempShareUrl = dic["shareUrl"]{
  122 + if tempShareUrl == ""{
  123 + shareUrl = self.currentUrl
  124 + }else{
  125 + shareUrl = tempShareUrl
  126 + }
  127 + }else{
  128 + shareUrl = self.currentUrl
  129 + }
  130 +
  131 + CNLiveShareManager.showShareViewWithParam(forShareTitle: title, shareUrl: shareUrl, shareDesc: desc, shareImage: shareImg, screenFull: false, hiddenWjj: true, hiddenQQ: false, hiddenWB: true, hiddenLifeCircle: true, hiddenWechatCircle: false, hiddenWechat: false, hiddenSafari: true, formVC: self, topImage: [], topTitles: [], platformType: .all) { title in
  132 +
  133 + } completerBlock: { resultType, platformType, typeString in
  134 + if resultType == .succ{
  135 +
  136 + }
  137 + }
  138 + })
  139 + }
  140 +
  141 + func checkURLWithStr(urlStr:String) -> String{
  142 + if URL(string: urlStr)?.host != WjjH5 {
  143 + return urlStr//不是wjjh5不作处理
  144 + }
  145 + var str = urlStr
  146 + let date = Date()
  147 + let formatter = DateFormatter()
  148 + formatter.dateFormat = "yyyyMMdd"
  149 + let dateStr = formatter.string(from: date)
  150 + let sidStr = String(format: "%@%@", UserInfoManager.shared.userInfo.uid,dateStr)
  151 + let signStr = sidStr.crypt(operation: CCOperation(kCCEncrypt), key: CNLiveMCEnvironmentManager.shared.appKey)
  152 + //看是 appKey还是appKeywjj
  153 + let sidSignStr = (signStr ?? "").isEmpty ? "" : signStr
  154 + let sourceArray = str.components(separatedBy: "?")
  155 + let buildVersion = Bundle.main.infoDictionary!["CFBundleVersion"] as! String
  156 + let appVersion = Bundle.main.infoDictionary!["CFBundleShortVersionString"] as! String
  157 + let uuid = CNLiveBusinessTools.getUidForStat(Date())
  158 + if sourceArray.count == 1{
  159 + //是wjjh5且无参数
  160 + str = String(format: "%@?shareSid=%@&sid=%@&plat=i&ver=%@&version=%@&wjjFrom=apple&wjjUUID=%@&appId=%@&voteId=%@&wjjToken=%@", str,UserInfoManager.shared.userInfo.uid,UserInfoManager.shared.userInfo.uid,buildVersion,appVersion,uuid,CNLiveMCEnvironmentManager.shared.appId,sidSignStr!,UserInfoManager.shared.userInfo.token)
  161 + return str
  162 + }
  163 + //是wjjh5且有参数
  164 + let paraArr = NSMutableArray(array: ["shareSid=","sid=","plat=","ver=","version=","wjjFrom=","wjjUUID=","appId=","voteId=","wjjToken="])
  165 + let valueArr = NSMutableArray(array:[UserInfoManager.shared.userInfo.uid,UserInfoManager.shared.userInfo.uid,"i",buildVersion,appVersion,"apple",uuid,CNLiveMCEnvironmentManager.shared.appId,sidSignStr!,UserInfoManager.shared.userInfo.token])
  166 + var i = 0
  167 + for paraStr in paraArr{
  168 + let tempStr = paraStr as! String
  169 + let paramStr = "&".appending(tempStr)
  170 + let paramStr2 = "?".appending(tempStr)
  171 +
  172 + if str.contains(paramStr){
  173 + //包含则替换 &sid=
  174 + let lastStr = str.components(separatedBy: tempStr).last
  175 + let lastSeparatedStr = (lastStr?.components(separatedBy: "&").first)!
  176 + let oldStr = tempStr.appending(lastSeparatedStr)
  177 + let tempValueStr = tempStr.appending(valueArr[i] as! String)
  178 + str = str.replacingOccurrences(of: oldStr, with: tempValueStr)
  179 + }else if str.contains(paramStr2){
  180 + //包含则替换 &sid=
  181 + let lastStr = str.components(separatedBy: tempStr).last
  182 + let lastSeparatedStr = (lastStr?.components(separatedBy: "&").first)!
  183 + let oldStr = tempStr.appending(lastSeparatedStr)
  184 + let tempValueStr = tempStr.appending(valueArr[i] as! String)
  185 + str = str.replacingOccurrences(of: oldStr, with: tempValueStr)
  186 + }else{
  187 + //不包含则拼接
  188 + str = String(format: "%@&%@%@", str,tempStr,valueArr[i] as! String)
  189 + }
  190 + i = i + 1
  191 + }
  192 + return str
  193 + }
  194 +
  195 + // MARK: - BtnAction
  196 + // 内部链接右上角···分享
  197 + @objc func moreNavBtnAction(){
  198 + self.configBridgeCallHander()
  199 + }
  200 + override func ClickBackBtn() {
  201 + if self.webView.canGoBack{
  202 + self.webView.goBack()
  203 + }else{
  204 + super.ClickBackBtn()
  205 + }
53 206 }
54 207  
55 208 // MARK: - WKWebViewDelegate
56 209 // 页面开始加载时调用
57 210 func webView(_ webView: WKWebView, didStartProvisionalNavigation navigation: WKNavigation!) {
58   - print("didStartProvisionalNavigation")
  211 +// print("didStartProvisionalNavigation")
59 212 }
60 213 // 当内容开始返回时调用
61 214 func webView(_ webView: WKWebView, didCommit navigation: WKNavigation!) {
62   - print("didCommit")
  215 +// print("didCommit")
63 216 }
  217 +
64 218 // 页面加载完成之后调用
65 219 func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) {
66   - print("didFinish")
  220 +// print("didFinish")
67 221 titleName = webView.title!
68 222 }
69 223 // 页面加载失败时调用
70 224 func webView(_ webView: WKWebView, didFailProvisionalNavigation navigation: WKNavigation!, withError error: Error) {
71   - print("didFailProvisionalNavigation")
  225 +// print("didFailProvisionalNavigation")
72 226 }
73 227 // 接收到服务器跳转请求之后调用
74 228 func webView(_ webView: WKWebView, didReceiveServerRedirectForProvisionalNavigation navigation: WKNavigation!) {
75   - print("didReceiveServerRedirectForProvisionalNavigation")
  229 +// print("didReceiveServerRedirectForProvisionalNavigation")
76 230 }
77 231 // 在收到响应后,决定是否跳转 -> 默认允许
78 232 func webView(_ webView: WKWebView, decidePolicyFor navigationResponse: WKNavigationResponse, decisionHandler: @escaping (WKNavigationResponsePolicy) -> Void) {
79   - print("decidePolicyFor")
  233 +
  234 +// print("decidePolicyFornavigationResponse")
  235 +
80 236 //允许跳转
81 237 decisionHandler(.allow)
82 238 //不允许跳转
83 239 // decisionHandler(.cancel)
84 240 }
85 241 // 在发送请求之前,决定是否跳转 -> 默认允许
86   - @available(iOS 13.0, *)
87   - func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, preferences: WKWebpagePreferences, decisionHandler: @escaping (WKNavigationActionPolicy, WKWebpagePreferences) -> Void) {
  242 + func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, decisionHandler: @escaping (WKNavigationActionPolicy) -> Void) {
  243 +// print("decidePolicyFornavigationAction")
  244 +
  245 + var urlStr = (navigationAction.request.url?.absoluteString)!
  246 +
  247 + if navigationAction.request.url?.host == WjjH5 {
  248 +
  249 + if urlStr.contains("&isWjjReport=true") || urlStr.contains("?isWjjReport=true"){
  250 + self.rightNavBtns = [self.moreNavBtn]
  251 + self.moreNavBtn.isHidden = false
  252 + }else{
  253 + self.moreNavBtn.isHidden = true
  254 + }
  255 +
  256 + urlStr = self.checkURLWithStr(urlStr: urlStr)
  257 + self.currentUrl = urlStr
  258 + }
88 259  
89 260 if navigationAction.navigationType == .other{
90 261 //跳转Appstore
... ... @@ -93,7 +264,10 @@ class CNWebViewController:CNLiveBaseViewController ,WKNavigationDelegate{
93 264 if UIApplication.shared.canOpenURL(url!) { UIApplication.shared.open(url!, options: [:], completionHandler: nil)
94 265 }
95 266 }
  267 + }else if navigationAction.navigationType == .linkActivated{
  268 +
  269 +
96 270 }
97   - decisionHandler(.allow, preferences)
  271 + decisionHandler(.allow)
98 272 }
99 273 }
... ...
metaCode/Classes/Main/HomePage/View/VerticalViews/MainView/CNIDCardView.swift
... ... @@ -73,39 +73,6 @@ class CNIDCardView: UIView{
73 73 if respStatue == .success {
74 74 let cardArray = result as! NSMutableArray
75 75 self.cardUIWithArray(cardArr: cardArray)
76   -
77   -// if cardArray.count > 0{
78   -// for i in (0..<cardArray.count){
79   -// let idCardModel = cardArray[i] as! MineStandInfoModel
80   -// let siBianGap:CGFloat = 17
81   -// let labelsGap:CGFloat = 10
82   -//
83   -// let keyLabel = UILabel.init()
84   -// keyLabel.textColor = HexColor(_idModel?.backgroundColor ?? "")
85   -// keyLabel.textAlignment = .left
86   -// keyLabel.font = Font(15)
87   -// keyLabel.backgroundColor = .clear
88   -// keyLabel.text = idCardModel.name ?? ""
89   -// keyLabel.frame = CGRect(x: siBianGap, y: siBianGap+CGFloat(i)*21+CGFloat(i)*labelsGap, width: 70, height: 21)
90   -// keyLabel.adjustsFontSizeToFitWidth = true
91   -// keyLabel.tag = 10000+i
92   -// self.addSubview(keyLabel)
93   -//
94   -// let valueLabel = UILabel.init()
95   -// valueLabel.textColor = HexColor(_idModel?.backgroundColor ?? "")
96   -// valueLabel.textAlignment = .left
97   -// valueLabel.font = Font(15)
98   -// valueLabel.backgroundColor = .clear
99   -// valueLabel.text = idCardModel.userInfo ?? ""
100   -// valueLabel.frame = CGRect(x: keyLabel.right+labelsGap+siBianGap, y: siBianGap+CGFloat(i)*21+CGFloat(i)*labelsGap, width: self.width-keyLabel.right-labelsGap-siBianGap-5, height: 21)
101   -// valueLabel.adjustsFontSizeToFitWidth = true
102   -// valueLabel.tag = 20000+i
103   -// self.addSubview(valueLabel)
104   -//
105   -// }
106   -// }else{
107   -// //没数据
108   -// }
109 76 }
110 77 }
111 78 }
... ... @@ -116,6 +83,24 @@ class CNIDCardView: UIView{
116 83 view.removeFromSuperview()
117 84 }
118 85 }
  86 +
  87 + var maxLblWidth:CGFloat = 0
  88 + for model in cardArr {
  89 + let idCardMdl = model as! MineStandInfoModel
  90 +
  91 + let keyLabel = UILabel.init()
  92 + keyLabel.textAlignment = .left
  93 + keyLabel.font = Font(15)
  94 + keyLabel.backgroundColor = .clear
  95 + keyLabel.text = idCardMdl.name ?? ""
  96 + keyLabel.sizeToFit()
  97 + let lblWidth = keyLabel.bounds.size.width
  98 + if maxLblWidth < lblWidth{
  99 + //更新更大的label宽度
  100 + maxLblWidth = lblWidth
  101 + }
  102 + }
  103 +
119 104 let cardArray = NSMutableArray(array: cardArr)
120 105 if cardArray.count > 0{
121 106 for i in (0..<cardArray.count){
... ... @@ -123,16 +108,48 @@ class CNIDCardView: UIView{
123 108 let siBianGap:CGFloat = 17
124 109 let labelsGap:CGFloat = 10
125 110  
126   - let keyLabel = UILabel.init()
127   - keyLabel.textColor = HexColor(_idModel?.backgroundColor ?? "")
128   - keyLabel.textAlignment = .left
129   - keyLabel.font = Font(15)
130   - keyLabel.backgroundColor = .clear
131   - keyLabel.text = idCardModel.name ?? ""
132   - keyLabel.frame = CGRect(x: siBianGap, y: siBianGap+CGFloat(i)*21+CGFloat(i)*labelsGap, width: 70, height: 21)
133   - keyLabel.adjustsFontSizeToFitWidth = true
134   - keyLabel.tag = 10000+i
135   - self.addSubview(keyLabel)
  111 + var keyLblRight:CGFloat = 0
  112 + if idCardModel.name?.count == 2{
  113 + //2个字特殊处理,2边对齐
  114 + let keyLabel1 = UILabel.init()
  115 + keyLabel1.textColor = HexColor(_idModel?.backgroundColor ?? "")
  116 + keyLabel1.textAlignment = .left
  117 + keyLabel1.font = Font(15)
  118 + keyLabel1.backgroundColor = .clear
  119 + keyLabel1.text = idCardModel.name?.subString(start: 0, length: 1) ?? ""
  120 + keyLabel1.sizeToFit()
  121 + keyLabel1.frame = CGRect(x: siBianGap, y: siBianGap+CGFloat(i)*21+CGFloat(i)*labelsGap, width: maxLblWidth, height: keyLabel1.bounds.size.height)
  122 + keyLabel1.adjustsFontSizeToFitWidth = true
  123 + keyLabel1.tag = 10000+i+100
  124 + self.addSubview(keyLabel1)
  125 +
  126 + let keyLabel2 = UILabel.init()
  127 + keyLabel2.textColor = HexColor(_idModel?.backgroundColor ?? "")
  128 + keyLabel2.textAlignment = .right
  129 + keyLabel2.font = Font(15)
  130 + keyLabel2.backgroundColor = .clear
  131 + keyLabel2.text = idCardModel.name?.subString(start: 1, length: 1) ?? ""
  132 + keyLabel2.sizeToFit()
  133 + keyLabel2.frame = CGRect(x: siBianGap, y: siBianGap+CGFloat(i)*21+CGFloat(i)*labelsGap, width: maxLblWidth, height: keyLabel1.bounds.size.height)
  134 + keyLabel2.adjustsFontSizeToFitWidth = true
  135 + keyLabel2.tag = 10000+i+200
  136 + self.addSubview(keyLabel2)
  137 + keyLblRight = keyLabel2.right
  138 + }else{
  139 + //其他字数左对齐
  140 + let keyLabel = UILabel.init()
  141 + keyLabel.textColor = HexColor(_idModel?.backgroundColor ?? "")
  142 + keyLabel.textAlignment = .left
  143 + keyLabel.font = Font(15)
  144 + keyLabel.backgroundColor = .clear
  145 + keyLabel.text = idCardModel.name ?? ""
  146 + keyLabel.sizeToFit()
  147 + keyLabel.frame = CGRect(x: siBianGap, y: siBianGap+CGFloat(i)*21+CGFloat(i)*labelsGap, width: keyLabel.bounds.size.width, height: keyLabel.bounds.size.height)
  148 + keyLabel.adjustsFontSizeToFitWidth = true
  149 + keyLabel.tag = 10000+i
  150 + self.addSubview(keyLabel)
  151 + keyLblRight = keyLabel.right
  152 + }
136 153  
137 154 let valueLabel = UILabel.init()
138 155 valueLabel.textColor = HexColor(_idModel?.backgroundColor ?? "")
... ... @@ -140,7 +157,7 @@ class CNIDCardView: UIView{
140 157 valueLabel.font = Font(15)
141 158 valueLabel.backgroundColor = .clear
142 159 valueLabel.text = idCardModel.userInfo ?? ""
143   - valueLabel.frame = CGRect(x: keyLabel.right+labelsGap+siBianGap, y: siBianGap+CGFloat(i)*21+CGFloat(i)*labelsGap, width: self.width-keyLabel.right-labelsGap-siBianGap-5, height: 21)
  160 + valueLabel.frame = CGRect(x: keyLblRight+labelsGap+siBianGap, y: siBianGap+CGFloat(i)*21+CGFloat(i)*labelsGap, width: self.width-keyLblRight-labelsGap-siBianGap-5, height: 21)
144 161 valueLabel.adjustsFontSizeToFitWidth = true
145 162 valueLabel.tag = 20000+i
146 163 self.addSubview(valueLabel)
... ...
metaCode/Classes/Main/HomePage/View/VerticalViews/MainView/CNMainView.swift
... ... @@ -56,35 +56,51 @@ class CNFrontMainView : UIView{
56 56 make.bottom.equalToSuperview()
57 57 }
58 58  
  59 +
  60 + frontDescContentView.addSubview(self.agencyTipsLabel)
  61 + agencyTipsLabel.snp.makeConstraints { make in
  62 + make.centerX.equalToSuperview()
  63 + make.bottom.equalToSuperview().offset(-62-36-8)
  64 + make.width.equalTo(self.width-60)
  65 + }
  66 +
  67 + frontDescContentView.addSubview(self.enterpriseTipsLabel)
  68 + enterpriseTipsLabel.snp.makeConstraints { make in
  69 + make.centerX.equalToSuperview()
  70 + make.bottom.equalTo(self.agencyTipsLabel.snp.top).offset(-2)
  71 + make.width.equalTo(self.agencyTipsLabel.snp.width)
  72 + }
  73 +
  74 +
59 75 frontDescContentView.addSubview(self.addStandBtn)
60 76 addStandBtn.snp.makeConstraints { make in
61 77 make.centerX.equalToSuperview()
62   - make.bottom.equalToSuperview().offset(-30)
  78 + make.bottom.equalToSuperview().offset(-62)
63 79 make.width.equalTo(150)
64   - make.height.equalTo(39)
  80 + make.height.equalTo(36)
65 81 }
66 82  
67 83 frontDescContentView.addSubview(self.personalStandBtn)
68 84 personalStandBtn.snp.makeConstraints { make in
69 85 make.right.equalToSuperview().offset(-self.width/2)
70   - make.bottom.equalToSuperview().offset(-45)
  86 + make.bottom.equalTo(self.addStandBtn.snp.bottom)
71 87 make.width.equalTo(120)
72   - make.height.equalTo(36)
  88 + make.height.equalTo(self.addStandBtn.snp.height)
73 89 }
74 90 frontDescContentView.addSubview(self.enterpriseStandBtn)
75 91 enterpriseStandBtn.snp.makeConstraints { make in
76 92 make.left.equalTo(self.personalStandBtn.snp.right)
77   - make.bottom.equalToSuperview().offset(-45)
  93 + make.bottom.equalTo(self.addStandBtn.snp.bottom)
78 94 make.width.equalTo(120)
79   - make.height.equalTo(36)
  95 + make.height.equalTo(self.addStandBtn.snp.height)
80 96 }
81 97  
82 98 frontDescContentView.addSubview(self.unStandBtnBgView)
83 99 unStandBtnBgView.snp.makeConstraints { make in
84 100 make.left.equalToSuperview().offset(30)
85   - make.bottom.equalToSuperview().offset(-45)
  101 + make.bottom.equalTo(self.addStandBtn.snp.bottom)
86 102 make.width.equalTo(self.width-60)
87   - make.height.equalTo(36)
  103 + make.height.equalTo(self.addStandBtn.snp.height)
88 104 }
89 105  
90 106  
... ... @@ -116,6 +132,27 @@ class CNFrontMainView : UIView{
116 132 return textView
117 133 }()
118 134  
  135 + ///未认证-企业认证提示
  136 + lazy var enterpriseTipsLabel: UILabel = {
  137 + let enterpriseTipsLabel = UILabel.init(frame: CGRectMake(0, 0, 0, 0))
  138 + enterpriseTipsLabel.textColor = .white
  139 + enterpriseTipsLabel.textAlignment = .center
  140 + enterpriseTipsLabel.font = Font(9)
  141 + enterpriseTipsLabel.text = "企业认证适合企业、个体工商户申请"
  142 + enterpriseTipsLabel.adjustsFontSizeToFitWidth=true
  143 + return enterpriseTipsLabel
  144 + }()
  145 + ///未认证-机构认证提示
  146 + lazy var agencyTipsLabel: UILabel = {
  147 + let agencyTipsLabel = UILabel.init(frame: CGRectMake(0, 0, 0, 0))
  148 + agencyTipsLabel.textColor = .white
  149 + agencyTipsLabel.textAlignment = .center
  150 + agencyTipsLabel.font = Font(9)
  151 + agencyTipsLabel.text = "机构认证适合国家机构、社会组织、高校等申请"
  152 + agencyTipsLabel.adjustsFontSizeToFitWidth=true
  153 + return agencyTipsLabel
  154 + }()
  155 +
119 156 ///未认证-店铺认证 按钮(一个按钮时)
120 157 lazy var addStandBtn: UIButton = {
121 158 let addStandBtn = UIButton(type: .custom)
... ... @@ -206,21 +243,21 @@ class CNFrontMainView : UIView{
206 243 make.left.equalToSuperview()
207 244 make.top.equalToSuperview()
208 245 make.width.equalTo((self.width-60)/3)
209   - make.height.equalTo(36)
  246 + make.height.equalToSuperview()
210 247 }
211 248 unStandBtnBgView.addSubview(self.StandBtn2)
212 249 StandBtn2.snp.makeConstraints { make in
213 250 make.centerX.equalToSuperview()
214 251 make.top.equalToSuperview()
215 252 make.width.equalTo(self.StandBtn1.snp.width)
216   - make.height.equalTo(36)
  253 + make.height.equalToSuperview()
217 254 }
218 255 unStandBtnBgView.addSubview(self.StandBtn3)
219 256 StandBtn3.snp.makeConstraints { make in
220 257 make.right.equalToSuperview()
221 258 make.top.equalToSuperview()
222 259 make.width.equalTo(self.StandBtn1.snp.width)
223   - make.height.equalTo(36)
  260 + make.height.equalToSuperview()
224 261 }
225 262  
226 263 unStandBtnBgView.addSubview(self.line1View)
... ... @@ -268,16 +305,17 @@ class CNFrontMainView : UIView{
268 305 lazy var upMoreGIF: UIImageView = {
269 306 let upMoreGIF = UIImageView()
270 307 upMoreGIF.frame = CGRect(x: self.width - 50, y: 0, width: 50, height: 30)
  308 + upMoreGIF.contentMode = .scaleAspectFit
271 309 return upMoreGIF
272 310 }()
273 311 //下滑更多Gif
274 312 lazy var downMoreGIF: UIImageView = {
275 313 let downMoreGIF = UIImageView()
276 314 downMoreGIF.frame = CGRect(x: self.width - 50, y: 0, width: 96, height: 30)
  315 + downMoreGIF.contentMode = .scaleAspectFit
277 316 return downMoreGIF
278 317 }()
279 318  
280   - // MARK: - 已认证
281 319 ///已认证-前置视图卡片容器
282 320 lazy var frontCardContentView : UIView = {
283 321  
... ... @@ -296,7 +334,7 @@ class CNFrontMainView : UIView{
296 334 frontCardContentView.addSubview(self.iDCardView)
297 335 iDCardView.snp.makeConstraints { make in
298 336 make.centerX.equalToSuperview()
299   - make.bottom.equalToSuperview().offset(-(45-30)/2.0-30-10)
  337 + make.bottom.equalToSuperview().offset(-62)
300 338 make.width.equalTo(262*KSreenWidth/375)
301 339 make.height.equalTo(0.52*262*KSreenWidth/375)
302 340 }
... ... @@ -352,22 +390,11 @@ class CNFrontMainView : UIView{
352 390 self.upMoreGIF.removeFromSuperview()
353 391 }
354 392 frontCardContentView.addSubview(self.upMoreGIF)
355   - upMoreGIF.snp.makeConstraints { make in
356   - make.top.equalToSuperview().offset(5)
357   - make.right.equalToSuperview().offset(-self.width/2+24)
358   - make.width.equalTo(48)
359   - make.height.equalTo(30)
360   - }
361 393 if frontCardContentView.contains(self.downMoreGIF){
362 394 self.downMoreGIF.removeFromSuperview()
363 395 }
364 396 frontCardContentView.addSubview(self.downMoreGIF)
365   - downMoreGIF.snp.makeConstraints { make in
366   - make.top.equalTo(self.iDCardView.snp.bottom).offset((45-30)/2.0)
367   - make.centerX.equalToSuperview()
368   - make.width.equalTo(96)
369   - make.height.equalTo(30)
370   - }
  397 + self.setUpMoreGIFAndDownMoreGIF()
371 398 //上滑 下滑引导gif
372 399 upMoreGIF.kf.setImage(with: URL(string: newValue!.upGuideImg))
373 400 downMoreGIF.kf.setImage(with: URL(string: newValue!.downGuideImg))
... ... @@ -477,6 +504,22 @@ class CNFrontMainView : UIView{
477 504 self.enterpriseStandBtn.isHidden = true
478 505 self.unStandBtnBgView.isHidden = true
479 506 }
  507 +
  508 + //有企业认证显示提示lbl
  509 + if idModel!.enterpriseAuth{
  510 + self.enterpriseTipsLabel.isHidden = false
  511 + self.enterpriseTipsLabel.textColor = HexColor(newValue!.backgroundColor)
  512 + }else{
  513 + self.enterpriseTipsLabel.isHidden = true
  514 + }
  515 + //有机构认证显示提示lbl
  516 + if idModel!.agencyAuth{
  517 + self.agencyTipsLabel.isHidden = false
  518 + self.agencyTipsLabel.textColor = HexColor(newValue!.backgroundColor)
  519 + }else{
  520 + self.agencyTipsLabel.isHidden = false
  521 + }
  522 +
480 523 }
481 524  
482 525 self.addStandBtn.backgroundColor = HexColor(newValue!.backgroundColor)
... ... @@ -488,22 +531,12 @@ class CNFrontMainView : UIView{
488 531 self.upMoreGIF.removeFromSuperview()
489 532 }
490 533 frontDescContentView.addSubview(self.upMoreGIF)
491   - upMoreGIF.snp.makeConstraints { make in
492   - make.top.equalToSuperview().offset(5)
493   - make.right.equalToSuperview().offset(-self.width/2+24)
494   - make.width.equalTo(48)
495   - make.height.equalTo(30)
496   - }
497 534 if frontDescContentView.contains(self.downMoreGIF){
498 535 self.downMoreGIF.removeFromSuperview()
499 536 }
500 537 frontDescContentView.addSubview(self.downMoreGIF)
501   - downMoreGIF.snp.makeConstraints { make in
502   - make.top.equalTo(self.personalStandBtn.snp.bottom).offset((45-30)/2.0)
503   - make.centerX.equalTo(self.personalStandBtn.snp.right)
504   - make.width.equalTo(96)
505   - make.height.equalTo(30)
506   - }
  538 +
  539 + self.setUpMoreGIFAndDownMoreGIF()
507 540 //上滑 下滑引导gif
508 541 upMoreGIF.kf.setImage(with: URL(string: newValue!.upGuideImg))
509 542 downMoreGIF.kf.setImage(with: URL(string: newValue!.downGuideImg))
... ... @@ -516,6 +549,22 @@ class CNFrontMainView : UIView{
516 549 }
517 550 }
518 551  
  552 + func setUpMoreGIFAndDownMoreGIF(){
  553 + upMoreGIF.snp.makeConstraints { make in
  554 + make.top.equalToSuperview().offset(20)
  555 + make.centerX.equalToSuperview()
  556 + make.width.equalTo(96)
  557 + make.height.equalTo(30)
  558 + }
  559 + downMoreGIF.snp.makeConstraints { make in
  560 + make.bottom.equalToSuperview().offset(-19)
  561 + make.centerX.equalToSuperview()
  562 + make.width.equalTo(96)
  563 + make.height.equalTo(30)
  564 + }
  565 + }
  566 +
  567 +
519 568 let unStandBtnBgViewLayer = "unStandBtnBgViewLayer"
520 569 func setUnStandBtnBgViewLayer(startHex:String,endHex:String){
521 570 let payLayer = self.subLayer(name: unStandBtnBgViewLayer, viewLayer: self.unStandBtnBgView.layer)
... ...
metaCode/Classes/Main/HomePages/View/HomepageDetail/CNLiveAlbumImageCell.swift
... ... @@ -13,7 +13,6 @@ class CNLiveAlbumImageCell:UITableViewCell{
13 13 lazy var iconImgView :UIImageView = {
14 14 let iconImgView = UIImageView(frame: CGRect(x: (KSreenWidth - KSreenWidth*(KSreenWidth/DownSlideSingleCourseW))/2, y: 0, width: KSreenWidth*(KSreenWidth/DownSlideSingleCourseW), height: KSreenWidth*(KSreenWidth/DownSlideSingleCourseW)))
15 15 iconImgView.contentMode = .scaleAspectFill
16   - iconImgView.clipsToBounds = true
17 16 return iconImgView
18 17 }()
19 18  
... ... @@ -30,7 +29,7 @@ class CNLiveAlbumImageCell:UITableViewCell{
30 29 private func setupUI() {
31 30 contentView.backgroundColor = HexColor(kCNDownSlideBackgroundColorHex)
32 31 self.contentView.addSubview(self.iconImgView)
33   -
  32 + self.contentView.clipsToBounds = true
34 33 }
35 34  
36 35  
... ...
metaCode/Classes/Main/HomePages/View/HomepageDetail/CNLiveDuanjuTitleCell.swift
... ... @@ -18,10 +18,10 @@ class CNLiveDuanjuTitleCell:UITableViewCell{
18 18  
19 19 if self.cellType == .course || self.cellType == .playletToCourse{
20 20 self.blockTitleLabl.text = _blockName ?? "全部课程"
21   - self.blockTitleLabl.top = KStatusBarHeight+10
  21 + self.blockTitleLabl.top = (allCourseCellHeight-30)/2
22 22 }else if self.cellType == .playlet{
23 23 self.blockTitleLabl.text = _blockName ?? "在追短剧"
24   - self.blockTitleLabl.top = 10
  24 + self.blockTitleLabl.top = (45-30)/2
25 25  
26 26 }
27 27 }
... ...
metaCode/Classes/Main/HomePages/View/PlayletHomePage/CNLivePlayletHomePageCell.swift
... ... @@ -95,7 +95,7 @@ class CNLivePlayletHomePageCell:UITableViewCell{
95 95 }
96 96 }else{
97 97 //需要付费
98   - if model.product?.productType == "0"{
  98 + if model.product?.productType == "0" || model.product?.productType == "4"{
99 99 //免费
100 100 self.payIconImgView.isHidden = true
101 101 }else if model.product?.productType == "1"{
... ...
metaCode/Classes/Main/HomePages/View/PlayletHomePage/CNLivePlayletHomePageHeaderCell.swift
... ... @@ -242,7 +242,7 @@ class CNLivePlayletHomePageHeaderCell:UITableViewCell{
242 242 //需要付费
243 243 self.paymentBtn.isUserInteractionEnabled = true
244 244 self.paymentChangeStatus(isPayed: false)
245   - if model.product?.albumProductType == "0"{
  245 + if model.product?.albumProductType == "0" || model.product?.albumProductType == "4"{
246 246 //免费
247 247 self.payIconImgView.isHidden = true
248 248 }else if model.product?.albumProductType == "1"{
... ...
metaCode/Supporting Files/Assets.xcassets/WebView/Contents.json 0 → 100644
  1 +{
  2 + "info" : {
  3 + "author" : "xcode",
  4 + "version" : 1
  5 + }
  6 +}
... ...
metaCode/Supporting Files/Assets.xcassets/WebView/web_more.imageset/Contents.json 0 → 100644
  1 +{
  2 + "images" : [
  3 + {
  4 + "idiom" : "universal",
  5 + "scale" : "1x"
  6 + },
  7 + {
  8 + "filename" : "web_more@2x.png",
  9 + "idiom" : "universal",
  10 + "scale" : "2x"
  11 + },
  12 + {
  13 + "filename" : "web_more@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/WebView/web_more.imageset/web_more@2x.png 0 → 100644

450 Bytes

metaCode/Supporting Files/Assets.xcassets/WebView/web_more.imageset/web_more@3x.png 0 → 100644

931 Bytes