// 图片预览
export function usePreviewImg () {
  let isView = false
  const previewImg = (urls, current = 0) => {
    if (!Array.isArray(urls)) {
      urls = [urls]
    }
    urls = urls.map(m => util.checkFileUrl(m))
    uni.previewImage({
      urls,
      current,
      success: () => {
        isView = true
      }
    })
  }

  onUnload(() => {
    if (isView) {
      uni.closePreviewImage()
    }
  })

  return {
    previewImg
  }
}
