// 图片预览
function previewImage(imageUrl) {
  // 允许的宽度,允许的高度
  const iwidth = 800;
  const iheight = 800;
  const image = new Image();
  image.src = imageUrl;
  let width = image.width;
  let height = image.height
  // 超出等比缩放
  if (width > 0 && height > 0) {
    if (width / height >= iwidth / iheight) {
      if (width > iwidth) {
        height = (height * iwidth) / width;
        width = iwidth;
      }
    } else {
      if (height > iheight) {
        width = (width * iheight) / height;
        height = iheight;
      }
    }
    layer.open({
      title: false,
      type: 1,
      closeBtn: false,
      shadeClose: true,
      area: [width, height],
      content: '<div style="width:' + width + 'px;height:' + height + 'px;"><img style="width: 100%; height: 100%;" src="' + imageUrl + '" onerror=src="/img/error.png" alt="' + imageUrl + '" /></div>'
    });
  }
}