INRecorderController.swift 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  1. //
  2. // INRecorderController.swift
  3. // Introduce
  4. //
  5. // Created by 胡志强 on 2021/11/29.
  6. // 首页
  7. import BFMaterialKit
  8. import BFRecordScreenKit
  9. import BFUIKit
  10. import Foundation
  11. import UIKit
  12. import TYAttributedLabel
  13. import BFCommonKit
  14. import BFAnalyzeKit
  15. public let cUserProtocol = "https://weapppiccdn.yishihui.com/resources/agreements/shishuo/videoservice.html?type=20"
  16. /** 隐私政策 */
  17. public let cPrivacy = "https://weapppiccdn.yishihui.com/resources/agreements/shishuo/videoagreement.html?type=20"
  18. class INRecorderController: BFBaseViewController {
  19. lazy var addVideoBtn: UIButton = {
  20. let btn = UIButton(type: .custom)
  21. // btn.setTitle("Add", for: .normal)
  22. btn.setImage(UIImage(named: "add"), for: .normal)
  23. btn.addTarget(self, action: #selector(addVideo), for: .touchUpInside)
  24. return btn
  25. }()
  26. lazy var bgView:UIImageView = {
  27. let bgView = UIImageView.init(frame: CGRect.init(x: 0, y: 0, width: cScreenWidth, height: cScreenHeigth))
  28. bgView.contentMode = .scaleAspectFill
  29. bgView.image = UIImage(named: "homebg")
  30. return bgView
  31. }()
  32. //欢迎界面
  33. lazy var welcomeView:UIView = {
  34. let view = UIView.init()
  35. view.backgroundColor = .white
  36. view.addCorner(corner:17)
  37. return view
  38. }()
  39. //欢迎界面背景
  40. lazy var welcomeBackView:UIView = {
  41. let view = UIView.init(frame: CGRect(x: 0, y: 0, width: cScreenWidth, height: cScreenHeigth))
  42. view.backgroundColor = UIColor.init(red: 0, green: 0, blue: 0, alpha: 0.6)
  43. return view
  44. }()
  45. lazy var welcomeTitle:UILabel = {
  46. let l = UILabel()
  47. l.text = "欢迎使用"
  48. l.textColor = .black
  49. l.font = UIFont.boldSystemFont(ofSize: 22)
  50. l.textAlignment = .center
  51. view.addSubview(l)
  52. return l
  53. }()
  54. lazy var protocolLab: TYAttributedLabel = {
  55. let protocolLab = TYAttributedLabel()
  56. protocolLab.highlightedLinkBackgroundColor = UIColor.clear
  57. protocolLab.backgroundColor = UIColor.clear
  58. protocolLab.numberOfLines = 0
  59. protocolLab.delegate = self
  60. protocolLab.font = UIFont.systemFont(ofSize: 14)
  61. protocolLab.text = "在您使用视说服务前,请认真阅读"
  62. protocolLab.textColor = UIColor(red: 0.262, green: 0.262, blue: 0.262, alpha: 1)
  63. protocolLab.appendLink(withText: "《视说用户协议》、 ", linkFont: UIFont.systemFont(ofSize: 14), linkColor: UIColor.hexColor(hexadecimal: "#90a9d2"), underLineStyle:CTUnderlineStyle(), linkData: cUserProtocol)
  64. protocolLab.appendLink(withText: " 《用户隐私政策》", linkFont: UIFont.systemFont(ofSize: 14), linkColor: UIColor.hexColor(hexadecimal: "#90a9d2"), underLineStyle:CTUnderlineStyle(), linkData: cPrivacy)
  65. protocolLab.appendLink(withText: "\n\n", linkFont: UIFont.systemFont(ofSize: 14), linkColor: UIColor.hexColor(hexadecimal: "#999999"), underLineStyle: CTUnderlineStyle(), linkData: nil)
  66. protocolLab.appendLink(withText: "点击同意表示您已阅读并且认可所有条款。", linkFont: UIFont.systemFont(ofSize: 14), linkColor: UIColor(red: 0.262, green: 0.262, blue: 0.262, alpha: 1), underLineStyle: CTUnderlineStyle(), linkData: nil)
  67. protocolLab.textAlignment = CTTextAlignment.left
  68. return protocolLab
  69. }()
  70. lazy var doneBtn:UIButton = {
  71. let doneBtn = UIButton()
  72. doneBtn.backgroundColor = UIColor.hexColor(hexadecimal: "#389AFF")
  73. doneBtn.setTitle("同意", for: .normal)
  74. doneBtn.titleLabel?.font = UIFont.systemFont(ofSize: 16)
  75. doneBtn.addTarget(self, action: #selector(doneAction), for: .touchUpInside)
  76. doneBtn.addCorner(corner: 4)
  77. return doneBtn
  78. }()
  79. lazy var cancleBtn:UIButton = {
  80. let cancleBtn = UIButton()
  81. cancleBtn.backgroundColor = UIColor.clear
  82. cancleBtn.setTitle("不同意", for: .normal)
  83. cancleBtn.setTitleColor( UIColor(red: 0.262, green: 0.262, blue: 0.262, alpha: 1), for: .normal)
  84. cancleBtn.titleLabel?.font = UIFont.systemFont(ofSize: 14)
  85. cancleBtn.addTarget(self, action: #selector(cancleAction), for: .touchUpInside)
  86. cancleBtn.addCorner(corner: 4)
  87. return cancleBtn
  88. }()
  89. override func viewWillAppear(_ animated: Bool) {
  90. super.viewWillAppear(animated)
  91. hiddenNavigation()
  92. // 曝光上报
  93. BFEventTrackAdaptor.baseReportUpload(businessType: .bt_pageView, objectType: nil, pageSource: .sp_homePage, commonParams: commonParams())
  94. }
  95. override func viewDidLoad() {
  96. super.viewDidLoad()
  97. view.backgroundColor = .black
  98. view.addSubview(bgView)
  99. view.addSubview(addVideoBtn)
  100. addVideoBtn.snp.makeConstraints { make in
  101. make.width.height.equalTo(170)
  102. make.center.equalToSuperview()
  103. }
  104. let l = UILabel()
  105. l.text = "选择视频/图片\n开始讲解"
  106. l.textColor = .white
  107. l.font = UIFont.systemFont(ofSize: 16)
  108. l.textAlignment = .center
  109. view.addSubview(l)
  110. l.numberOfLines = 2
  111. l.snp.makeConstraints { make in
  112. make.top.equalTo(addVideoBtn.snp.bottom)
  113. make.centerX.equalToSuperview()
  114. make.width.equalTo(200)
  115. make.height.equalTo(48)
  116. }
  117. //欢迎界面
  118. if(getUserDefaults(key: "welcomeViewisshow") == nil){
  119. view.addSubview(welcomeBackView)
  120. welcomeBackView.addSubview(welcomeView)
  121. welcomeView.addSubview(protocolLab)
  122. welcomeView.addSubview(welcomeTitle)
  123. welcomeView.addSubview(doneBtn)
  124. welcomeView.addSubview(cancleBtn)
  125. welcomeView.snp.makeConstraints{ make in
  126. make.center.equalToSuperview()
  127. make.width.equalTo(280)
  128. make.height.equalTo(350)
  129. }
  130. welcomeTitle.snp.makeConstraints{ make in
  131. make.centerX.equalToSuperview()
  132. make.width.equalTo(120)
  133. make.top.equalToSuperview().offset(30)
  134. make.height.equalTo(31)
  135. }
  136. protocolLab.snp.makeConstraints{ make in
  137. make.centerX.equalToSuperview()
  138. make.width.equalTo(230)
  139. make.top.equalTo(welcomeTitle.snp.bottom).offset(16)
  140. make.height.equalTo(140)
  141. }
  142. doneBtn.snp.makeConstraints { make in
  143. make.centerX.equalToSuperview()
  144. make.width.equalTo(230)
  145. make.height.equalTo(47)
  146. make.top.equalTo(protocolLab.snp.bottom).offset(30)
  147. }
  148. cancleBtn.snp.makeConstraints { make in
  149. make.centerX.equalToSuperview()
  150. make.width.equalTo(230)
  151. make.height.equalTo(20)
  152. make.top.equalTo(doneBtn.snp.bottom).offset(17)
  153. }
  154. }
  155. // add by ak 取 nsl token
  156. BFRecordScreenViewModel.getNlsAccessToken { [weak self] token, appkey in
  157. BFLog(message: "提前取一次nls appkey is \(appkey), token is \(token)")
  158. }
  159. }
  160. @objc func doneAction() {
  161. welcomeBackView.isHidden = true
  162. saveUserDefaults(key: "welcomeViewisshow", value: "true")
  163. }
  164. @objc func cancleAction() {
  165. welcomeBackView.isHidden = true
  166. exit(-1)
  167. }
  168. override func didReceiveMemoryWarning() {
  169. super.didReceiveMemoryWarning()
  170. // Dispose of any resources that can be recreated.
  171. }
  172. @objc func addVideo() {
  173. if (getUserDefaults(key: "welcomeViewisshow") == nil) {
  174. welcomeBackView.isHidden = false
  175. }else{
  176. let vc = INPhotoVideosController()
  177. vc.hidesBottomBarWhenPushed = true
  178. navigationController?.pushViewController(vc, animated: true)
  179. // 按钮点击
  180. BFEventTrackAdaptor.baseReportUpload(businessType: .bt_buttonClick, objectType: .ot_addVideo, pageSource: .sp_homePage, commonParams: commonParams())
  181. }
  182. }
  183. }
  184. //点击超链接回调
  185. extension INRecorderController: TYAttributedLabelDelegate {
  186. func attributedLabel(_: TYAttributedLabel!, textStorageClicked textStorage: TYTextStorageProtocol!, at _: CGPoint) {
  187. let link: String? = (textStorage as? TYLinkTextStorage)?.linkData as? String ?? ""
  188. if link != nil, (link?.count ?? 0) > 0 {
  189. let detail = BFBaseWebViewController()
  190. detail.baseUrl = link
  191. self.navigationController?.pushViewController(detail, animated: true)
  192. }
  193. }
  194. }