var wx_url = window.location.href.split('#'),
phone = getCookie('phone'),
accaUserId = getCookie('accaUserId'),
userAccessToken = getCookie('userAccessToken');
$.ajax({
type: "POST",
url: "https://wx.zbgedu.com/getSignature.html",
data: { 'url': window.location.href },
dataType: "json",
success: function (data) {
if (typeof data !== 'object') {
data = JSON.parse(data);
}
if (data && typeof data['state'] != 'undefined' && data['state'] == 'success') {
data = data['data'];
//初始化
wx.config({
debug: false,
appId: data['appId'],
timestamp: data['timestamp'],
nonceStr: data['nonceStr'],
signature: data['signature'],
jsApiList: ['onMenuShareAppMessage', 'onMenuShareQQ', 'onMenuShareTimeline', 'onMenuShareQZone', 'onMenuShareWeibo', 'updateAppMessageShareData', 'updateTimelineShareData',"chooseImage","previewImage","uploadImage","downloadImage","scanQRCode"]
// 所用到的小程序的所有api
});
wx.ready(function () {
var ua = window.navigator.userAgent.toLowerCase();
//先判断是否微信浏览器
if (ua.match(/MicroMessenger/i) == "micromessenger") {
//再判断一下是否在小程序里
wx.miniProgram.getEnv((res) => {
console.info("res", res);
if (res.miniprogram) {
wx.checkJsApi({
jsApiList: ['scanQRCode', 'previewImage'],
success: function (res) {
// alert(7)
}
});
wx.previewImage({
current: 'https://www.zbgedu.com/special/active_statics/Applets/helper/ewm-zbge.jpg', // 当前显示图片的http链接
urls: ['https://www.zbgedu.com/special/active_statics/Applets/helper/ewm-zbge.jpg'] // 需要预览的图片http链接列表
});
alert(2222);
}
});
} else {
return 'no'
}
});
wx.error(function (res) {
// alert("错误"+res);
})
}
}
});
记录一次小程序webview内嵌h5页面实现长按识别二维码
最新推荐文章于 2024-07-13 15:19:09 发布