<div id="wechatBtn" class="btn-wechat-mp__wrap">
<div class="btn-wechat-mp--show" id="openBtn">
<div class="btn-wechat-mp__icon">
</div>
<span>立即使用</span>
</div>
<wx-open-launch-weapp id="launch-btn" username="gh_01a5aa3b4944" path="pages/index/index.html">
<script type="text/wxtag-template">
<style>.btn { padding: 12px }</style>
<button class="btn">打开小程序</button>
</script>
</wx-open-launch-weapp>
</div>
<script>
var btn = document.getElementById('launch-btn');
btn.addEventListener('launch', function (e) {
console.log('success');
});
btn.addEventListener('error', function (e) {
console.log('fail', e.detail);
});
var btn2 = document.getElementById('wechatBtn');
btn2.addEventListener('click', function (e) {
console.log("btnclick");
onClickOpens();
});
function onClickOpens() {
$.get("https://pcszmcjzs.bishan.gov.cn:8888/certout/sso/wechat/getSignature",
{ requestUrl: encodeURI(window.location.href) },
function (res) {
if (res.code == 200) {
wx.config({
debug: false,
appId: 'wxd5c9d2cc0287ef87',
timestamp: res.data.timestamp,
nonceStr: res.data.nonceStr,
signature: res.data.signature,
jsApiList: [
"onMenuShareTimeline",
"onMenuShareAppMessage",
"onMenuShareQQ",
"onMenuShareWeibo",
"onMenuShareQZone",
"openLocation",
"chooseWXPay",
],
openTagList: ['wx-open-launch-weapp']
});
}
});
wx.ready(function () {
console.log("ready")
});
wx.error(function (res) {
console.log("error", res)
});
}
</script>
链接地址:https://wsga.gaj.cq.gov.cn/bs/home.html
这样试试
<style> .btn { padding: 12px; width: 100px; height: 80px; } </style> <wx-open-launch-weapp id="launch-btn" username="gh_01a5aa3b4944" path="pages/index/index.html"> <template> <button class="btn">打开小程序</button> </template> </wx-open-launch-weapp>