diff --git a/src/components/filter/index.tsx b/src/components/filter/index.tsx
index 7198974..cdbd37e 100644
--- a/src/components/filter/index.tsx
+++ b/src/components/filter/index.tsx
@@ -4,7 +4,7 @@ import classnames from 'classnames'
import { memo, useEffect, useRef, useState } from 'react'
import styles from './index.module.scss'
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'
type params = {
@@ -83,7 +83,7 @@ export default memo(({ onClose, onFiltr, show = false, onRest }: params) => {
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}
diff --git a/src/components/uploadImage/index.tsx b/src/components/uploadImage/index.tsx
index ebd820a..fd33669 100644
--- a/src/components/uploadImage/index.tsx
+++ b/src/components/uploadImage/index.tsx
@@ -1,6 +1,7 @@
import Taro from '@tarojs/taro'
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 styles from './index.module.scss'
import useUploadCDNImg from '@/use/useUploadImage'
@@ -12,7 +13,7 @@ interface ImageParam {
defaultList?: string[]
onlyRead?: false | true
}
-const PictureItem: FC = memo(({ onChange, defaultList, onlyRead = false }) => {
+const PictureItem = ({ onChange, defaultList, onlyRead = false }: ImageParam) => {
const { getWxPhoto } = useUploadCDNImg()
const [imageList, setImageLise] = useState([])
@@ -24,7 +25,7 @@ const PictureItem: FC = memo(({ onChange, defaultList, onlyRead = fa
const uploadImage = async() => {
const list: any = await getWxPhoto('after-sale', 5)
const images: any[] = []
- list?.map((item) => {
+ list?.forEach((item) => {
images.push(item.url)
})
setImageLise([...imageList, ...images])
@@ -53,7 +54,7 @@ const PictureItem: FC = memo(({ onChange, defaultList, onlyRead = fa
return (
{imageList?.map((item, index) => (
-
+
{!onlyRead && delImage(index)} className={classnames(styles.miconfont_close, 'iconfont icon-qingkong')}>}
@@ -66,6 +67,6 @@ const PictureItem: FC = memo(({ onChange, defaultList, onlyRead = fa
)}
)
-})
+}
-export default PictureItem
+export default memo(PictureItem)
diff --git a/src/pages/addressAdd/index.tsx b/src/pages/addressAdd/index.tsx
index 19be3ca..b5aea16 100644
--- a/src/pages/addressAdd/index.tsx
+++ b/src/pages/addressAdd/index.tsx
@@ -8,19 +8,21 @@ import './index.scss'
import { addressAddApi, addressDetailApi, addressEditApi } from '@/api/addressManager'
import useLogin from '@/use/useLogin'
-export default () => {
+const AddressAdd = () => {
useLogin()
const [showSiteModal, setShowSiteModal] = useState(false)
const { type, id } = useRouter().params
- useEffect(() => {
- if (type == 'add') {
- setNavigationBarTitle({ title: '新增收货地址' })
- }
- else {
- initalFormData()
- setNavigationBarTitle({ title: '编辑收货地址' })
- }
- }, [])
+ // 保存
+ const [formData, setFormData] = useState({
+ name: '',
+ phone: '',
+ site: '',
+ siteArray: [],
+ district_id: '',
+ address_detail: '',
+ is_default: false,
+ id: 0,
+ })
// 获取编辑地址信息
const { fetchData: getFromData } = addressDetailApi()
const initalFormData = async() => {
@@ -43,17 +45,7 @@ export default () => {
const { fetchData } = addressAddApi()
const { fetchData: editFetch } = addressEditApi()
- // 保存
- const [formData, setFormData] = useState({
- name: '',
- phone: '',
- site: '',
- siteArray: [],
- district_id: '',
- address_detail: '',
- is_default: false,
- id: 0,
- })
+
const rules = {
name: [
{
@@ -104,7 +96,7 @@ export default () => {
Taro.eventCenter.trigger('addressList:refresh')
Taro.navigateBack()
alert.success('保存成功')
- }
+ }
else {
alert.error(result.msg)
}
@@ -113,6 +105,15 @@ export default () => {
alert.none(message)
})
}
+ useEffect(() => {
+ if (type == 'add') {
+ setNavigationBarTitle({ title: '新增收货地址' })
+ }
+ else {
+ initalFormData()
+ setNavigationBarTitle({ title: '编辑收货地址' })
+ }
+ }, [])
// 监听表单完善
const [hozon, setHozon] = useState(false)
useEffect(() => {
@@ -131,7 +132,7 @@ export default () => {
site: ev.map(item => `${item.name} `),
district_id: ev[ev.length - 1]?.id,
})
- }
+ }
else {
alert.error('请选择地址')
}
@@ -163,12 +164,12 @@ export default () => {
设为默认地址
setFormData({ ...formData, is_default: !formData.is_default })}>
- {formData.is_default
+ {formData.is_default
? (
- )
+ )
: (
)}
@@ -182,3 +183,5 @@ export default () => {
)
}
+
+export default AddressAdd
diff --git a/src/pages/classList/components/filter/index.tsx b/src/pages/classList/components/filter/index.tsx
index e92e4fa..981ec47 100644
--- a/src/pages/classList/components/filter/index.tsx
+++ b/src/pages/classList/components/filter/index.tsx
@@ -3,12 +3,12 @@ import classnames from 'classnames'
import { useEffect, useState } from 'react'
import styles from './index.module.scss'
import Popup from '@/components/popup'
-import type { Params as PopuParams } from '@/components/popup'
+import type { Params as PopuParams } from '@/components/popup'
type params = {
onFiltr?: (val: object) => void
} & PopuParams
-export default ({ onClose, onFiltr, show = false }: params) => {
+const Filter = ({ onClose, onFiltr, show = false }: params) => {
const [filterObj, setFilterObj] = useState({
series: '',
minWidth: '',
@@ -43,9 +43,9 @@ export default ({ onClose, onFiltr, show = false }: params) => {
const setNumber = (e, field) => {
console.log(e)
const num = parseFloat(e.detail.value)
- if (isNaN(num)) {
+ if (Number.isNaN(num)) {
filterObj[field] = null
- }
+ }
else {
filterObj[field] = parseFloat(num.toFixed(2))
}
@@ -156,3 +156,4 @@ export default ({ onClose, onFiltr, show = false }: params) => {
)
}
+export default Filter
diff --git a/src/pages/classList/index.tsx b/src/pages/classList/index.tsx
index afc0a20..28426d0 100644
--- a/src/pages/classList/index.tsx
+++ b/src/pages/classList/index.tsx
@@ -2,7 +2,7 @@ import { Input, ScrollView, Text, Textarea, View } from '@tarojs/components'
import Taro, { useRouter } from '@tarojs/taro'
import classnames from 'classnames'
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 styles from './index.module.scss'
import Search from '@/components/search'
@@ -15,7 +15,7 @@ import { dataLoadingStatus, getFilterData } from '@/common/util'
import LoadingCard from '@/components/loadingCard'
import useLogin from '@/use/useLogin'
-export default () => {
+const ClassList = () => {
useLogin()
const [showPopup, setShowPopup] = useState(false)
@@ -70,6 +70,17 @@ export default () => {
return dataLoadingStatus({ list: categoryList.list, total: categoryList.total, status: state.loading })
}, [categoryList, state])
+ // 筛选条件格式化
+ const [selectList, setSelectList] = useState()
+ 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) => {
pageNum.current.page = 1
@@ -85,19 +96,6 @@ export default () => {
})
formatSelectList(e)
}
-
- // 筛选条件格式化
- const [selectList, setSelectList] = useState()
- 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) => {
pageNum.current.page = 1
@@ -148,3 +146,4 @@ export default () => {
)
}
+export default ClassList
diff --git a/src/pages/collection/index.tsx b/src/pages/collection/index.tsx
index bd29baa..738c309 100644
--- a/src/pages/collection/index.tsx
+++ b/src/pages/collection/index.tsx
@@ -1,4 +1,3 @@
-import { Text, View } from '@tarojs/components'
import Taro, { useDidHide, useDidShow } from '@tarojs/taro'
import classnames from 'classnames'
import { useCallback, useEffect, useRef, useState } from 'react'
@@ -10,7 +9,8 @@ import Search from '@/components/search'
import { getFilterData } from '@/common/util'
import { alert, goLink } from '@/common/common'
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 () => {
useLogin()
@@ -57,7 +57,7 @@ export default () => {
if (res.success) {
alert.success('创建成功')
getFavoriteList()
- }
+ }
else {
alert.error('创建失败')
}
@@ -95,11 +95,11 @@ export default () => {
if (res.success) {
alert.success('删除成功')
getFavoriteList()
- }
+ }
else {
alert.error('删除失败')
}
- }
+ }
else if (res.cancel) {
console.log('用户点击取消')
}
@@ -120,7 +120,7 @@ export default () => {
alert.success('编辑成功')
getFavoriteList()
closeUpdate()
- }
+ }
else {
alert.error('编辑失败')
}
@@ -135,7 +135,7 @@ export default () => {
const onCreatSuccess = (submitData) => {
if (!initData.id) {
onCreate(submitData)
- }
+ }
else {
onUpdate({ ...submitData, id: initData.id })
}
@@ -166,4 +166,4 @@ export default () => {
)
-}
+}
diff --git a/src/pages/company/index.tsx b/src/pages/company/index.tsx
index be09555..955d420 100644
--- a/src/pages/company/index.tsx
+++ b/src/pages/company/index.tsx
@@ -85,7 +85,7 @@ export default () => {
Taro.eventCenter.trigger('company:detail')
Taro.navigateBack()
alert.success('保存成功')
- }
+ }
else {
alert.error(result.msg)
}
@@ -112,7 +112,7 @@ export default () => {
city_id: ev[1]?.id,
district_id: ev[ev.length - 1]?.id,
})
- }
+ }
else {
alert.error('请选择完整地址')
}
diff --git a/src/pages/userEdit/index.tsx b/src/pages/userEdit/index.tsx
index ac758b3..9d4ca93 100644
--- a/src/pages/userEdit/index.tsx
+++ b/src/pages/userEdit/index.tsx
@@ -49,7 +49,7 @@ export default () => {
let result
if (type == 'Ickname') {
result = await realNameUpdateFetch({ real_name: text })
- }
+ }
else {
const params = await getCompanyFetch()
result = await saveFetch({
@@ -62,7 +62,7 @@ export default () => {
;(ModifyIcknameEl.current as any).setModalShow(false)
;(ModifyCompanyNameEl.current as any).setModalShow(false)
alert.success('保存成功')
- }
+ }
else {
alert.none(result.msg)
}
@@ -93,7 +93,7 @@ export default () => {
if (portraitUpdateResult.success) {
getAdminUserInfo()
alert.success('保存成功')
- }
+ }
else {
alert.none(portraitUpdateResult.msg)
}
@@ -104,7 +104,7 @@ export default () => {
const mGetPhoneNumber = (ev) => {
if (ev.detail?.code) {
getPhoneNumber(ev.detail.code)
- }
+ }
else {
alert.none('绑定失败!')
}
@@ -142,7 +142,7 @@ export default () => {
if (result.success) {
getAdminUserInfo()
alert.success('保存成功')
- }
+ }
else {
alert.none(result.msg)
}
@@ -163,7 +163,7 @@ export default () => {
if (item.id == 0) { item.name = '--请选择类型--' }
return item
})
- }
+ }
else {
return []
}
@@ -184,12 +184,12 @@ export default () => {
icon=""
/>
- {(formData as any)?.phone
+ {(formData as any)?.phone
? (
{(formData as any)?.phone}
- )
+ )
: (