uni-app开发的APP跳转到微信小程序
<svg xmlns="http://www.w3.org/2000/svg" style="display: none"><path stroke-linecap="round" d="M5,0 0,2.5 5,5z" id="raphael-marker-block" style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0)"></path>
</svg>
<p>uni-app开发的APP跳转到微信小程序需要调用H5+的原生界面控件。</p>
<p><strong>注意事项:</strong></p>
<ul><li>用到了分享功能,在打包原生应用时,需要注意:首先勾选权限配置,manifest.json->App 模块权限配置->Share。然后,manifest.json->App SDK 配置->分享,按照提示填写微信分享的信息(微信开放平台,不是微信公众平台)。</li><li>因为涉及到第三方 SDK 的配置,需要打包自定义基座进行测试。真机运行自定义基座包使用说明</li><li>需要在微信开放平台开启APP跳转小程序,并管理相应的小程序<br> <img src="https://img-blog.csdnimg.cn/2019041816473523.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3N1cGVybG92ZXJf,size_16,color_FFFFFF,t_70"></li></ul>
<h4>跳转到微信小程序的代码:</h4>
<pre><code><template>
<view class="center">
<view class="text"@click="checkWeChat">跳转到小程序</view>
</view>
</template>
<script>
export default {
data() {
return {
sweixin: null
}
},
onLoad() {
this.getPlus()
},
methods: {
getPlus() {
//获取当前显示的webview
var pages = getCurrentPages()
var page = pages
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;
shares=t;
}
that.sweixin=shares['weixin'];
}, function(e){
console.log("获取分享服务列表失败:"+e.message);
});
//放入当前的webview
currentWebview.append(pusher);
},
checkWeChat() {
//调用微信小程序
this.sweixin.launchMiniProgram({
id:'gh_244-------' //要跳转小程序的原始ID
})
}
}
}
</script>
</code></pre>
<h4>小程序原始ID获取方法:</h4>
<p>登录微信公众平台,设置->基本设置,最下边为原始ID<br> <img src="https://img-blog.csdnimg.cn/20190418163908245.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3N1cGVybG92ZXJf,size_16,color_FFFFFF,t_70"><br> <img src="https://img-blog.csdnimg.cn/20190418164018863.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3N1cGVybG92ZXJf,size_16,color_FFFFFF,t_70"><br> 参考资料:<br> App端跳转小程序方式<br> uni-app中如何使用5+的原生界面控件</p><br><br>
来源:https://www.cnblogs.com/xiao-lang/p/17707734.html
頁:
[1]