Commit d0fa5d6a86fc42a308498b5e304a2e75f528070f

Authored by 张旭
1 parent 58c23d28

追剧 ,积分接口调整

metaCode/Classes/Main/HomePages/Controller/AuthController/CNLiveAuthViewController.swift
... ... @@ -57,6 +57,7 @@ class CNLiveAuthViewController:CNLiveBaseViewController,UITableViewDelegate,UITa
57 57 override func viewWillAppear(_ animated: Bool) {
58 58 super.viewWillAppear(animated)
59 59 self.updateStatusBarAndTabbarFrame(visible: true)
  60 + self.getMyAlbumCollection(page: 1)
60 61 }
61 62 override func viewDidLoad() {
62 63 super.viewDidLoad()
... ...
metaCode/Classes/Main/HomePages/Controller/PlayletHomePage/CNLivePlayletHomePageController.swift
... ... @@ -14,7 +14,8 @@ class CNLivePlayletHomePageController:CNLiveBaseViewController, UITableViewDataS
14 14 let kCNLivePlayletCellIdentifier = "kCNLivePlayletCellIdentifier"
15 15 let kCNLivePlayletHeaderCellIdentifier = "kCNLivePlayletHeaderCellIdentifier"
16 16 ///数据源
17   - var albumModelArr:Array<CNLiveAlbumListModel>?
  17 + var albumModelArr:Array<CNLiveAlbumListModel> = [CNLiveAlbumListModel]()
  18 + var albumId = ""
18 19 // MARK: - 懒加载
19 20  
20 21 lazy var tableView : UITableView = {
... ... @@ -28,6 +29,11 @@ class CNLivePlayletHomePageController:CNLiveBaseViewController, UITableViewDataS
28 29 return tableView
29 30 }()
30 31  
  32 + init(aid:String){
  33 + super.init(nibName: nil, bundle: nil)
  34 + self.albumId = aid
  35 + self.getAlbumList(aid: aid)// self.albumModel!.contentId 或 self.albumMsgModel!.albumId
  36 + }
31 37 init(albumModelArr:Array<CNLiveAlbumListModel>) {
32 38 self.albumModelArr = Array(albumModelArr)
33 39 super.init(nibName: nil, bundle: nil)
... ... @@ -46,6 +52,39 @@ class CNLivePlayletHomePageController:CNLiveBaseViewController, UITableViewDataS
46 52 self.view.addSubview(self.tableView)
47 53 self.tableView.frame = CGRect(x: 0, y: KNavigationHeight, width: KSreenWidth, height: KSreenHeight-KNavigationHeight)
48 54 }
  55 +
  56 + // MARK: - 获取短剧主页数据
  57 + //获取专辑视频列表详情(播放地址 ,点赞数等信息)
  58 + func getAlbumList(aid:String){
  59 + showLoading(message: "")
  60 + CNLiveHomePageViewModel.getAlbumList(aid: aid){ result, status in
  61 + hiddenLoading()
  62 + if status == .success{
  63 + let arr = result as! Array<CNLiveAlbumListModel>
  64 + self.albumModelArr = Array(arr)
  65 + self.getAlbumMsg(aid: aid)
  66 + }else{
  67 +
  68 + }
  69 + }
  70 + }
  71 + //获取专辑详情(简介等)
  72 + func getAlbumMsg(aid:String){
  73 + CNLiveHomePageViewModel.getAlbumMsg(aid: aid) { result, status in
  74 + hiddenLoading()
  75 + if status == .success{
  76 + let model = result as! CNLiveAlbumMsgModel
  77 + for listModel in self.albumModelArr {
  78 + listModel.albumMsgModel = model
  79 + }
  80 + self.tableView.reloadData()
  81 + }else{
  82 +
  83 + }
  84 + }
  85 + }
  86 +
  87 +
49 88 func numberOfSections(in tableView: UITableView) -> Int {
50 89 2
51 90 }
... ... @@ -53,7 +92,7 @@ class CNLivePlayletHomePageController:CNLiveBaseViewController, UITableViewDataS
53 92 if section == 0{
54 93 return 1
55 94 }
56   - return self.albumModelArr!.count
  95 + return self.albumModelArr.count
57 96 }
58 97  
59 98 func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
... ... @@ -68,8 +107,13 @@ class CNLivePlayletHomePageController:CNLiveBaseViewController, UITableViewDataS
68 107 self.jianjieLblHeight = jianjieHeight
69 108 self.tableView.reloadData()
70 109 }
71   - let albumListModel = self.albumModelArr![0]
72   - cell.albumListModel = albumListModel
  110 + cell.homePageNeedReloadActionBlock = {
  111 + self.getAlbumList(aid: self.albumId)
  112 + }
  113 + if self.albumModelArr.count > 0{
  114 + let albumListModel = self.albumModelArr[0]
  115 + cell.albumListModel = albumListModel
  116 + }
