Commit 2979c247975ac639c21cb63daef7571a4d7fdce0

Authored by “张旭”
1 parent bf53e195

点播 默认商品列表 相关推荐--默认数据

metaCode/Classes/Main/HomePages/Model/CNLiveAlbumModel.swift
@@ -52,7 +52,19 @@ class CNLiveAlbumModel:BaseModel{ @@ -52,7 +52,19 @@ class CNLiveAlbumModel:BaseModel{
52 ///"weixin://dl/business/?t=NnvptiuER3k" 52 ///"weixin://dl/business/?t=NnvptiuER3k"
53 var s_showType = "" 53 var s_showType = ""
54 //还有部分属性没写 54 //还有部分属性没写
  55 + var number = ""//取price赋值给price/// {"shop":{"group_img":"","simg":"https://wjj.ys2.cnliveimg.com/769/shop/img/2021/11/26/61a0a34c44436.png","group_name":"","fee_type":"3","title":"测试店铺","im_uid":"daren_11748645","spec_people_id":"0","im_group_id":"","is_gift":"1","phone":"","spec_people_img":"","id":"313","state":"2","gift_style_type":"0","news_img":""},"price":"58.00","shop_type":"1","to":"18064033","type":"2","prices":"68.00"}
  56 + //自定义属性
  57 + var numberModel:CNLiveAlbumNumberModel?
55 } 58 }
  59 +class CNLiveAlbumNumberModel:BaseModel{
  60 + var shop = ""
  61 + var price = ""//价格
  62 + var shop_type = ""
  63 + var to = ""
  64 + var type = ""
  65 + var prices = ""
  66 +}
  67 +
