调用微信 图片预览功能

function getSignatureInfo1(list, item) {
      $.ajax({
        type: 'post',
        dataType: 'json',
        cache: false,
        timeout: 50000,
        url: '', // 获取签名的地址
        data: {
          pageUrl: location.href.split('#')[0]
        },
        success: function (data) {
            wxSignInfo = {
              debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
              appId: data.appid, // 必填,公众号的唯一标识
              timestamp: data.timestamp, // 必填,生成签名的时间戳
              nonceStr: data.nonceStr, // 必填,生成签名的随机串
              signature: data.signature, // 必填,签名,见附录1
              jsApiList: ['chooseImage','uploadImage','previewImage'] // 必填,需要使用的JS接口列表,所有JS接口列表见附录2
            };
            wx.config(wxSignInfo);
                wx.ready(function(){ //调用拍照
                  wx.previewImage({
                      current: '`${ossUrl}${item}`', // 当前显示图片的http链接
                      urls: list, // 所有图片
                      success: function (res) {
                      },
                      fail: function(re){
                          wx.getNetworkType({
                              success: function (res) {
                                  newNet = res.networkType; // 返回网络类型2g,3g,4g,wifi
                              }
                          });
                      }
                  });
                });
          wx.error(function (res) {
            $('body').attr('style', 'overflow: hidden');
            fnLayerBox('微信签名有误')
            return false;
          });

        }
      });
    };

 

posted @ 2020-08-28 11:09  鸿兮萄  阅读(578)  评论(0)    收藏  举报