73 117 return cell
74 118 }else{
75 119 guard let cell = tableView.dequeueReusableCell(withIdentifier: kCNLivePlayletCellIdentifier) as? CNLivePlayletHomePageCell
... ... @@ -77,7 +121,7 @@ class CNLivePlayletHomePageController:CNLiveBaseViewController, UITableViewDataS
77 121 let cell = CNLivePlayletHomePageCell()
78 122 return cell
79 123 }
80   - let albumListModel = self.albumModelArr![indexPath.row]
  124 + let albumListModel = self.albumModelArr[indexPath.row]
81 125 cell.albumListModel = albumListModel
82 126 return cell
83 127 }
... ...
metaCode/Classes/Main/HomePages/View/HomepageDetail/CNLiveAlbumCell.swift
... ... @@ -105,29 +105,29 @@ class CNLiveAlbumCell:UITableViewCell{
105 105 }
106 106  
107 107 //获取专辑详情(简介等)
108   - func getAlbumMsg(){
109   - var aid = ""
110   - if self.albumModel != nil{
111   - aid = self.albumModel!.contentId
112   - }else if self.albumMsgModel != nil{
113   - aid = self.albumMsgModel!.albumId
114   - }else{
115   - aid = ""
116   - }
117   - CNLiveHomePageViewModel.getAlbumMsg(aid: aid) { result, status in
118   - hiddenLoading()
119   - if status == .success{
120   - let model = result as! CNLiveAlbumMsgModel
121   - for listModel in self.albumModelArr! {
122   - listModel.albumMsgModel = model
123   - }
124   - print("暂时跳转主页")
125   - navigationViewController().pushViewController(CNLivePlayletHomePageController(albumModelArr: self.albumModelArr!), animated: false)
126   - }else{
127   -
128   - }
129   - }
130   - }
  108 +// func getAlbumMsg(){
  109 +// var aid = ""
  110 +// if self.albumModel != nil{
  111 +// aid = self.albumModel!.contentId
  112 +// }else if self.albumMsgModel != nil{
  113 +// aid = self.albumMsgModel!.albumId
  114 +// }else{
  115 +// aid = ""
  116 +// }
  117 +// CNLiveHomePageViewModel.getAlbumMsg(aid: aid) { result, status in
  118 +// hiddenLoading()
  119 +// if status == .success{
  120 +// let model = result as! CNLiveAlbumMsgModel
  121 +// for listModel in self.albumModelArr! {
  122 +// listModel.albumMsgModel = model
  123 +// }
  124 +// print("暂时跳转主页")
  125 +// navigationViewController().visibleViewController?.navigationController?.pushViewController(CNLivePlayletHomePageController(albumModelArr: self.albumModelArr!), animated: true)
  126 +// }else{
  127 +//
  128 +// }
  129 +// }
  130 +// }
