Commit 30e63fe7d66ea077ff7293493e0ff1dcffbdf46e

Authored by “张旭”
1 parent 7177c249

短剧全部课程样式适配 , 短剧播放按钮错误问题 ,电商h5交互支付 , 电商h5分享交互 , 电商h5返回交互. 还差拉起支付

metaCode.xcodeproj/project.pbxproj
... ... @@ -110,6 +110,8 @@
110 110 19AD65AA2BA041210045A444 /* CNLiveGoodsDetailsTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 19AD65A92BA041210045A444 /* CNLiveGoodsDetailsTableViewCell.swift */; };
111 111 19AD65AC2BA16CF20045A444 /* CNLiveShopCommentRequestShareModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 19AD65AB2BA16CF20045A444 /* CNLiveShopCommentRequestShareModel.swift */; };
112 112 19AD65AE2BA177C20045A444 /* CNLiveShopGoodsDetailsTableHeaderView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 19AD65AD2BA177C20045A444 /* CNLiveShopGoodsDetailsTableHeaderView.swift */; };
  113 + 19B153CB2BC3E1870018906C /* CNLiveShopPayController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 19B153CA2BC3E1870018906C /* CNLiveShopPayController.swift */; };
  114 + 19B153CD2BC3EB690018906C /* CNLiveShoph5ViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 19B153CC2BC3EB690018906C /* CNLiveShoph5ViewModel.swift */; };
113 115 19BB1FDF2AEA3A450094D962 /* CNSlideBaseNavigationController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 19BB1FDE2AEA3A450094D962 /* CNSlideBaseNavigationController.swift */; };
114 116 19BB1FE12AEB5C220094D962 /* CNLiveShopConsoleController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 19BB1FE02AEB5C220094D962 /* CNLiveShopConsoleController.swift */; };
115 117 19BB1FE32AEB8B7C0094D962 /* CNLiveShopConsoleViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 19BB1FE22AEB8B7C0094D962 /* CNLiveShopConsoleViewModel.swift */; };
... ... @@ -379,6 +381,8 @@
379 381 19AD65A92BA041210045A444 /* CNLiveGoodsDetailsTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNLiveGoodsDetailsTableViewCell.swift; sourceTree = "<group>"; };
380 382 19AD65AB2BA16CF20045A444 /* CNLiveShopCommentRequestShareModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNLiveShopCommentRequestShareModel.swift; sourceTree = "<group>"; };
381 383 19AD65AD2BA177C20045A444 /* CNLiveShopGoodsDetailsTableHeaderView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNLiveShopGoodsDetailsTableHeaderView.swift; sourceTree = "<group>"; };
  384 + 19B153CA2BC3E1870018906C /* CNLiveShopPayController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNLiveShopPayController.swift; sourceTree = "<group>"; };
  385 + 19B153CC2BC3EB690018906C /* CNLiveShoph5ViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNLiveShoph5ViewModel.swift; sourceTree = "<group>"; };
382 386 19BB1FDE2AEA3A450094D962 /* CNSlideBaseNavigationController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNSlideBaseNavigationController.swift; sourceTree = "<group>"; };
383 387 19BB1FE02AEB5C220094D962 /* CNLiveShopConsoleController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNLiveShopConsoleController.swift; sourceTree = "<group>"; };
384 388 19BB1FE22AEB8B7C0094D962 /* CNLiveShopConsoleViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNLiveShopConsoleViewModel.swift; sourceTree = "<group>"; };
... ... @@ -961,6 +965,14 @@
961 965 path = CNLiveDownslideOperationManager;
962 966 sourceTree = "<group>";
963 967 };
  968 + 19B153C92BC3E1550018906C /* ShopPayController */ = {
  969 + isa = PBXGroup;
  970 + children = (
  971 + 19B153CA2BC3E1870018906C /* CNLiveShopPayController.swift */,
  972 + );
  973 + path = ShopPayController;
  974 + sourceTree = "<group>";
  975 + };
964 976 19BB1FE42AEB93850094D962 /* Model */ = {
965 977 isa = PBXGroup;
966 978 children = (
... ... @@ -1406,6 +1418,7 @@
1406 1418 1926C28E2AE0D76C00C71DC3 /* CNLiveDownSlideViewModel.swift */,
1407 1419 19BB1FE22AEB8B7C0094D962 /* CNLiveShopConsoleViewModel.swift */,
1408 1420 19BB1FED2AF0E1EC0094D962 /* CNLiveShopDetailViewModel.swift */,
  1421 + 19B153CC2BC3EB690018906C /* CNLiveShoph5ViewModel.swift */,
1409 1422 );
1410 1423 name = ViewModel;
1411 1424 path = HomePage/ViewModel;
... ... @@ -1444,6 +1457,7 @@
1444 1457 1917333D2B284C6B007BCC04 /* ShopCoupon */,
1445 1458 191732FC2B0B3EB4007BCC04 /* GoodsDetail */,
1446 1459 19565EC32AF8ACC2007D6727 /* GoodsManager */,
  1460 + 19B153C92BC3E1550018906C /* ShopPayController */,
1447 1461 );
1448 1462 name = Controller;
1449 1463 path = HomePage/Controller;
... ... @@ -1811,6 +1825,7 @@
1811 1825 19565EC72AF8AD38007D6727 /* CNLiveShopNewProductController.swift in Sources */,
1812 1826 798A44F72A3077ED00815935 /* CNLiveHotButton.swift in Sources */,
1813 1827 7CD6753D2A2740B0008354C1 /* CNMainView.swift in Sources */,
  1828 + 19B153CB2BC3E1870018906C /* CNLiveShopPayController.swift in Sources */,
