第一种
<script> export default { data() { return { sweixin: null } }, onLoad() { this.getPlus() }, methods: { getPlus() { //获取当前显示的webview var pages = getCurrentPages() var page = pages[pages.length - 1] var currentWebview = page.$getAppWebview() //调用H5+APP的扩展API var shares = null; let that = this var pusher = plus.share.getServices(function(s) { shares = {}; for (var i in s) { var t = s[i]; shares[t.id] = t; } that.sweixin = shares['weixin']; }, function(e) { console.log("获取分享服务列表失败:" + e.message); }); //放入当前的webview currentWebview.append(pusher); }, checkWeChat() { //调用微信小程序 if(this.sweixin){ this.sweixin.launchMiniProgram({ id: '' //要跳转小程序的原始ID }) } } } } </script>
第二种
plus.share.getServices( res => { let sweixin = null; for (let i in res) { if (res[i].id == 'weixin') { sweixin = res[i]; } } //唤醒微信小程序 if (sweixin) { sweixin.launchMiniProgram({ id: 'gh_0720325777cc', // type: 0, //小程序版本 0-正式版; 1-测试版; 2-体验版。 // path: 'pages/index/index?id=' + 1 //小程序的页面,用传的参数在小程序接值判断跳转指定页面 }); } } );