131 131 //获取专辑视频列表详情(播放地址 ,点赞数等信息)
132 132 func getAlbumList(){
133 133 showLoading(message: "")
... ... @@ -139,15 +139,19 @@ class CNLiveAlbumCell:UITableViewCell{
139 139 }else{
140 140 aid = ""
141 141 }
142   - CNLiveHomePageViewModel.getAlbumList(aid: aid){ result, status in
143   - hiddenLoading()
144   - if status == .success{
145   - let arr = result as! Array<CNLiveAlbumListModel>
146   - self.albumModelArr = Array(arr)
147   - self.getAlbumMsg()
148   - }else{
149   -
150   - }
151   - }
  142 +
  143 + navigationViewController().visibleViewController?.navigationController?.pushViewController(CNLivePlayletHomePageController(aid: aid), animated: true)
  144 + return
  145 +//
  146 +// CNLiveHomePageViewModel.getAlbumList(aid: aid){ result, status in
  147 +// hiddenLoading()
  148 +// if status == .success{
  149 +// let arr = result as! Array<CNLiveAlbumListModel>
  150 +// self.albumModelArr = Array(arr)
  151 +// self.getAlbumMsg()
  152 +// }else{
  153 +//
  154 +// }
  155 +// }
152 156 }
153 157 }
... ...
metaCode/Classes/Main/HomePages/View/PlayletHomePage/CNLivePlayletHomePageCell.swift
... ... @@ -23,15 +23,23 @@ class CNLivePlayletHomePageCell:UITableViewCell{
23 23 }
24 24 //MARK: - 懒加载
25 25 lazy var iconImgView :UIImageView = {
26   - let iconImgView = UIImageView(frame: CGRect(x: 20, y: 10, width: 60, height: 90))
  26 + let iconImgView = UIImageView(frame: CGRect(x: 15, y: 12, width: 57, height: 75))
  27 + iconImgView.layer.cornerRadius = 5
  28 + iconImgView.clipsToBounds = true
27 29 return iconImgView
28 30 }()
  31 + lazy var payIconImgView :UIImageView = {
  32 + let payIconImgView = UIImageView(frame: CGRect(x: 0, y: 0, width: 30, height: 14))
  33 + payIconImgView.image = UIImage(named: "homePage_payed")
  34 + return payIconImgView
  35 + }()
  36 +
