CNUpSlideView.swift
3.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
//
// CNUpSlideView.swift
// metaCode
//
// Created by daojian on 2023/5/31.
// 上滑后的下面页面
import Foundation
import WebKit
let UpDownTypeH5 = 1///h5
let UpDownTypePage = 2///原生page页面
let UpDownTypeShopDetail = 3///店铺详情
let UpDownTypeShopControlConsole = 4///店铺控制台
let UpDownTypeAuthAlertUp = 5///上滑地址 认证-弹窗
let UpDownTypeAuthAlertDown = 6///下滑地址 认证-弹窗
///上滑显示的VIew
class CNUpSlideView:UIView{
lazy var webView: CNWebView = {
let configuration = WKWebViewConfiguration()
configuration.allowsInlineMediaPlayback = true
let preferences = WKPreferences()
preferences.javaScriptCanOpenWindowsAutomatically = true
preferences.javaScriptEnabled = true
configuration.preferences.minimumFontSize = 0.0
configuration.preferences = preferences
configuration.userContentController = WKUserContentController()
var url:URL?
if (_downPath != ""){
url = URL.init(string: "http://wjjh5.cnlive.com/cnBlockMore.html?channelName=yjzg&pageId=&isShowTitle=true&blockType=28&contentType=13&title=%E5%9B%AD%E9%95%BF%E8%AF%BE%E7%A8%8B&pageName=&moreUrl=https%3A%2F%2Fcmsapi.cnlive.com%2FcontentApi%2FgetBlockContents%3FblockId%3D12165")//_downPath!)//"https://managemall.cnlive.com/html/mall/1/#/pages/main/goodsList/goodsList?scene=app")//
}else{
url = nil
}
let webView = CNWebView(frame: CGRectMake(10, KNavigationHeight+KStatusBarHeight+10, self.width - 20, self.height-KNavigationHeight-KStatusBarHeight-10), configuration: configuration,url: url)
webView.cnWebView.scrollView.showsVerticalScrollIndicator = false
webView.cnWebView.scrollView.showsHorizontalScrollIndicator = false
webView.cnWebView.backgroundColor = .clear
webView.cnWebView.layer.cornerRadius = 29
webView.cnWebView.layer.maskedCorners = [.layerMinXMinYCorner, .layerMaxXMinYCorner]
webView.cnWebView.clipsToBounds = true
return webView
}()
lazy var upSlideVC: CNLiveDownShopDetailController = {
let upSlideVC = CNLiveDownShopDetailController.init()
upSlideVC.view.width = KSreenWidth
upSlideVC.view.height = KSreenHeight
upSlideVC.view.backgroundColor = .white
return upSlideVC
}()
//IDmodel
var _idModel : StandListModel?
var idModel : StandListModel? {
get{
_idModel
}
set{
_idModel = newValue
}
}
var type:Int?
var _downPath:String?
var downPath:String? {
get{
return _downPath
}
set{
_downPath = newValue!
self.subviews.forEach { view in
view.removeFromSuperview()
}
if(type == UpDownTypeH5){
self.addSubview(self.webView)
}
else if(type == UpDownTypePage){
}else if(type == UpDownTypeShopDetail){
currentViewController()?.addChild(self.upSlideVC)//看行不行
self.upSlideVC.didMove(toParent: currentViewController())
self.addSubview(self.upSlideVC.view)
}else if(type == UpDownTypeShopControlConsole){
}
}
}
override init(frame: CGRect) {
super.init(frame: frame)
let tap = UITapGestureRecognizer.init(target: self, action: #selector(upSlideViewTap))
tap.cancelsTouchesInView = false
self.addGestureRecognizer(tap)
self.initUI()
}
@objc func upSlideViewTap() {
print("upSlideViewTap")
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
func initUI()
{
self.isUserInteractionEnabled = true
self.backgroundColor = UIColor.clear
self.layer.cornerRadius = 20
}
}