Commit d45189668049ab234ee012c7a73b4e57a62ae9b8
1 parent
ed29f805
分享方法的调用
Showing
2 changed files
with
33 additions
and
5 deletions
src/pages/common/common.vue
| @@ -82,6 +82,38 @@ | @@ -82,6 +82,38 @@ | ||
| 82 | } | 82 | } |
| 83 | }, | 83 | }, |
| 84 | /** | 84 | /** |
| 85 | + * APP内拉起分享 | ||
| 86 | + * @param {int} type [分享类型] | ||
| 87 | + * @param {int} id [页面id] | ||
| 88 | + */ | ||
| 89 | + toShare(type, id) { | ||
| 90 | + // 判断APP内 | ||
| 91 | + if (this.isCNLive.value) { | ||
| 92 | + | ||
| 93 | + // 调用分享(新方法) | ||
| 94 | + if (window.webkit && window.webkit.messageHandlers && window.webkit.messageHandlers.toShare) { | ||
| 95 | + | ||
| 96 | + // 分享 | ||
| 97 | + window.webkit.messageHandlers.toShare.postMessage({body: {type: type, id: id}}); | ||
| 98 | + } else if (window.obj && window.obj.toShare) { | ||
| 99 | + | ||
| 100 | + // 分享 | ||
| 101 | + window.obj.toShare(type, id); | ||
| 102 | + } | ||
| 103 | + | ||
| 104 | + // 调用分享(旧方法) | ||
| 105 | + if (window.webkit && window.webkit.messageHandlers && window.webkit.messageHandlers.share) { | ||
| 106 | + | ||
| 107 | + // 分享 | ||
| 108 | + window.webkit.messageHandlers.share.postMessage({body: this.appShareParams}); | ||
| 109 | + } else if (window.obj && window.obj.shareUrl) { | ||
| 110 | + | ||
| 111 | + // 分享 | ||
| 112 | + window.obj.shareUrl(JSON.stringify(this.appShareParams)); | ||
| 113 | + } | ||
| 114 | + } | ||
| 115 | + }, | ||
| 116 | + /** | ||
| 85 | * 返回上一页 | 117 | * 返回上一页 |
| 86 | */ | 118 | */ |
| 87 | back(){ | 119 | back(){ |
src/pages/index/index.vue
| @@ -68,7 +68,7 @@ | @@ -68,7 +68,7 @@ | ||
| 68 | <!--头部返回和分享--> | 68 | <!--头部返回和分享--> |
| 69 | <div v-show="isCNLive.value" class="top_box"> | 69 | <div v-show="isCNLive.value" class="top_box"> |
| 70 | <img @click="$parent.back()" src="../../../static/img/back.jpg" alt=""/> | 70 | <img @click="$parent.back()" src="../../../static/img/back.jpg" alt=""/> |
| 71 | - <img @click="$parent.back()" src="../../../static/img/share.jpg" alt=""/> | 71 | + <img @click="$parent.toShare('22','1')" src="../../../static/img/share.jpg" alt=""/> |
| 72 | </div> | 72 | </div> |
| 73 | </div> | 73 | </div> |
| 74 | </template> | 74 | </template> |
| @@ -189,10 +189,6 @@ | @@ -189,10 +189,6 @@ | ||
| 189 | // this.playerOptions.sources[0].src = "https://wjjtest.ys2.cnliveimg.com/802/shop/img/2019/12/30/5e0973f0aa9be.mp4" | 189 | // this.playerOptions.sources[0].src = "https://wjjtest.ys2.cnliveimg.com/802/shop/img/2019/12/30/5e0973f0aa9be.mp4" |
| 190 | // } | 190 | // } |
| 191 | }, | 191 | }, |
| 192 | - /** | ||
| 193 | - * 接口调用 | ||
| 194 | - * @param {object} [ 分享参数] | ||
| 195 | - */ | ||
| 196 | 192 | ||
| 197 | } | 193 | } |
| 198 | } | 194 | } |