🌈 style(typos): 修复eslint的报错

This commit is contained in:
xuan 2022-12-05 11:56:40 +08:00
parent d49314aa5b
commit 9dd7e9db18
10 changed files with 87 additions and 83 deletions

View File

@ -4,7 +4,7 @@ import classnames from 'classnames'
import { memo, useEffect, useRef, useState } from 'react' import { memo, useEffect, useRef, useState } from 'react'
import styles from './index.module.scss' import styles from './index.module.scss'
import Popup from '@/components/popup' import Popup from '@/components/popup'
import type { Params as PopuParams } from '@/components/popup' import type { Params as PopuParams } from '@/components/popup'
import { GetProductKindListApi } from '@/api/material' import { GetProductKindListApi } from '@/api/material'
type params = { type params = {
@ -83,7 +83,7 @@ export default memo(({ onClose, onFiltr, show = false, onRest }: params) => {
<View <View
key={item.id} key={item.id}
onClick={() => changeKind(item)} onClick={() => changeKind(item)}
className={classnames(styles.btn_item, filterObj.seriesId == item.id && styles.select_btn_item)} className={classnames(styles.btn_item, filterObj.seriesId == item.id && styles.select_btn_item)}
> >
{item.name} {item.name}
</View> </View>

View File

@ -1,6 +1,7 @@
import Taro from '@tarojs/taro' import Taro from '@tarojs/taro'
import { Image, Text, View } from '@tarojs/components' import { Image, Text, View } from '@tarojs/components'
import { FC, memo, useEffect, useState } from 'react' import type { FC } from 'react'
import { memo, useEffect, useState } from 'react'
import classnames from 'classnames' import classnames from 'classnames'
import styles from './index.module.scss' import styles from './index.module.scss'
import useUploadCDNImg from '@/use/useUploadImage' import useUploadCDNImg from '@/use/useUploadImage'
@ -12,7 +13,7 @@ interface ImageParam {
defaultList?: string[] defaultList?: string[]
onlyRead?: false | true onlyRead?: false | true
} }
const PictureItem: FC<ImageParam> = memo(({ onChange, defaultList, onlyRead = false }) => { const PictureItem = ({ onChange, defaultList, onlyRead = false }: ImageParam) => {
const { getWxPhoto } = useUploadCDNImg() const { getWxPhoto } = useUploadCDNImg()
const [imageList, setImageLise] = useState<string[]>([]) const [imageList, setImageLise] = useState<string[]>([])
@ -24,7 +25,7 @@ const PictureItem: FC<ImageParam> = memo(({ onChange, defaultList, onlyRead = fa
const uploadImage = async() => { const uploadImage = async() => {
const list: any = await getWxPhoto('after-sale', 5) const list: any = await getWxPhoto('after-sale', 5)
const images: any[] = [] const images: any[] = []
list?.map((item) => { list?.forEach((item) => {
images.push(item.url) images.push(item.url)
}) })
setImageLise([...imageList, ...images]) setImageLise([...imageList, ...images])
@ -53,7 +54,7 @@ const PictureItem: FC<ImageParam> = memo(({ onChange, defaultList, onlyRead = fa
return ( return (
<View className={styles.image_main}> <View className={styles.image_main}>
{imageList?.map((item, index) => ( {imageList?.map((item, index) => (
<View className={styles.ImgItem}> <View className={styles.ImgItem} key={index}>
<Image mode="aspectFill" src={formatImgUrl(item)} onClick={showImage}></Image> <Image mode="aspectFill" src={formatImgUrl(item)} onClick={showImage}></Image>
{!onlyRead && <View onClick={() => delImage(index)} className={classnames(styles.miconfont_close, 'iconfont icon-qingkong')}></View>} {!onlyRead && <View onClick={() => delImage(index)} className={classnames(styles.miconfont_close, 'iconfont icon-qingkong')}></View>}
</View> </View>
@ -66,6 +67,6 @@ const PictureItem: FC<ImageParam> = memo(({ onChange, defaultList, onlyRead = fa
)} )}
</View> </View>
) )
}) }
export default PictureItem export default memo(PictureItem)

View File

@ -8,19 +8,21 @@ import './index.scss'
import { addressAddApi, addressDetailApi, addressEditApi } from '@/api/addressManager' import { addressAddApi, addressDetailApi, addressEditApi } from '@/api/addressManager'
import useLogin from '@/use/useLogin' import useLogin from '@/use/useLogin'
export default () => { const AddressAdd = () => {
useLogin() useLogin()
const [showSiteModal, setShowSiteModal] = useState(false) const [showSiteModal, setShowSiteModal] = useState(false)
const { type, id } = useRouter().params const { type, id } = useRouter().params
useEffect(() => { // 保存
if (type == 'add') { const [formData, setFormData] = useState({
setNavigationBarTitle({ title: '新增收货地址' }) name: '',
} phone: '',
else { site: '',
initalFormData() siteArray: [],
setNavigationBarTitle({ title: '编辑收货地址' }) district_id: '',
} address_detail: '',
}, []) is_default: false,
id: 0,
})
// 获取编辑地址信息 // 获取编辑地址信息
const { fetchData: getFromData } = addressDetailApi() const { fetchData: getFromData } = addressDetailApi()
const initalFormData = async() => { const initalFormData = async() => {
@ -43,17 +45,7 @@ export default () => {
const { fetchData } = addressAddApi() const { fetchData } = addressAddApi()
const { fetchData: editFetch } = addressEditApi() const { fetchData: editFetch } = addressEditApi()
// 保存
const [formData, setFormData] = useState({
name: '',
phone: '',
site: '',
siteArray: [],
district_id: '',
address_detail: '',
is_default: false,
id: 0,
})
const rules = { const rules = {
name: [ name: [
{ {
@ -104,7 +96,7 @@ export default () => {
Taro.eventCenter.trigger('addressList:refresh') Taro.eventCenter.trigger('addressList:refresh')
Taro.navigateBack() Taro.navigateBack()
alert.success('保存成功') alert.success('保存成功')
} }
else { else {
alert.error(result.msg) alert.error(result.msg)
} }
@ -113,6 +105,15 @@ export default () => {
alert.none(message) alert.none(message)
}) })
} }
useEffect(() => {
if (type == 'add') {
setNavigationBarTitle({ title: '新增收货地址' })
}
else {
initalFormData()
setNavigationBarTitle({ title: '编辑收货地址' })
}
}, [])
// 监听表单完善 // 监听表单完善
const [hozon, setHozon] = useState(false) const [hozon, setHozon] = useState(false)
useEffect(() => { useEffect(() => {
@ -131,7 +132,7 @@ export default () => {
site: ev.map(item => `${item.name} `), site: ev.map(item => `${item.name} `),
district_id: ev[ev.length - 1]?.id, district_id: ev[ev.length - 1]?.id,
}) })
} }
else { else {
alert.error('请选择地址') alert.error('请选择地址')
} }
@ -163,12 +164,12 @@ export default () => {
<View className="add-address-default"> <View className="add-address-default">
<Text></Text> <Text></Text>
<View onClick={() => setFormData({ ...formData, is_default: !formData.is_default })}> <View onClick={() => setFormData({ ...formData, is_default: !formData.is_default })}>
{formData.is_default {formData.is_default
? ( ? (
<View className="add-address-default-active"> <View className="add-address-default-active">
<Text className="iconfont icon-tick" /> <Text className="iconfont icon-tick" />
</View> </View>
) )
: ( : (
<View className="add-address-default-noactive"></View> <View className="add-address-default-noactive"></View>
)} )}
@ -182,3 +183,5 @@ export default () => {
</View> </View>
) )
} }
export default AddressAdd

View File

@ -3,12 +3,12 @@ import classnames from 'classnames'
import { useEffect, useState } from 'react' import { useEffect, useState } from 'react'
import styles from './index.module.scss' import styles from './index.module.scss'
import Popup from '@/components/popup' import Popup from '@/components/popup'
import type { Params as PopuParams } from '@/components/popup' import type { Params as PopuParams } from '@/components/popup'
type params = { type params = {
onFiltr?: (val: object) => void onFiltr?: (val: object) => void
} & PopuParams } & PopuParams
export default ({ onClose, onFiltr, show = false }: params) => { const Filter = ({ onClose, onFiltr, show = false }: params) => {
const [filterObj, setFilterObj] = useState({ const [filterObj, setFilterObj] = useState({
series: '', series: '',
minWidth: '', minWidth: '',
@ -43,9 +43,9 @@ export default ({ onClose, onFiltr, show = false }: params) => {
const setNumber = (e, field) => { const setNumber = (e, field) => {
console.log(e) console.log(e)
const num = parseFloat(e.detail.value) const num = parseFloat(e.detail.value)
if (isNaN(num)) { if (Number.isNaN(num)) {
filterObj[field] = null filterObj[field] = null
} }
else { else {
filterObj[field] = parseFloat(num.toFixed(2)) filterObj[field] = parseFloat(num.toFixed(2))
} }
@ -156,3 +156,4 @@ export default ({ onClose, onFiltr, show = false }: params) => {
</Popup> </Popup>
) )
} }
export default Filter

View File

@ -2,7 +2,7 @@ import { Input, ScrollView, Text, Textarea, View } from '@tarojs/components'
import Taro, { useRouter } from '@tarojs/taro' import Taro, { useRouter } from '@tarojs/taro'
import classnames from 'classnames' import classnames from 'classnames'
import { useCallback, useEffect, useMemo, useRef, useState } from 'react' import { useCallback, useEffect, useMemo, useRef, useState } from 'react'
import type { ListProps } from '../searchList/components/selectData' import type { ListProps } from '../searchList/components/selectData'
import SelectData from '../searchList/components/selectData' import SelectData from '../searchList/components/selectData'
import styles from './index.module.scss' import styles from './index.module.scss'
import Search from '@/components/search' import Search from '@/components/search'
@ -15,7 +15,7 @@ import { dataLoadingStatus, getFilterData } from '@/common/util'
import LoadingCard from '@/components/loadingCard' import LoadingCard from '@/components/loadingCard'
import useLogin from '@/use/useLogin' import useLogin from '@/use/useLogin'
export default () => { const ClassList = () => {
useLogin() useLogin()
const [showPopup, setShowPopup] = useState(false) const [showPopup, setShowPopup] = useState(false)
@ -70,6 +70,17 @@ export default () => {
return dataLoadingStatus({ list: categoryList.list, total: categoryList.total, status: state.loading }) return dataLoadingStatus({ list: categoryList.list, total: categoryList.total, status: state.loading })
}, [categoryList, state]) }, [categoryList, state])
// 筛选条件格式化
const [selectList, setSelectList] = useState<ListProps[]>()
const formatSelectList = (val = { data: {}, field: {} }) => {
const data: ListProps[] = []
for (const key in val.data) {
if (key !== 'seriesId' && val.data[key] != '') {
data.push({ title: val.field[key], value: val.data[key] })
}
}
setSelectList([...data])
}
// 获取筛选条件 // 获取筛选条件
const getFiltr = (e) => { const getFiltr = (e) => {
pageNum.current.page = 1 pageNum.current.page = 1
@ -85,19 +96,6 @@ export default () => {
}) })
formatSelectList(e) formatSelectList(e)
} }
// 筛选条件格式化
const [selectList, setSelectList] = useState<ListProps[]>()
const formatSelectList = (val = { data: {}, field: {} }) => {
const data: ListProps[] = []
for (const key in val.data) {
if (key !== 'seriesId' && val.data[key] != '') {
data.push({ title: val.field[key], value: val.data[key] })
}
}
setSelectList([...data])
}
// 输入了搜索关键字 // 输入了搜索关键字
const getSearchData = useCallback((e) => { const getSearchData = useCallback((e) => {
pageNum.current.page = 1 pageNum.current.page = 1
@ -148,3 +146,4 @@ export default () => {
</View> </View>
) )
} }
export default ClassList

View File

@ -1,4 +1,3 @@
import { Text, View } from '@tarojs/components'
import Taro, { useDidHide, useDidShow } from '@tarojs/taro' import Taro, { useDidHide, useDidShow } from '@tarojs/taro'
import classnames from 'classnames' import classnames from 'classnames'
import { useCallback, useEffect, useRef, useState } from 'react' import { useCallback, useEffect, useRef, useState } from 'react'
@ -10,7 +9,8 @@ import Search from '@/components/search'
import { getFilterData } from '@/common/util' import { getFilterData } from '@/common/util'
import { alert, goLink } from '@/common/common' import { alert, goLink } from '@/common/common'
import { CreateFavoriteApi, DelFavoriteApi, FavoriteListApi, UpdateFavoriteApi } from '@/api/favorite' import { CreateFavoriteApi, DelFavoriteApi, FavoriteListApi, UpdateFavoriteApi } from '@/api/favorite'
import useLogin from '@/use/useLogin' import useLogin from '@/use/useLogin'
import { View, Text } from '@tarojs/components'
export default () => { export default () => {
useLogin() useLogin()
@ -57,7 +57,7 @@ export default () => {
if (res.success) { if (res.success) {
alert.success('创建成功') alert.success('创建成功')
getFavoriteList() getFavoriteList()
} }
else { else {
alert.error('创建失败') alert.error('创建失败')
} }
@ -95,11 +95,11 @@ export default () => {
if (res.success) { if (res.success) {
alert.success('删除成功') alert.success('删除成功')
getFavoriteList() getFavoriteList()
} }
else { else {
alert.error('删除失败') alert.error('删除失败')
} }
} }
else if (res.cancel) { else if (res.cancel) {
console.log('用户点击取消') console.log('用户点击取消')
} }
@ -120,7 +120,7 @@ export default () => {
alert.success('编辑成功') alert.success('编辑成功')
getFavoriteList() getFavoriteList()
closeUpdate() closeUpdate()
} }
else { else {
alert.error('编辑失败') alert.error('编辑失败')
} }
@ -135,7 +135,7 @@ export default () => {
const onCreatSuccess = (submitData) => { const onCreatSuccess = (submitData) => {
if (!initData.id) { if (!initData.id) {
onCreate(submitData) onCreate(submitData)
} }
else { else {
onUpdate({ ...submitData, id: initData.id }) onUpdate({ ...submitData, id: initData.id })
} }
@ -166,4 +166,4 @@ export default () => {
<CreatePopup defaultValue={initData} show={collectioinShow} onClose={closeCollection} onSuccess={onCreatSuccess} /> <CreatePopup defaultValue={initData} show={collectioinShow} onClose={closeCollection} onSuccess={onCreatSuccess} />
</View> </View>
) )
} }

View File

@ -85,7 +85,7 @@ export default () => {
Taro.eventCenter.trigger('company:detail') Taro.eventCenter.trigger('company:detail')
Taro.navigateBack() Taro.navigateBack()
alert.success('保存成功') alert.success('保存成功')
} }
else { else {
alert.error(result.msg) alert.error(result.msg)
} }
@ -112,7 +112,7 @@ export default () => {
city_id: ev[1]?.id, city_id: ev[1]?.id,
district_id: ev[ev.length - 1]?.id, district_id: ev[ev.length - 1]?.id,
}) })
} }
else { else {
alert.error('请选择完整地址') alert.error('请选择完整地址')
} }

View File

@ -49,7 +49,7 @@ export default () => {
let result let result
if (type == 'Ickname') { if (type == 'Ickname') {
result = await realNameUpdateFetch({ real_name: text }) result = await realNameUpdateFetch({ real_name: text })
} }
else { else {
const params = await getCompanyFetch() const params = await getCompanyFetch()
result = await saveFetch({ result = await saveFetch({
@ -62,7 +62,7 @@ export default () => {
;(ModifyIcknameEl.current as any).setModalShow(false) ;(ModifyIcknameEl.current as any).setModalShow(false)
;(ModifyCompanyNameEl.current as any).setModalShow(false) ;(ModifyCompanyNameEl.current as any).setModalShow(false)
alert.success('保存成功') alert.success('保存成功')
} }
else { else {
alert.none(result.msg) alert.none(result.msg)
} }
@ -93,7 +93,7 @@ export default () => {
if (portraitUpdateResult.success) { if (portraitUpdateResult.success) {
getAdminUserInfo() getAdminUserInfo()
alert.success('保存成功') alert.success('保存成功')
} }
else { else {
alert.none(portraitUpdateResult.msg) alert.none(portraitUpdateResult.msg)
} }
@ -104,7 +104,7 @@ export default () => {
const mGetPhoneNumber = (ev) => { const mGetPhoneNumber = (ev) => {
if (ev.detail?.code) { if (ev.detail?.code) {
getPhoneNumber(ev.detail.code) getPhoneNumber(ev.detail.code)
} }
else { else {
alert.none('绑定失败!') alert.none('绑定失败!')
} }
@ -142,7 +142,7 @@ export default () => {
if (result.success) { if (result.success) {
getAdminUserInfo() getAdminUserInfo()
alert.success('保存成功') alert.success('保存成功')
} }
else { else {
alert.none(result.msg) alert.none(result.msg)
} }
@ -163,7 +163,7 @@ export default () => {
if (item.id == 0) { item.name = '--请选择类型--' } if (item.id == 0) { item.name = '--请选择类型--' }
return item return item
}) })
} }
else { else {
return [] return []
} }
@ -184,12 +184,12 @@ export default () => {
icon="" icon=""
/> />
<UserEditList label="手机号" placeholder="去绑定" icon=""> <UserEditList label="手机号" placeholder="去绑定" icon="">
{(formData as any)?.phone {(formData as any)?.phone
? ( ? (
<View className="user-edit-content-phone"> <View className="user-edit-content-phone">
<View>{(formData as any)?.phone}</View> <View>{(formData as any)?.phone}</View>
</View> </View>
) )
: ( : (
<Button className="user-edit-content-bindphone" openType="getPhoneNumber" onGetPhoneNumber={mGetPhoneNumber}> <Button className="user-edit-content-bindphone" openType="getPhoneNumber" onGetPhoneNumber={mGetPhoneNumber}>

View File

@ -5,7 +5,7 @@ import { weightDeleteApi, weightListApi } from '@/api/weightList'
import './index.scss' import './index.scss'
import Taro, { showModal } from '@tarojs/taro' import Taro, { showModal } from '@tarojs/taro'
import { alert } from '@/common/common' import { alert } from '@/common/common'
import useLogin from '@/use/useLogin' import useLogin from '@/use/useLogin'
const weightListManager = () => { const weightListManager = () => {
useLogin() useLogin()
@ -53,7 +53,7 @@ const WeightList = (props: Params) => {
if (result.success) { if (result.success) {
alert.success('删除成功') alert.success('删除成功')
getData() getData()
} }
else { else {
alert.success(result.msg) alert.success(result.msg)
} }
@ -100,4 +100,4 @@ const WeightList = (props: Params) => {
) )
} }
export default weightListManager export default weightListManager

View File

@ -22,7 +22,7 @@ export default () => {
const res = await GetSign(params) const res = await GetSign(params)
if (res.success) { if (res.success) {
resolve(res.data) resolve(res.data)
} }
else { else {
reject({ reject({
code: res.code || '9999', code: res.code || '9999',
@ -38,10 +38,10 @@ export default () => {
if (RegExp(`.?(${imgType.join('|')})$`, 'i').test(name.toLowerCase())) { if (RegExp(`.?(${imgType.join('|')})$`, 'i').test(name.toLowerCase())) {
return 'image' return 'image'
} }
else if (RegExp(`.(${videoType.join('|')})$`, 'i').test(name.toLowerCase())) { else if (RegExp(`.(${videoType.join('|')})$`, 'i').test(name.toLowerCase())) {
return 'video' return 'video'
} }
else { else {
return false return false
} }
@ -96,7 +96,7 @@ export default () => {
Taro.showLoading({ Taro.showLoading({
title: '上传中...', title: '上传中...',
}) })
} }
else { else {
Taro.hideLoading() Taro.hideLoading()
} }
@ -113,10 +113,10 @@ export default () => {
}) })
} }
// product 产品相关,图片、纹理图等 全平台 // product 产品相关,图片、纹理图等 全平台
// after-sale 售后(申请退货、退款)相关的、图片、视频 全平台 // after-sale 售后(申请退货、退款)相关的、图片、视频 全平台
// mall 电子商城相关的 全平台 // mall 电子商城相关的 全平台
// logistics 物流(发货、提货)相关的、图片、视频 全平台 // logistics 物流(发货、提货)相关的、图片、视频 全平台
type cdn_upload_type_Param = 'product' | 'after-sale' | 'mall' | 'logistics' type cdn_upload_type_Param = 'product' | 'after-sale' | 'mall' | 'logistics'
/** /**
* *
@ -139,13 +139,13 @@ export default () => {
list.push(data) list.push(data)
} }
resolve(list) resolve(list)
} }
else { else {
// 兼容以前上传一张的情况 // 兼容以前上传一张的情况
const data = await uploadCDNImg(res.tempFiles[0], cdn_upload_type, cdn_upload_type) const data = await uploadCDNImg(res.tempFiles[0], cdn_upload_type, cdn_upload_type)
resolve(data) resolve(data)
} }
} }
catch (res) { catch (res) {
reject(res) reject(res)
} }