Commit 9938271f6f832e47a2c57704205e9ffb497aff2a
1 parent
96632251
商品预览
Showing
17 changed files
with
831 additions
and
16 deletions
Podfile
metaCode.xcodeproj/project.pbxproj
| ... | ... | @@ -105,6 +105,9 @@ |
| 105 | 105 | 1965FA3E2AFB176E00F0F435 /* CNLiveShopAddGoodsSingleView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1965FA3D2AFB176E00F0F435 /* CNLiveShopAddGoodsSingleView.swift */; }; |
| 106 | 106 | 1965FA402AFB38AA00F0F435 /* CNLiveAddGoodsSelectUploadImageView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1965FA3F2AFB38AA00F0F435 /* CNLiveAddGoodsSelectUploadImageView.swift */; }; |
| 107 | 107 | 1965FA422AFB79EA00F0F435 /* CNLiveGoodsCategoryController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1965FA412AFB79EA00F0F435 /* CNLiveGoodsCategoryController.swift */; }; |
| 108 | + 19AD65AA2BA041210045A444 /* CNLiveGoodsDetailsTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 19AD65A92BA041210045A444 /* CNLiveGoodsDetailsTableViewCell.swift */; }; | |
| 109 | + 19AD65AC2BA16CF20045A444 /* CNLiveShopCommentRequestShareModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 19AD65AB2BA16CF20045A444 /* CNLiveShopCommentRequestShareModel.swift */; }; | |
| 110 | + 19AD65AE2BA177C20045A444 /* CNLiveShopGoodsDetailsTableHeaderView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 19AD65AD2BA177C20045A444 /* CNLiveShopGoodsDetailsTableHeaderView.swift */; }; | |
| 108 | 111 | 19BB1FDF2AEA3A450094D962 /* CNSlideBaseNavigationController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 19BB1FDE2AEA3A450094D962 /* CNSlideBaseNavigationController.swift */; }; |
| 109 | 112 | 19BB1FE12AEB5C220094D962 /* CNLiveShopConsoleController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 19BB1FE02AEB5C220094D962 /* CNLiveShopConsoleController.swift */; }; |
| 110 | 113 | 19BB1FE32AEB8B7C0094D962 /* CNLiveShopConsoleViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 19BB1FE22AEB8B7C0094D962 /* CNLiveShopConsoleViewModel.swift */; }; |
| ... | ... | @@ -368,6 +371,9 @@ |
| 368 | 371 | 1965FA3D2AFB176E00F0F435 /* CNLiveShopAddGoodsSingleView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNLiveShopAddGoodsSingleView.swift; sourceTree = "<group>"; }; |
| 369 | 372 | 1965FA3F2AFB38AA00F0F435 /* CNLiveAddGoodsSelectUploadImageView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNLiveAddGoodsSelectUploadImageView.swift; sourceTree = "<group>"; }; |
| 370 | 373 | 1965FA412AFB79EA00F0F435 /* CNLiveGoodsCategoryController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNLiveGoodsCategoryController.swift; sourceTree = "<group>"; }; |
| 374 | + 19AD65A92BA041210045A444 /* CNLiveGoodsDetailsTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNLiveGoodsDetailsTableViewCell.swift; sourceTree = "<group>"; }; | |
| 375 | + 19AD65AB2BA16CF20045A444 /* CNLiveShopCommentRequestShareModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNLiveShopCommentRequestShareModel.swift; sourceTree = "<group>"; }; | |
| 376 | + 19AD65AD2BA177C20045A444 /* CNLiveShopGoodsDetailsTableHeaderView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNLiveShopGoodsDetailsTableHeaderView.swift; sourceTree = "<group>"; }; | |
| 371 | 377 | 19BB1FDE2AEA3A450094D962 /* CNSlideBaseNavigationController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNSlideBaseNavigationController.swift; sourceTree = "<group>"; }; |
| 372 | 378 | 19BB1FE02AEB5C220094D962 /* CNLiveShopConsoleController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNLiveShopConsoleController.swift; sourceTree = "<group>"; }; |
| 373 | 379 | 19BB1FE22AEB8B7C0094D962 /* CNLiveShopConsoleViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNLiveShopConsoleViewModel.swift; sourceTree = "<group>"; }; |
| ... | ... | @@ -856,6 +862,8 @@ |
| 856 | 862 | 19BB1FF12AF21A950094D962 /* CNLliveShopDetailBannerCell.swift */, |
| 857 | 863 | 19565EBF2AF4DE0E007D6727 /* CNLiveShopDetailBtnsCell.swift */, |
| 858 | 864 | 19565EC12AF616CA007D6727 /* CNLiveShopDetailOrderAssetCell.swift */, |
| 865 | + 19AD65A92BA041210045A444 /* CNLiveGoodsDetailsTableViewCell.swift */, | |
| 866 | + 19AD65AD2BA177C20045A444 /* CNLiveShopGoodsDetailsTableHeaderView.swift */, | |
| 859 | 867 | ); |
| 860 | 868 | path = ShopDetail; |
| 861 | 869 | sourceTree = "<group>"; |
| ... | ... | @@ -925,6 +933,7 @@ |
| 925 | 933 | 19565ED32AF9FEB4007D6727 /* CNLiveShopAddEditGoodsModel.swift */, |
| 926 | 934 | 191732EA2B070943007BCC04 /* CNLiveShopGoodsManageDetailsGoodsCategoryModel.swift */, |
| 927 | 935 | 191732EC2B073C52007BCC04 /* CNLiveShopClassifyListModel.swift */, |
| 936 | + 19AD65AB2BA16CF20045A444 /* CNLiveShopCommentRequestShareModel.swift */, | |
| 928 | 937 | ); |
| 929 | 938 | path = GoodsManager; |
| 930 | 939 | sourceTree = "<group>"; |
| ... | ... | @@ -1688,6 +1697,7 @@ |
| 1688 | 1697 | 7963989D2A260E6200D045EB /* CNLiveBaseViewController.swift in Sources */, |
| 1689 | 1698 | 798A44FB2A30999900815935 /* CNLiveAlertTool.swift in Sources */, |
| 1690 | 1699 | 191732EB2B070943007BCC04 /* CNLiveShopGoodsManageDetailsGoodsCategoryModel.swift in Sources */, |
| 1700 | + 19AD65AA2BA041210045A444 /* CNLiveGoodsDetailsTableViewCell.swift in Sources */, | |
| 1691 | 1701 | 19565EC02AF4DE0E007D6727 /* CNLiveShopDetailBtnsCell.swift in Sources */, |
| 1692 | 1702 | 191732E92B0706B3007BCC04 /* CNLiveShopClassifyCell.swift in Sources */, |
| 1693 | 1703 | 790D01A52A2DF65E00C5978D /* CNLiveLoginPickerView.swift in Sources */, |
| ... | ... | @@ -1794,6 +1804,7 @@ |
| 1794 | 1804 | 792E57DB2A3AE9F4005834DB /* CNLiveCommonQiniuTool.swift in Sources */, |
| 1795 | 1805 | 191732F12B084822007BCC04 /* CNLiveShopClassifyInputTableViewCell.swift in Sources */, |
| 1796 | 1806 | 191733212B143F3A007BCC04 /* CNLiveGradientView.swift in Sources */, |
| 1807 | + 19AD65AE2BA177C20045A444 /* CNLiveShopGoodsDetailsTableHeaderView.swift in Sources */, | |
| 1797 | 1808 | 19BB1FE62AEB93B80094D962 /* CNLiveShopUserInfoModel.swift in Sources */, |
| 1798 | 1809 | 7CD675472A274167008354C1 /* NewPagedFlowView.m in Sources */, |
| 1799 | 1810 | 191732ED2B073C52007BCC04 /* CNLiveShopClassifyListModel.swift in Sources */, |
| ... | ... | @@ -1861,6 +1872,7 @@ |
| 1861 | 1872 | 790B1FB42A4153E90074CF00 /* CNLiveMineBaseModel.swift in Sources */, |
| 1862 | 1873 | 794294AA2B4D4381008AAFA0 /* CNLiveShortVideoCommentListView.swift in Sources */, |
| 1863 | 1874 | 7978A8432A396632007C86B8 /* CNLiveMineViewModel.swift in Sources */, |
| 1875 | + 19AD65AC2BA16CF20045A444 /* CNLiveShopCommentRequestShareModel.swift in Sources */, | |
| 1864 | 1876 | 191733022B0C4EAB007BCC04 /* CNLiveSelUplSingleImageView.swift in Sources */, |
| 1865 | 1877 | 798A44EE2A305AAC00815935 /* CNLiveBaseNavigationController.swift in Sources */, |
| 1866 | 1878 | 1938BD412B4BEC6900390A34 /* CNLiveAlbumListModel.swift in Sources */, | ... | ... |
metaCode/Classes/Main/HomePage/Controller/GoodsDetail/CNLiveShopGoodsDetailsViewController.swift
| ... | ... | @@ -6,6 +6,11 @@ |
| 6 | 6 | // |
| 7 | 7 | |
| 8 | 8 | import Foundation |
| 9 | +import YYImage | |
| 10 | +import YYWebImage | |
| 11 | +import SKPhotoBrowser | |
| 12 | +import CNLiveShareToolKit | |
| 13 | +import BKCycleScrollView | |
| 9 | 14 | |
| 10 | 15 | ///分类类型 |
| 11 | 16 | enum CNLiveShopGoodsDetailsVCType:Int { |
| ... | ... | @@ -15,7 +20,10 @@ enum CNLiveShopGoodsDetailsVCType:Int { |
| 15 | 20 | case preview |
| 16 | 21 | } |
| 17 | 22 | |
| 18 | -class CNLiveShopGoodsDetailsViewController:CNLiveBaseViewController{ | |
| 23 | +class CNLiveShopGoodsDetailsViewController:CNLiveBaseViewController,UITableViewDelegate,UITableViewDataSource, BKCycleScrollViewDelegate{ | |
| 24 | + | |
| 25 | + let kDSGoodsDetailsTableViewCellID = "DSGoodsDetailsTableViewCell" | |
| 26 | + let kDSPlayerAnimateTimeInterval:CGFloat = 0.25 | |
| 19 | 27 | /// 格式 |
| 20 | 28 | var type:CNLiveShopGoodsDetailsVCType? |
| 21 | 29 | /// 商品id |
| ... | ... | @@ -23,8 +31,346 @@ class CNLiveShopGoodsDetailsViewController:CNLiveBaseViewController{ |
| 23 | 31 | /// 编辑商品预览使用 |
| 24 | 32 | var detailsModel:CNLiveShopGoodsDetailsModel? |
| 25 | 33 | |
| 34 | + var leftCircleBgView:CNLiveRoundedRectView? | |
| 35 | + var leftImageView:YYAnimatedImageView? | |
| 36 | + var shareCircleBgView:CNLiveRoundedRectView? | |
| 37 | + var shareImageView:YYAnimatedImageView? | |
| 38 | + | |
| 39 | + var CSV_playerView :CNLivePlayerView? | |
| 40 | + | |
| 41 | + weak var cycleScrollView :BKCycleScrollView? = { | |
| 42 | + let cycleScrollView = BKCycleScrollView() | |
| 43 | + return cycleScrollView | |
| 44 | + }() | |
| 45 | + | |
| 46 | + lazy var tableView : UITableView = { | |
| 47 | + let tableView = UITableView(frame: CGRect(x: 0, y: 0, width: KSreenWidth, height: self.view.height), style: .plain) | |
| 48 | + tableView.dataSource = self | |
| 49 | + tableView.delegate = self | |
| 50 | + tableView.separatorStyle = .none | |
| 51 | + tableView.tableFooterView = UIView.init() | |
| 52 | + tableView.backgroundColor = HexColor("#f1f2f6") | |
| 53 | + tableView.register(CNLiveGoodsDetailsTableViewCell.self, forCellReuseIdentifier: kDSGoodsDetailsTableViewCellID) | |
| 54 | + return tableView | |
| 55 | + }() | |
| 56 | + | |
| 57 | + //图片集合 | |
| 58 | + lazy var imgs :NSMutableArray = { | |
| 59 | + let imgs = NSMutableArray() | |
| 60 | + return imgs | |
| 61 | + }() | |
| 62 | + | |
| 26 | 63 | override func viewDidLoad() { |
| 27 | 64 | super.viewDidLoad() |
| 65 | + self.initNav() | |
| 66 | + self.view.insertSubview(self.tableView, belowSubview: self.topNavView) | |
| 67 | + navigationBarHidden = false | |
| 68 | + if self.type == .preview{ | |
| 69 | + self.insertData() | |
| 70 | + }else{ | |
| 71 | + self.requestGoodsInfo() | |
| 72 | + } | |
| 73 | + } | |
| 74 | + | |
| 75 | + override func viewWillLayoutSubviews() { | |
| 76 | + super.viewWillLayoutSubviews() | |
| 77 | + self.tableView.frame = CGRect(x: 0, y: 0, width: self.view.width, height: self.view.height) | |
| 78 | + } | |
| 79 | + | |
| 80 | + var isPrefersStatusBarHidden:Bool = false | |
| 81 | + override var prefersStatusBarHidden: Bool { | |
| 82 | + return self.isPrefersStatusBarHidden | |
| 83 | + } | |
| 84 | + | |
| 85 | + deinit { | |
| 86 | + if (self.cycleScrollView != nil){ | |
| 87 | + self.cycleScrollView = nil | |
| 88 | + } | |
| 89 | + self.destroyPlayerView() | |
| 90 | + } | |
| 91 | + | |
| 92 | + func initNav(){ | |
| 93 | + self.topNavView.backgroundColor = UIColor(white: 1, alpha: 0) | |
| 94 | + self.topLine.alpha = 0 | |
| 95 | + self.leftNavBtns.forEach { $0.removeFromSuperview() } | |
| 96 | + | |
| 97 | + let backNavBtn = UIButton(type: .custom) | |
| 98 | + backNavBtn.frame = CGRect(x: 0, y: get_system_statusBar_height(), width: get_system_nav_ui_height(), height: get_system_nav_ui_height()) | |
| 99 | + backNavBtn.addTarget(self, action: #selector(backNavBtnClick), for: .touchUpInside) | |
| 100 | + self.topNavView.addSubview(backNavBtn) | |
| 101 | + | |
| 102 | + self.leftCircleBgView = CNLiveRoundedRectView(frame: CGRect(x: 15, y: (backNavBtn.height - 32)/2, width: 32, height: 32)) | |
| 103 | + self.leftCircleBgView?.fillColor = HexColor("#848484", alpha: 0.45) | |
| 104 | + self.leftCircleBgView?.radius = self.leftCircleBgView!.height/2 | |
| 105 | + self.leftCircleBgView?.isUserInteractionEnabled = false | |
| 106 | + backNavBtn.addSubview(self.leftCircleBgView!) | |
| 107 | + | |
| 108 | + let wLeftImageView = YYAnimatedImageView(frame: CGRect(x: 15, y: (backNavBtn.height - 32)/2, width: 32, height: 32)) | |
| 109 | + wLeftImageView.clipsToBounds = true | |
| 110 | + wLeftImageView.contentMode = .scaleAspectFit | |
| 111 | + wLeftImageView.image = UIImage(named: "DS_goods_back_g") | |
| 112 | + backNavBtn.addSubview(wLeftImageView) | |
| 113 | + | |
| 114 | + self.leftImageView = YYAnimatedImageView(frame: CGRect(x: 15, y: (backNavBtn.height - 32)/2, width: 32, height: 32)) | |
| 115 | + self.leftImageView?.clipsToBounds = true | |
| 116 | + self.leftImageView?.contentMode = .scaleAspectFit | |
| 117 | + self.leftImageView?.image = UIImage(named: "DS_goods_back_g") | |
| 118 | + self.leftImageView?.alpha = 0 | |
| 119 | + backNavBtn.addSubview(self.leftImageView!) | |
| 120 | + | |
| 121 | + if self.goodsId?.count ?? 0 > 0{ | |
| 122 | + let shareNavBtn = UIButton(type: .custom) | |
| 123 | + shareNavBtn.frame = CGRect(x: KSreenWidth-62, y: get_system_statusBar_height(), width: get_system_nav_ui_height(), height: get_system_nav_ui_height()) | |
| 124 | + shareNavBtn.addTarget(self, action: #selector(shareNavBtnClick), for: .touchUpInside) | |
| 125 | + self.topNavView.addSubview(shareNavBtn) | |
| 126 | + | |
| 127 | + self.shareCircleBgView = CNLiveRoundedRectView(frame: CGRect(x: 15, y: (shareNavBtn.height - 32)/2, width: 32, height: 32)) | |
| 128 | + self.shareCircleBgView?.fillColor = HexColor("#848484", alpha: 0.45) | |
| 129 | + self.shareCircleBgView?.radius = self.shareCircleBgView!.height/2 | |
| 130 | + self.shareCircleBgView?.isUserInteractionEnabled = false | |
| 131 | + shareNavBtn.addSubview(self.shareCircleBgView!) | |
| 132 | + | |
| 133 | + let wShareImageView = YYAnimatedImageView(frame: CGRect(x: 15, y: (shareNavBtn.height - 32), width: 32, height: 32)) | |
| 134 | + wShareImageView.clipsToBounds = true | |
| 135 | + wShareImageView.contentMode = .scaleAspectFit | |
| 136 | + wShareImageView.image = UIImage(named: "DS_goods_share_g") | |
| 137 | + wShareImageView.alpha = 0 | |
| 138 | + shareNavBtn.addSubview(wShareImageView) | |
| 139 | + | |
| 140 | + self.shareImageView = YYAnimatedImageView(frame: CGRect(x: 15, y: (shareNavBtn.height - 32), width: 32, height: 32)) | |
| 141 | + self.shareImageView?.clipsToBounds = true | |
| 142 | + self.shareImageView?.contentMode = .scaleAspectFit | |
| 143 | + self.shareImageView?.image = UIImage(named: "DS_goods_share_g") | |
| 144 | + self.shareImageView?.alpha = 0 | |
| 145 | + shareNavBtn.addSubview(self.shareImageView!) | |
| 146 | + } | |
| 147 | + } | |
| 148 | + | |
| 149 | + func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { | |
| 150 | + return self.detailsModel?.detail_img.count ?? 0 | |
| 151 | + } | |
| 152 | + | |
| 153 | + func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { | |
| 154 | + let detailsContentModel = self.detailsModel?.detail_img[indexPath.row] | |
| 155 | + if detailsContentModel?.w ?? 0 > 0{ | |
| 156 | + return floor(self.view.width / (detailsContentModel?.w ?? 0) * (detailsContentModel?.h ?? 0)) | |
| 157 | + }else{ | |
| 158 | + return 200 | |
| 159 | + } | |
| 160 | + } | |
| 161 | + | |
| 162 | + func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { | |
| 163 | + let cell = tableView.dequeueReusableCell(withIdentifier: kDSGoodsDetailsTableViewCellID) as! CNLiveGoodsDetailsTableViewCell | |
| 164 | + let detailsContentModel = self.detailsModel?.detail_img[indexPath.row] | |
| 165 | + | |
| 166 | + var escapedUrl = detailsContentModel?.simg?.removingPercentEncoding | |
| 167 | + escapedUrl = escapedUrl?.addingPercentEncoding(withAllowedCharacters: CharacterSet.urlQueryAllowed) | |
| 168 | + cell.displayImageView?.yy_setImage(with: URL(string: escapedUrl!), placeholder: nil, options: [.showNetworkActivity , .setImageWithFadeAnimation], completion: { image, url, from, stage, error in | |
| 169 | + | |
| 170 | + if (image == nil) { | |
| 171 | + return | |
| 172 | + } | |
| 173 | + if (image!.size.height == detailsContentModel?.h) { | |
| 174 | + return | |
| 175 | + } | |
| 176 | + detailsContentModel?.w = image!.size.width | |
| 177 | + detailsContentModel?.h = image!.size.height | |
| 178 | + DispatchQueue.main.async { | |
| 179 | + self.tableView.reloadData() | |
| 180 | + } | |
| 181 | + }) | |
| 182 | + return cell | |
| 183 | + } | |
| 184 | + | |
| 185 | + func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { | |
| 186 | + | |
| 187 | + let browser = SKPhotoBrowser(photos: self.imgs as! [SKPhotoProtocol]) | |
| 188 | + browser.initializePageIndex(indexPath.row) | |
| 189 | + currentViewController()?.present(browser, animated: true) | |
| 190 | + } | |
| 191 | + | |
| 192 | + // MARK: - UIScrollViewDelegate | |
| 193 | + func scrollViewDidScroll(_ scrollView: UIScrollView) { | |
| 194 | + if self.tableView == scrollView{ | |
| 195 | + if self.tableView.contentOffset.y < 0{ | |
| 196 | + self.topNavView.backgroundColor = UIColor(white: 1, alpha: 0) | |
| 197 | + self.leftCircleBgView?.alpha = 1 | |
| 198 | + self.leftImageView?.alpha = 0 | |
| 199 | + | |
| 200 | + self.shareCircleBgView?.alpha = 1 | |
| 201 | + self.shareImageView?.alpha = 0 | |
| 202 | + self.topLine.alpha = 0 | |
| 203 | + }else if self.tableView.contentOffset.y >= 128{ | |
| 204 | + self.topNavView.backgroundColor = UIColor(white: 1, alpha: 1) | |
| 205 | + self.leftCircleBgView?.alpha = 0 | |
| 206 | + self.leftImageView?.alpha = 1 | |
| 207 | + | |
| 208 | + self.shareCircleBgView?.alpha = 0 | |
| 209 | + self.shareImageView?.alpha = 1 | |
| 210 | + self.topLine.alpha = 1 | |
| 211 | + }else{ | |
| 212 | + let indexAlpha = self.tableView.contentOffset.y/128.0 | |
| 213 | + self.leftCircleBgView?.alpha = 1 - indexAlpha | |
| 214 | + self.leftImageView?.alpha = indexAlpha | |
| 215 | + self.shareCircleBgView?.alpha = 1 - indexAlpha | |
| 216 | + self.shareImageView?.alpha = indexAlpha | |
| 217 | + self.topLine.alpha = indexAlpha | |
| 218 | + self.topNavView.backgroundColor = UIColor(white: 1, alpha: indexAlpha) | |
| 219 | + } | |
| 220 | + } | |
| 221 | + } | |
| 222 | + | |
| 223 | + // MARK: - 获取商品详情 | |
| 224 | + func requestGoodsInfo(){ | |
| 225 | + showLoading(message: "") | |
| 226 | + CNLiveShopGoodListViewModel.getGoodsInfoWithGoodsId(goodsId: self.goodsId ?? "") { result, status in | |
| 227 | + hiddenLoading() | |
| 228 | + if status == .failed{ | |
| 229 | + showMessage(message: "获取失败") | |
| 230 | + return | |
| 231 | + } | |
| 232 | + if status == .success{ | |
| 233 | + let model = result as! CNLiveShopGoodsDetailsModel | |
| 234 | + self.detailsModel = model | |
| 235 | + self.insertData() | |
| 236 | + } | |
| 237 | + } | |
| 238 | + } | |
| 239 | + | |
| 240 | + func insertData(){ | |
| 241 | + var headerView:CNLiveShopGoodsDetailsTableHeaderView? | |
| 242 | + if self.tableView.tableHeaderView == nil{ | |
| 243 | + headerView = CNLiveShopGoodsDetailsTableHeaderView(frame: CGRect(x: 0, y: 0, width: KSreenWidth, height: 0)) | |
| 244 | + headerView!.bannerView.delegate = self | |
| 245 | + headerView!.clickGiveGiftBlock = { | |
| 246 | + | |
| 247 | + } | |
| 248 | + }else{ | |
| 249 | + headerView = self.tableView.tableHeaderView as? CNLiveShopGoodsDetailsTableHeaderView | |
| 250 | + } | |
| 251 | + headerView!.detailsModel = self.detailsModel | |
| 252 | + self.tableView.tableHeaderView = headerView | |
| 253 | + self.tableView.reloadData() | |
| 254 | + self.tableView.setContentOffset(CGPointZero, animated: true) | |
| 255 | + for model in self.detailsModel!.detail_img { | |
| 256 | + let photo = SKPhoto.photoWithImageURL(model.simg ?? "") | |
| 257 | + photo.shouldCachePhotoURLImage = false | |
| 258 | + photo.photoURL = model.simg | |
| 259 | + self.imgs.add(photo) | |
| 260 | + } | |
| 28 | 261 | } |
| 29 | 262 | |
| 263 | + // MARK: - 销毁播放器 | |
| 264 | + func destroyPlayerView(){ | |
| 265 | + self.CSV_playerView?.stop() | |
| 266 | + if self.CSV_playerView?.currentOrientation != .portrait{ | |
| 267 | + self.CSV_playerView?.currentOrientation = .portrait | |
| 268 | + } | |
| 269 | + self.CSV_playerView?.superview?.removeFromSuperview() | |
| 270 | + self.CSV_playerView?.removeFromSuperview() | |
| 271 | + self.CSV_playerView = nil | |
| 272 | + } | |
| 273 | + | |
| 274 | + // MARK: - BKCycleScrollViewDelegate | |
| 275 | + func cycleScrollView(_ cycleScrollView: BKCycleScrollView, play playIndex: UInt, superView: UIView) { | |
| 276 | + let dataModel = cycleScrollView.displayDataArr![Int(playIndex)] as BKCycleScrollDataModel | |
| 277 | + if (self.CSV_playerView == nil){ | |
| 278 | + let playerView = CNLivePlayerView() | |
| 279 | + self.CSV_playerView = playerView | |
| 280 | + if dataModel.imageUrl.count > 0{ | |
| 281 | + self.CSV_playerView?.controlView.coverImageUrl = dataModel.imageUrl | |
| 282 | + }else if dataModel.image.size != CGSizeZero{ | |
| 283 | + self.CSV_playerView?.controlView.coverImage = dataModel.image | |
| 284 | + } | |
| 285 | + self.CSV_playerView?.controlView.fullScreenType = .inWindowOrientation | |
| 286 | + self.CSV_playerView?.controlView.topNaviView?.backBtn?.isHidden = true | |
| 287 | + self.CSV_playerView?.isMonitorDeviceOrientation = false | |
| 288 | + self.CSV_playerView?.controlView.gestureView?.panGestureRecognizer?.isEnabled = false | |
| 289 | + self.CSV_playerView?.controlView.coverImageViewContentMode = .scaleAspectFill | |
| 290 | + self.CSV_playerView?.switchInterfaceOrientationCallBack = { playerView in | |
| 291 | + if playerView.controlView.isFullScreen!{ | |
| 292 | + playerView.controlView.bottomProgressView?.isHidden = true | |
| 293 | + }else{ | |
| 294 | + playerView.controlView.bottomProgressView?.isHidden = false | |
| 295 | + } | |
| 296 | + if #available(iOS 11.0, *) { | |
| 297 | + self.setNeedsUpdateOfHomeIndicatorAutoHidden() | |
| 298 | + } else { | |
| 299 | + | |
| 300 | + } | |
| 301 | + UIView.animate(withDuration: self.kDSPlayerAnimateTimeInterval) { | |
| 302 | + //iPhoneX系列在横屏时隐藏状态栏 | |
| 303 | + if playerView.controlView.isAlphaMessage == false{ | |
| 304 | + if (isiPhoneXSeries || Double(UIDevice.current.systemVersion) ?? 0 >= 13) && (playerView.controlView.isFullScreen != nil) { | |
| 305 | + self.isPrefersStatusBarHidden = true | |
| 306 | + }else{ | |
| 307 | + self.isPrefersStatusBarHidden = false | |
| 308 | + } | |
| 309 | + self.setNeedsStatusBarAppearanceUpdate() | |
| 310 | + } | |
| 311 | + if playerView.controlView.isFullScreen ?? false{ | |
| 312 | + playerView.isMonitorDeviceOrientation = true | |
| 313 | + }else{ | |
| 314 | + playerView.isMonitorDeviceOrientation = false | |
| 315 | + } | |
| 316 | + } | |
| 317 | + if playerView.currentOrientation == .portrait{ | |
| 318 | + playerView.controlView.gestureView?.panGestureRecognizer?.isEnabled = false | |
| 319 | + }else{ | |
| 320 | + if playerView.controlView.isLockScreen{ | |
| 321 | + playerView.controlView.gestureView?.panGestureRecognizer?.isEnabled = false | |
| 322 | + }else{ | |
| 323 | + playerView.controlView.gestureView?.panGestureRecognizer?.isEnabled = true | |
| 324 | + } | |
| 325 | + } | |
| 326 | + } | |
| 327 | + self.CSV_playerView?.playerPlayingCallBack = { | |
| 328 | + playerView in | |
| 329 | + self.cycleScrollView?.playVideo() | |
| 330 | + } | |
| 331 | + self.CSV_playerView?.playerPausedCallBack = { | |
| 332 | + playerView in | |
| 333 | + self.cycleScrollView?.pauseVideo() | |
| 334 | + } | |
| 335 | + self.CSV_playerView?.playerDidToEndCallBack = { | |
| 336 | + playerView in | |
| 337 | + self.cycleScrollView?.stopVideo() | |
| 338 | + self.destroyPlayerView() | |
| 339 | + } | |
| 340 | + } | |
| 341 | + superView.addSubview(self.CSV_playerView!) | |
| 342 | + self.CSV_playerView!.frame = superView.bounds | |
| 343 | + let model = cycleScrollView.displayDataArr?[Int(playIndex)] | |
| 344 | + self.CSV_playerView?.setPlayUrl(playUrl: URL(string: model?.videoUrl ?? "") ?? URL(fileURLWithPath: ""), isLive: false) | |
| 345 | + self.CSV_playerView?.play() | |
| 346 | + } | |
| 347 | + | |
| 348 | + func cycleScrollView(_ cycleScrollView: BKCycleScrollView, pause pauseIndex: UInt) { | |
| 349 | + self.CSV_playerView?.pauseWithIsRemoveKVOsAndNotifications(isRemove: false) | |
| 350 | + } | |
| 351 | + | |
| 352 | + func cycleScrollView(_ cycleScrollView: BKCycleScrollView, stop stopIndex: UInt) { | |
| 353 | + self.destroyPlayerView() | |
| 354 | + } | |
| 355 | + | |
| 356 | + // MARK: - BtnAction | |
| 357 | + @objc func backNavBtnClick(){ | |
| 358 | + self.navigationController?.popViewController(animated: true) | |
| 359 | + } | |
| 360 | + | |
| 361 | + @objc func shareNavBtnClick(){ | |
| 362 | + CNLiveShopGoodListViewModel.postGetShareDataWithType(type: 2, targetId: self.goodsId!, ext: "") {[weak self] result, status in | |
| 363 | + let model = result as! CNLiveShopCommentRequestShareModel | |
| 364 | + CNLiveShareManager.showShareViewWithParam(forShareTitle: model.share_title, shareUrl: model.url, shareDesc: model.share_desc, shareImage: model.share_img, screenFull: false, hiddenWjj: true, hiddenQQ: false, hiddenWB: true, hiddenLifeCircle: true, hiddenWechatCircle: false, hiddenWechat: false, hiddenSafari: false, formVC: self, topImage: nil, topTitles: nil, platformType: .all) { str in | |
| 365 | + | |
| 366 | + } completerBlock: { resultType, platformType, typtString in | |
| 367 | + if (resultType == .succ) { | |
| 368 | + showMessage(message: "分享成功") | |
| 369 | + } | |
| 370 | + if (resultType == .fail) { | |
| 371 | + showMessage(message: "分享失败") | |
| 372 | + } | |
| 373 | + } | |
| 374 | + } | |
| 375 | + } | |
| 30 | 376 | } | ... | ... |
metaCode/Classes/Main/HomePage/Controller/GoodsManager/CNLiveShopNewProductController.swift
| ... | ... | @@ -185,7 +185,7 @@ class CNLiveShopNewProductController:CNLiveBaseViewController{ |
| 185 | 185 | previewBtn.setTitleColor(HexColor("#3A3A3A"), for: .normal) |
| 186 | 186 | previewBtn.titleLabel?.font = Font_15 |
| 187 | 187 | previewBtn.addTarget(self, action: #selector(previewBtnClick), for: .touchUpInside) |
| 188 | -// self.bottomNavView.addSubview(previewBtn) | |
| 188 | + self.bottomNavView.addSubview(previewBtn) | |
| 189 | 189 | |
| 190 | 190 | let saveBtn = UIButton(type: .custom) |
| 191 | 191 | saveBtn.frame = CGRect(x: previewBtn.right, y: 0, width: self.view.width - previewBtn.right, height: KTabBarHeight) |
| ... | ... | @@ -441,10 +441,14 @@ class CNLiveShopNewProductController:CNLiveBaseViewController{ |
| 441 | 441 | } |
| 442 | 442 | goodsDetailsModel.detail_img = Array(contentDetailsImage) as! [CNLiveGoodsDetailsContentModel] |
| 443 | 443 | let kvArray = NSMutableArray() |
| 444 | - kvArray.add(["k":"品名","v":singleView18.contentTextField.text]) | |
| 445 | - kvArray.add(["k":"规格","v":singleView19.contentTextField.text]) | |
| 446 | - kvArray.add(["k":"寄送区域","v":singleView20.contentTextField.text]) | |
| 447 | - kvArray.add(["k":"发货时效","v":singleView21.contentTextField.text]) | |
| 444 | + let str18 = (singleView18.contentTextField.text ?? "") as String | |
| 445 | + let str19 = (singleView19.contentTextField.text ?? "") as String | |
| 446 | + let str20 = (singleView20.contentTextField.text ?? "") as String | |
| 447 | + let str21 = (singleView21.contentTextField.text ?? "") as String | |
| 448 | + kvArray.add(["k":"品名","v":str18]) | |
| 449 | + kvArray.add(["k":"规格","v":str19]) | |
| 450 | + kvArray.add(["k":"寄送区域","v":str20]) | |
| 451 | + kvArray.add(["k":"发货时效","v":str21]) | |
| 448 | 452 | let tempArray = NSMutableArray(array: self.bgScrollView.subviews) |
| 449 | 453 | |
| 450 | 454 | let subArr = tempArray.subarray(with: NSRange(location: 0, length: tempArray.index(of: singleView19))) | ... | ... |
metaCode/Classes/Main/HomePage/Controller/GoodsManager/CNLiveShopProductManagerController.swift
| ... | ... | @@ -157,7 +157,10 @@ class CNLiveShopProductManagerController:CNLiveBaseViewController, UITableViewDa |
| 157 | 157 | func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { |
| 158 | 158 | |
| 159 | 159 | let goodsModel = self.dataArray[indexPath.row] as! CNLiveShopGoodsListModel |
| 160 | - | |
| 160 | + let vc = CNLiveShopNewProductController.init() | |
| 161 | + vc.type = .edit | |
| 162 | + vc.goodsId = goodsModel.id! | |
| 163 | + self.navigationController?.pushViewController(vc, animated: true) | |
| 161 | 164 | } |
| 162 | 165 | func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { |
| 163 | 166 | return 167 | ... | ... |
metaCode/Classes/Main/HomePage/View/Shop/ShopDetail/CNLiveGoodsDetailsTableViewCell.swift
0 → 100644
| 1 | +// | |
| 2 | +// CNLiveGoodsDetailsTableViewCell.swift | |
| 3 | +// metaCode | |
| 4 | +// | |
| 5 | +// Created by zx on 2024/3/12. | |
| 6 | +// | |
| 7 | + | |
| 8 | +import Foundation | |
| 9 | +import YYImage | |
| 10 | + | |
| 11 | +class CNLiveGoodsDetailsTableViewCell:UITableViewCell{ | |
| 12 | + var displayImageView:YYAnimatedImageView? | |
| 13 | + override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { | |
| 14 | + super.init(style: style, reuseIdentifier: reuseIdentifier) | |
| 15 | + self.selectionStyle = .none | |
| 16 | + self.initUI() | |
| 17 | + self.initLayout() | |
| 18 | + } | |
| 19 | + | |
| 20 | + required init?(coder: NSCoder) { | |
| 21 | + fatalError("init(coder:) has not been implemented") | |
| 22 | + } | |
| 23 | + | |
| 24 | + // MARK: - initUI | |
| 25 | + func initUI(){ | |
| 26 | + self.displayImageView = YYAnimatedImageView() | |
| 27 | + self.displayImageView?.contentMode = .scaleAspectFill | |
| 28 | + self.displayImageView?.clipsToBounds = true | |
| 29 | + self.contentView.addSubview(self.displayImageView!) | |
| 30 | + } | |
| 31 | + | |
| 32 | + // MARK: - initLayout | |
| 33 | + func initLayout(){ | |
| 34 | + self.displayImageView!.snp.makeConstraints({ make in | |
| 35 | + make.left.top.right.bottom.equalTo(self) | |
| 36 | + }) | |
| 37 | + } | |
| 38 | +} | ... | ... |
metaCode/Classes/Main/HomePage/View/Shop/ShopDetail/CNLiveShopGoodsDetailsTableHeaderView.swift
0 → 100644
| 1 | +// | |
| 2 | +// CNLiveShopGoodsDetailsTableHeaderView.swift | |
| 3 | +// metaCode | |
| 4 | +// | |
| 5 | +// Created by zx on 2024/3/13. | |
| 6 | +// | |
| 7 | + | |
| 8 | +import Foundation | |
| 9 | +import YYImage | |
| 10 | +import BKCycleScrollView | |
| 11 | + | |
| 12 | +typealias clickGiveGiftCallBackBlock = () -> Void | |
| 13 | + | |
| 14 | +// MARK: - 顶部轮播图 | |
| 15 | +class CNLiveShopGoodsDetailsTableHeaderView:UIView{ | |
| 16 | + | |
| 17 | + let kCNLliveShopDetailBannerCellID = "kCNLliveShopDetailBannerCellID" | |
| 18 | + | |
| 19 | + /// 顶部轮播图 | |
| 20 | + lazy var bannerView: BKCycleScrollView = { | |
| 21 | + let bannerView = BKCycleScrollView(frame: CGRect(x: 0, y: 0, width: self.width, height: self.width)) | |
| 22 | +// bannerView.placeholderImage = [UIImage get1_1PlaceholderImage]; | |
| 23 | + bannerView.isAutoScroll = false | |
| 24 | + return bannerView | |
| 25 | + }() | |
| 26 | + | |
| 27 | + /// 数据 | |
| 28 | + var _detailsModel:CNLiveShopGoodsDetailsModel? | |
| 29 | + var detailsModel:CNLiveShopGoodsDetailsModel?{ | |
| 30 | + get{ | |
| 31 | + _detailsModel | |
| 32 | + } | |
| 33 | + set{ | |
| 34 | + _detailsModel = newValue! | |
| 35 | + let bannerDataArr = NSMutableArray() | |
| 36 | + if _detailsModel?.video?.video_url?.count ?? 0 > 0{ | |
| 37 | + let model = BKCycleScrollDataModel() | |
| 38 | + model.videoUrl = _detailsModel!.video!.video_url! | |
| 39 | + model.imageUrl = _detailsModel?.video?.video_img ?? "" | |
| 40 | + model.image = _detailsModel?.video?.video_image ?? UIImage() | |
| 41 | + bannerDataArr.add(model) | |
| 42 | + } | |
| 43 | + for imageModel in detailsModel!.image { | |
| 44 | + let model = BKCycleScrollDataModel() | |
| 45 | + model.imageUrl = imageModel.simg ?? "" | |
| 46 | + bannerDataArr.add(model) | |
| 47 | + } | |
| 48 | + self.bannerView.displayDataArr = bannerDataArr as? [BKCycleScrollDataModel] | |
| 49 | + self.titleLab.text = self.detailsModel?.title | |
| 50 | + self.titleLab.height = self.titleLab.text?.calculateHeightWith(width: self.titleLab.width, font: self.titleLab.font) ?? 0 | |
| 51 | + self.subtitleLab.text = self.detailsModel?.ads | |
| 52 | + self.subtitleLab.y = self.titleLab.bottom+15 | |
| 53 | + self.subtitleLab.height = self.subtitleLab.text?.calculateHeightWith(width: self.titleLab.width, font: self.titleLab.font) ?? 0 | |
| 54 | + self.initTopStyleSubUI() | |
| 55 | + self.initGuigeSubUI() | |
| 56 | + self.initBottomDescSubUI() | |
| 57 | + self.height = self.bottomDescView.bottom | |
| 58 | + } | |
| 59 | + } | |
| 60 | + | |
| 61 | + /** | |
| 62 | + 点击送礼回调 | |
| 63 | + */ | |
| 64 | + var clickGiveGiftBlock:clickGiveGiftCallBackBlock? | |
| 65 | + lazy var titleLab: UILabel = { | |
| 66 | + let titleLab = UILabel.init(frame: CGRectMake(20, self.bannerView.bottom+15, self.width-40, 0)) | |
| 67 | + titleLab.textColor = HexColor("#3a3a3a") | |
| 68 | + titleLab.textAlignment = .center | |
| 69 | + titleLab.numberOfLines = 0 | |
| 70 | + titleLab.font = Font_17 | |
| 71 | + titleLab.adjustsFontSizeToFitWidth=true | |
| 72 | + return titleLab | |
| 73 | + }() | |
| 74 | + | |
| 75 | + lazy var subtitleLab: UILabel = { | |
| 76 | + let subtitleLab = UILabel.init(frame: CGRectMake(20, self.titleLab.bottom+15, self.width-40, 0)) | |
| 77 | + subtitleLab.textColor = HexColor("#828282") | |
| 78 | + subtitleLab.textAlignment = .center | |
| 79 | + subtitleLab.numberOfLines = 0 | |
| 80 | + subtitleLab.font = Font_14 | |
| 81 | + subtitleLab.adjustsFontSizeToFitWidth=true | |
| 82 | + return subtitleLab | |
| 83 | + }() | |
| 84 | + | |
| 85 | + lazy var topStyleView :UIView = { | |
| 86 | + let topStyleView = UIView(frame: CGRect(x: 0, y: self.subtitleLab.bottom+15, width: self.width, height: 0)) | |
| 87 | + return topStyleView | |
| 88 | + }() | |
| 89 | + | |
| 90 | + lazy var guigeView :UIView = { | |
| 91 | + let guigeView = UIView(frame: CGRect(x: 0, y: self.topStyleView.bottom, width: self.width, height: 0)) | |
| 92 | + return guigeView | |
| 93 | + }() | |
| 94 | + | |
| 95 | + lazy var bottomDescView :UIView = { | |
| 96 | + let bottomDescView = UIView(frame: CGRect(x: 0, y: self.guigeView.bottom, width: self.width, height: 0)) | |
| 97 | + return bottomDescView | |
| 98 | + }() | |
| 99 | + | |
| 100 | + override init(frame: CGRect) { | |
| 101 | + super.init(frame: frame) | |
| 102 | + self.backgroundColor = .white | |
| 103 | + self.initUI() | |
| 104 | + } | |
| 105 | + | |
| 106 | + required init?(coder: NSCoder) { | |
| 107 | + fatalError("init(coder:) has not been implemented") | |
| 108 | + } | |
| 109 | + | |
| 110 | + func initUI(){ | |
| 111 | + self.addSubview(self.bannerView) | |
| 112 | + self.addSubview(self.titleLab) | |
| 113 | + self.addSubview(self.subtitleLab) | |
| 114 | + self.addSubview(self.topStyleView) | |
| 115 | + self.addSubview(self.guigeView) | |
| 116 | + self.addSubview(self.bottomDescView) | |
| 117 | + } | |
| 118 | + | |
| 119 | + func initTopStyleSubUI(){ | |
| 120 | + self.topStyleView.subviews.forEach { $0.removeFromSuperview() } | |
| 121 | + self.topStyleView.y = (self.detailsModel?.ads?.count ?? 0 > 0 ? self.subtitleLab.bottom : self.titleLab.bottom)+15 | |
| 122 | + | |
| 123 | + let priceLabel = UILabel(frame: CGRect(x: 20, y: 0, width: KSreenWidth-20*2, height: 55)) | |
| 124 | + priceLabel.textColor = HexColor("#ff725c") | |
| 125 | + priceLabel.font = SystemFont_Fit(45) | |
| 126 | + priceLabel.text = String(format: "¥%@", self.detailsModel?.price ?? 0) | |
| 127 | + priceLabel.textAlignment = .center | |
| 128 | + self.topStyleView.addSubview(priceLabel) | |
| 129 | + self.topStyleView.height = 55 | |
| 130 | + | |
| 131 | + if self.detailsModel?.prices?.count ?? 0 > 0 && Float(self.detailsModel?.prices ?? "0") ?? 0 > Float(self.detailsModel?.price ?? "0") ?? 0{ | |
| 132 | + let originalPriceLab = UILabel(frame: CGRect(x: 20, y: self.topStyleView.height, width: KSreenWidth-20*2, height: 20)) | |
| 133 | + originalPriceLab.textColor = HexColor("#999999") | |
| 134 | + originalPriceLab.font = Font_14 | |
| 135 | + originalPriceLab.textAlignment = .center | |
| 136 | + let originalPrice = NSAttributedString(string: String(format: " ¥%@ ", self.detailsModel?.prices ?? "0"), attributes: [NSAttributedString.Key.strikethroughStyle:NSUnderlineStyle.single ]) | |
| 137 | + originalPriceLab.attributedText = originalPrice | |
| 138 | + self.topStyleView.addSubview(originalPriceLab) | |
| 139 | + self.topStyleView.height = self.topStyleView.height+20 | |
| 140 | + } | |
| 141 | + if self.detailsModel?.is_gift == true{ | |
| 142 | + let fAdsImageView = YYAnimatedImageView(frame: CGRect(x: 0, y: self.topStyleView.height+15, width: self.width, height: 50)) | |
| 143 | + fAdsImageView.clipsToBounds = true | |
| 144 | + fAdsImageView.contentMode = .scaleAspectFill | |
| 145 | + fAdsImageView.isUserInteractionEnabled = true | |
| 146 | + fAdsImageView.kf.setImage(with: URL(string: self.detailsModel?.give_goods_img ?? "")) | |
| 147 | + self.topStyleView.addSubview(fAdsImageView) | |
| 148 | + | |
| 149 | + let giveGoodsTap = UITapGestureRecognizer(target: self, action: #selector(giveGoodsTap)) | |
| 150 | + fAdsImageView.addGestureRecognizer(giveGoodsTap) | |
| 151 | + self.topStyleView.height = self.topStyleView.height + 15 + 50 | |
| 152 | + } | |
| 153 | + self.topStyleView.height = self.topStyleView.height + 20 | |
| 154 | + let line = YYAnimatedImageView(frame: CGRect(x: 20, y: self.topStyleView.height-DS_RRV_ONE_PIXEL, width: self.topStyleView.width-40, height: DS_RRV_ONE_PIXEL)) | |
| 155 | + line.backgroundColor = HexColor("#e4e4e4") | |
| 156 | + self.topStyleView.addSubview(line) | |
| 157 | + } | |
| 158 | + | |
| 159 | + func initGuigeSubUI(){ | |
| 160 | + self.guigeView.y = self.topStyleView.bottom | |
| 161 | + self.guigeView.subviews.forEach { $0.removeFromSuperview() } | |
| 162 | + | |
| 163 | + let titleDataArr = NSMutableArray() | |
| 164 | + if self.detailsModel?.attr.count ?? 0 > 0{ | |
| 165 | + for i in 0..<(self.detailsModel?.attr.count ?? 0){ | |
| 166 | + let model = self.detailsModel?.attr[i] | |
| 167 | + if model?.k?.count ?? 0 > 0 && model?.v?.count ?? 0 > 0{ | |
| 168 | + titleDataArr.add(["left":model!.k,"right":model!.v]) | |
| 169 | + } | |
| 170 | + } | |
| 171 | + } | |
| 172 | + if self.detailsModel?.attrArray.count ?? 0 > 0{ | |
| 173 | + for i in 0..<(self.detailsModel?.attrArray.count ?? 0){ | |
| 174 | + let dict = self.detailsModel?.attrArray[i] | |
| 175 | + let k = dict?["k"] as? String | |
| 176 | + let v = dict?["v"] as? String | |
| 177 | + if k?.count ?? 0 > 0 && v?.count ?? 0 > 0{ | |
| 178 | + titleDataArr.add(["left":(dict?["k"] as! String),"right":(dict?["v"] as! String)]) | |
| 179 | + } | |
| 180 | + } | |
| 181 | + } | |
| 182 | + if self.detailsModel?.storageArray.count ?? 0 > 0{ | |
| 183 | + for i in 0..<(self.detailsModel?.storageArray.count ?? 0){ | |
| 184 | + let dict = self.detailsModel?.storageArray[i] | |
| 185 | + let k = dict?["k"] as? String | |
| 186 | + let v = dict?["v"] as? String | |
| 187 | + if k?.count ?? 0 > 0 && v?.count ?? 0 > 0{ | |
| 188 | + titleDataArr.add(["left":(dict?["k"] as! String),"right":(dict?["v"] as! String)]) | |
| 189 | + } | |
| 190 | + } | |
| 191 | + } | |
| 192 | + if titleDataArr.count == 0{ | |
| 193 | + self.guigeView.height = 0 | |
| 194 | + return | |
| 195 | + } | |
| 196 | + let markLine = YYAnimatedImageView(frame: CGRect(x: 120, y: 0, width: self.guigeView.width-240, height: DS_RRV_ONE_PIXEL)) | |
| 197 | + markLine.backgroundColor = HexColor("#b4b4b4") | |
| 198 | + self.guigeView.addSubview(markLine) | |
| 199 | + | |
| 200 | + let markLab = UILabel(frame: CGRect(x: markLine.left+(markLine.width-87.5)/2, y: 17, width: 87.5, height: 20)) | |
| 201 | + markLab.textColor = HexColor("#666666") | |
| 202 | + markLab.textAlignment = .center | |
| 203 | + markLab.numberOfLines = 0 | |
| 204 | + markLab.font = Font_14 | |
| 205 | + markLab.backgroundColor = .white | |
| 206 | + markLab.text = "已选规格" | |
| 207 | + self.guigeView.addSubview(markLab) | |
| 208 | + | |
| 209 | + markLine.centerY = markLab.centerY | |
| 210 | + var lastView:UIView? | |
| 211 | + for i in 0..<titleDataArr.count { | |
| 212 | + let dic = titleDataArr[i] as! Dictionary<String, Any> | |
| 213 | + let view = UIView(frame: CGRect(x: 20, y: (lastView != nil) ? lastView!.bottom : (markLab.bottom+13), width: self.guigeView.width-40, height: 35)) | |
| 214 | + self.guigeView.addSubview(view) | |
| 215 | + | |
| 216 | + let leftLab = UILabel(frame: CGRect(x: 25, y: 0, width: 60, height: 35)) | |
| 217 | + leftLab.textColor = HexColor("#6d6d6d") | |
| 218 | + leftLab.textAlignment = .center | |
| 219 | + leftLab.numberOfLines = 0 | |
| 220 | + leftLab.font = Font_14 | |
| 221 | + leftLab.text = dic["left"] as? String | |
| 222 | + view.addSubview(leftLab) | |
| 223 | + leftLab.height = (leftLab.text?.calculateHeightWith(width: leftLab.width, font:leftLab.font) ?? 0) + 15 | |
| 224 | + | |
| 225 | + let rightLab = UILabel(frame: CGRect(x: 125, y: 0, width: 195, height: 35)) | |
| 226 | + rightLab.textColor = HexColor("#aaaaaa") | |
| 227 | + rightLab.textAlignment = .center | |
| 228 | + rightLab.numberOfLines = 0 | |
| 229 | + rightLab.font = Font_14 | |
| 230 | + rightLab.text = dic["right"] as? String | |
| 231 | + view.addSubview(rightLab) | |
| 232 | + rightLab.height = (rightLab.text?.calculateHeightWith(width: rightLab.width, font: rightLab.font) ?? 0) + 15 | |
| 233 | + | |
| 234 | + if rightLab.height > leftLab.height{ | |
| 235 | + view.height = rightLab.height | |
| 236 | + }else{ | |
| 237 | + view.height = leftLab.height | |
| 238 | + } | |
| 239 | + let line = YYAnimatedImageView(frame: CGRect(x: 0, y: 0, width: view.width, height: DS_RRV_ONE_PIXEL)) | |
| 240 | + line.backgroundColor = HexColor("#d4d4d4") | |
| 241 | + view.addSubview(line) | |
| 242 | + lastView = view | |
| 243 | + } | |
| 244 | + | |
| 245 | + let leftLine = YYAnimatedImageView(frame: CGRect(x: lastView!.x, y: markLab.bottom+13, width: DS_RRV_ONE_PIXEL, height: lastView!.bottom-(markLab.bottom+13))) | |
| 246 | + leftLine.backgroundColor = HexColor("#d4d4d4") | |
| 247 | + self.guigeView.addSubview(leftLine) | |
| 248 | + | |
| 249 | + let middleLine = YYAnimatedImageView(frame: CGRect(x: lastView!.x+108, y: markLab.bottom+13, width: DS_RRV_ONE_PIXEL, height: lastView!.bottom-(markLab.bottom+13))) | |
| 250 | + middleLine.backgroundColor = HexColor("#d4d4d4") | |
| 251 | + self.guigeView.addSubview(middleLine) | |
| 252 | + | |
| 253 | + let rightLine = YYAnimatedImageView(frame: CGRect(x: lastView!.right-DS_RRV_ONE_PIXEL, y: markLab.bottom+13, width: DS_RRV_ONE_PIXEL, height: lastView!.bottom-(markLab.bottom+13))) | |
| 254 | + rightLine.backgroundColor = HexColor("#d4d4d4") | |
| 255 | + self.guigeView.addSubview(rightLine) | |
| 256 | + | |
| 257 | + let bottomLine = YYAnimatedImageView(frame: CGRect(x: lastView!.x, y: lastView!.bottom, width: lastView!.width, height: DS_RRV_ONE_PIXEL)) | |
| 258 | + bottomLine.backgroundColor = HexColor("#d4d4d4") | |
| 259 | + self.guigeView.addSubview(bottomLine) | |
| 260 | + | |
| 261 | + let line = YYAnimatedImageView(frame: CGRect(x: 20, y: bottomLine.bottom+20, width: self.guigeView.width-40, height: DS_RRV_ONE_PIXEL)) | |
| 262 | + line.backgroundColor = HexColor("#e4e4e4") | |
| 263 | + self.guigeView.addSubview(line) | |
| 264 | + self.guigeView.height = line.bottom | |
| 265 | + } | |
| 266 | + | |
| 267 | + func initBottomDescSubUI(){ | |
| 268 | + self.bottomDescView.y = self.guigeView.bottom | |
| 269 | + self.bottomDescView.subviews.forEach { $0.removeFromSuperview() } | |
| 270 | + | |
| 271 | + let markLine = YYAnimatedImageView(frame: CGRect(x: 120, y: 0, width: self.bottomDescView.width-240, height: DS_RRV_ONE_PIXEL)) | |
| 272 | + markLine.backgroundColor = HexColor("#b4b4b4") | |
| 273 | + self.bottomDescView.addSubview(markLine) | |
| 274 | + | |
| 275 | + let markLab = UILabel.init(frame: CGRectMake(markLine.left+(markLine.width-87.5)/2, 17, 87.5, 20)) | |
| 276 | + markLab.textColor = HexColor("#666666") | |
| 277 | + markLab.textAlignment = .center | |
| 278 | + markLab.numberOfLines = 0 | |
| 279 | + markLab.font = Font_14 | |
| 280 | + markLab.backgroundColor = .white | |
| 281 | + markLab.text = "商品详情" | |
| 282 | + self.bottomDescView.addSubview(markLab) | |
| 283 | + | |
| 284 | + markLine.centerY = markLab.centerY | |
| 285 | + self.bottomDescView.height = markLab.bottom+20 | |
| 286 | + } | |
| 287 | + | |
| 288 | + @objc func giveGoodsTap(){ | |
| 289 | + if (self.clickGiveGiftBlock != nil){ | |
| 290 | + self.clickGiveGiftBlock!() | |
| 291 | + } | |
| 292 | + } | |
| 293 | +} | ... | ... |
metaCode/Classes/Main/HomePage/ViewModel/GoodsManager/CNLiveShopGoodListViewModel.swift
| ... | ... | @@ -367,4 +367,35 @@ class CNLiveShopGoodListViewModel:NSObject{ |
| 367 | 367 | } |
| 368 | 368 | } |
| 369 | 369 | |
| 370 | + // MARK: - 获取分享数据 | |
| 371 | + /// 获取分享数据 | |
| 372 | + /// @param type 分享类型 1文创商品 2普通商品 3主题活动 4店铺首页 5达人 6动态 7达人列表 8礼物分享 9优选库首页 10电影作品详情 12服务号 ... | |
| 373 | + /// @param targetId 目标id | |
| 374 | + /// @param ext 后台要求的附加参数 | |
| 375 | + /// @param result 结果 | |
| 376 | + static func postGetShareDataWithType(type:NSInteger,targetId:String,ext:String,resultBlock: @escaping downSlideResultBlock){ | |
| 377 | + let param = NSMutableDictionary() | |
| 378 | + param.setValue("\(type)", forKey: "type") | |
| 379 | + param.setValue(targetId, forKey: "id") | |
| 380 | + param.setValue(ext, forKey: "ext") | |
| 381 | + CNLiveNetworking.setAllowRequestDefaultArgument(true) | |
| 382 | + CNLiveNetworking.setupShowDataResult(false) | |
| 383 | + CNLiveNetworking.setupDSRequest(true) | |
| 384 | + let custom_param = NSMutableDictionary() | |
| 385 | + custom_param.setValue(CNLiveMCEnvironmentManager.shared.appId_wjj, forKey: "appId") | |
| 386 | + custom_param.setValue(CNLiveMCEnvironmentManager.shared.appKey_wjj, forKey: "appKey") | |
| 387 | + CNLiveNetworking.setupCustomParam(custom_param as? [String : String]) | |
| 388 | + CNLiveNetworking.requestNetwork(with: .POST, urlString: APPBaseWjjBUrl+"/api/v1/getShareData", param: param as! [String : String], cacheType: .networkOnly) { task, result, error in | |
| 389 | + hiddenLoading() | |
| 390 | + if (error == nil) { | |
| 391 | + let respDic = result as! NSDictionary | |
| 392 | + let resp = respDic["data"] as! NSDictionary | |
| 393 | + let shareModel = newDictionaryToModel(resp as! [String : Any], CNLiveShopCommentRequestShareModel.self) | |
| 394 | + resultBlock(shareModel,.success) | |
| 395 | + }else{ | |
| 396 | + resultBlock(NSNull(),.failed) | |
| 397 | + } | |
| 398 | + } | |
| 399 | + } | |
| 400 | + | |
| 370 | 401 | } | ... | ... |
metaCode/Classes/Main/Model/GoodsManager/CNLiveShopCommentRequestShareModel.swift
0 → 100644
| 1 | +// | |
| 2 | +// CNLiveShopCommentRequestShareModel.swift | |
| 3 | +// metaCode | |
| 4 | +// | |
| 5 | +// Created by zx on 2024/3/13. | |
| 6 | +// | |
| 7 | + | |
| 8 | +import Foundation | |
| 9 | + | |
| 10 | +/// 第一级 | |
| 11 | +class CNLiveShopCommentRequestShareModel:BaseModel{ | |
| 12 | + | |
| 13 | + ///分享url | |
| 14 | + var url: String = "" | |
| 15 | + ///微信分享类型 1h5 2小程序 | |
| 16 | + var wx_type:Int = 1 | |
| 17 | + /// | |
| 18 | + var mini_app_id: String = "" | |
| 19 | + ///小程序跳转路径 | |
| 20 | + var mini_app_url: String = "" | |
| 21 | + ///分享标题 | |
| 22 | + var share_title: String = "" | |
| 23 | + ///分享简介 | |
| 24 | + var share_desc: String = "" | |
| 25 | + ///分享图片 | |
| 26 | + var share_img: String = "" | |
| 27 | + /// | |
| 28 | + var share_type: String = "" | |
| 29 | + ///小程序appid | |
| 30 | + var app_id: String = "" | |
| 31 | + ///商品数据 | |
| 32 | + var goods = CNLiveShopCommentRequestShareGoodsModel() | |
| 33 | +} | |
| 34 | + | |
| 35 | +/// 商品属性 | |
| 36 | +class CNLiveShopCommentRequestShareGoodsModel:BaseModel{ | |
| 37 | + ///现价 | |
| 38 | + var price: String = "" | |
| 39 | + ///原价 | |
| 40 | + var prices: String = "" | |
| 41 | +} | ... | ... |
metaCode/Classes/Main/Util/CNLivePlayer/CNLivePlayerControlView.swift
| ... | ... | @@ -436,14 +436,14 @@ class CNLivePlayerControlView:UIView,CNLivePlayerGestureViewDelegate{ |
| 436 | 436 | } |
| 437 | 437 | set{ |
| 438 | 438 | _autoHideBrightnessViewTime = newValue |
| 439 | - UIView.animate(withDuration: CGFloat(kDSPlayerAnimateTimeInterval)) { | |
| 440 | - [weak self] in | |
| 441 | - if self!.autoHideBrightnessViewTime <= 0{ | |
| 442 | - self!.brightnessView?.alpha = 0 | |
| 443 | - }else{ | |
| 444 | - self?.brightnessView?.alpha = 1 | |
| 445 | - } | |
| 446 | - } | |
| 439 | +// UIView.animate(withDuration: CGFloat(kDSPlayerAnimateTimeInterval)) { | |
| 440 | +// [weak self] in | |
| 441 | +// if self!.autoHideBrightnessViewTime <= 0{ | |
| 442 | +// self!.brightnessView?.alpha = 0 | |
| 443 | +// }else{ | |
| 444 | +// self?.brightnessView?.alpha = 1 | |
| 445 | +// } | |
| 446 | +// } | |
| 447 | 447 | } |
| 448 | 448 | } |
| 449 | 449 | //滑动手势操作内容 | ... | ... |
metaCode/Classes/Main/Util/CNLivePlayer/CNLivePlayerView.swift
| ... | ... | @@ -128,7 +128,9 @@ class CNLivePlayerView:UIView,PLPlayerDelegate{ |
| 128 | 128 | self?.play() |
| 129 | 129 | } |
| 130 | 130 | controlView.switchAlphaMessageStateCallBack = {[weak self] in |
| 131 | - self?.switchAlphaMessageStateCallBack!(self!) | |
| 131 | + if ((self?.switchAlphaMessageStateCallBack?(self!)) != nil){ | |
| 132 | + self?.switchAlphaMessageStateCallBack!(self!) | |
| 133 | + } | |
| 132 | 134 | } |
| 133 | 135 | controlView.switchLockScreenCallBack = {[weak self] in |
| 134 | 136 | if ((self?.switchLockScreenCallBack?(self!)) != nil){ | ... | ... |
metaCode/Supporting Files/Assets.xcassets/Shop/DS_goods_back_g.imageset/Contents.json
0 → 100644
| 1 | +{ | |
| 2 | + "images" : [ | |
| 3 | + { | |
| 4 | + "idiom" : "universal", | |
| 5 | + "scale" : "1x" | |
| 6 | + }, | |
| 7 | + { | |
| 8 | + "filename" : "DS_goods_back_g@2x.png", | |
| 9 | + "idiom" : "universal", | |
| 10 | + "scale" : "2x" | |
| 11 | + }, | |
| 12 | + { | |
| 13 | + "filename" : "DS_goods_back_g@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/Shop/DS_goods_back_g.imageset/DS_goods_back_g@2x.png
0 → 100644
1.09 KB
metaCode/Supporting Files/Assets.xcassets/Shop/DS_goods_back_g.imageset/DS_goods_back_g@3x.png
0 → 100644
1.63 KB
metaCode/Supporting Files/Assets.xcassets/Shop/DS_goods_share_g.imageset/Contents.json
0 → 100644
| 1 | +{ | |
| 2 | + "images" : [ | |
| 3 | + { | |
| 4 | + "idiom" : "universal", | |
| 5 | + "scale" : "1x" | |
| 6 | + }, | |
| 7 | + { | |
| 8 | + "filename" : "DS_goods_share_g@2x.png", | |
| 9 | + "idiom" : "universal", | |
| 10 | + "scale" : "2x" | |
| 11 | + }, | |
| 12 | + { | |
| 13 | + "filename" : "DS_goods_share_g@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/Shop/DS_goods_share_g.imageset/DS_goods_share_g@2x.png
0 → 100644
1.13 KB
metaCode/Supporting Files/Assets.xcassets/Shop/DS_goods_share_g.imageset/DS_goods_share_g@3x.png
0 → 100644
2.19 KB