function addLoadEvent(func){
let oldonload=window.onload;
if(typeof window.onload!="function"){
window.onload=func();
}else{
window.onload=()=>{
oldonload();
func();
}
}
}
let imgs=new Array();
let ImgUrl="";
function getPicInfo(){
let imgObj=document.getElementsByTagName('img');
for(let i=0; i<imgObj.length; i++){
imgs.push(imgObj[i].src);
imgObj[i].onclick=function(){
ImgUrl = this.src;
WeixinJSBridge.invoke("imagePreview",{
"urls":imgs,
"current":ImgUrl
})
}
}
}
addLoadEvent(getPicInfo);
在 window.onload后 直接调用