$(document).ready(function () {
//查看缓存,判断是否有已经有上传过照片,但是没有提交且刷新页面导致照片消失的情况,在提交表单的时候会清除此缓存
var zpIDs = localStorage.getItem("zpIDs");
alert(1);
alert(zpIDs);
if(zpIDs!=null&&zpIDs!=''){
var IDs = zpIDs.split(",");
for (var i = 0; i < IDs.length; i++) {
WX_FUN.showImgByobj(IDs[i], addImg, IDs[i]);
}
}
}
_WXUtils.prototype={
init: function(appId,timestamp,nonceStr,signature){
//配置微信JS调用
wx.config({
debug: false,
appId: appId,
timestamp: timestamp,
nonceStr: nonceStr,
signature: signature,
jsApiList: [
]
});
},
//用于显示图片 add by lv
showImgByobj:function(localId,callback,obj){
alert(1111);
//用于适配新版的ios 微信
if(window.__wxjs_is_wkwebview==true){
alert(2222);
wx.getLocalImgData({
localId: localId.toString(),
success: function (res) {
var localData = res.localData;
alert(3333);
callback(localData,obj);
}
});
}else{
callback(localId,obj);
}
}
}
//动态添加img ,add by lv
function addImg(src, localId) {
var id = localId.replace(/[^0-9]/ig, "");
var lis_count = $("#xsphoto li").length;
var li = "<li class='mui-table-view-cell mui-media mui-col-xs-4'>" +
"<div class='imgDiv'>" +
"<img class='mui-media-object' src='" + src + "'>" +
"<input type='hidden' name='picbase64str_zp' id='" + id + "'/>" +
"<a href='#' onclick='delImg(this," + lis_count + ")'>" +
"<img src='${req.contextPath}/images/cha.png' class='delete' />" +
"</a>" +
"</div>" +
"</li>";
$("#xsphoto ul").append(li);
}
alert(1111)和alert(2222);都可以执行,但是alert(3333)就不执行,可见
wx.getLocalImgData 没有执行或者执行失败?有大佬知道原因吗?