29 37 ///标题
30 38 lazy var titleLabl: UILabel = {
31   - let titleLabel = UILabel.init(frame: CGRectMake(self.iconImgView.right+15, 15, KSreenWidth-(self.iconImgView.right+15)-10, 21))
  39 + let titleLabel = UILabel.init(frame: CGRectMake(self.iconImgView.right+15, self.iconImgView.top, KSreenWidth-(self.iconImgView.right+15)-10, 21))
32 40 titleLabel.textColor = HexColor("#333333")
33 41 titleLabel.textAlignment = .left
34   - titleLabel.font = Font_15
  42 + titleLabel.font = Font_13
35 43 titleLabel.numberOfLines = 2
36 44 titleLabel.text = "啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊"
37 45 let height = titleLabel.qmui_lineHeight
... ... @@ -40,10 +48,10 @@ class CNLivePlayletHomePageCell:UITableViewCell{
40 48 }()
41 49 ///时长
42 50 lazy var timeLabel: UILabel = {
43   - let titleLabel = UILabel.init(frame: CGRectMake(self.iconImgView.right+15, self.titleLabl.bottom+10, 40, 21))
  51 + let titleLabel = UILabel.init(frame: CGRectMake(self.iconImgView.right+15, self.iconImgView.bottom-21, 150, 21))
44 52 titleLabel.textColor = HexColor("#333333")
45 53 titleLabel.textAlignment = .left
46   - titleLabel.font = Font_15
  54 + titleLabel.font = Font_12
47 55 titleLabel.text = "04:31"
48 56 let height = titleLabel.qmui_lineHeight
49 57 titleLabel.height = height
... ... @@ -54,6 +62,7 @@ class CNLivePlayletHomePageCell:UITableViewCell{
54 62 super.init(style: style, reuseIdentifier: reuseIdentifier)
55 63 self.selectionStyle = .none
56 64 self.addSubview(self.iconImgView)
  65 + self.iconImgView.addSubview(self.payIconImgView)
57 66 self.addSubview(self.titleLabl)
58 67 self.addSubview(self.timeLabel)
59 68 }
... ... @@ -62,8 +71,45 @@ class CNLivePlayletHomePageCell:UITableViewCell{
62 71 fatalError("init(coder:) has not been implemented")
63 72 }
64 73 func setupNewUI(model:CNLiveAlbumListModel){
65   - self.titleLabl.text = model.title
66   - self.timeLabel.text = model.time
  74 + self.titleLabl.text = model.title
  75 + self.timeLabel.text = model.duration
67 76 self.iconImgView.kf.setImage(with: URL(string: model.poster))
  77 + if model.product?.check == true{
  78 + //付过费 或 免费
  79 + self.payIconImgView.isHidden = true
  80 + //显示已购买 或者 不显示
  81 + if model.product?.productType == "0"{
  82 + //免费
  83 + self.payIconImgView.isHidden = true
  84 + }else if model.product?.productType == "1"{
  85 + //积分
  86 + self.payIconImgView.isHidden = false
  87 + self.payIconImgView.image = UIImage(named: "homePage_payed")
  88 + }else if model.product?.productType == "2"{
  89 + //付费
  90 + self.payIconImgView.isHidden = false
  91 + self.payIconImgView.image = UIImage(named: "homePage_payed")
  92 + }else{
  93 + self.payIconImgView.isHidden = false
  94 + self.payIconImgView.image = UIImage(named: "homePage_payed")
  95 + }
  96 + }else{
  97 + //需要付费
  98 + if model.product?.productType == "0"{
  99 + //免费
  100 + self.payIconImgView.isHidden = true
  101 + }else if model.product?.productType == "1"{
  102 + //积分
  103 + self.payIconImgView.isHidden = false
  104 + self.payIconImgView.image = UIImage(named: "homePage_payment")
  105 + }else if model.product?.productType == "2"{
  106 + //付费
  107 + self.payIconImgView.isHidden = false
  108 + self.payIconImgView.image = UIImage(named: "homePage_payment")
  109 + }else{
  110 + self.payIconImgView.isHidden = false
  111 + self.payIconImgView.image = UIImage(named: "homePage_payment")
  112 + }
  113 + }
68 114 }
69 115 }
... ...
metaCode/Classes/Main/HomePages/View/PlayletHomePage/CNLivePlayletHomePageHeaderCell.swift
... ... @@ -13,8 +13,17 @@ import Kingfisher
13 13  
14 14 //cell高度变化
15 15 typealias homePageHeaderCellChangedBlockActionBlock = (_ cell: CNLivePlayletHomePageHeaderCell ,_ jianjieHeight:CGFloat) -> Void
  16 +//刷新短剧首页
  17 +typealias homePageNeedReloadBlockActionBlock = () -> Void
  18 +
  19 +
16 20 class CNLivePlayletHomePageHeaderCell:UITableViewCell{
17 21 var homePageHeaderCellChangedBlock:homePageHeaderCellChangedBlockActionBlock?
  22 + var homePageNeedReloadActionBlock:homePageNeedReloadBlockActionBlock?
  23 +
  24 +
  25 + let followBtnSubLayer = "followBtnSubLayer"
  26 + let payBtnSubLayer = "payBtnSubLayer"
18 27  
19 28 var _albumListModel : CNLiveAlbumListModel?
20 29 var albumListModel : CNLiveAlbumListModel? {
... ... @@ -30,11 +39,12 @@ class CNLivePlayletHomePageHeaderCell:UITableViewCell{
30 39  
31 40 //MARK: - 懒加载
32 41 lazy var iconImgView :UIImageView = {
33   - let iconImgView = UIImageView(frame: CGRect(x: 20, y: 20, width: 112, height: 147))
  42 + let iconImgView = UIImageView(frame: CGRect(x: 15, y: 20, width: 112, height: 147))
34 43 iconImgView.layer.cornerRadius = 5
35 44 iconImgView.clipsToBounds = true
36 45 return iconImgView
37 46 }()
  47 +
38 48 lazy var payIconImgView :UIImageView = {
39 49 let payIconImgView = UIImageView(frame: CGRect(x: 0, y: 0, width: 30, height: 14))
40 50 payIconImgView.image = UIImage(named: "homePage_payment")
... ... @@ -70,7 +80,7 @@ class CNLivePlayletHomePageHeaderCell:UITableViewCell{
70 80 titleLabel.textAlignment = .left
71 81 titleLabel.font = Font_12
72 82 titleLabel.backgroundColor = UIColor(red:0.98, green:0.98, blue:0.98, alpha:1.00)
73   - titleLabel.text = "啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈啊哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈啊哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈啊哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈啊哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈啊哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈"
  83 + titleLabel.text = "简介"
74 84 titleLabel.numberOfLines = 0
75 85 var lines = titleLabel.getRealLabelTextLines()
76 86 let height = titleLabel.qmui_lineHeight
... ... @@ -113,9 +123,8 @@ class CNLivePlayletHomePageHeaderCell:UITableViewCell{
113 123 gradient.locations = [0, 1]
114 124 gradient.startPoint = CGPoint(x: 0.96, y: 0.42)
115 125 gradient.endPoint = CGPoint(x: 0.42, y: 0.42)
116   - gradient.name = "followBtnSubLayer"
  126 + gradient.name = followBtnSubLayer
117 127 followBtn.layer.insertSublayer(gradient, at: 0)
118   -// #FDF4E4
119 128 return followBtn
120 129 }()
121 130 //付费解锁全集|已购买
... ... @@ -123,8 +132,6 @@ class CNLivePlayletHomePageHeaderCell:UITableViewCell{
123 132 let paymentBtn = UIButton(type: .custom)
124 133 paymentBtn.setTitle("付费解锁全集", for: .normal)
125 134 paymentBtn.setTitleColor(HexColor("#FFFFFF"), for: .normal)
126   - paymentBtn.setTitle("已购买", for: .selected)
127   - paymentBtn.setTitleColor(HexColor("#619CFF"), for: .selected)
128 135 paymentBtn.titleLabel?.font = Font_15
129 136 paymentBtn.layer.cornerRadius = 20
130 137 paymentBtn.clipsToBounds = true
... ... @@ -136,9 +143,8 @@ class CNLivePlayletHomePageHeaderCell:UITableViewCell{
136 143 gradient.locations = [0, 1]
137 144 gradient.startPoint = CGPoint(x: 0, y: 0.5)
138 145 gradient.endPoint = CGPoint(x: 0.5, y: 0.5)
  146 + gradient.name = payBtnSubLayer
139 147 paymentBtn.layer.insertSublayer(gradient, at: 0)
140   -
141   -// #ECF3FF
142 148 return paymentBtn
143 149 }()
144 150 ///全部剧集
... ... @@ -204,20 +210,50 @@ class CNLivePlayletHomePageHeaderCell:UITableViewCell{
204 210 self.titleLabl.text = model.albumMsgModel?.albumName ?? "专辑名称"
205 211 self.jishuLabel.text = String(format: "共%@集",model.albumMsgModel?.episodeNow ?? "1")
206 212 self.iconImgView.kf.setImage(with: URL(string: model.albumMsgModel?.albumImg ?? ""))
207   - if model.product?.albumProductType == "0"{
208   - //免费
  213 + if model.product?.check == true{
  214 + //付过费 或 免费
  215 + self.paymentBtn.isUserInteractionEnabled = false
  216 + self.paymentChangeStatus(isPayed: true)
209 217 self.payIconImgView.isHidden = true
210   - }else if model.product?.albumProductType == "1"{
211   - //积分
212   - self.payIconImgView.isHidden = false
213   - }else if model.product?.albumProductType == "2"{
214   - //付费
215   - self.payIconImgView.isHidden = false
  218 + //显示已购买 或者 不显示
  219 + if model.albumMsgModel?.product?.albumProductType == "0"{
  220 + //免费
  221 + self.payIconImgView.isHidden = true
  222 + }else if model.product?.albumProductType == "1"{
  223 + //积分
  224 + self.payIconImgView.isHidden = false
  225 + self.payIconImgView.image = UIImage(named: "homePage_payed")
  226 + }else if model.product?.albumProductType == "2"{
  227 + //付费
  228 + self.payIconImgView.isHidden = false
  229 + self.payIconImgView.image = UIImage(named: "homePage_payed")
  230 + }else{
  231 + self.payIconImgView.isHidden = false
  232 + self.payIconImgView.image = UIImage(named: "homePage_payed")
  233 + }
216 234 }else{
217   - self.payIconImgView.isHidden = false
  235 + //需要付费
  236 + self.paymentBtn.isUserInteractionEnabled = true
  237 + self.paymentChangeStatus(isPayed: false)
  238 + if model.product?.albumProductType == "0"{
  239 + //免费
  240 + self.payIconImgView.isHidden = true
  241 + }else if model.product?.albumProductType == "1"{
  242 + //积分
  243 + self.payIconImgView.isHidden = false
  244 + self.payIconImgView.image = UIImage(named: "homePage_payment")
  245 + }else if model.product?.albumProductType == "2"{
  246 + //付费
  247 + self.payIconImgView.isHidden = false
  248 + self.payIconImgView.image = UIImage(named: "homePage_payment")
  249 + }else{
  250 + self.payIconImgView.isHidden = false
  251 + self.payIconImgView.image = UIImage(named: "homePage_payment")
  252 + }
218 253 }
219   - self.jianjieLabel.text = (model.albumMsgModel?.desc != "") ? model.albumMsgModel?.desc : "啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈啊哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈啊哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈啊哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈啊哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈啊哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈"//"短剧简介"
220   - var lines = jianjieLabel.getRealLabelTextLines()
  254 +
  255 + self.jianjieLabel.text = (model.albumMsgModel?.desc != "") ? model.albumMsgModel?.desc : "短剧简介"
  256 + let lines = jianjieLabel.getRealLabelTextLines()
221 257 let height = jianjieLabel.qmui_lineHeight
222 258 if lines <= 2{
223 259 self.expandBtn.isHidden = true
... ... @@ -234,20 +270,100 @@ class CNLivePlayletHomePageHeaderCell:UITableViewCell{
234 270 self.jianjieLabel.height = 2*height
235 271 }
236 272 if model.albumMsgModel!.collection{
  273 + self.followChangeStatus(isFollowed: true)
  274 + }else{
  275 + self.followChangeStatus(isFollowed: false)
  276 + }
  277 + }
  278 +
  279 + // MARK: - Action
  280 + @objc func expandBtnAction(button:UIButton){
  281 + button.isSelected = !button.isSelected
  282 + let lines = jianjieLabel.getRealLabelTextLines()
  283 + let height = jianjieLabel.qmui_lineHeight
  284 +
  285 + if button.isSelected{
  286 + //文本收起状态,点击展开
  287 + self.jianjieLabel.height = CGFloat(lines)*height
  288 + }else{
  289 + //文本展开状态,点击收起
  290 + self.jianjieLabel.height = 2*height
  291 + }
  292 + self.homePageHeaderCellChangedBlock!(self, self.jianjieLabel.height)
  293 + self.expandBtn.top = self.jianjieLabel.bottom
  294 +
  295 + }
  296 + @objc func followBtnAction(button:UIButton){
  297 + button.isSelected = !button.isSelected
  298 + if button.isSelected{
  299 + //已追剧->取消追剧
  300 + if self.albumListModel?.albumMsgModel?.product?.check == true{
  301 + //已购买,不能取消追剧
  302 + }else{
  303 + self.postAlbumCollect(type: 2)
  304 + }
  305 + }else{
  306 + //未追剧->追剧
  307 + self.postAlbumCollect(type: 1)
  308 + }
  309 + }
  310 + @objc func paymentBtnAction(button:UIButton){
  311 + button.isSelected = !button.isSelected
  312 + if self.albumListModel?.product?.check == false{
  313 + //未购买->购买
  314 + //弹窗购买,再调用接口
  315 +
  316 +
  317 +// self.postOrderVideoByPoint()
  318 +
  319 + }
  320 + }
  321 + func paymentChangeStatus(isPayed:Bool){
  322 + if isPayed{
  323 + //已购买
  324 + self.paymentBtn.setTitle("已购买", for: .normal)
  325 + self.paymentBtn.setTitleColor(HexColor("#619CFF"), for: .normal)
  326 +
  327 + let payLayer = self.paymentBtn.layer.qmui_layer(withName: payBtnSubLayer)
  328 + payLayer?.removeFromSuperlayer()
  329 + self.paymentBtn.backgroundColor = HexColor("#ECF3FF")
  330 + }else{
  331 + //未购买
  332 + self.paymentBtn.setTitle("付费解锁全集", for: .normal)
  333 + self.paymentBtn.setTitleColor(HexColor("#FFFFFF"), for: .normal)
  334 +
  335 + let payLayer = self.paymentBtn.layer.qmui_layer(withName: payBtnSubLayer)
  336 + if (payLayer != nil){
  337 + //已添加layer
  338 + }else{
  339 + //未添加layer
  340 + let gradient = CAGradientLayer()
  341 + gradient.frame = self.bounds
  342 + gradient.colors = [HexColor("#67C5FF")!.cgColor, HexColor("#609AFF")!.cgColor]
  343 + gradient.locations = [0, 1]
  344 + gradient.startPoint = CGPoint(x: 0, y: 0.5)
  345 + gradient.endPoint = CGPoint(x: 0.5, y: 0.5)
  346 + gradient.name = followBtnSubLayer
  347 + self.paymentBtn.layer.insertSublayer(gradient, at: 0)
  348 + self.paymentBtn.backgroundColor = .clear
  349 + }
  350 + }
  351 +
  352 + }
  353 + func followChangeStatus(isFollowed:Bool){
  354 + if isFollowed{
237 355 //已追剧
238 356 self.followBtn.setTitleColor(HexColor("#F5A623"), for: .normal)
239 357 self.followBtn.setTitle("已追剧", for: .normal)
240   - self.followBtn.isUserInteractionEnabled = false
241   - let follLayer = self.followBtn.layer.qmui_layer(withName: "followBtnSubLayer")
  358 + let follLayer = self.followBtn.layer.qmui_layer(withName: followBtnSubLayer)
242 359 follLayer?.removeFromSuperlayer()
243 360 self.followBtn.backgroundColor = HexColor("#FDF4E4")
244 361 }else{
245 362 //未追剧
246 363 self.followBtn.setTitle("追剧", for: .normal)
247 364 self.followBtn.setTitleColor(HexColor("#FFFFFF"), for: .normal)
248   - self.followBtn.isUserInteractionEnabled = true
249 365  
250   - let follLayer = self.followBtn.layer.qmui_layer(withName: "followBtnSubLayer")
  366 + let follLayer = self.followBtn.layer.qmui_layer(withName: followBtnSubLayer)
251 367 if (follLayer != nil){
252 368 //已添加layer
253 369 }else{
... ... @@ -258,50 +374,46 @@ class CNLivePlayletHomePageHeaderCell:UITableViewCell{
258 374 gradient.locations = [0, 1]
259 375 gradient.startPoint = CGPoint(x: 0.96, y: 0.42)
260 376 gradient.endPoint = CGPoint(x: 0.42, y: 0.42)
261   - gradient.name = "followBtnSubLayer"
  377 + gradient.name = followBtnSubLayer
262 378 followBtn.layer.insertSublayer(gradient, at: 0)
263 379 self.followBtn.backgroundColor = .clear
264 380 }
265   -
266   - }
267   - }
268   -
269   - // MARK: - Action
270   - @objc func expandBtnAction(button:UIButton){
271   - button.isSelected = !button.isSelected
272   - let lines = jianjieLabel.getRealLabelTextLines()
273   - let height = jianjieLabel.qmui_lineHeight
274 381  
275   - if button.isSelected{
276   - //文本收起状态,点击展开
277   - self.jianjieLabel.height = CGFloat(lines)*height
278   - }else{
279   - //文本展开状态,点击收起
280   - self.jianjieLabel.height = 2*height
281 382 }
282   - self.homePageHeaderCellChangedBlock!(self, self.jianjieLabel.height)
283   - self.expandBtn.top = self.jianjieLabel.bottom
284   -
285 383 }
286   - @objc func followBtnAction(button:UIButton){
287 384  
288   - //网络请求追剧
289   - CNLiveHomePageViewModel.postAlbumCollect(aid: self.albumListModel?.albumMsgModel?.albumId ?? "", type: 1) { result, status in
  385 + // MARK: - 积分付费接口
  386 + func postOrderVideoByPoint(){
  387 + //付费接口
  388 + CNLiveHomePageViewModel.orderVideoByPoint(prdId: self.albumListModel?.product?.productId ?? "") { result, status in
290 389 if status == .success{
291   - self.followBtn.setTitleColor(HexColor("#F5A623"), for: .normal)
292   - self.followBtn.setTitle("已追剧", for: .normal)
293   - self.followBtn.isUserInteractionEnabled = false
294   - let follLayer = self.followBtn.layer.qmui_layer(withName: "followBtnSubLayer")
295   - follLayer?.removeFromSuperlayer()
296   - self.followBtn.backgroundColor = HexColor("#FDF4E4")
297   - }else{
  390 + //购买成功
298 391  
  392 + //刷新短剧首页数据
  393 + self.homePageNeedReloadActionBlock!()
  394 + }else{
  395 + //购买失败
  396 + let errMsg = result as! String
  397 + showMessage(message: errMsg)
299 398 }
300 399 }
  400 +
301 401 }
302   - @objc func paymentBtnAction(button:UIButton){
303   - button.isSelected = !button.isSelected
304   -
  402 + // MARK: - 网络请求 追剧1/取消追剧2
  403 + func postAlbumCollect(type:NSInteger){
  404 + CNLiveHomePageViewModel.postAlbumCollect(aid: self.albumListModel?.albumMsgModel?.albumId ?? "", type: type) { result, status in
  405 + if status == .success{
  406 + if type == 1{
  407 + self.followChangeStatus(isFollowed: true)
  408 + }else if type == 0{
  409 + self.followChangeStatus(isFollowed: false)
  410 + }else{
  411 + self.followChangeStatus(isFollowed: false)
  412 + }
  413 + }else{
  414 + showMessage(message: "网络请求失败")
  415 + }
  416 + }
305 417 }
306 418  
307 419 }
... ...
metaCode/Classes/Main/HomePages/ViewModel/CNLiveHomePageViewModel.swift
... ... @@ -177,4 +177,63 @@ class CNLiveHomePageViewModel:NSObject{
177 177 }
178 178 }
179 179 }
  180 +
  181 + /// 积分支付
  182 + static func orderVideoByPoint(prdId:String,resultBlock: @escaping downSlideResultBlock) {
  183 + let param = NSMutableDictionary()
  184 + param.setValue(UserInfoManager.shared.userInfo.uid, forKey: "sid")
  185 + param.setValue(APPId, forKey: "sp_id")
  186 + param.setValue(prdId, forKey: "prdId")
  187 + param.setValue("apple", forKey: "frmId")
  188 + param.setValue(CNLiveHomePageViewModel.getRandomOrderId(), forKey: "srvOrderId")
  189 +
  190 + CNLiveNetworking.setupShowResult(true)
  191 + CNLiveNetworking.setAllowRequestDefaultArgument(true)
  192 + CNLiveNetworking.setupShowDataResult(false)
  193 + CNLiveNetworking.setupSignRequestKey(APPKey)//APPKey_wjj APPKey
  194 +
  195 + CNLiveNetworking.requestNetwork(with: .POST, urlString: "\(CNLiveEnvironmentManager.shared.img_token_url)/pom/orderVideoByPoint", param: param as! [String : String], cacheType: .networkOnly) { task, result, error in
  196 + hiddenLoading()
  197 + if (error == nil) {
  198 + let resp = result as! NSDictionary
  199 + let errorCode = "\(resp["errorCode"] ?? "0")"
  200 + if (errorCode == "0") {
  201 + //兑换成功
  202 + resultBlock(NSNull(),.success)
  203 + }else if (errorCode == "4002") {
  204 + //积分不足
  205 + resultBlock("积分不足",.failed)
  206 + }else
  207 + {
  208 + resultBlock("兑换失败,请稍候再试!",.failed)
  209 + }
  210 + }
  211 + }
  212 + }
  213 + static func getRandomOrderId() -> String {
  214 + // appId+渠道+年月日+毫秒数后10位+2位数的随机数
  215 + var randomOrderId = ""
  216 + //年月日
  217 + let formatter = DateFormatter()
  218 + formatter.dateFormat = "yyyyMMdd"
  219 + let currentDate = Date()
  220 + let currentDateString = formatter.string(from: currentDate)
  221 +
  222 + //取毫秒时间戳
  223 + let timestamp13 = String(format: "%ld",self.getNow13Timestamp())//timeStamp)
  224 + //拼接
  225 + randomOrderId = String(format: "%@%@%@%d", APPId, currentDateString, timestamp13, Int.random(in: 0..<10))
  226 +
  227 + return randomOrderId
  228 + }
  229 + static func getNow13Timestamp() -> Int {
  230 + let formatter = DateFormatter()
  231 + formatter.dateStyle = .medium
  232 + formatter.timeStyle = .short
  233 + formatter.dateFormat = "yyyy-MM-dd HH:mm:ss"
  234 + formatter.timeZone = TimeZone(identifier: "Asia/Beijing")
  235 + let dateNow = Date()
  236 + let timeStamp = Int(dateNow.timeIntervalSince1970)
  237 + return timeStamp*1000
  238 + }
180 239 }
... ...
metaCode/Supporting Files/Assets.xcassets/HomePage/homePage_payed.imageset/Contents.json 0 → 100644
  1 +{
  2 + "images" : [
  3 + {
  4 + "idiom" : "universal",
  5 + "scale" : "1x"
  6 + },
  7 + {
  8 + "filename" : "homePage_payed@2x.png",
  9 + "idiom" : "universal",
  10 + "scale" : "2x"
  11 + },
  12 + {
  13 + "filename" : "homePage_payed@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/HomePage/homePage_payed.imageset/homePage_payed@2x.png 0 → 100644

2.86 KB

metaCode/Supporting Files/Assets.xcassets/HomePage/homePage_payed.imageset/homePage_payed@3x.png 0 → 100644

5.77 KB