🌈 style(eslint): add eslint rules
This commit is contained in:
@@ -1,14 +1,14 @@
|
||||
import Taro from '@tarojs/taro'
|
||||
import { memo, useEffect, useState } from 'react'
|
||||
import useUploadCDNImg from '@/use/useUploadImage'
|
||||
import { Image, Text, View } from '@tarojs/components'
|
||||
import { formatImgUrl } from '@/common/format'
|
||||
import { memo, useEffect, useState } from 'react'
|
||||
import classnames from 'classnames'
|
||||
import styles from './index.module.scss'
|
||||
import useUploadCDNImg from '@/use/useUploadImage'
|
||||
import { formatImgUrl } from '@/common/format'
|
||||
import Popup from '@/components/popup'
|
||||
import IconFont from '@/components/iconfont/iconfont'
|
||||
//图片列表
|
||||
type ImageParam = {
|
||||
// 图片列表
|
||||
interface ImageParam {
|
||||
onChange?: (val: string[]) => void
|
||||
defaultList?: string[]
|
||||
onlyRead?: boolean
|
||||
@@ -22,22 +22,23 @@ const PictureItem = memo<ImageParam>(({ onChange, defaultList, onlyRead = false
|
||||
setImageLise(defaultList || [])
|
||||
}, [defaultList])
|
||||
|
||||
//上传图片
|
||||
const uploadImage = async () => {
|
||||
// 上传图片
|
||||
const uploadImage = async() => {
|
||||
setshowPopup(true)
|
||||
}
|
||||
|
||||
//上传图片逻辑
|
||||
const handPic = async (id) => {
|
||||
// 上传图片逻辑
|
||||
const handPic = async(id) => {
|
||||
// let resArr = List.filter(item => {
|
||||
// return item.check
|
||||
// })
|
||||
if (id == 1) {
|
||||
var list: any = await getWxPhoto('after-sale', 5)
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
var list: any = await getChatPhoto('after-sale', 5)
|
||||
}
|
||||
let images: any[] = []
|
||||
const images: any[] = []
|
||||
list?.map((item) => {
|
||||
images.push(item.url)
|
||||
})
|
||||
@@ -45,19 +46,19 @@ const PictureItem = memo<ImageParam>(({ onChange, defaultList, onlyRead = false
|
||||
setshowPopup(false)
|
||||
}
|
||||
|
||||
//删除图片
|
||||
// 删除图片
|
||||
const delImage = (index) => {
|
||||
imageList.splice(index, 1)
|
||||
setImageLise(() => [...imageList])
|
||||
}
|
||||
//监听上传的图片变化
|
||||
// 监听上传的图片变化
|
||||
useEffect(() => {
|
||||
onChange?.(imageList)
|
||||
}, [imageList])
|
||||
|
||||
//预览图片
|
||||
// 预览图片
|
||||
const showImage = () => {
|
||||
let list = imageList?.map((item) => {
|
||||
const list = imageList?.map((item) => {
|
||||
return formatImgUrl(item, '!w800')
|
||||
})
|
||||
Taro.previewImage({
|
||||
@@ -66,15 +67,16 @@ const PictureItem = memo<ImageParam>(({ onChange, defaultList, onlyRead = false
|
||||
})
|
||||
}
|
||||
|
||||
//筛选内容展示
|
||||
// 筛选内容展示
|
||||
const [showPopup, setshowPopup] = useState(false)
|
||||
const [List, setList] = useState<any[]>([{ id: 1, name: '手机相册', check: false }, { id: 2, name: '从微信对话选择', check: false }])
|
||||
//点击选择的方式
|
||||
// 点击选择的方式
|
||||
const handItem = (item) => {
|
||||
List.map(it => {
|
||||
List.map((it) => {
|
||||
if (item.id == it.id) {
|
||||
it.check = true
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
it.check = false
|
||||
}
|
||||
return it
|
||||
@@ -88,22 +90,22 @@ const PictureItem = memo<ImageParam>(({ onChange, defaultList, onlyRead = false
|
||||
<View className={styles.image_main}>
|
||||
{imageList?.map((item, index) => (
|
||||
<View className={styles.ImgItem}>
|
||||
<Image mode='aspectFill' src={formatImgUrl(item)} onClick={showImage}></Image>
|
||||
<Image mode="aspectFill" src={formatImgUrl(item)} onClick={showImage}></Image>
|
||||
{!onlyRead && <View onClick={() => delImage(index)}>
|
||||
<IconFont name={'icon-guanbi'} size={30} customClassName={styles['miconfont_close']} color={'#ffffff'}></IconFont>
|
||||
<IconFont name="icon-guanbi" size={30} customClassName={styles.miconfont_close} color="#ffffff"></IconFont>
|
||||
</View>}
|
||||
</View>
|
||||
))}
|
||||
{!onlyRead && (
|
||||
<View className={styles.uploadImg} onClick={uploadImage}>
|
||||
<IconFont name={'icon-xinzeng'} size={100} color={'#d8d8d8'}></IconFont>
|
||||
<IconFont name="icon-xinzeng" size={100} color="#d8d8d8"></IconFont>
|
||||
{/* <Text className={classnames(styles.miconfont, 'iconfont icon-xinzeng')}></Text> */}
|
||||
{/* <Text className={styles.uploadText}>上传照片</Text> */}
|
||||
</View>
|
||||
)}
|
||||
|
||||
</View>
|
||||
<Popup title={'选择方式'} show={showPopup} onClose={() => setshowPopup(false)} isFixed={true}>
|
||||
<Popup title="选择方式" show={showPopup} onClose={() => setshowPopup(false)} isFixed>
|
||||
<View className={styles.bigBoxThree}>
|
||||
{
|
||||
List.map((item, index) => {
|
||||
|
||||
Reference in New Issue
Block a user