记录一次小程序webview内嵌h5页面实现长按识别二维码

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);
                            })
                        }
                    }
                });

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值