1814 1829 191733662B39237D007BCC04 /* CNLiveShopGoodsManageListTableViewCell.swift in Sources */,
1815 1830 793CAF522A58FCA200882EF4 /* CNLiveMineExchangeViewController.swift in Sources */,
1816 1831 1917334E2B2C1A08007BCC04 /* CNLiveSelectCouponTapView.swift in Sources */,
... ... @@ -1862,6 +1877,7 @@
1862 1877 1938BD3F2B4BE7C500390A34 /* CNLiveAlbumMsgModel.swift in Sources */,
1863 1878 798A44FF2A30A0A800815935 /* CNLiveInputFeedBackViewController.swift in Sources */,
1864 1879 79282A442A2F1C1E00B5F8CF /* CNLiveLoginAuthView.swift in Sources */,
  1880 + 19B153CD2BC3EB690018906C /* CNLiveShoph5ViewModel.swift in Sources */,
1865 1881 79BB96A62AF21E2800AEA4AC /* CNLiveShopOrderDetailViewController.swift in Sources */,
1866 1882 194455A12B6B3310006C5A2A /* CNWebView.swift in Sources */,
1867 1883 1938BD2C2B4801A700390A34 /* CNHomePageAnimationTransition.swift in Sources */,
... ... @@ -2132,7 +2148,7 @@
2132 2148 CODE_SIGN_ENTITLEMENTS = metaCode/metaCode.entitlements;
2133 2149 CODE_SIGN_IDENTITY = "Apple Development";
2134 2150 CODE_SIGN_STYLE = Automatic;
2135   - CURRENT_PROJECT_VERSION = 1.0.9.24.03.29.15;
  2151 + CURRENT_PROJECT_VERSION = 1.1.0.24.04.09.15;
2136 2152 DEBUG_INFORMATION_FORMAT = dwarf;
2137 2153 DEVELOPMENT_TEAM = 94X49GG3ZW;
2138 2154 ENABLE_BITCODE = NO;
... ... @@ -2205,7 +2221,7 @@
2205 2221 "$(inherited)",
2206 2222 "@executable_path/Frameworks",
2207 2223 );
2208   - MARKETING_VERSION = 1.0.9;
  2224 + MARKETING_VERSION = 1.1.0;
2209 2225 OTHER_LDFLAGS = (
2210 2226 "$(inherited)",
2211 2227 "-all_load",
... ... @@ -2387,7 +2403,7 @@
2387 2403 CODE_SIGN_ENTITLEMENTS = metaCode/metaCode.entitlements;
2388 2404 CODE_SIGN_IDENTITY = "Apple Development";
2389 2405 CODE_SIGN_STYLE = Automatic;
2390   - CURRENT_PROJECT_VERSION = 1.0.9.24.03.29.15;
  2406 + CURRENT_PROJECT_VERSION = 1.1.0.24.04.09.15;
2391 2407 DEVELOPMENT_TEAM = 94X49GG3ZW;
2392 2408 ENABLE_BITCODE = NO;
2393 2409 ENABLE_MODULE_VERIFIER = NO;
... ... @@ -2459,7 +2475,7 @@
2459 2475 "$(inherited)",
2460 2476 "@executable_path/Frameworks",
2461 2477 );
2462   - MARKETING_VERSION = 1.0.9;
  2478 + MARKETING_VERSION = 1.1.0;