56 class CNLiveAlbumProductModel:BaseModel{ 68 class CNLiveAlbumProductModel:BaseModel{
57 var productId = "" 69 var productId = ""
58 var productTitle = "" 70 var productTitle = ""
metaCode/Classes/Main/HomePages/ViewModel/CNLiveHomePageViewModel.swift
@@ -528,7 +528,15 @@ class CNLiveHomePageViewModel:NSObject,URLSessionTaskDelegate{ @@ -528,7 +528,15 @@ class CNLiveHomePageViewModel:NSObject,URLSessionTaskDelegate{
528 if (errorCode == "0") { 528 if (errorCode == "0") {
529 let dataDic = resp["data"] as! Dictionary<String, Any> 529 let dataDic = resp["data"] as! Dictionary<String, Any>
530 let dataMdl = newDictionaryToModel(dataDic , CNLiveAlbumBaseModel.self) 530 let dataMdl = newDictionaryToModel(dataDic , CNLiveAlbumBaseModel.self)
531 - resultBlock(dataMdl,.success) 531 +
  532 + let albumBaseModel = dataMdl as! CNLiveAlbumBaseModel
  533 + for (_,model) in albumBaseModel.list.enumerated(){
  534 + if let numberMdl = jsonToModel(model.number, CNLiveAlbumNumberModel.self) as? CNLiveAlbumNumberModel{
  535 + model.numberModel = numberMdl
  536 + }
  537 + }
  538 +
  539 + resultBlock(albumBaseModel,.success)
532 } 540 }
533 else{ 541 else{
534 resultBlock(NSNull(),.failed) 542 resultBlock(NSNull(),.failed)
metaCode/Classes/Main/HuBiLieHomePage/Controller/CNLiveTVPlayerViewController.swift
@@ -225,7 +225,7 @@ class CNLiveTVPlayerViewController:UIViewController, UITableViewDataSource, UITa @@ -225,7 +225,7 @@ class CNLiveTVPlayerViewController:UIViewController, UITableViewDataSource, UITa
225 225
226 func configDataArray(){ 226 func configDataArray(){
227 //配置数据 227 //配置数据
228 - var tempDataArray = NSMutableArray() 228 + let tempDataArray = NSMutableArray()
229 //单集 简介 229 //单集 简介
230 if let vodPlayModel = self.vodPlayModel{//单集有值-简介 230 if let vodPlayModel = self.vodPlayModel{//单集有值-简介
231 for (_,mdl) in vodPlayModel.blockList.enumerated(){ 231 for (_,mdl) in vodPlayModel.blockList.enumerated(){
@@ -268,6 +268,7 @@ class CNLiveTVPlayerViewController:UIViewController, UITableViewDataSource, UITa @@ -268,6 +268,7 @@ class CNLiveTVPlayerViewController:UIViewController, UITableViewDataSource, UITa
268 } 268 }
269 //商品 269 //商品
270 if let vodPlayModel = self.vodPlayModel{//单集有值 270 if let vodPlayModel = self.vodPlayModel{//单集有值
  271 +
271 if vodPlayModel.goodsJson.count > 0{ 272 if vodPlayModel.goodsJson.count > 0{
272 let goodMdls = jsonArrayToModel(vodPlayModel.goodsJson, CNLiveVodPlayShopModel.self) 273 let goodMdls = jsonArrayToModel(vodPlayModel.goodsJson, CNLiveVodPlayShopModel.self)
273 if goodMdls.count > 0{//CNLiveVodPlayModel [CNLiveVodPlayShopModel] 274 if goodMdls.count > 0{//CNLiveVodPlayModel [CNLiveVodPlayShopModel]
@@ -275,7 +276,11 @@ class CNLiveTVPlayerViewController:UIViewController, UITableViewDataSource, UITa @@ -275,7 +276,11 @@ class CNLiveTVPlayerViewController:UIViewController, UITableViewDataSource, UITa
275 tempDataArray.add(goodMdls) 276 tempDataArray.add(goodMdls)
276 }else{ 277 }else{
277 //没商品 278 //没商品
  279 + self.getGoodBlockContents()
278 } 280 }
  281 + }else{
  282 + //没商品
  283 + self.getGoodBlockContents()
279 } 284 }
280 } 285 }
281 286
@@ -1087,7 +1092,20 @@ class CNLiveTVPlayerViewController:UIViewController, UITableViewDataSource, UITa @@ -1087,7 +1092,20 @@ class CNLiveTVPlayerViewController:UIViewController, UITableViewDataSource, UITa
1087 cell.vodPlayShopModels = vodPlayShopModels 1092 cell.vodPlayShopModels = vodPlayShopModels
1088 cell.expandBlock = {[weak self] vodPlayShopModels in 1093 cell.expandBlock = {[weak self] vodPlayShopModels in
1089 guard let self = self else { return } 1094 guard let self = self else { return }
1090 - self.shopCellDetailBtnAction(vodPlayShopModels: vodPlayShopModels) 1095 + self.shopCellDetailBtnAction(vodPlayShopModels: vodPlayShopModels as? [CNLiveVodPlayShopModel], albumModels: nil)
  1096 + }
  1097 + return cell
  1098 + }else if let vodPlayShopModels = self.dataArray[indexPath.row] as? [CNLiveAlbumModel]{
  1099 + //默认电商商品
  1100 + guard let cell = tableView.dequeueReusableCell(withIdentifier: kCNLiveVodPlayShopCellIdentifier) as? CNLiveVodPlayShopCell
  1101 + else {
  1102 + let cell = CNLiveVodPlayShopCell()
  1103 + return cell
  1104 + }
  1105 + cell.albumModels = vodPlayShopModels
  1106 + cell.expandBlock = {[weak self] vodPlayShopModels in
  1107 + guard let self = self else { return }
  1108 + self.shopCellDetailBtnAction(vodPlayShopModels: nil, albumModels: vodPlayShopModels as? [CNLiveAlbumModel])
1091 } 1109 }
1092 return cell 1110 return cell
1093 }else { 1111 }else {
@@ -1114,6 +1132,9 @@ class CNLiveTVPlayerViewController:UIViewController, UITableViewDataSource, UITa @@ -1114,6 +1132,9 @@ class CNLiveTVPlayerViewController:UIViewController, UITableViewDataSource, UITa
1114 }else if let vodPlayShopModels = self.dataArray[indexPath.row] as? [CNLiveVodPlayShopModel]{ 1132 }else if let vodPlayShopModels = self.dataArray[indexPath.row] as? [CNLiveVodPlayShopModel]{
1115 //电商 1133 //电商
1116 return 145.0 1134 return 145.0
  1135 + }else if let vodPlayShopModels = self.dataArray[indexPath.row] as? [CNLiveAlbumModel]{
  1136 + //默认电商
  1137 + return 145.0
1117 }else { 1138 }else {
1118 1139
1119 } 1140 }
@@ -1146,13 +1167,19 @@ class CNLiveTVPlayerViewController:UIViewController, UITableViewDataSource, UITa @@ -1146,13 +1167,19 @@ class CNLiveTVPlayerViewController:UIViewController, UITableViewDataSource, UITa
1146 return .allButUpsideDown 1167 return .allButUpsideDown
1147 } 1168 }
1148 1169
1149 - func shopCellDetailBtnAction(vodPlayShopModels:[CNLiveVodPlayShopModel]) { 1170 + //电商商品展开
  1171 + func shopCellDetailBtnAction(vodPlayShopModels:[CNLiveVodPlayShopModel]?,albumModels:[CNLiveAlbumModel]?) {
1150 bottomCommentShowContainView.isHidden = false 1172 bottomCommentShowContainView.isHidden = false
1151 1173
1152 let detailBgView = CNLiveVodShopBottomView(frame: bottomCommentShowContainView.bounds) 1174 let detailBgView = CNLiveVodShopBottomView(frame: bottomCommentShowContainView.bounds)
1153 detailBgView.backgroundColor = .white 1175 detailBgView.backgroundColor = .white
1154 bottomCommentShowContainView.addSubview(detailBgView) 1176 bottomCommentShowContainView.addSubview(detailBgView)
1155 - detailBgView.vodPlayShopModels = vodPlayShopModels 1177 + if vodPlayShopModels?.count ?? 0 > 0{
  1178 + detailBgView.vodPlayShopModels = vodPlayShopModels
  1179 + }
  1180 + if albumModels?.count ?? 0 > 0{
  1181 + detailBgView.albumModels = albumModels
  1182 + }
1156 detailBgView.expandHideBlock = {[weak self] in 1183 detailBgView.expandHideBlock = {[weak self] in
1157 guard let self = self else { return } 1184 guard let self = self else { return }
1158 self.bottomCommentShowContainView.removeAllSubviews() 1185 self.bottomCommentShowContainView.removeAllSubviews()
@@ -1393,6 +1420,29 @@ class CNLiveTVPlayerViewController:UIViewController, UITableViewDataSource, UITa @@ -1393,6 +1420,29 @@ class CNLiveTVPlayerViewController:UIViewController, UITableViewDataSource, UITa
1393 } 1420 }
1394 } 1421 }
1395 1422
  1423 + // MARK: - 获取默认商品block
  1424 + func getGoodBlockContents(){
  1425 + showLoading(message: "")
  1426 + CNLiveHomePageViewModel.getBlockContents(blockId: "12385", page: 1) {[weak self] result, status in
  1427 + hiddenLoading()
  1428 + guard let self = self else { return }
  1429 + if status == .success{
  1430 + let albumBaseModel = result as! CNLiveAlbumBaseModel
  1431 + self.dataArray.add(albumBaseModel.list)
  1432 + self.tableView.reloadData()
  1433 +
  1434 + }else if (status == .noNetwork) {
  1435 +// self.network_type = .noNetwork
  1436 +// self.tableView.reloadEmptyDataSet()
  1437 + } else {
  1438 +// self.network_type = .failed
  1439 +// self.tableView.reloadEmptyDataSet()
  1440 + }
  1441 + }
  1442 +
  1443 +
  1444 + }
  1445 +
1396 // MARK: - 点播play接口 1446 // MARK: - 点播play接口
1397 /* 1447 /*
1398 func requestGetVodPlayApi(contentId:String){ 1448 func requestGetVodPlayApi(contentId:String){
metaCode/Classes/Main/HuBiLieHomePage/View/VodDetail/CNLiveVodPlayShopCell.swift
@@ -8,7 +8,8 @@ @@ -8,7 +8,8 @@
8 8
9 import Foundation 9 import Foundation
10 10
11 -typealias CNLiveVodShopCellExpandBlock = (_ vodPlayShopModels:[CNLiveVodPlayShopModel])->Void 11 +//typealias CNLiveVodShopCellExpandBlock = (_ vodPlayShopModels:[CNLiveVodPlayShopModel])->Void
  12 +typealias CNLiveVodShopCellExpandBlock = (_ vodPlayShopModels:Any)->Void
12 13
13 class CNLiveVodPlayShopCell:UITableViewCell, UICollectionViewDelegate, UICollectionViewDataSource{ 14 class CNLiveVodPlayShopCell:UITableViewCell, UICollectionViewDelegate, UICollectionViewDataSource{
14 var expandBlock:CNLiveVodShopCellExpandBlock? 15 var expandBlock:CNLiveVodShopCellExpandBlock?
@@ -23,6 +24,18 @@ class CNLiveVodPlayShopCell:UITableViewCell, UICollectionViewDelegate, UICollect @@ -23,6 +24,18 @@ class CNLiveVodPlayShopCell:UITableViewCell, UICollectionViewDelegate, UICollect
23 self.setupNewUI(models: vodPlayShopModels!) 24 self.setupNewUI(models: vodPlayShopModels!)
24 } 25 }
25 } 26 }
  27 + //默认电商商品list
  28 + var _albumModels : [CNLiveAlbumModel]?
  29 + var albumModels : [CNLiveAlbumModel]? {
  30 + get{
  31 + _albumModels
  32 + }
  33 + set{
  34 + _albumModels = newValue!
  35 + self.setupNewUI(goodsModels: _albumModels!)
  36 + }
  37 + }
  38 +
26 39
27 lazy var albumListArr: NSMutableArray = { 40 lazy var albumListArr: NSMutableArray = {
28 var albumListArr = NSMutableArray() 41 var albumListArr = NSMutableArray()
@@ -103,13 +116,24 @@ class CNLiveVodPlayShopCell:UITableViewCell, UICollectionViewDelegate, UICollect @@ -103,13 +116,24 @@ class CNLiveVodPlayShopCell:UITableViewCell, UICollectionViewDelegate, UICollect
103 self.contentView.clipsToBounds = true 116 self.contentView.clipsToBounds = true
104 } 117 }
105 118
  119 + func setupNewUI(goodsModels:[CNLiveAlbumModel]){
  120 + self.albumListArr = NSMutableArray(array: goodsModels)
  121 + self.realHotCollectionView.reloadData()
  122 + }
  123 +
106 func setupNewUI(models:[CNLiveVodPlayShopModel]){ 124 func setupNewUI(models:[CNLiveVodPlayShopModel]){
107 self.albumListArr = NSMutableArray(array: models) 125 self.albumListArr = NSMutableArray(array: models)
108 self.realHotCollectionView.reloadData() 126 self.realHotCollectionView.reloadData()
109 } 127 }
110 128
111 @objc func detailBtnAction(){ 129 @objc func detailBtnAction(){
112 - self.expandBlock?(self.vodPlayShopModels!) 130 + if let vodPlayShopModels = self.vodPlayShopModels,self.vodPlayShopModels != nil,self.vodPlayShopModels?.count ?? 0 > 0{
  131 + self.expandBlock?(vodPlayShopModels)
  132 + }else if let albumModels = self.albumModels,self.albumModels != nil ,self.albumModels?.count ?? 0 > 0{
  133 + self.expandBlock?(albumModels)
  134 + }else{
  135 +
  136 + }
113 } 137 }
114 138
115 func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { 139 func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
@@ -120,7 +144,11 @@ class CNLiveVodPlayShopCell:UITableViewCell, UICollectionViewDelegate, UICollect @@ -120,7 +144,11 @@ class CNLiveVodPlayShopCell:UITableViewCell, UICollectionViewDelegate, UICollect
120 144
121 let cell = collectionView.dequeueReusableCell(withReuseIdentifier: kCNLiveVodPlayShopCollectionCellIdentifier, for: indexPath) as! CNLiveVodPlayShopCollectionCell 145 let cell = collectionView.dequeueReusableCell(withReuseIdentifier: kCNLiveVodPlayShopCollectionCellIdentifier, for: indexPath) as! CNLiveVodPlayShopCollectionCell
122 146
123 - cell.vodPlayShopModel = self.albumListArr[indexPath.row] as? CNLiveVodPlayShopModel 147 + if let model = self.albumListArr[indexPath.row] as? CNLiveVodPlayShopModel{
  148 + cell.vodPlayShopModel = model
  149 + }else if let model = self.albumListArr[indexPath.row] as? CNLiveAlbumModel{
  150 + cell.albumModel = model
  151 + }
124 return cell 152 return cell
125 } 153 }
126 func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { 154 func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
@@ -129,6 +157,11 @@ class CNLiveVodPlayShopCell:UITableViewCell, UICollectionViewDelegate, UICollect @@ -129,6 +157,11 @@ class CNLiveVodPlayShopCell:UITableViewCell, UICollectionViewDelegate, UICollect
129 let urlString = "https://managemall.cnlive.com/html/mall/1/#/pages/main/detail/detail?"+"id=\(vodPlayShopModel.id)&uid=\(UserInfoManager.shared.userInfo.uid)" 157 let urlString = "https://managemall.cnlive.com/html/mall/1/#/pages/main/detail/detail?"+"id=\(vodPlayShopModel.id)&uid=\(UserInfoManager.shared.userInfo.uid)"
130 158
131 CNLiveDownSlideTool.pushWebAndVodVCWithContentsMdl(model: kCNDownSlideContentsModelModelProduct , contentId: "" , pid: "" , shareUrl: "" , thirdUrl: urlString , title: vodPlayShopModel.title , s_to: "" ,trailerId: "" , controller: nil, slideModel: nil) 159 CNLiveDownSlideTool.pushWebAndVodVCWithContentsMdl(model: kCNDownSlideContentsModelModelProduct , contentId: "" , pid: "" , shareUrl: "" , thirdUrl: urlString , title: vodPlayShopModel.title , s_to: "" ,trailerId: "" , controller: nil, slideModel: nil)
  160 + }else if let albumModel = self.albumListArr[indexPath.row] as? CNLiveAlbumModel{
  161 + //默认商品
  162 + let urlString = "https://managemall.cnlive.com/html/mall/1/#/pages/main/detail/detail?"+"id=\(albumModel.contentId)&uid=\(UserInfoManager.shared.userInfo.uid)"
  163 +
  164 + CNLiveDownSlideTool.pushWebAndVodVCWithContentsMdl(model: kCNDownSlideContentsModelModelProduct , contentId: "" , pid: "" , shareUrl: "" , thirdUrl: urlString , title: albumModel.title , s_to: "" ,trailerId: "" , controller: nil, slideModel: nil)
132 } 165 }
133 } 166 }
134 167
metaCode/Classes/Main/HuBiLieHomePage/View/VodDetail/CNLiveVodPlayShopCollectionCell.swift
@@ -21,6 +21,18 @@ class CNLiveVodPlayShopCollectionCell: UICollectionViewCell { @@ -21,6 +21,18 @@ class CNLiveVodPlayShopCollectionCell: UICollectionViewCell {
21 setupNewUI(model: _vodPlayShopModel!) 21 setupNewUI(model: _vodPlayShopModel!)
22 } 22 }
23 } 23 }
  24 + //默认商品列表
  25 + var _albumModel : CNLiveAlbumModel?
  26 + var albumModel : CNLiveAlbumModel? {
  27 + get{
  28 + _albumModel
  29 + }
  30 + set{
  31 + _albumModel = newValue!
  32 + self.setupNewUI(goodsModel: _albumModel!)
  33 + }
  34 + }
  35 +
24 36
25 lazy var iconImgView :UIImageView = { 37 lazy var iconImgView :UIImageView = {
26 let iconImgView = UIImageView(frame: CGRect(x: 9, y: 9, width: 72, height: 72)) 38 let iconImgView = UIImageView(frame: CGRect(x: 9, y: 9, width: 72, height: 72))
@@ -113,6 +125,11 @@ class CNLiveVodPlayShopCollectionCell: UICollectionViewCell { @@ -113,6 +125,11 @@ class CNLiveVodPlayShopCollectionCell: UICollectionViewCell {
113 self.titleLabel.text = model.title 125 self.titleLabel.text = model.title
114 self.subTitleLabel.text = model.price 126 self.subTitleLabel.text = model.price
115 } 127 }
  128 + func setupNewUI(goodsModel:CNLiveAlbumModel){
  129 + self.iconImgView.kf.setImage(with: URL(string: goodsModel.poster))
  130 + self.titleLabel.text = goodsModel.title
  131 + self.subTitleLabel.text = goodsModel.numberModel?.price
  132 + }
116 133
117 //购买 134 //购买
118 @objc func payBtnAction(){ 135 @objc func payBtnAction(){
metaCode/Classes/Main/HuBiLieHomePage/View/VodDetail/CNLiveVodShopBottomView.swift
@@ -24,6 +24,19 @@ class CNLiveVodShopBottomView:UIView, UITableViewDataSource, UITableViewDelegate @@ -24,6 +24,19 @@ class CNLiveVodShopBottomView:UIView, UITableViewDataSource, UITableViewDelegate
24 } 24 }
25 } 25 }
26 26
  27 + //默认电商商品list
  28 + var _albumModels : [CNLiveAlbumModel]?
  29 + var albumModels : [CNLiveAlbumModel]? {
  30 + get{
  31 + _albumModels
  32 + }
  33 + set{
  34 + _albumModels = newValue!
  35 + self.setupNewUI(goodsModels: _albumModels!)
  36 + }
  37 + }
  38 +
  39 +
27 lazy var titleLabel: UILabel = { 40 lazy var titleLabel: UILabel = {
28 let titleLbl = UILabel() 41 let titleLbl = UILabel()
29 titleLbl.font = BoldFont_18 42 titleLbl.font = BoldFont_18
@@ -99,6 +112,13 @@ class CNLiveVodShopBottomView:UIView, UITableViewDataSource, UITableViewDelegate @@ -99,6 +112,13 @@ class CNLiveVodShopBottomView:UIView, UITableViewDataSource, UITableViewDelegate
99 self.dataArray.add(model) 112 self.dataArray.add(model)
100 self.tableView.reloadData() 113 self.tableView.reloadData()
101 } 114 }
  115 + func setupNewUI(goodsModels:[CNLiveAlbumModel]){
  116 + self.titleLabel.text = blockTitle
  117 + self.dataArray = NSMutableArray()//NSMutableArray(array: model)
  118 + self.dataArray.add(goodsModels)
  119 + self.tableView.reloadData()
  120 + }
  121 +
102 122
103 // MARK: - UITableViewDelegate 123 // MARK: - UITableViewDelegate
104 func numberOfSections(in tableView: UITableView) -> Int { 124 func numberOfSections(in tableView: UITableView) -> Int {
@@ -119,6 +139,16 @@ class CNLiveVodShopBottomView:UIView, UITableViewDataSource, UITableViewDelegate @@ -119,6 +139,16 @@ class CNLiveVodShopBottomView:UIView, UITableViewDataSource, UITableViewDelegate
119 139
120 cell.vodPlayShopModel = vodPlayShopModel 140 cell.vodPlayShopModel = vodPlayShopModel
121 return cell 141 return cell
  142 + }else if let vodPlayShopModel = self.dataArray[indexPath.row] as? [CNLiveAlbumModel]{
  143 + //默认商品
  144 + guard let cell = tableView.dequeueReusableCell(withIdentifier: kCNLiveVodShopExpandCellIdentifier) as? CNLiveVodShopExpandCell
  145 + else {
  146 + let cell = CNLiveVodShopExpandCell()
  147 + return cell
  148 + }
  149 +
  150 + cell.albumModels = vodPlayShopModel
  151 + return cell
122 } 152 }
123 return UITableViewCell() 153 return UITableViewCell()
124 } 154 }
@@ -131,6 +161,13 @@ class CNLiveVodShopBottomView:UIView, UITableViewDataSource, UITableViewDelegate @@ -131,6 +161,13 @@ class CNLiveVodShopBottomView:UIView, UITableViewDataSource, UITableViewDelegate
131 let hang = Int(ceil(CGFloat(vodPlayShopModel.count)*0.5)) 161 let hang = Int(ceil(CGFloat(vodPlayShopModel.count)*0.5))
132 let totalRowH = Float(Float(hang)*rowH) 162 let totalRowH = Float(Float(hang)*rowH)
133 return CGFloat(totalRowH) 163 return CGFloat(totalRowH)
  164 + }else if let vodPlayShopModel = self.dataArray[indexPath.row] as? [CNLiveAlbumModel]{
  165 + let imgWH:Float = Float((KSreenWidth-15*3)*0.5)
  166 + let bottomH:Float = 55.0
  167 + let rowH:Float = imgWH+bottomH+15.0
  168 + let hang = Int(ceil(CGFloat(vodPlayShopModel.count)*0.5))
  169 + let totalRowH = Float(Float(hang)*rowH)
  170 + return CGFloat(totalRowH)
134 } 171 }
135 return 60 172 return 60
136 } 173 }
metaCode/Classes/Main/HuBiLieHomePage/View/VodDetail/CNLiveVodShopExpandCell.swift
@@ -24,6 +24,23 @@ class CNLiveVodShopExpandCell: UITableViewCell { @@ -24,6 +24,23 @@ class CNLiveVodShopExpandCell: UITableViewCell {
24 setupNewUI(model: _vodPlayShopModel!) 24 setupNewUI(model: _vodPlayShopModel!)
25 } 25 }
26 } 26 }
  27 + //默认电商商品list
  28 + var _albumModels : [CNLiveAlbumModel]?
  29 + var albumModels : [CNLiveAlbumModel]? {
  30 + get{
  31 + _albumModels
  32 + }
  33 + set{
  34 + _albumModels = newValue!
  35 + for obj in contentView.subviews{
  36 + if obj.tag > 100{
  37 + obj.removeFromSuperview()
  38 + }
  39 + }
  40 + self.setupNewUI(goodsModels: _albumModels!)
  41 + }
  42 + }
  43 +
27 44
28 //MARK: - 懒加载 45 //MARK: - 懒加载
29 46
@@ -37,7 +54,89 @@ class CNLiveVodShopExpandCell: UITableViewCell { @@ -37,7 +54,89 @@ class CNLiveVodShopExpandCell: UITableViewCell {
37 required init?(coder: NSCoder) { 54 required init?(coder: NSCoder) {
38 fatalError("init(coder:) has not been implemented") 55 fatalError("init(coder:) has not been implemented")
39 } 56 }
40 - 57 + //默认商品
  58 + func setupNewUI(goodsModels:[CNLiveAlbumModel]){
  59 +
  60 + //总显示块数/循环数
  61 + let totalNum = goodsModels.count
  62 + //lieIndex 当前是contents的第0列还是第1列
  63 + var lieIndex = 0
  64 + //hangIndex 当前是第几行,1...n
  65 + var hangIndex = 1
  66 +
  67 + let imgWH = (KSreenWidth-15*3)*0.5
  68 + let bottomH = 55.0
  69 + let rowH = imgWH+bottomH+15.0
  70 +
  71 + for i in 0..<totalNum{//i是第几行
  72 + if lieIndex == 0{
  73 + //显示左边的块
  74 + let contentMdl = goodsModels[(hangIndex-1)*2+(lieIndex)]
  75 + let imageView = UIImageView(frame: CGRectMake(DownSlideRecommendLeftGap, CGFloat(hangIndex-1)*rowH, CGFloat(imgWH), CGFloat(imgWH)))
  76 + imageView.kf.setImage(with: URL(string:contentMdl.poster))
  77 + imageView.tag = i+1000
  78 + imageView.layer.cornerRadius = 9
  79 + imageView.clipsToBounds = true
  80 + imageView.contentMode = .scaleAspectFill
  81 +
  82 + imageView.isUserInteractionEnabled = true
  83 + imageView.addGestureRecognizer(UITapGestureRecognizer.init(target: self, action: #selector(imgTapAction)))
  84 + contentView.addSubview(imageView)
  85 +
  86 + let titleStr = contentMdl.title
  87 + let subTitleStr = "¥\(contentMdl.numberModel?.price ?? "未知金额")"
  88 + let titleLbl = UILabel(frame: CGRect(x: imageView.left, y: imageView.bottom+10, width: imageView.width, height: 21))
  89 + titleLbl.font = BoldFont_15
  90 + titleLbl.textColor = HexColor("#333333")
  91 + titleLbl.text = titleStr
  92 + titleLbl.tag = i+1000
  93 + contentView.addSubview(titleLbl)
  94 +
  95 + let subTitleLbl = UILabel(frame: CGRect(x: titleLbl.left, y: titleLbl.bottom, width: titleLbl.width, height: 24))
  96 + subTitleLbl.font = Font_17
  97 + subTitleLbl.textColor = HexColor("#E56E32")
  98 + subTitleLbl.text = subTitleStr
  99 + subTitleLbl.tag = i+1000
  100 + contentView.addSubview(subTitleLbl)
  101 +
  102 + lieIndex = 1
  103 + }else{
  104 + //lieIndex==1显示右边的块
  105 + let contentMdl = goodsModels[(hangIndex-1)*2+(lieIndex)]
  106 + let imageView = UIImageView(frame: CGRectMake(CGFloat(DownSlideRecommendLeftGap*2)+CGFloat(imgWH), CGFloat(hangIndex-1)*rowH, CGFloat(imgWH), CGFloat(imgWH)))
  107 + imageView.kf.setImage(with: URL(string:contentMdl.poster))
  108 + imageView.tag = i+1000
  109 + imageView.layer.cornerRadius = 14
  110 + imageView.clipsToBounds = true
  111 + imageView.contentMode = .scaleAspectFill
  112 +
  113 + imageView.isUserInteractionEnabled = true
  114 + imageView.addGestureRecognizer(UITapGestureRecognizer.init(target: self, action: #selector(imgTapAction)))
  115 + contentView.addSubview(imageView)
  116 +
  117 + let titleStr = contentMdl.title
  118 + let subTitleStr = "¥\(contentMdl.numberModel?.price ?? "未知金额")"
  119 +
  120 + let titleLbl = UILabel(frame: CGRect(x: imageView.left, y: imageView.bottom+10, width: imageView.width, height: 21))
  121 + titleLbl.font = BoldFont_15
  122 + titleLbl.textColor = HexColor("#333333")
  123 + titleLbl.text = titleStr
  124 + titleLbl.tag = i+1000
  125 + contentView.addSubview(titleLbl)
  126 +
  127 + let subTitleLbl = UILabel(frame: CGRect(x: titleLbl.left, y: titleLbl.bottom, width: titleLbl.width, height: 24))
  128 + subTitleLbl.font = Font_17
  129 + subTitleLbl.textColor = HexColor("#E56E32")
  130 + subTitleLbl.tag = i+1000
  131 + subTitleLbl.text = subTitleStr
  132 + contentView.addSubview(subTitleLbl)
  133 +
  134 + lieIndex = 0
  135 + hangIndex += 1
  136 + }
  137 + }
  138 + }
  139 +
41 func setupNewUI(model:[CNLiveVodPlayShopModel]){ 140 func setupNewUI(model:[CNLiveVodPlayShopModel]){
42 141
43 //总显示块数/循环数 142 //总显示块数/循环数
@@ -123,10 +222,17 @@ class CNLiveVodShopExpandCell: UITableViewCell { @@ -123,10 +222,17 @@ class CNLiveVodShopExpandCell: UITableViewCell {
123 @objc func imgTapAction(ges: UITapGestureRecognizer){ 222 @objc func imgTapAction(ges: UITapGestureRecognizer){
124 let imageView = ges.view as! UIImageView 223 let imageView = ges.view as! UIImageView
125 let i = imageView.tag-1000 224 let i = imageView.tag-1000
126 - let contentMdl = (self.vodPlayShopModel?[i])!  
127 - let urlString = "https://managemall.cnlive.com/html/mall/1/#/pages/main/detail/detail?"+"id=\(contentMdl.id)&uid=\(UserInfoManager.shared.userInfo.uid)"  
128 -  
129 - CNLiveDownSlideTool.pushWebAndVodVCWithContentsMdl(model: kCNDownSlideContentsModelModelProduct , contentId: "" , pid: "" , shareUrl: "" , thirdUrl: urlString , title: contentMdl.title , s_to: "" ,trailerId: "" , controller: nil, slideModel: nil) 225 + if self.vodPlayShopModel?.count ?? 0 > 0{
  226 + let contentMdl = (self.vodPlayShopModel?[i])!
  227 + let urlString = "https://managemall.cnlive.com/html/mall/1/#/pages/main/detail/detail?"+"id=\(contentMdl.id)&uid=\(UserInfoManager.shared.userInfo.uid)"
  228 +
  229 + CNLiveDownSlideTool.pushWebAndVodVCWithContentsMdl(model: kCNDownSlideContentsModelModelProduct , contentId: "" , pid: "" , shareUrl: "" , thirdUrl: urlString , title: contentMdl.title , s_to: "" ,trailerId: "" , controller: nil, slideModel: nil)
  230 + }else if self.albumModels?.count ?? 0 > 0{
  231 + let contentMdl = (self.albumModels?[i])!
  232 + let urlString = "https://managemall.cnlive.com/html/mall/1/#/pages/main/detail/detail?"+"id=\(contentMdl.contentId)&uid=\(UserInfoManager.shared.userInfo.uid)"
  233 +
  234 + CNLiveDownSlideTool.pushWebAndVodVCWithContentsMdl(model: kCNDownSlideContentsModelModelProduct , contentId: "" , pid: "" , shareUrl: "" , thirdUrl: urlString , title: contentMdl.title , s_to: "" ,trailerId: "" , controller: nil, slideModel: nil)
  235 + }
130 } 236 }
131 237
132 } 238 }