Commit 06c25675 by pierce

fixed bugs

parent 21a4c4bf
......@@ -262,68 +262,62 @@ public class GDWebView: WKWebView, WKNavigationDelegate, WKScriptMessageHandler
public func userContentController(_ userContentController: WKUserContentController, didReceive message: WKScriptMessage) {
//TODO:处理这里的逻辑: added By Pidan
// if message.name == GDWebView.kJavaScriptInteractKey {
//
// guard let body : String = message.body as? String else {return}
//
// guard let jsonData = body.data(using: String.Encoding.utf8, allowLossyConversion: false) else {return}
// let json = try! JSON(data: jsonData)
//
// let dataDict = json["data"]
// let webCid = json["cid"].intValue
// switch webCid {
if message.name == GDWebView.kJavaScriptInteractKey {
guard let body : String = message.body as? String else {return}
guard let jsonData = body.data(using: String.Encoding.utf8, allowLossyConversion: false) else {return}
let json = try! JSON(data: jsonData)
let dataDict = json["data"]
let webCid = json["cid"].intValue
switch webCid {
// case 1: // CID 为 1,打开榜单
// // TODO: 打开榜单
// if DevConfig.devEnv {
// FTIndicator.showToastMessage("不支持功能")
// }
// break
// case 2: // CID 为2,打开网页
// let shouldShare = dataDict["share"].boolValue
// let halfScreen = dataDict["isShowHalf"].boolValue
// let urlStr = dataDict["url"].stringValue
//
// if halfScreen {
// let heightRatio = CGFloat(dataDict["heightScale"].doubleValue / 100.0)
// let widthRatio = CGFloat(dataDict["viewHeight"].doubleValue / 100.0)
//
// var shouldCloseGift = true
// if dataDict["closeGiftWindow"].isEmpty == false {
// shouldCloseGift = dataDict["closeGiftWindow"].boolValue
// }
//
case 2: // CID 为2,打开网页
let shouldShare = dataDict["share"].boolValue
let halfScreen = dataDict["isShowHalf"].boolValue
let urlStr = dataDict["url"].stringValue
if halfScreen {
let heightRatio = CGFloat(dataDict["heightScale"].doubleValue / 100.0)
let widthRatio = CGFloat(dataDict["viewHeight"].doubleValue / 100.0)
var shouldCloseGift = true
if dataDict["closeGiftWindow"].isEmpty == false {
shouldCloseGift = dataDict["closeGiftWindow"].boolValue
}
//TODO:处理这里的逻辑: added By Pidan
// if let functionView = GDLiveHelper.shared.liveVC?.functionView as? GDLiveFunctionView {
//
// functionView.showHalfScreenView(for: urlStr, heightRatio: heightRatio, widthRadio: widthRatio, closeGiftPanel: shouldCloseGift)
// }
//
// } else {
// let webVC = GDWebViewController(url: urlStr)
// webVC.showShare = shouldShare
// webVC.hidesBottomBarWhenPushed = true
// if let vc = self.getPresentViewController?() {
// vc.navigationController?.pushViewController(webVC, animated: true)
// } else {
// self.viewController?.navigationController?.pushViewController(webVC, animated: true)
// }
//
// }
// case 4: // CID 为 4,打开客服
// let serviceVC = GDServiceController()
// serviceVC.hidesBottomBarWhenPushed = true
// if let vc = self.getPresentViewController?() {
// vc.navigationController?.pushViewController(serviceVC, animated: true)
// } else {
// self.viewController?.navigationController?.pushViewController(serviceVC, animated: true)
//
// }
//
// break
// case 5: // CID 为 5,跳转外链
// if let url: URL = URL(string: dataDict["url"].stringValue) {
// UIApplication.shared.openURL(url)
// }
// break
} else {
let webVC = GDWebViewController(url: urlStr)
webVC.showShare = shouldShare
webVC.hidesBottomBarWhenPushed = true
if let vc = self.getPresentViewController?() {
vc.navigationController?.pushViewController(webVC, animated: true)
} else {
self.viewController?.navigationController?.pushViewController(webVC, animated: true)
}
}
case 4: // CID 为 4,打开客服
//TODO:处理这里的逻辑: added By Pidan
// GDRouter.ChatRoom?.showServiceCharRoom()
break
case 5: // CID 为 5,跳转外链
if let url: URL = URL(string: dataDict["url"].stringValue) {
UIApplication.shared.openURL(url)
}
break
// case 6: // CID 为 6,打开兑换钻石页面,废弃
// if DevConfig.devEnv {
// FTIndicator.showToastMessage("不支持功能")
......@@ -974,13 +968,13 @@ public class GDWebView: WKWebView, WKNavigationDelegate, WKScriptMessageHandler
// } else {
// shareInviteView.show(on: self)
// }
// default:
// break
// }
//
// // 发布
// actionPublisher.accept((cid: webCid, data: dataDict))
// }
default:
break
}
// 发布
actionPublisher.accept((cid: webCid, data: dataDict))
}
}
// MARK: Public
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment