import { rpxToPx } from "@/utils/tools";
import { View, Image } from "@tarojs/components";
import Taro from "@tarojs/taro";
import { useEffect, useState } from "react";
export default function SingleImage(props: { url: string }) {
const [loaded, setLoaded] = useState(false)
const [width, setWidth] = useState(346)
const [height, setHeight] = useState(346)
const kMax = 346
// const
//346
useEffect(() => {
Taro.downloadFile({
url: props.url,
success: (res) => {
Taro.getImageInfo({
src: res.tempFilePath,
success: function (res) {
console.log(res.width)
console.log(res.height)
if (res.width >= res.height) {
setWidth(kMax)
setHeight(kMax * res.height / res.width)
}
else {
setHeight(kMax)
setWidth(kMax * res.width / res.height)
}
setLoaded(true)
}
})
}
})
}, [])
if (!loaded) return
return {
if (process.env.TARO_ENV == 'weapp') {
e.stopPropagation()
}
Taro.previewImage({
current: props.url,
urls: [props.url]
})
}}
style={{
width: rpxToPx(width),
height: rpxToPx(height),
marginBottom:rpxToPx(7)
}} />
}