|
@@ -148,38 +148,37 @@
|
|
|
if(!id){
|
|
|
copyUrl();
|
|
|
} else if (isiOS) {
|
|
|
- var u = navigator.userAgent;
|
|
|
- if(!!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/)){
|
|
|
- $.ajax({
|
|
|
- url: baseUrl + '/api/user/v1/promote',
|
|
|
- type: 'get',
|
|
|
- headers: {
|
|
|
- 'Authorization': id //id
|
|
|
- },
|
|
|
- contentType: "application/json",
|
|
|
- dataType: 'json',
|
|
|
- cache: false,
|
|
|
- success: function (res) {
|
|
|
- var jsonStr = JSON.stringify(res.data)
|
|
|
- var jsonObj = JSON.parse(jsonStr)
|
|
|
- // WKWebView使用
|
|
|
- // 使用下方方法,会报错,为使界面执行逻辑通畅,因此使用try-catch
|
|
|
- try {
|
|
|
- getMessage(jsonObj);
|
|
|
- } catch (error) {
|
|
|
- console.log(error)
|
|
|
- }
|
|
|
- try {
|
|
|
- window.webkit.messageHandlers.getMessage.postMessage(jsonObj)
|
|
|
- } catch (error) {
|
|
|
- console.log(error)
|
|
|
- }
|
|
|
- }
|
|
|
- })
|
|
|
- }else{
|
|
|
- copyUrl();
|
|
|
+ alert(window.webkit.messageHandlers.getMessage.postMessage);
|
|
|
+ if(!window.webkit.messageHandlers.getMessage.postMessage){
|
|
|
+ copyUrl();
|
|
|
+ return
|
|
|
}
|
|
|
-
|
|
|
+ $.ajax({
|
|
|
+ url: baseUrl + '/api/user/v1/promote',
|
|
|
+ type: 'get',
|
|
|
+ headers: {
|
|
|
+ 'Authorization': id //id
|
|
|
+ },
|
|
|
+ contentType: "application/json",
|
|
|
+ dataType: 'json',
|
|
|
+ cache: false,
|
|
|
+ success: function (res) {
|
|
|
+ var jsonStr = JSON.stringify(res.data)
|
|
|
+ var jsonObj = JSON.parse(jsonStr)
|
|
|
+ // WKWebView使用
|
|
|
+ // 使用下方方法,会报错,为使界面执行逻辑通畅,因此使用try-catch
|
|
|
+ try {
|
|
|
+ getMessage(jsonObj);
|
|
|
+ } catch (error) {
|
|
|
+ console.log(error)
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ window.webkit.messageHandlers.getMessage.postMessage(jsonObj)
|
|
|
+ } catch (error) {
|
|
|
+ console.log(error)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
} else if (isAndroid) {
|
|
|
if(window.native){
|
|
|
window.native.onClikWebView()
|