局长信箱-h5-互联网端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

99 lines
4.5 KiB

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script src="https://res.wx.qq.com/open/js/jweixin-1.6.0.js"></script>
<style>
#launch-btn {
position: absolute;
top: 0;
right: 0;
left: 0;
bottom: 0;
overflow: hidden;
}
</style>
</head>
<body>
<script>
// fetch('https://mailbox.biutag.com/api/auth/wx/sign?url=' + location.href, {
// headers: {
// "Authorization": "76c52217a78d42fb9ef00ccf28c358d6"
// }
// }).then(res => {
// return res.json()
// }).then(res => {
// console.log(res)
// const config = wx.config({
// debug: true, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
// appId: "wx03c2abbf3291a7c7", // 必填,公众号的唯一标识
// timestamp: res.data.timestamp, // 必填,生成签名的时间戳
// nonceStr: res.data.nonceStr, // 必填,生成签名的随机串
// signature: res.data.signature, // 必填,签名
// jsApiList: ["chooseImage", "checkJsApi", "onMenuShareTimeline"], // 必填,需要使用的JS接口列表
// openTagList: ["wx-open-launch-weapp"]
// });
// })
// https://auth.weijing.gov.cn/fcfe/authgzh/index.html
const config = wx.config({
debug: true, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
appId: "wx03c2abbf3291a7c7", // 必填,公众号的唯一标识
timestamp: 1705891375, // 必填,生成签名的时间戳
nonceStr: "3xiulpJE6TKNp2V7", // 必填,生成签名的随机串
signature: "501a1041ac10759b709d0b66efd81d79f6a8dcd9", // 必填,签名
jsApiList: ["chooseImage", "checkJsApi", "onMenuShareTimeline"], // 必填,需要使用的JS接口列表
openTagList: ["wx-open-launch-weapp"]
});
</script>
<div>
<wx-open-launch-weapp id="launch-btn" appid="wx6eb7bd5c49012475" username="gh_a3858f362acb" path="pages/index/index"
env-version="trial" style="display: block; width: 100px; height: 50px; border: 1px solid #ccc">
<script type="text/wxtag-template">
<style>.btn { padding: 12px }</style>
<button class="btn">打开小程序</button>
</script>
</wx-open-launch-weapp>
</div>
<div style="width: 80vw; height: 44px; position: relative;">
<div id="launch-btn2"></div>
</div>
<button onclick="chooseImage()" style="margin-top: 20px;">选择图片</button>
<script>
const script = document.createElement("script");
script.type = "text/wxtag-template";
script.text = `<div style="height:44px; width: 100vw; background-color: red"></div>`;
const pathParam = '';
const extraData = '';
const html = `<wx-open-launch-weapp style="width:100%;height:100%;display:block;" appid="wx6eb7bd5c49012475" username="gh_a3858f362acb" path="pages/index/index?${pathParam}" extra-data="${extraData}">${script.outerHTML}</wx-open-launch-weapp>`;
document.querySelector("#launch-btn2").innerHTML = html;
var btn = document.getElementById('launch-btn');
btn.addEventListener('launch', function (e) {
console.log('launch success');
});
btn.addEventListener('error', function (e) {
console.log('launch fail', e.detail);
});
console.log(btn)
function chooseImage() {
wx.chooseImage({
count: 1, // 默认9
sizeType: ['original', 'compressed'], // 可以指定是原图还是压缩图,默认二者都有
sourceType: ['album', 'camera'], // 可以指定来源是相册还是相机,默认二者都有
success: function (res) {
var localIds = res.localIds; // 返回选定照片的本地ID列表,localId可以作为img标签的src属性显示图片
console.log(localIds)
}
});
}
</script>
</body>
</html>