用了js代码解决
调用代码:
//图片预览
$("#Tolist").on("click",".img_prev",function(){
var hosts = window.location.host;
var url ="http://"+hosts+$(this).attr("src");
var arr = Array();
$(".img_prev").each(function(index){
var temp = "http://"+hosts+$(this).attr("src");
//alert(index);
arr.push(temp);
});
//移动端查看图片
wx.previewImage({
current:encodeURI(url), // 当前显示图片的http链接
urls: arr, // 需要预览的图片http链接列表
fail:function(e){
//pc端查看图片
var _this = $(this);
imgShow("#outerdiv", "#innerdiv", "#bigimg", url);
},
complete:function(e){
console.log(e);
}
});
});

实现代码:
//pc端查看图片方式
var isShow = false;
function imgShow(outerdiv, innerdiv, bigimg, url) {
var src =url;//_this.attr("value");//获取当前点击的pimg元素中的src属性
$(bigimg).attr("src", src);//设置#bigimg元素的src属性
/!*获取当前点击图片的真实大小,并显示弹出层及大图*!/
$("<img/>").attr("src", src).load(function () {
var windowW = $(window).width();//获取当前窗口宽度
var windowH = $(window).height();//获取当前窗口高度
var realWidth = this.width;//获取图片真实宽度
var realHeight = this.height;//获取图片真实高度
var imgWidth, imgHeight;
var scale = 0.9;//缩放尺寸,当图片真实宽度和高度大于窗口宽度和高度时进行缩放
if (realHeight > windowH * scale) {
imgHeight = windowH * scale;
imgWidth = imgHeight / realHeight * realWidth;
if (imgWidth > windowW * scale) {
imgWidth = windowW * scale;
}
} else if (realWidth > windowW * scale) {
imgWidth = windowW * scale;
imgHeight = imgWidth / realWidth * realHeight;
} else {
imgWidth = realWidth;
imgHeight = realHeight;
}
$(bigimg).css("width", imgWidth);//以最终的宽度对图片缩放
var w = (windowW - imgWidth) / 2;// 计算图片与窗口左边距
var h = (windowH - imgHeight) / 2;// 计算图片与窗口上边距
$(innerdiv).css({
"top": h,
"left": w
});//设置#innerdiv的top和left属性
$(outerdiv).fadeIn("fast", showmask);//淡入显示#outerdiv及.pimg
});
var e = window.event || arguments.callee.caller.arguments[0];
stopBubble(e);
$(outerdiv).click(function () {
if(isShow)
$(this).fadeOut("fast");
isShow = false;
});
}
function showmask() {
isShow = true;
}
function stopBubble(e) {
//如果提供了事件对象,则这是一个非IE浏览器
if (e && e.stopPropagation)
//因此它支持W3C的stopPropagation()方法
e.stopPropagation();
else
//否则,我们需要使用IE的方式来取消事件冒泡
window.event.cancelBubble = true;
}
说明:在wx.previewImage代码中的fail回调法中,去调用自行写的查看图片显示的js代码。 实现大图预览。