这个path路径可以写到js文件里面吗,是放到function doShare() {}里面还是外面,那path="pages/index/index"是可以删掉吗?
let launch = document.getElementById('launch-btn')
let path = `pages/index/index?source=wtProduct&to=h5tp&sourceType=wt&agentCode=${sales_agent}&linkUrl=${commonurl_front+'common/blank.html'}`
launch.setAttribute('path',path)
<div class="hktshare"
style="position: fixed; z-index: 999999999999999; top: 10.84rem; right: 0.1rem; width: 50px;height: 50px;">
<wx-open-launch-weapp id="launch-btn" username="gh_4b4a3e566703" path="pages/index/index">
<template>
<style>
.btnhkt {width: 50px;height: 50px;border: none;}
.btnhkt:active {box-shadow: none;}
</style>
<img class="btnhkt" src="https://sales-dev.ihxlife.com/HuaPM_V/bcard/image/room/hkt.png" />
</template>
</wx-open-launch-weapp>
</div>
doShare();
function doShare() {
$.ajax({
url: 'https://uc-dev-bg.ihxlife.com/wechat/signatureinfo/get',
data: {
pageUrl: location.href.split('#')[0]
},
type: 'GET',
success: function (sdata) {
var configData = {
debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
appId: sdata.data.app_id, //
timestamp: sdata.data.timestamp,
nonceStr: sdata.data.nonceStr,
signature: sdata.data.signature,
jsApiList: ['showOptionMenu', 'onMenuShareTimeline', 'onMenuShareAppMessage',
'hideMenuItems'
], // 必填,需要使用的JS接口列表,所有JS接口列表见附录2
openTagList: ['wx-open-launch-weapp']
};
// 加载微信SDK引入js
wx.config(configData);
wx.ready(function () {
//alert('JS-SDK注册成功!可以使用了');
wx.showOptionMenu();
// console.log('link', link)
})
}
})
}