Commit 35738883 authored by DavidHuang's avatar DavidHuang

1、支持商品分享 的链接跳转 商品详情

parent 2ba1839f
...@@ -84,7 +84,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, WXApiDelegate { ...@@ -84,7 +84,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, WXApiDelegate {
if arrItems.count > 0 { if arrItems.count > 0 {
if let type = arrItems["type"] as? String,let iType = Int(type) { if let type = arrItems["type"] as? String,let iType = Int(type) {
if iType == 1 { if iType == 1 {
//跳转 //跳转直播
DispatchQueue.main.asyncAfter(deadline: .now() + 0.25) { DispatchQueue.main.asyncAfter(deadline: .now() + 0.25) {
if !YHLoginManager.shared.isLogin() { if !YHLoginManager.shared.isLogin() {
printLog("需要登录") printLog("需要登录")
...@@ -111,10 +111,34 @@ class AppDelegate: UIResponder, UIApplicationDelegate, WXApiDelegate { ...@@ -111,10 +111,34 @@ class AppDelegate: UIResponder, UIApplicationDelegate, WXApiDelegate {
} }
} }
} }
else if iType == 4 {
//跳转商品详情
DispatchQueue.main.asyncAfter(deadline: .now() + 0.25) {
// - 获取它对应的参数
if let goodsId = arrItems["id"] as? String {
NotificationCenter.default.post(name: YhConstant.YhNotification.closeShareUIInLiveRoomNotifiction, object: nil)
var url = YHBaseUrlManager.shared.curH5URL() + "superAppBridge.html#/goods/sales-detail" + "?id=\(goodsId)"
if YHLoginManager.shared.isLogin() {
let token = YHLoginManager.shared.h5Token
url = url + "&param=" + token
}
var tUrl = url
if !url.contains("navigationH=") {
tUrl = url + "?navigationH=\(k_Height_NavigationtBarAndStatuBar)"
if url.contains("?") {
tUrl = url + "&navigationH=\(k_Height_NavigationtBarAndStatuBar)"
}
}
let vc = YHH5WebViewVC()
vc.url = tUrl
vc.isHideNavigationBar = false
UIViewController.current?.navigationController?.pushViewController(vc, animated: true)
}
}
}
else { else {
printLog("未处理的类型 \(iType)") printLog("未处理的类型 \(iType)")
} }
} }
} }
......
...@@ -671,6 +671,57 @@ extension YHJsApi { ...@@ -671,6 +671,57 @@ extension YHJsApi {
let shareH5Describe : String = jsonObject["ShareH5Describe"] as? String ?? "" let shareH5Describe : String = jsonObject["ShareH5Describe"] as? String ?? ""
let shareH5Url : String = jsonObject["ShareH5Url"] as? String ?? "" let shareH5Url : String = jsonObject["ShareH5Url"] as? String ?? ""
let contentUrl : String = jsonObject["ContentUrl"] as? String ?? "" let contentUrl : String = jsonObject["ContentUrl"] as? String ?? ""
let realUrl : String = shareH5Url.replacingOccurrences(ofPattern: "#", withTemplate: "")
// var realUrl : String = "https://test-hklife.galaxy-immi.com/superAppBridge.html/goods/sales-detail?id=73"
if !realUrl.isEmpty {
if let url = URL(string: realUrl) {
let components = URLComponents(url: url, resolvingAgainstBaseURL: false)
if let queryItems = components?.queryItems {
var arrItems : [String : Any] = [:]
for item in queryItems {
if let value = item.value {
arrItems.updateValue(value, forKey: item.name)
}
}
if !arrItems.keys.isEmpty {
let id : String = arrItems["id"] as? String ?? ""
let shareYinheID : String = arrItems["shareYinheID"] as? String ?? ""
print(id)
print(shareYinheID)
let tParam = ["id":id,"shareYinheID":shareYinheID]
YHShareManager.shared.createMutilShareShortUrl(type: 4, param: tParam) { shortUrl, error in
if let url = shortUrl {
let tmpT = url.base64Encoded ?? ""//对deepLink使用 base64编码
var oldUrl = shareH5Url
if oldUrl.contains("?") {
oldUrl = oldUrl + "&appDeepLink=\(tmpT)"
} else {
oldUrl = oldUrl + "?appDeepLink=\(tmpT)"
}
DispatchQueue.main.async {
YHShareAlertView.show(image: contentUrl, title: shareH5Title, subMessage: shareH5Describe, linkUrl: oldUrl, isLive: false)
}
return
}
DispatchQueue.main.async {
YHShareAlertView.show(image: contentUrl, title: shareH5Title, subMessage: shareH5Describe, linkUrl: shareH5Url, isLive: false)
}
return
}
return
}
}
}
}
YHShareAlertView.show(image: contentUrl, title: shareH5Title, subMessage: shareH5Describe, linkUrl: shareH5Url, isLive: false) YHShareAlertView.show(image: contentUrl, title: shareH5Title, subMessage: shareH5Describe, linkUrl: shareH5Url, isLive: false)
} else { } else {
printLog("ddddd") printLog("ddddd")
......
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 to comment