!??!不是微信公眾號菜單跳轉(zhuǎn)小程序
微信公眾號菜單跳轉(zhuǎn)小程序:公眾號和小程序相互關(guān)聯(lián),在公眾號的自定義菜單中配置即可
1、綁定域名
先登錄微信公眾平臺進(jìn)入“公眾號設(shè)置”的“功能設(shè)置”里填寫“JS接口安全域名”。
?。?!登錄后可在“開發(fā)者中心”查看相應(yīng)的接口權(quán)限。
文章來源:http://www.zghlxwxcb.cn/news/detail-649386.html
?2、安裝依賴 jweixin-module
npm install jweixin-module --save
3、引入掛載
!??!main.js引入掛載
import wx from 'jweixin-module'
//單頁面掛載main.js中也要寫以下代碼
Vue.config.ignoredElements.push('wx-open-launch-weapp')
!?。雾撁嬉霋燧d
import wx from 'jweixin-module'
4、通過 config 接口注入權(quán)限驗(yàn)證配置(需要后端配合)
? ? ? ? ?。?!Java代碼請移步到微信公眾號H5分享微信好友,最后僅供參考文章來源地址http://www.zghlxwxcb.cn/news/detail-649386.html
??。。≡陧撁娉跏蓟虞d(onLoad、created)
//#ifdef H5
uni.request({
url: '請求地址',
method: 'POST',
data:'傳參',
header: {//配置請求頭
'Content-Type': this.$store.state.contentType,
'Authorization' : this.$store.state.token
},
success: res => {
if (res.statusCode < 500) {
if (res.data.code === 200) {
// console.log('res.data', res.data.data)
wx.config({
debug: true, // 開啟調(diào)試模式,調(diào)用的所有api的返回值會在客戶端alert出來,若要查看傳入的參數(shù),可以在pc端打開,參數(shù)信息會通過log打出,僅在pc端時(shí)才會打印。
appId: res.data.data.appId, // 必填,公眾號的唯一標(biāo)識
timestamp: res.data.data.timeStamp, // 必填,生成簽名的時(shí)間戳
nonceStr: res.data.data.nonceStr, // 必填,生成簽名的隨機(jī)串
signature: res.data.data.sign, // 必填,簽名,見附錄1
jsApiList: ["wx-open-launch-weapp"], // 必填,需要使用的JS接口列表
openTagList:['wx-open-launch-weapp'], // 可選,需要使用的開放標(biāo)簽列表,例如['wx-open-launch-weapp','wx-open-launch-app']
})
wx.ready(res => {
console.log('res',res);
});
wx.error(res => {
console.log('error',res);
});
}
} else {
console.error('服務(wù)器錯(cuò)誤,請檢查')
}
},
fail: err => {
uni.showToast({
title: '請求失敗',
icon: 'error'
})
}
})
//#endif
5、html代碼:
<wx-open-launch-weapp
@launch="handleLaunchFn"
class="launch-btn"
username="目標(biāo)小程序的原始ID" <!-- 不是appId,是以gh_開頭的原始ID -->
path="pages/index/index?openID=123456&str=666"<!-- 要跳轉(zhuǎn)目標(biāo)小程序的路徑頁面 -->
style="display: block;">
<script type="text/wxtag-template">
<style>
.text {
font-size: 30rpx;
}
</style>
<view class="text">測試跳轉(zhuǎn)小程序</view>
</script>
</wx-open-launch-weapp>
methods: {
handleLaunchFn (e) {
console.log('success', e)
}
}
到了這里,關(guān)于uniapp微信公眾號(h5)端跳轉(zhuǎn)微信小程序的文章就介紹完了。如果您還想了解更多內(nèi)容,請?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!