2463 2479 OTHER_LDFLAGS = (
2464 2480 "$(inherited)",
2465 2481 "-all_load",
... ...
metaCode/Classes/Main/HomePage/Controller/DownSlideController/CNUpSlideDetailViewController.swift
... ... @@ -230,54 +230,41 @@ class CNUpSlideDetailViewController: CNLiveBaseViewController,UITableViewDataSou
230 230 func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
231 231  
232 232 if indexPath.section == 0{
233   - if self.cellType == .playlet{
234   - //短剧大图
235   - guard let cell = tableView.dequeueReusableCell(withIdentifier: kCNLiveAlbumImageCellIdentifier) as? CNLiveAlbumImageCell
  233 + if self.cellType == .courseToMyCurriculum{
  234 + //我的课程
  235 + guard let cell = tableView.dequeueReusableCell(withIdentifier: kCNLiveCourseTitleCellIdentifier) as? CNLiveDuanjuTitleCell
236 236 else {
237   - let cell = CNLiveAlbumImageCell()
  237 + let cell = CNLiveDuanjuTitleCell()
238 238 return cell
239 239 }
240   - cell.iconImgView.image = self.cell.bgImageView.image
241   - cell.titleLabel.text = self.cell.slideModel?.contents[0].title ?? ""
  240 + cell.cellType = .courseToMyCurriculum
  241 + cell.blockName = "我的课程"
242 242 return cell
243   - }else if self.cellType == .course || self.cellType == .playletToCourse || self.cellType == .courseToMyCurriculum{
244   - if self.cellType == .courseToMyCurriculum{
245   - //我的课程
  243 + }else{
  244 + if self.slideModel?.type == SlideModelTypeAllCourse12{
  245 + //全部课程
246 246 guard let cell = tableView.dequeueReusableCell(withIdentifier: kCNLiveCourseTitleCellIdentifier) as? CNLiveDuanjuTitleCell
247 247 else {
248 248 let cell = CNLiveDuanjuTitleCell()
249 249 return cell
250 250 }
251   - cell.cellType = .courseToMyCurriculum
252   - cell.blockName = "我的课程"
  251 + cell.cellType = .course
  252 + cell.blockName = self.slideModel?.blockName
253 253 return cell
254   - }else{
255   - if self.slideModel?.type == SlideModelTypeAllCourse12{
256   - //全部课程
257   - guard let cell = tableView.dequeueReusableCell(withIdentifier: kCNLiveCourseTitleCellIdentifier) as? CNLiveDuanjuTitleCell
258   - else {
259   - let cell = CNLiveDuanjuTitleCell()
260   - return cell
261   - }
262   - cell.cellType = .course
263   - cell.blockName = self.slideModel?.blockName
264   - return cell
265   -
266   - }else if self.slideModel?.type == SlideModelTypeOneCourse75{
267   - //大图课程
268   - guard let cell = tableView.dequeueReusableCell(withIdentifier: kCNLiveAlbumImageCellIdentifier) as? CNLiveAlbumImageCell
269   - else {
270   - let cell = CNLiveAlbumImageCell()
271   - return cell
272   - }
273   - cell.iconImgView.image = self.cell.bgImageView.image
274   - cell.titleLabel.text = self.cell.slideModel?.contents[0].title ?? ""
  254 +
  255 + }else if self.slideModel?.type == SlideModelTypeOneCourse75{
  256 + //大图课程
  257 + guard let cell = tableView.dequeueReusableCell(withIdentifier: kCNLiveAlbumImageCellIdentifier) as? CNLiveAlbumImageCell
  258 + else {
  259 + let cell = CNLiveAlbumImageCell()
275 260 return cell
276   -
277 261 }
  262 + cell.iconImgView.image = self.cell.bgImageView.image
  263 + cell.titleLabel.text = self.cell.slideModel?.contents[0].title ?? ""
  264 + return cell
  265 +
278 266 }
279 267 }
280   -
281 268 }else{
282 269 //列表cell
283 270 let albumModel = self.dataArray[indexPath.row] as! CNLiveAlbumModel
... ... @@ -297,17 +284,12 @@ class CNUpSlideDetailViewController: CNLiveBaseViewController,UITableViewDataSou
297 284 }
298 285 func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
299 286 if indexPath.section == 0{
300   - if self.cellType == .playlet{
301   - //短剧大图
  287 + if self.slideModel?.type == SlideModelTypeAllCourse12{
  288 + //全部课程
  289 + return allCourseCellHeight+get_system_statusBar_height()
  290 + }else if self.slideModel?.type == SlideModelTypeOneCourse75{
  291 + //大图课程
302 292 return KSreenWidth
303   - }else if self.cellType == .course || self.cellType == .playletToCourse{
304   - if self.slideModel?.type == SlideModelTypeAllCourse12{
305   - //全部课程
306   - return allCourseCellHeight+get_system_statusBar_height()
307   - }else if self.slideModel?.type == SlideModelTypeOneCourse75{
308   - //大图课程
309   - return KSreenWidth
310   - }
311 293 }
312 294 }else{
313 295 return 75
... ... @@ -319,16 +301,11 @@ class CNUpSlideDetailViewController: CNLiveBaseViewController,UITableViewDataSou
319 301 let albumModel = self.dataArray[indexPath.row] as! CNLiveAlbumModel
320 302 if indexPath.section == 0{
321 303 //大图统一不能点击跳转
322   - if self.cellType == .playlet{
323   - //短剧大图,跳转播放页
324   -// navigationViewController().visibleViewController?.navigationController?.pushViewController(CNLiveShortVideoViewController(aid: albumModel.contentId), animated: pushAnimated)
325   - }else if self.cellType == .course || self.cellType == .playletToCourse{
326   - if self.slideModel?.type == SlideModelTypeAllCourse12{
327   - //全部课程,跳转h5
  304 + if self.slideModel?.type == SlideModelTypeAllCourse12{
  305 + //全部课程,跳转h5
328 306  
329   - }else if self.slideModel?.type == SlideModelTypeOneCourse75{
330   - //大图课程,跳转h5
331   - }
  307 + }else if self.slideModel?.type == SlideModelTypeOneCourse75{
  308 + //大图课程,跳转h5
332 309 }
333 310 }else{
334 311 CNLiveDownSlideTool.pushWebVCWithContentsMdl(model: albumModel.model, contentId: albumModel.contentId, pid: albumModel.pid, shareUrl: albumModel.shareUrl, thirdUrl: albumModel.thirdUrl, title: albumModel.title, s_to: albumModel.s_to, trailerId: albumModel.trailerId, controller: self)
... ...
metaCode/Classes/Main/HomePage/Controller/ShopPayController/CNLiveShopPayController.swift 0 → 100644
  1 +//
  2 +// CNLiveShopPayController.swift
  3 +// metaCode
  4 +//
  5 +// Created by zx on 2024/4/8.
  6 +// 支付页面
  7 +
  8 +import Foundation
  9 +
  10 +class CNLiveShopPayController:CNLiveBaseViewController{
  11 +
  12 + override func viewDidLoad() {
  13 + super.viewDidLoad()
  14 +
  15 + }
  16 +}
... ...
metaCode/Classes/Main/HomePage/Controller/WebController/CNWebView.swift
... ... @@ -13,13 +13,16 @@ import CommonCrypto
13 13 import CNLiveBusinessTools
14 14 import SKPhotoBrowser
15 15  
  16 +//返回 Web控制器回调
  17 +typealias cnWebControllerBackNavBlock = ()->Void
  18 +
16 19 //更新Web控制器导航回调
17 20 typealias cnWebControllerUpdateNavBlock = (_ isFinish:Bool , _ titleName:String ,_ isDecidePolicy:Bool , _ urlStr:String)->Void
18 21  
19 22 //更新Web控制器 currentUrl
20 23 typealias cnWebControllerUpdateCurrentUrlBlock = (_ currentUrl:String)->Void
21 24  
22   -class CNWebView:UIView,WKNavigationDelegate{
  25 +class CNWebView:UIView,WKNavigationDelegate, WKScriptMessageHandler{
23 26  
24 27 var configuration:WKWebViewConfiguration?
25 28  
... ... @@ -34,9 +37,14 @@ class CNWebView:UIView,WKNavigationDelegate{
34 37  
35 38 //CNWebController
36 39 var isCNWebController:Bool = false//是否网页控制器
37   - var webControllerUpdateNavBlock:cnWebControllerUpdateNavBlock?
  40 + var webControllerBackNavBlock:cnWebControllerBackNavBlock?//back返回
  41 +
  42 + var webControllerUpdateNavBlock:cnWebControllerUpdateNavBlock?//刷新
38 43 var webControllerUpdateCurrentUrlBlock:cnWebControllerUpdateCurrentUrlBlock?
39 44  
  45 + required init?(coder: NSCoder) {
  46 + fatalError("init(coder:) has not been implemented")
  47 + }
40 48  
41 49 init(frame: CGRect, configuration: WKWebViewConfiguration ,url:URL?) {
42 50 super.init(frame: frame)
... ... @@ -55,20 +63,124 @@ class CNWebView:UIView,WKNavigationDelegate{
55 63 self.currentUrl = urlStr
56 64  
57 65 self.cnWebView.load(URLRequest.init(url:URL(string: urlStr)!))
  66 + self.configBridge()
  67 + self.configBridgeRegister()
  68 + self.webViewAddScriptMessageHandler()
  69 +// if URL(string: urlStr)?.host == WjjH5 {
  70 +// self.configBridgeRegister()
  71 +//
  72 +// }else if URL(string: urlStr)?.host == ManageshopH5 || URL(string: urlStr)?.host == ManagemallshopH5{
  73 +// self.webViewAddScriptMessageHandler()
  74 +// }
58 75 }
59   - self.configBridge()
60   - self.configBridgeRegister()
61 76 }
62 77 }
63 78 }
64 79 }
65 80  
  81 + // MARK: - 电商h5的交互回调调用
  82 + //电商 js 交互原生
  83 + func webViewAddScriptMessageHandler(){
  84 + self.cnWebView.configuration.userContentController.add(self, name: "pop")
  85 + self.cnWebView.configuration.userContentController.add(self, name: "toShare")
  86 + self.cnWebView.configuration.userContentController.add(self, name: "openAppPayment")
  87 + }
  88 +
  89 + func webViewRemoveScriptMessageHandler(){
  90 + self.cnWebView.configuration.userContentController.add(self, name: "pop")
  91 + self.cnWebView.configuration.userContentController.add(self, name: "toShare")
  92 + self.cnWebView.configuration.userContentController.add(self, name: "openAppPayment")
  93 + }
  94 + //电商h5的回调
  95 + func userContentController(_ userContentController: WKUserContentController, didReceive message: WKScriptMessage) {
  96 + // 初始化 body 为 nil
  97 + var body: Any? = nil
  98 + // 检查 message.body 是否不是 NSNull 并且是 NSDictionary 的实例
  99 + if let dictionary = message.body as? [String: Any], !dictionary.isEmpty {
  100 + // 获取所有的键
  101 + let allKeys = dictionary.keys
  102 + // 检查是否包含 "body" 键
  103 + if allKeys.contains("body") {
  104 + // 取出 "body" 键对应的值
  105 + body = dictionary["body"]
  106 + }
  107 + }
  108 + if message.name == "openAppPayment" {
  109 + // 跳转支付页面
  110 + if let json = body as? [String: Any] {
  111 + // 检查 json 是否非空
  112 + guard !json.isEmpty else {
  113 + print("json 字典是空的")
  114 + return
  115 + }
  116 + // 获取所有键
  117 + let allKeys = json.keys
  118 + // 使用可选链获取 orderNumber,如果不存在则返回空字符串
  119 + let orderNumber = json["orderNumber"] as? String ?? ""
  120 + // 获取 payModel,如果不存在或者不是字符串类型,则使用默认值 "2"
  121 +// let payModel = (json["payModel"] as? String) ?? "2"
  122 + // 现在你可以使用 orderNumber 和 payModel 进行后续操作
  123 + print("orderNumber: \(orderNumber)")
  124 + // 跳转支付页面
  125 +
  126 +// navigationViewController().pushViewController(<#T##viewController: UIViewController##UIViewController#>, animated: pushAnimated)
  127 + }
  128 + }else if message.name == "pop" {
  129 + //返回上一级控制器
  130 + if self.cnWebView.canGoBack{
  131 + self.cnWebView.goBack()
  132 + }else{
  133 + self.webControllerBackNavBlock?()
  134 + }
  135 + }else if message.name == "toShare" {
  136 + //拉起分享
  137 + if let json = body as? [String: Any] {
  138 + // 检查 json 是否非空
  139 + guard !json.isEmpty else {
  140 + print("json 字典是空的")
  141 + return
  142 + }
  143 + // 获取所有键
  144 + let allKeys = json.keys
  145 + // 使用可选链和条件绑定获取 type,如果不存在或不是数字,则使用默认值 0
  146 + let type: UInt = (json["type"] as? NSNumber)?.uintValue ?? 0
  147 + // 使用可选链获取 id 和 ext,如果不存在则返回空字符串
  148 + let targetId = json["id"] as? String ?? ""
  149 + let ext = json["ext"] as? String ?? ""
  150 + // 现在你可以使用 type, idStr 和 ext 进行后续操作
  151 + print("type: \(type)")
  152 + print("id: \(targetId)")
  153 + print("ext: \(ext)")
  154 + //请求分享参数
  155 + showLoading(message: "")
  156 + CNLiveShoph5ViewModel.postGetShareDataWithType(type: NSInteger(type), targetId: targetId, ext: ext) { result, status in
  157 + let shareModel = result as! CNLiveShopCommentRequestShareModel
  158 +
  159 + let shareTitle = shareModel.share_title
  160 + let shareUrl = shareModel.url
  161 + let shareDesc = shareModel.share_desc
  162 + let shareImage = shareModel.share_img
  163 + CNLiveShareManager.showShareViewWithParam(forShareTitle: shareTitle, shareUrl: shareUrl, shareDesc: shareDesc, shareImage: shareImage, screenFull: false, hiddenWjj: true, hiddenQQ: false, hiddenWB: true, hiddenLifeCircle: true, hiddenWechatCircle: false, hiddenWechat: false, hiddenSafari: true, formVC: currentViewController(), topImage: [], topTitles: [], platformType: .all) { title in
  164 +
  165 + } completerBlock: { resultType, platformType, typeString in
  166 + if resultType == .succ{
  167 +
  168 + }
  169 + }
  170 +
  171 + }
  172 +
  173 + }
  174 + }
  175 + }
  176 +
  177 + // MARK: - wjjh5的交互回调调用
66 178 func configBridge(){
67 179 WKWebViewJavascriptBridge.enableLogging()
68 180 self.bridge = WKWebViewJavascriptBridge(for: self.cnWebView)
69 181 self.bridge?.setWebViewDelegate(self)
70 182 }
71   - //h5拉起原生
  183 + //wjjh5拉起原生
72 184 func configBridgeRegister() -> Void {
73 185 //h5拉起原生分享 js call oc
74 186 self.bridge?.registerHandler("wjjylzgVideoShare", handler: { data, responseCallback in
... ... @@ -124,15 +236,83 @@ class CNWebView:UIView,WKNavigationDelegate{
124 236 CNLiveShareImageManager.pushWeChatMiniProgrem(withMiniAppId: miniAppId, path: miniPath, extMsg: "", extDic: [:])
125 237 }
126 238 })
  239 +
  240 + //h5拉起原生跳转苹果内购
  241 + self.bridge?.registerHandler("wjjHtmlPullApplePay", handler: { data, responseCallback in
  242 + print("js call oc\(data)")
  243 + let dataDic = data as! Dictionary<String, Any>
  244 + let body = dataDic["body"] as? String
  245 + let notify_url = dataDic["notify_url"] as? String
  246 + let orderId = dataDic["orderId"] as? String
  247 + let prdId = dataDic["prdId"] as? String
  248 + let total_fee = dataDic["total_fee"] as? Int
  249 + print("拉起苹果内购")
  250 +
  251 + })
  252 +
  253 + //h5拉起原生支付(iOS不加,虚拟付费视频都内购)
  254 +// self.bridge?.registerHandler("wjjHtmlPullAppPay", handler: { data, responseCallback in
  255 +// print("js call oc\(data)")
  256 +// let dic = data as! Dictionary<String, Any>
  257 +//
  258 +//// [CNLivePayCostModule showDefaultPayViwWithParamDict:htmlDict PayCostType:CNLivePayCostTypeHtml FromVC:formVC ResultBlock:^(CNLivePayCostTypeResult resultType) {
  259 +//// if (resultType == CNLivePayCostTypeResultSucc) {
  260 +//// NSString * orderId = [resultParam stringValueForKey:@"orderId" default:@""];
  261 +//// [weakSelf.bridge callHandler:@"wjjHtmlPullAppPayCallback" data:@{@"orderId":orderId,@"payStatus":payResult == CNLiveContentPayResultSucc?@"0":@"1"} responseCallback:^(id responseData) {
  262 +//// NSLog(@"成功");
  263 +//// }];
  264 +// // }
  265 +//// }];
  266 +//
  267 +// })
  268 +
127 269 }
128 270  
129   - required init?(coder: NSCoder) {
130   - fatalError("init(coder:) has not been implemented")
131   - }
132   -
  271 + // MARK: - 检查url
133 272 func checkURLWithStr(urlStr:String) -> String{
134 273 if URL(string: urlStr)?.host != WjjH5 {
135   - return urlStr//不是wjjh5不作处理
  274 + if URL(string: urlStr)?.host == ManageshopH5 || URL(string: urlStr)?.host == ManagemallshopH5{
  275 + //是电商url,拼接uid
  276 + var str = urlStr
  277 + let sourceArray = str.components(separatedBy: "?")
  278 + if sourceArray.count == 1{
  279 + //是电商h5且无参数
  280 + str = String(format: "%@?uid=%@", str,UserInfoManager.shared.userInfo.uid)
  281 + return str
  282 + }
  283 + //是电商h5且有参数
  284 + let paraArr = NSMutableArray(array: ["uid="])
  285 + let valueArr = NSMutableArray(array:[UserInfoManager.shared.userInfo.uid])
  286 + var i = 0
  287 + for paraStr in paraArr{
  288 + let tempStr = paraStr as! String
  289 + let paramStr = "&".appending(tempStr)
  290 + let paramStr2 = "?".appending(tempStr)
  291 +
  292 + if str.contains(paramStr){
  293 + //包含则替换 &sid=
  294 + let lastStr = str.components(separatedBy: tempStr).last
  295 + let lastSeparatedStr = (lastStr?.components(separatedBy: "&").first)!
  296 + let oldStr = tempStr.appending(lastSeparatedStr)
  297 + let tempValueStr = tempStr.appending(valueArr[i] as! String)
  298 + str = str.replacingOccurrences(of: oldStr, with: tempValueStr)
  299 + }else if str.contains(paramStr2){
  300 + //包含则替换 &sid=
  301 + let lastStr = str.components(separatedBy: tempStr).last
  302 + let lastSeparatedStr = (lastStr?.components(separatedBy: "&").first)!
  303 + let oldStr = tempStr.appending(lastSeparatedStr)
  304 + let tempValueStr = tempStr.appending(valueArr[i] as! String)
  305 + str = str.replacingOccurrences(of: oldStr, with: tempValueStr)
  306 + }else{
  307 + //不包含则拼接
  308 + str = String(format: "%@&%@%@", str,tempStr,valueArr[i] as! String)
  309 + }
  310 + i = i + 1
  311 + }
  312 + return str
  313 + }else{
  314 + return urlStr//不是wjjh5且不是电商h5不作处理
  315 + }
136 316 }
137 317 var str = urlStr
138 318 let date = Date()
... ...
metaCode/Classes/Main/HomePage/Controller/WebController/CNWebViewController.swift
... ... @@ -16,6 +16,7 @@ import SKPhotoBrowser
16 16  
17 17 let WjjH5 = "wjjh5.cnlive.com"
18 18 let ManageshopH5 = "manageshop.cnlive.com"
  19 +let ManagemallshopH5 = "managemall.cnlive.com"
19 20  
20 21 class CNWebViewController:CNLiveBaseViewController ,WKNavigationDelegate{
21 22  
... ... @@ -62,6 +63,7 @@ class CNWebViewController:CNLiveBaseViewController ,WKNavigationDelegate{
62 63 self.webView.cnWebView.stopLoading()
63 64 self.webView.cnWebView.navigationDelegate = nil
64 65 self.webView.cnWebView.uiDelegate = nil
  66 + self.webView.webViewRemoveScriptMessageHandler()
65 67 print("WKWebView dealloc")
66 68 }
67 69  
... ... @@ -87,6 +89,9 @@ class CNWebViewController:CNLiveBaseViewController ,WKNavigationDelegate{
87 89 }
88 90 }
89 91 }
  92 + self.webView.webControllerBackNavBlock = {
  93 + self.navigationController?.popViewController(animated: true)
  94 + }
90 95 self.webView.webControllerUpdateCurrentUrlBlock = { [weak self] currentUrlStr in
91 96 self!.currentUrl = currentUrlStr
92 97 }
... ...
metaCode/Classes/Main/HomePage/View/VerticalViews/DownSlide/CNDownSlideSingleCourseCell.swift
... ... @@ -120,7 +120,7 @@ class CNDownSlideSingleCourseCell: UITableViewCell {
120 120 bgBackView.backgroundColor = .white
121 121  
122 122 var titleTop:CGFloat = DownSlideRecommendLeftGap
123   - if model.blockSubTitle.count ?? 0 > 0{
  123 + if model.blockSubTitle.count > 0{
124 124 let subtitleLbl = UILabel(frame: CGRect(x: DownSlideRecommendLeftGap, y: DownSlideRecommendLeftGap, width: DownSlideSingleCourseW-DownSlideRecommendLeftGap*2, height: 17))
125 125 subtitleLbl.text = model.blockSubTitle
126 126 subtitleLbl.font = Font_12
... ... @@ -148,20 +148,20 @@ class CNDownSlideSingleCourseCell: UITableViewCell {
148 148  
149 149 //小icon
150 150 let imageView = UIImageView(frame: CGRectMake(DownSlideRecommendLeftGap, titleLbl.bottom+DownSlideRecommendLeftGap+CGFloat(i)*(DownSlideAllCourseRowTopYGap+DownSlideAllCourseRowImageWH+DownSlideAllCourseRowBottomYGap), CGFloat(DownSlideAllCourseRowImageWH), CGFloat(DownSlideAllCourseRowImageWH)))
151   - imageView.kf.setImage(with: URL(string:contentMdl.poster ?? ""))
  151 + imageView.kf.setImage(with: URL(string:contentMdl.poster ))
152 152 imageView.layer.cornerRadius = 12
153 153 imageView.clipsToBounds = true
154 154 imageView.contentMode = .scaleAspectFill
155 155 bgBackView.addSubview(imageView)
156 156  
157 157 let titleLbl = UILabel(frame: CGRect(x: imageView.right+DownSlideRecommendLeftGap, y: imageView.top, width: DownSlideSingleCourseW-90-imageView.right, height: 21))
158   - titleLbl.text = contentMdl.title ?? ""
  158 + titleLbl.text = contentMdl.title
159 159 titleLbl.font = Font_15
160 160 titleLbl.textColor = HexColor("#333333")
161 161 bgBackView.addSubview(titleLbl)
162 162  
163 163 let subTitleLbl = UILabel(frame: CGRect(x: titleLbl.left, y:titleLbl.bottom+3 , width: titleLbl.width, height: 17))
164   - subTitleLbl.text = contentMdl.subTitle ?? ""
  164 + subTitleLbl.text = contentMdl.subTitle
165 165 subTitleLbl.font = Font_12
166 166 subTitleLbl.textColor = HexColor("#999999")
167 167 bgBackView.addSubview(subTitleLbl)
... ... @@ -170,7 +170,12 @@ class CNDownSlideSingleCourseCell: UITableViewCell {
170 170 enterBtn.frame = CGRect(x: bgBackView.right-25-65, y: 0, width: 65, height: 30)
171 171 enterBtn.centerY = imageView.centerY
172 172 enterBtn.setBackgroundImage(UIImage(named: "homepage_down_enter"), for: .normal)
173   - enterBtn.setTitle("进入", for: .normal)
  173 + if contentMdl.model == kCNDownSlideContentsModelModelAlbum_ugc{
  174 + enterBtn.setTitle("播放", for: .normal)
  175 + }else{
  176 + enterBtn.setTitle("进入", for: .normal)
  177 + }
  178 +
174 179 enterBtn.titleLabel?.font = BoldFont_13
175 180 enterBtn.setTitleColor(HexColor("#FFFFFF"), for: .normal)
176 181 enterBtn.addTarget(self, action: #selector(enterBtnAction(_:)), for: .touchUpInside)
... ...
metaCode/Classes/Main/HomePage/View/VerticalViews/DownSlide/CNDownSlideView.swift
... ... @@ -39,7 +39,7 @@ class CNDownSlideView:UIView{
39 39  
40 40 var url:URL?
41 41 if (_downPath != ""){
42   - url = URL.init(string: _downPath!)
  42 + url = URL.init(string:_downPath!)//"https://managemall.cnlive.com/html/mall/1/#/pages/main/goodsList/goodsList?scene=app"cn)//_downPath!)//
43 43 }else{
44 44 url = nil
45 45 }
... ...
metaCode/Classes/Main/HomePage/View/VerticalViews/UpSlide/CNUpSlideView.swift
... ... @@ -30,7 +30,7 @@ class CNUpSlideView:UIView{
30 30  
31 31 var url:URL?
32 32 if (_downPath != ""){
33   - url = URL.init(string: _downPath!)
  33 + url = URL.init(string: "http://wjjh5.cnlive.com/cnBlockMore.html?channelName=yjzg&pageId=&isShowTitle=true&blockType=28&contentType=13&title=%E5%9B%AD%E9%95%BF%E8%AF%BE%E7%A8%8B&pageName=&moreUrl=https%3A%2F%2Fcmsapi.cnlive.com%2FcontentApi%2FgetBlockContents%3FblockId%3D12165")//_downPath!)//"https://managemall.cnlive.com/html/mall/1/#/pages/main/goodsList/goodsList?scene=app")//
34 34 }else{
35 35 url = nil
36 36 }
... ...
metaCode/Classes/Main/HomePage/ViewModel/CNLiveShoph5ViewModel.swift 0 → 100644
  1 +//
  2 +// CNLiveShoph5ViewModel.swift
  3 +// metaCode
  4 +//
  5 +// Created by zx on 2024/4/8.
  6 +// 电商h5请求
  7 +
  8 +import Foundation
  9 +import CNLiveRequestBastKit
  10 +
  11 +class CNLiveShoph5ViewModel:NSObject{
  12 + /// 获取分享数据
  13 + /// @param type 分享类型 1 文创商品详情 2普通商品详情 3主题活动列表 4店铺首页 5达人详情 6动态详情 7达人列表 8礼物详情 9优选库首页 10电影作品详情 11电影作品列表 12 服务号详情 13 抽奖详情 14 电影作品活动 15电影作品个人中心 16 新店铺首页 17 大众体育活动列表 18 活动首页分享 19 抽奖活动 20抽奖活动列表 21开箱子活动 22崇学向善活动页面 23获取大众体育类型列表 24活动首页 25折扣活动列表分享 26折扣活动分享商品 27崇学向善活动页面2 28领头雁首页 29领头雁成绩查询 30领头雁证书分享 31武汉活动小家音响 32抗议扶贫活动 33领头雁新闻分享 34领头雁招募 35美食中国 36公共加载页面 37领头雁电商活动 38活动专区 39成长活动 40成长商品详情 41成长活动订单列表
  14 + /// @param targetId 目标id
  15 + /// @param ext 后台要求的附加参数
  16 + /// @param result 结果
  17 + static func postGetShareDataWithType(type:NSInteger,targetId:String,ext:String,resultBlock: @escaping downSlideResultBlock) {
  18 + let param = NSMutableDictionary()
  19 + param.setValue("\(type)", forKey: "type")
  20 + param.setValue(targetId, forKey: "id")
  21 + param.setValue(ext, forKey: "ext")
  22 +
  23 + CNLiveNetworking.setAllowRequestDefaultArgument(true)
  24 + CNLiveNetworking.setupShowDataResult(false)
  25 + CNLiveNetworking.setupDSRequest(true)
  26 + let custom_param = NSMutableDictionary()
  27 + custom_param.setValue(CNLiveMCEnvironmentManager.shared.appId_wjj, forKey: "appId")
  28 + custom_param.setValue(CNLiveMCEnvironmentManager.shared.appKey_wjj, forKey: "appKey")
  29 + CNLiveNetworking.setupCustomParam(custom_param as? [String : String])
  30 + CNLiveNetworking.requestNetwork(with: .POST, urlString: APPBaseWjjShopUrl+"/Api/Index3/getShareData", param: param as! [String : String], cacheType: .networkOnly) { task, result, error in
  31 + hiddenLoading()
  32 + if (error == nil) {
  33 + let resp = result as! NSDictionary
  34 + let dataDic = resp["data"] as! NSDictionary
  35 + let shopDetailModel = newDictionaryToModel(dataDic as! [String : Any], CNLiveShopCommentRequestShareModel.self)
  36 + resultBlock(shopDetailModel,.success)
  37 + }else{
  38 + resultBlock(NSNull(),.failed)
  39 + }
  40 + }
  41 + }
  42 +
  43 +
  44 +
  45 +
  46 +}
... ...
metaCode/Classes/Main/Model/CNLiveDownSlideModel.swift
... ... @@ -39,14 +39,13 @@ class CNLiveDownSlideModel: BaseModel {
39 39  
40 40 }
41 41  
42   -//下滑tableview背景颜色
43 42 let kCNDownSlideContentsModelModel1: String = "1"
44 43 let kCNDownSlideContentsModelModel2: String = "2"
45 44 let kCNDownSlideContentsModelModel3: String = "3"
46 45 let kCNDownSlideContentsModelModel4: String = "4"
47 46 let kCNDownSlideContentsModelModelAlbum: String = "album"
48 47 let kCNDownSlideContentsModelModelAlbum_video: String = "album_video"
49   -let kCNDownSlideContentsModelModelAlbum_ugc: String = "album_ugc"
  48 +let kCNDownSlideContentsModelModelAlbum_ugc: String = "album_ugc"//短剧
50 49 let kCNDownSlideContentsModelModelServing: String = "serving"//微信小程序
51 50  
52 51  
... ...
metaCode/Classes/Main/Util/CNLiveDownSlideTool.swift
... ... @@ -43,6 +43,7 @@ class CNLiveDownSlideTool:NSObject{
43 43 }
44 44 }else if (model == kCNDownSlideContentsModelModel3) || (model == kCNDownSlideContentsModelModel4){
45 45 let webVC = CNWebViewController()
  46 +// webVC.url = URL(string: "http://wjjh5.cnlive.com/cnBlockMore.html?channelName=yjzg&pageId=&isShowTitle=true&blockType=28&contentType=13&title=%E5%9B%AD%E9%95%BF%E8%AF%BE%E7%A8%8B&pageName=&moreUrl=https%3A%2F%2Fcmsapi.cnlive.com%2FcontentApi%2FgetBlockContents%3FblockId%3D12165")//"https://managemall.cnlive.com/html/mall/1/#/pages/main/goodsList/goodsList?scene=app")
46 47 webVC.url = URL(string: thirdUrl)
47 48 if controller != nil{
48 49 controller!.navigationController?.pushViewController(webVC, animated: pushAnimated)
... ...