🐳 chore(eslint): 修正所有文件的eslint 错误❌

This commit is contained in:
xuan
2022-11-28 11:06:15 +08:00
parent 99a920975f
commit cc99111b4f
149 changed files with 3270 additions and 3252 deletions
+10 -10
View File
@@ -2,11 +2,11 @@
import { Button, Navigator, ScrollView, Text, View } from '@tarojs/components'
import { forwardRef, memo, useEffect, useImperativeHandle, useState } from 'react'
import './index.scss'
import { mppurchaseraddresslist } from '@/api/addressList'
import { MpPurchaserAddressList } from '@/api/addressList'
import { alert } from '@/common/common'
import Taro, { showModal, useDidShow, useRouter } from '@tarojs/taro'
import IconFont from '@/components/iconfont/iconfont'
import { mpsaleOrderaddress } from '@/api/order'
import { MpSaleOrderAddress } from '@/api/order'
interface Params {
refresherEnabled?: boolean// 是否开启刷新
@@ -19,12 +19,14 @@ interface Params {
}
// 地址列表
const AddressList = memo(forwardRef((props: Params, AddressListRef) => {
const AddressList = (props: Params, AddressListRef) => {
const pages = Taro.getCurrentPages() // 获取当前的页面栈
const prevPage = pages[pages.length - 2]
// 焦点
const [focusId, setFocusId] = useState()
const { addButtonEnabled = true, focusBorderEnabled = false } = props
const { fetchData, state } = mppurchaseraddresslist()
const { fetchData, state } = MpPurchaserAddressList()
// 获取数据
const getData = async() => {
const result = await fetchData({ purchaser_id: props.purchaser_id })
@@ -64,12 +66,10 @@ const AddressList = memo(forwardRef((props: Params, AddressListRef) => {
setRefreshState(false)
}
const data = Array.from({ length: 15 })
// 焦点
const [focusId, setFocusId] = useState()
const router = useRouter()
const [addressObj, setAddressObj] = useState<any>({})
// 列表选择
const { fetchData: selectFetch } = mpsaleOrderaddress()
const { fetchData: selectFetch } = MpSaleOrderAddress()
const handleSelect = async(item: any, index: number) => {
if (router.params.orderId && router.params.orderId != '-100') {
console.log(typeof (router.params.orderId) != 'undefined', 'router.params.orderId')
@@ -126,7 +126,7 @@ const AddressList = memo(forwardRef((props: Params, AddressListRef) => {
// data.length>0?
// data.map((item,index)=>{
return (
<View onClick={() => handleSelect(item, index)} className={`address-list ${focusId == item.id && 'address-active'}`}>
<View key={index} onClick={() => handleSelect(item, index)} className={`address-list ${focusId == item.id && 'address-active'}`}>
<View className="address-user">
{item.name}
<Text className="address-list-phone">{item.phone}</Text>
@@ -164,6 +164,6 @@ const AddressList = memo(forwardRef((props: Params, AddressListRef) => {
{addButtonEnabled && <Navigator url={`/pages/addAddress/index?type=add&purchaser_id=${Number(props.purchaser_id)}`} hoverClass="none" className="add-address">添加收货地址</Navigator>}
</View>
)
}))
}
export default AddressList
export default memo(forwardRef(AddressList))
+3 -3
View File
@@ -20,8 +20,7 @@ interface prosObj {
showDetail?: boolean
goodsObj?: any
}
export default memo(forwardRef((props: prosObj, ref) => {
const BottomBtns = (props: prosObj, ref) => {
const {
obj = {
sale_mode: 0,
@@ -192,4 +191,5 @@ export default memo(forwardRef((props: prosObj, ref) => {
</View>
)
}))
}
export default memo(forwardRef(BottomBtns))
+3 -3
View File
@@ -10,8 +10,7 @@ interface prosObj {
clientId?: Number
clientName?: string
}
export default memo((props: prosObj) => {
const BottomCustomer = (props: prosObj) => {
const {
isDisabled = true,
handSure,
@@ -32,4 +31,5 @@ export default memo((props: prosObj) => {
<Button className={classnames(isDisabled ? styles.activeButton : styles.button)} disabled={isDisabled} onClick={() => { handSure?.() }}> 加入购物车</Button >
</View >
)
})
}
export default memo(BottomCustomer)
+4 -8
View File
@@ -19,7 +19,7 @@ interface ListParams{
}
// 表单列表
const FromList = memo((props: ListParams) => {
const FromList = (props: ListParams) => {
const { type = 'input', value = '', style = {}, labelStyle = {}, contentStyle = {}, required = false } = props
return (
@@ -37,11 +37,11 @@ const FromList = memo((props: ListParams) => {
&& <View><Text onClick={() => props.onInput && props.onInput({ detail: { value: '' } })} className="iconfont icon-qingkong" /></View>
}
</View>
: type == 'textarea'
: type == 'textarea'
? <Textarea value={value} placeholder-class="phcolor" onInput={props?.onInput} placeholder={props.placeholder} />
: <>
{
props.value
props.value
? <View>{value}</View>
: <View className="form-list-right-placeholder">
{props.placeholder}
@@ -55,9 +55,5 @@ const FromList = memo((props: ListParams) => {
</View>
</View>
)
})
const A = () => {
}
export default FromList
export default memo(FromList)
+7 -10
View File
@@ -17,9 +17,7 @@ interface ListParams{
required?: boolean
showIcon?: boolean // 是否显示右边的箭头,type=select
}
// 表单列表
const FromList = memo((props: ListParams) => {
const FromListCertification = (props: ListParams) => {
const { type = 'input', value = '', style = {}, labelStyle = {}, contentStyle = {}, required = false, showIcon = true } = props
return (
@@ -37,11 +35,11 @@ const FromList = memo((props: ListParams) => {
&& <View><Text onClick={() => props.onInput && props.onInput({ detail: { value: '' } })} className="iconfont icon-qingkong" /></View>
}
</View>
: type == 'textarea'
: type == 'textarea'
? <Textarea value={value} placeholder-class="phcolor" onInput={props?.onInput} placeholder={props.placeholder} />
: <>
{
props.value
props.value
? <View>{value}</View>
: <View className="From-list-certification-right-placeholder">
{props.placeholder}
@@ -57,9 +55,8 @@ const FromList = memo((props: ListParams) => {
</View>
</View>
)
})
const A = () => {
}
export default FromList
// 表单列表
const FromList = memo(FromListCertification)
export default FromList
+33 -32
View File
@@ -1,4 +1,4 @@
import type { ReactNode } from 'react'
import type { ReactNode } from 'react'
import { useEffect, useMemo, useRef, useState } from 'react'
import InfiniteScroll from '@/components/infiniteScroll'
import { dataLoadingStatus, getFilterData } from '@/common/util'
@@ -10,20 +10,23 @@ interface Params {
fetchData: (data: object) => any
change?: (data: any) => void
}
export default (props: Params) => {
const InfiniteScrollPaging = (props: Params) => {
const { query = {} } = props
useEffect(() => {
refreshDataRef.current = refreshData
dataRef.current = data
getData({ moreStatus: true }, { moreStatus: true })
}, [])
useEffect(() => {
if (!isEmptyObject(query)) {
setData({ list: [], total: 0 })
getData({ moreStatus: true }, { moreStatus: true })
}
}, [query])
// 加载刷新数据
const [refreshData, setRefreshData] = useState({
refreshStatus: false,
moreStatus: false,
page: 1,
size: 10,
loading: false,
})
const refreshDataRef = useRef({})
// 渲染(数据)
const [data, setData] = useState({
list: [],
total: 0,
})
const getData = async(startStatus, endStatus) => {
const tRefreshDataRef = refreshDataRef.current as any
setRefreshData({
@@ -45,7 +48,7 @@ export default (props: Params) => {
...endStatus,
loading: false,
})
}
}
else {
setData({
list: result.data.list,
@@ -59,7 +62,7 @@ export default (props: Params) => {
loading: false,
})
}
}
}
else {
alert.none(result.msg)
setRefreshData({
@@ -70,20 +73,6 @@ export default (props: Params) => {
})
}
}
// 加载刷新数据
const [refreshData, setRefreshData] = useState({
refreshStatus: false,
moreStatus: false,
page: 1,
size: 10,
loading: false,
})
const refreshDataRef = useRef({})
// 渲染(数据)
const [data, setData] = useState({
list: [],
total: 0,
})
const dataRef = useRef({})
// 下拉刷新
const handleRefresh = async() => {
@@ -119,7 +108,17 @@ export default (props: Params) => {
const statusMore = useMemo(() => {
return dataLoadingStatus({ list: data.list, total: data.total, status: refreshData.loading })
}, [refreshData.loading])
useEffect(() => {
refreshDataRef.current = refreshData
dataRef.current = data
getData({ moreStatus: true }, { moreStatus: true })
}, [])
useEffect(() => {
if (!isEmptyObject(query)) {
setData({ list: [], total: 0 })
getData({ moreStatus: true }, { moreStatus: true })
}
}, [query])
return (
<InfiniteScroll
refresherEnabled
@@ -127,9 +126,11 @@ export default (props: Params) => {
moreStatus={refreshData.moreStatus}
selfOnRefresherRefresh={handleRefresh}
selfonScrollToLower={handleMoreLoad}
statusMore={statusMore}
statusMore={statusMore}
>
{props.children}
</InfiniteScroll>
)
}
export default InfiniteScrollPaging
+5 -6
View File
@@ -1,10 +1,8 @@
import { Image, View } from '@tarojs/components'
import Taro from '@tarojs/taro'
import { memo, useCallback, useEffect, useMemo, useState } from 'react'
import LabAndImgShow from '../LabAndImgShow'
import styles from './index.module.scss'
import Preview from '@/pages/details/components/preview'
import { formatImgUrl, formatRemoveHashTag } from '@/common/format'
import { formatImgUrl } from '@/common/format'
// 该组件宽高为100%需调整外层元素宽高
interface Param {
@@ -17,14 +15,14 @@ interface Param {
showStatus?: true | false
onClick?: (val: Param['value']) => void
}
export default memo(({ value, onClick, showStatus = false }: Param) => {
const LabAndImg = ({ value, onClick, showStatus = false }: Param) => {
const [imgs, setImgs] = useState<string[]>([])
// lab是否都是0
const rgbStyle = useMemo(() => {
if (value?.lab && (value.lab.l || value.lab.a || value.lab.b)) {
return { backgroundColor: `rgb(${value.rgb?.r} ${value.rgb?.g} ${value.rgb?.b})` }
}
}
else {
return null
}
@@ -63,4 +61,5 @@ export default memo(({ value, onClick, showStatus = false }: Param) => {
<LabAndImgShow value={value} show={labAndImgShow} onClose={closeLabAndImgShow} />
</>
)
})
}
export default memo(LabAndImg)
+9 -9
View File
@@ -15,20 +15,14 @@ export interface colorParams {
onClose?: () => void
showNumber?: number // 图片显示张数,0不限制
}
export default ({ value, show = false, onClose, showNumber = 1 }: colorParams) => {
useEffect(() => {
if (show && rgbStyle) { setLabShow(() => true) }
if (show && value?.texture_url) { onShowImage() }
if (!show) { setLabShow(() => false) }
}, [show])
const LabAndImgShow = ({ value, show = false, onClose, showNumber = 1 }: colorParams) => {
// 显示颜色
const [labShow, setLabShow] = useState(false)
// lab是否都是0
const rgbStyle = useMemo(() => {
if (value?.lab && (value.lab.l || value.lab.a || value.lab.b)) {
return { backgroundColor: `rgb(${value.rgb?.r} ${value.rgb?.g} ${value.rgb?.b})` }
}
}
else {
return null
}
@@ -49,7 +43,11 @@ export default ({ value, show = false, onClose, showNumber = 1 }: colorParams) =
urls: n_res,
})
}
useEffect(() => {
if (show && rgbStyle) { setLabShow(() => true) }
if (show && value?.texture_url) { onShowImage() }
if (!show) { setLabShow(() => false) }
}, [show])
return (
<>
{labShow && (
@@ -63,3 +61,5 @@ export default ({ value, show = false, onClose, showNumber = 1 }: colorParams) =
</>
)
}
export default LabAndImgShow
+3 -3
View File
@@ -8,12 +8,12 @@ interface Params{
}
// 消息提示
const Message = memo((props: Params) => {
const Message = (props: Params) => {
return (
<View className="message-custom-tips">
<Text className="iconfont icon-zhuyi"></Text> {props.text}
</View>
)
})
}
export default Message
export default memo(Message)
+12 -13
View File
@@ -17,15 +17,9 @@ interface Props {
showPopup: boolean
popupClose: () => void
}
export default memo((props: Props) => {
const RefundCodelist = (props: Props) => {
const { fetchData: payFetch } = GetReturnPayCode()
const [PicUrl, setPicUrl] = useState<string>('')
useEffect(() => {
// 判断进来的是否是空对象,减少性能问题
const length = Object.keys(props.obj)
if (length.length > 0) { getPic() }
}, [props.obj])
const getPic = async() => {
Taro.showLoading({
@@ -142,11 +136,12 @@ export default memo((props: Props) => {
// 检查是否开启保存图片权限
const { check } = useCheckAuthorize({ scope: 'scope.writePhotosAlbum', msg: '您没授权,无法保存图片' })
const saveImageCheck = async() => {
const res = await check()
res && saveImage()
}
useEffect(() => {
// 判断进来的是否是空对象,减少性能问题
const length = Object.keys(props.obj)
if (length.length > 0) { getPic() }
}, [props.obj])
// 保存图片
const saveImage = () => {
const time = new Date().valueOf()
@@ -171,7 +166,10 @@ export default memo((props: Props) => {
},
})
}
const saveImageCheck = async() => {
const res = await check()
res && saveImage()
}
return (
<Popup show={props.showPopup} title="退款码单" onClose={() => props.popupClose?.()}>
<View className={styles.popupBox}>
@@ -184,4 +182,5 @@ export default memo((props: Props) => {
</View>
</Popup>
)
})
}
export default memo(RefundCodelist)
+2 -2
View File
@@ -15,7 +15,7 @@ interface PropsType {
onSelect?: (data: { id: number; name: string }) => void
}
const segmentedControl: FC<PropsType> = (props) => {
const SegmentedControl: FC<PropsType> = (props) => {
const [selectInfo, setSelectInfo] = useState({
selected: -1, // 当前选中的id
tabId: '', // 需要滚动到的id
@@ -69,4 +69,4 @@ const segmentedControl: FC<PropsType> = (props) => {
</View>
)
}
export default segmentedControl
export default SegmentedControl
@@ -18,20 +18,20 @@ interface EnumList {
name: string
}
// 营销部门
const SelectSaleType = memo(forwardRef((props: SelectSaleTypeProps, ref) => {
const SelectSaleType = (props: SelectSaleTypeProps, ref) => {
const selectName = '营销部门'
const { onChange, onCloseOverlay } = props
console.log(props)
const { fetchData } = EnumMarketingDepartmentApi()
const [enumList, setEnumList] = useState<EnumList[]>([])
const getData = async() => {
const res = await fetchData()
setEnumList([{ id: -1, code: '', name: '全部' }, ...res.data.list])
}
const [enumList, setEnumList] = useState<EnumList[]>([])
useEffect(() => {
getData()
}, [])
@@ -67,9 +67,9 @@ const SelectSaleType = memo(forwardRef((props: SelectSaleTypeProps, ref) => {
<DropDownItem title={displayTitle} value={currentValue} activeColor="#337fff" ref={dropDownRef} onCloseOverlay={onCloseOverlay}>
<View className={styles.grid}>
{!!enumList.length
&& enumList.map((item: EnumList) => {
&& enumList.map((item: EnumList, key) => {
return (
<FilterButton isActive={item.id === currentValue} onClick={() => handleClick(item.id)}>
<FilterButton key={key} isActive={item.id === currentValue} onClick={() => handleClick(item.id)}>
{item.name}
</FilterButton>
)
@@ -77,5 +77,5 @@ const SelectSaleType = memo(forwardRef((props: SelectSaleTypeProps, ref) => {
</View>
</DropDownItem>
)
}))
export default SelectSaleType
}
export default memo(forwardRef(SelectSaleType))
@@ -22,20 +22,19 @@ interface EnumList {
name: string
}
// 销售排行指标
const SelectSaleRankingIndicators: FC<SelectSaleTypeProps> = memo((props) => {
const SelectSaleRankingIndicators: FC<SelectSaleTypeProps> = (props) => {
const selectName = '排行指标'
const { onChange, dropDownStyle, dropDownClassName } = props
console.log(props)
const { fetchData } = SaleOrderDataFormdataFormStatus()
const [enumList, setEnumList] = useState<EnumList[]>([])
const getData = async() => {
const res = await fetchData()
setEnumList([{ id: -1, code: '', name: '全部' }, ...res.data.list])
}
const [enumList, setEnumList] = useState<EnumList[]>([])
useEffect(() => {
getData()
}, [])
@@ -58,9 +57,9 @@ const SelectSaleRankingIndicators: FC<SelectSaleTypeProps> = memo((props) => {
<DropDownItem title={displayTitle} customClassName={dropDownClassName} customStyle={dropDownStyle} value={currentValue} activeColor="#337fff" showOverlay={false}>
<View className={classnames(styles.grid)}>
{!!enumList.length
&& enumList.map((item: EnumList) => {
&& enumList.map((item: EnumList, key) => {
return (
<FilterButton isActive={item.id === currentValue} onClick={() => handleClick(item.id)}>
<FilterButton key={key} isActive={item.id === currentValue} onClick={() => handleClick(item.id)}>
{item.name}
</FilterButton>
)
@@ -68,5 +67,5 @@ const SelectSaleRankingIndicators: FC<SelectSaleTypeProps> = memo((props) => {
</View>
</DropDownItem>
)
})
export default SelectSaleRankingIndicators
}
export default memo(SelectSaleRankingIndicators)
+6 -7
View File
@@ -19,19 +19,18 @@ interface EnumList {
name: string
}
// 销售类型
const SelectSaleType = memo(forwardRef((props: SelectSaleTypeProps, ref) => {
const SelectSaleType = (props: SelectSaleTypeProps, ref) => {
const selectName = '销售类型'
const { onChange, defaultValue = 0, onCloseOverlay } = props
console.log(props)
const { fetchData } = EnumSalesTypeApi()
const [enumList, setEnumList] = useState<EnumList[]>([])
const getData = async() => {
const res = await fetchData()
setEnumList([{ id: -1, code: '', name: '全部' }, ...res.data.list])
}
const [enumList, setEnumList] = useState<EnumList[]>([])
useEffect(() => {
getData()
}, [])
@@ -68,9 +67,9 @@ const SelectSaleType = memo(forwardRef((props: SelectSaleTypeProps, ref) => {
<DropDownItem title={displayTitle} value={currentValue} activeColor="#337fff" ref={dropDownRef} onCloseOverlay={onCloseOverlay}>
<View className={styles.grid}>
{!!enumList.length
&& enumList.map((item: EnumList) => {
&& enumList.map((item: EnumList, key) => {
return (
<FilterButton isActive={item.id === currentValue} onClick={() => handleClick(item.id)}>
<FilterButton key={key} isActive={item.id === currentValue} onClick={() => handleClick(item.id)}>
{item.name}
</FilterButton>
)
@@ -78,5 +77,5 @@ const SelectSaleType = memo(forwardRef((props: SelectSaleTypeProps, ref) => {
</View>
</DropDownItem>
)
}))
export default SelectSaleType
}
export default memo(forwardRef(SelectSaleType))
+6 -6
View File
@@ -78,7 +78,7 @@ const FilterTimeOptions = {
type Key = keyof typeof FilterTimeOptions
type Value = typeof FilterTimeOptions[Key]
const SelectTimePicker = memo(forwardRef((props: SelectSaleTypeProps, ref) => {
const SelectTimePicker = (props: SelectSaleTypeProps, ref) => {
const { onChange: change, onCloseOverlay, defaultValue = '0', timeOptions = FilterTimeOptions } = props
// rerender 的时候需要更新 ref 的值
const Options = useRef({ ...timeOptions, custom: FilterTimeOptions.custom })
@@ -98,6 +98,7 @@ const SelectTimePicker = memo(forwardRef((props: SelectSaleTypeProps, ref) => {
const handClose = () => {
setShowTime(false)
}
const customFilterButtonText = useRef('自定义时间')
const handleClick = (key: Key) => {
setCurrentValue(key)
@@ -118,7 +119,6 @@ const SelectTimePicker = memo(forwardRef((props: SelectSaleTypeProps, ref) => {
}
// const [customFilterButtonText, setCustomFilterButtonText] = useState('自定义时间')
const customFilterButtonText = useRef('自定义时间')
// 点击自定义时间
const handleCustomTime = () => {
@@ -151,9 +151,9 @@ const SelectTimePicker = memo(forwardRef((props: SelectSaleTypeProps, ref) => {
<View className={styles.grid} style={{ paddingBottom: '24rpx' }}>
{Object.entries(Options.current)
.slice(0, -1)
.map(([key, value]) => {
.map(([key, value], index) => {
return (
<FilterButton isActive={key === currentValue} onClick={() => handleClick(key as Key)}>
<FilterButton key={index} isActive={key === currentValue} onClick={() => handleClick(key as Key)}>
{value.name}
</FilterButton>
)
@@ -167,5 +167,5 @@ const SelectTimePicker = memo(forwardRef((props: SelectSaleTypeProps, ref) => {
<TimePickerPopup start={currentDate.start} end={currentDate.end} showTime={showTime} closePopup={handClose} onSelectDate={onSelectDate}></TimePickerPopup>
</>
)
}))
export default SelectTimePicker
}
export default memo(forwardRef(SelectTimePicker))
+7 -7
View File
@@ -20,8 +20,7 @@ interface Param {
fixedBottom?: true|false // 是否固定在底部
}
export default memo(({ orderInfo, onClick, fixedBottom = true }: Param) => {
const AfterOrderBtns = ({ orderInfo, onClick, fixedBottom = true }: Param) => {
// 售后订单状态
const {
ReturnStageApplying,
@@ -92,10 +91,10 @@ export default memo(({ orderInfo, onClick, fixedBottom = true }: Param) => {
const submitBtns = throttle((val, index) => {
if (val == 1) {
cancelOrder({ title: '要取消退货吗?', val })
}
}
else if (val == 6) {
cancelOrder({ title: '要取消退款吗?', val })
}
}
else {
onClick?.(val)
}
@@ -112,11 +111,11 @@ export default memo(({ orderInfo, onClick, fixedBottom = true }: Param) => {
if (res.success) {
alert.success('取消成功')
onClick?.(val)
}
}
else {
alert.none(res.msg)
}
}
}
else if (res.cancel) {
console.log('用户点击取消')
}
@@ -155,4 +154,5 @@ export default memo(({ orderInfo, onClick, fixedBottom = true }: Param) => {
</View>}
</>
)
})
}
export default memo(AfterOrderBtns)
+3 -2
View File
@@ -8,7 +8,7 @@ interface Param {
number: number // 数字
status: 0 | 1 | 2 // 0 小型,1中型,2大
}
export default memo(({ number = 0, status = 1 }: Param) => {
const AmountShow = ({ number = 0, status = 1 }: Param) => {
const priceDom = useCallback(() => {
const res = number.toFixed(2).split('.')
const int_num = `${parseInt(res[0])}`
@@ -22,4 +22,5 @@ export default memo(({ number = 0, status = 1 }: Param) => {
)
}, [number])
return <View className={classnames(styles.order_price_num, status == 1 && styles.emphasis_num, status == 2 && styles.emphasis_num_big)}>{priceDom()}</View>
})
}
export default memo(AmountShow)
+7 -7
View File
@@ -12,25 +12,23 @@ interface params {
swiperOnClick?: (val: item) => void
style?: Object
}
export default (props: params) => {
const Banner = (props: params) => {
const { swiperOnClick, style = {} } = props
const [list, setList] = useState<any[]>([])
const { fetchData, state } = GetBannerList()
useEffect(() => {
getData()
}, [])
const getData = async() => {
const res = await fetchData()
setList(res.data?.list)
}
useEffect(() => {
getData()
}, [])
const skipTo = (item) => {
if (item.jump_type == 2 || item.jump_type == 0) {
goLink(`${item.link}&title=${item.title}`)
}
}
else {
goLink(item.link)
}
@@ -52,3 +50,5 @@ export default (props: params) => {
</View>
)
}
export default Banner
+3 -1
View File
@@ -8,7 +8,7 @@ interface params {
show?: true | false
onClose?: () => void
}
export default ({ show, onClose }: params) => {
const BindSalesManPopUp = ({ show, onClose }: params) => {
const onCustomer = async() => {
const res = await Taro.showModal({
title: '是否拨打服务热线',
@@ -54,3 +54,5 @@ export default ({ show, onClose }: params) => {
</>
)
}
export default BindSalesManPopUp
+35 -29
View File
@@ -12,8 +12,7 @@ interface params {
onOff: () => void
onFind: () => void
}
export default memo(({ state, show = false, onClose, onLink, onOff, onFind }: params) => {
const Popup = ({ state, show = false, onClose, onLink, onOff, onFind }: params) => {
const [popupShow, setPopupShow] = useState(show)
useEffect(() => {
setPopupShow(show)
@@ -31,38 +30,44 @@ export default memo(({ state, show = false, onClose, onLink, onOff, onFind }: pa
<View className={style.list}>
<ScrollView scrollY className={style.scroll}>
{
(state.devices && state.devices.length > 0) && state?.devices.map((item) => {
return (
<View className={style.item} onClick={() => onLink(item)}>
<View>{item.name}</View>
{
(!state.connecting && !state.connected) && <View >链接</View>
|| (state.connecting && item.deviceId == state.connecting.deviceId) && <View className={style.link_ing}>正在链接...</View>
|| (state.connected && item.deviceId == state.connected.deviceId) && <View className={style.link_success}>链接成功</View>
}
</View>
)
})
|| <View className={style.noDevice}>
{
(!state.discovering) && <>
<View>暂无设备,请按以下条件检查</View>
<View className={style.n_item}>1.请确保取色仪处于激活状态</View>
<View className={style.n_item}>2.请确保取色仪没有链接其他设备</View>
<View className={style.n_item}>3.请打开手机定位</View>
</>
|| <View>设备搜索中</View>
}
(state.devices && state.devices.length > 0)
? state?.devices.map((item, key) => {
return (
<View className={style.item} onClick={() => onLink(item)} key={key}>
<View>{item.name}</View>
{
(!state.connecting && !state.connected)
? <View >链接</View>
: (state.connecting && (item.deviceId == state.connecting.deviceId))
? <View className={style.link_ing}>正在链接...</View>
: (state.connected && (item.deviceId == state.connected.deviceId)) ? <View className={style.link_success}>链接成功</View> : null
}
</View>
)
})
: <View className={style.noDevice}>
{
(!state.discovering)
? <>
<View>暂无设备,请按以下条件检查</View>
<View className={style.n_item}>1.请确保取色仪处于激活状态</View>
<View className={style.n_item}>2.请确保取色仪没有链接其他设备</View>
<View className={style.n_item}>3.请打开手机定位</View>
</>
: <View>设备搜索中</View>
}
</View>
</View>
}
</ScrollView>
</View>
{
state.connected && <View className={`${style.footer} ${style.footer_off}`} onClick={onOff}>断开链接</View>
|| (!state.connected && state.discovering) && <View className={`${style.footer} ${style.finding}`}>搜索中<Loading width={30} color="orange" /></View>
|| <View className={style.footer} onClick={onFind}>重新搜索</View>
state.connected
? <View className={`${style.footer} ${style.footer_off}`} onClick={onOff}>断开链接</View>
: (!state.connected && state.discovering)
? <View className={`${style.footer} ${style.finding}`}>搜索中<Loading width={30} color="orange" /></View>
: <View className={style.footer} onClick={onFind}>重新搜索</View>
}
</View>
<View className={style.mask} onClick={onCloseListener}></View>
@@ -70,4 +75,5 @@ export default memo(({ state, show = false, onClose, onLink, onOff, onFind }: pa
}
</>
)
})
}
export default memo(Popup)
+4 -3
View File
@@ -22,7 +22,7 @@ interface params {
customClassName?: string
customTextClass?: string
}
export default forwardRef((props: params, ref) => {
const Checkbox = (props: params, ref) => {
const {
onSelect,
onClose,
@@ -61,7 +61,7 @@ export default forwardRef((props: params, ref) => {
const res = !selected
if (res) {
onSelect?.()
}
}
else {
onClose?.()
}
@@ -116,4 +116,5 @@ export default forwardRef((props: params, ref) => {
)}
</View>
)
})
}
export default forwardRef(Checkbox)
+24 -21
View File
@@ -16,7 +16,7 @@ interface params {
unit?: string
disable?: boolean // 是否禁用
}
export default ({ minNum = 0, maxNum = 10000, step = 1, digits = 0, defaultNum = 0, onChange: onValueChange, onBlue, onClickBtn, unit = '', disable = false }: params) => {
const Counter = ({ minNum = 0, maxNum = 10000, step = 1, digits = 0, defaultNum = 0, onChange: onValueChange, onBlue, onClickBtn, unit = '', disable = false }: params) => {
const [value, setValue] = usePropsValue<number>({
value: defaultNum,
defaultValue: defaultNum,
@@ -24,6 +24,19 @@ export default ({ minNum = 0, maxNum = 10000, step = 1, digits = 0, defaultNum =
onValueChange && onValueChange(nextValue)
},
})
// 保留小数
const formatDigits = (num) => {
num = `${num}`
if (num.includes('.') && digits > 0) {
console.log('num::', num.includes('.'))
const res = num.split('.')
const last_num = res[1].substr(0, digits)
return `${res[0]}.${last_num}`
}
return parseFloat(num)
}
// 加号
const onPlus = (event) => {
event.stopPropagation()
@@ -44,18 +57,6 @@ export default ({ minNum = 0, maxNum = 10000, step = 1, digits = 0, defaultNum =
onClickBtn?.(parseFloat(num_res))
}
// 保留小数
const formatDigits = (num) => {
num = `${num}`
if (num.includes('.') && digits > 0) {
console.log('num::', num.includes('.'))
const res = num.split('.')
const last_num = res[1].substr(0, digits)
return `${res[0]}.${last_num}`
}
return parseFloat(num)
}
// 检查数据
const checkData = (val) => {
const num = parseFloat(val)
@@ -70,24 +71,24 @@ export default ({ minNum = 0, maxNum = 10000, step = 1, digits = 0, defaultNum =
setValue(minNum)
return minNum
}
else if (!isNaN(Number(res))) {
else if (!Number.isNaN(Number(res))) {
let count = formatDigits(res)
count = checkData(count)
setValue(count as number)
return count
}
}
else {
const num = parseFloat(res)
if (!isNaN(num)) {
if (!Number.isNaN(num)) {
let count = formatDigits(num)
count = checkData(count)
setValue(count as number)
return count
}
}
else {
setValue(defaultNum)
return defaultNum
}
}
}
}
@@ -95,13 +96,13 @@ export default ({ minNum = 0, maxNum = 10000, step = 1, digits = 0, defaultNum =
const num = parseFloat(String(value))
console.log('onInputEven res===>', num)
if (!isNaN(num)) {
if (!Number.isNaN(num)) {
let count = formatDigits(num)
count = checkData(count)
setValue(count as number)
onBlue?.(count as number)
return count
}
}
else {
setValue(defaultNum)
onBlue?.(defaultNum)
@@ -109,7 +110,7 @@ export default ({ minNum = 0, maxNum = 10000, step = 1, digits = 0, defaultNum =
}
}
const noop = (e) => {
e.stopPropagation()
e.stopPropagation()
}
return (
<View className={styles.main}>
@@ -126,3 +127,5 @@ export default ({ minNum = 0, maxNum = 10000, step = 1, digits = 0, defaultNum =
</View>
)
}
export default Counter
+3 -2
View File
@@ -2,7 +2,7 @@ import { View } from '@tarojs/components'
import { memo } from 'react'
import styles from './index.module.scss'
export default memo(() => {
const DotLoading = () => {
return (
<>
<View className={styles.load_box}>
@@ -14,4 +14,5 @@ export default memo(() => {
</View>
</>
)
})
}
export default memo(DotLoading)
+5 -6
View File
@@ -10,7 +10,6 @@ import Iconfont from '../iconfont/iconfont'
import Popup from '../popup'
import Cell from '../cell'
import styles from './index.module.scss'
import { usePropsValue } from '@/use/useCommon'
// 弹窗选择向上弹窗还是向下弹窗
type Direction = 'up' | 'down'
// 配置 菜单可选项
@@ -36,8 +35,7 @@ interface PropsType extends DropDownEvent {
customStyle?: React.CSSProperties
hasBottomBtn?: boolean // 底部有按钮不允许点击蒙层关闭
}
export default forwardRef((props: PropsType, ref) => {
const DropDownItem = (props: PropsType, ref) => {
const { children, direction = 'down', title = '', value, options = [], change, activeColor, showOverlay = true, hasBottomBtn = false, customClassName, customStyle, onCloseOverlay } = props
const [showPopup, setShowPopup] = useState(false)
@@ -61,9 +59,9 @@ export default forwardRef((props: PropsType, ref) => {
const defaultOptions = useMemo(() => {
const currentValue = value
return options?.map(({ text, value }) => {
return options?.map(({ text, value }, key) => {
currentValue === value && setText(text)
return <Cell title={text} desc="" isLink onClick={() => handleClickOption(value)}></Cell>
return <Cell key={key} title={text} desc="" isLink onClick={() => handleClickOption(value)}></Cell>
})
}, [value])
@@ -144,4 +142,5 @@ export default forwardRef((props: PropsType, ref) => {
</Popup>
</View>
)
})
}
export default forwardRef(DropDownItem)
+3 -3
View File
@@ -6,8 +6,7 @@ interface PropsObj {
picUrl?: string
text?: string
}
export default memo((pros: PropsObj) => {
const Empty = (pros: PropsObj) => {
const {
picUrl = '',
text = '无搜索历史',
@@ -19,4 +18,5 @@ export default memo((pros: PropsObj) => {
<View className={styles.text}>{text}</View>
</View>
)
})
}
export default memo(Empty)
+12 -11
View File
@@ -4,7 +4,6 @@ import { memo, useCallback, useEffect, useLayoutEffect, useMemo, useState } from
import classnames from 'classnames'
import AmountShow from '../amountShow'
import styles from './index.module.scss'
import { formatKbPrice } from '@/common/common'
interface Param {
style?: Object
@@ -17,7 +16,7 @@ interface Param {
messageShow?: true|false
numberFormat?: 'number'|'text' // 数字还是字符串
}
export default memo(({ number = 0, titleStatus = true, title = '', messageTitle = '', numberStatus = 1, messageWidth = 430, messageShow = false, numberFormat = 'number' }: Param) => {
const EstimatedAmount = ({ number = 0, titleStatus = true, title = '', messageTitle = '', numberStatus = 1, messageWidth = 430, messageShow = false, numberFormat = 'number' }: Param) => {
const [show, setShow] = useState(messageShow)
const onClose = () => {
setShow(false)
@@ -28,14 +27,6 @@ export default memo(({ number = 0, titleStatus = true, title = '', messageTitle
const [style, setStyle] = useState<{ top: string }>()
useEffect(() => {
if (show) {
getDomDes('#message')
}
else {
setStyle(() => ({ top: '0' }))
}
}, [show])
// 设置弹出层高度
const getDomDes = (id) => {
setTimeout(() => {
@@ -46,6 +37,15 @@ export default memo(({ number = 0, titleStatus = true, title = '', messageTitle
}).exec()
}, 0)
}
useEffect(() => {
if (show) {
getDomDes('#message')
}
else {
setStyle(() => ({ top: '0' }))
}
}, [show])
return (
<>
<View className={styles.order_price}>
@@ -62,4 +62,5 @@ export default memo(({ number = 0, titleStatus = true, title = '', messageTitle
</View>
</>
)
})
}
export default memo(EstimatedAmount)
+5 -3
View File
@@ -4,14 +4,15 @@ 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 = {
onFiltr?: (val: object) => void // 确定搜索
onRest?: (val: Object) => void // 重置
} & PopuParams
export default memo(({ onClose, onFiltr, show = false, onRest }: params) => {
const Filter = ({ onClose, onFiltr, show = false, onRest }: params) => {
// 搜索条件
const [filterObj, setFilterObj] = useState({
seriesName: '',
@@ -115,4 +116,5 @@ export default memo(({ onClose, onFiltr, show = false, onRest }: params) => {
</View>
</Popup>
)
})
}
export default memo(Filter)
+8 -5
View File
@@ -4,13 +4,14 @@ 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'
import { GetProductKindListApi } from '@/api/material'
type params = {
onFiltr?: (val: object) => void
} & PopuParams
export default ({ onClose, onFiltr, show = false }: params) => {
const FilterV2 = ({ onClose, onFiltr, show = false }: params) => {
// 搜索条件
const [filterObj, setFilterObj] = useState({
seriesId: '',
@@ -64,9 +65,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))
}
@@ -126,4 +127,6 @@ export default ({ onClose, onFiltr, show = false }: params) => {
</Popup>
)
}
}
export default FilterV2
+3 -3
View File
@@ -26,8 +26,7 @@ interface props {
goodList?: any[]
onBlur?: (a: any, c: any) => void
}
export default memo((props: props) => {
const GoodsItem = (props: props) => {
const [value, setValue] = useState<any>({ count: props.value.nums })
const onInputEven = (e) => {
@@ -99,5 +98,6 @@ export default memo((props: props) => {
</View>
</View>
)
})
}
export default memo(GoodsItem)
// ($event) => onInputEven($event, props.value)
+1 -1
View File
@@ -9,7 +9,7 @@ const SystemWidth = Taro.getSystemInfoSync().windowWidth
const quot = '"'
function hex2rgb(hex) {
const rgb = []
const rgb: number[] = []
hex = hex.substr(1)
+114 -113
View File
@@ -1,5 +1,5 @@
import { ScrollView, View } from '@tarojs/components'
import type { ReactNode } from 'react'
import type { ReactNode } from 'react'
import React, { memo, useMemo, useState } from 'react'
import LoadingCard from '../loadingCard'
import style from './index.module.scss'
@@ -30,126 +30,127 @@ interface Params {
enableBackToTop?: boolean
emptySlot?: React.ReactNode
}
export default memo(
({
styleObj,
selfonScrollToLower,
selfOnScrollToUpper,
selfOnScroll,
selfOnRefresherPulling,
selfOnRefresherRefresh,
selfOnRefresherRestore,
selfOnRefresherAbort,
safeAreaInsetBottom = true,
enableLoadMoreStatus = true,
children,
lowerThresholdNum = 5,
paddingBottom = 0,
refresherTriggered = false,
refresherEnabled = false,
moreStatus = true,
statusMore = 0,
enableBackToTop = true,
emptySlot,
}: Params) => {
const scrollToLower = () => {
selfonScrollToLower?.()
}
const scrollToUpper = () => {
selfOnScrollToUpper?.()
}
const scroll = (e) => {
selfOnScroll?.(e)
}
const refresherPulling = () => {
selfOnRefresherPulling?.()
}
const refresherRefresh = () => {
selfOnRefresherRefresh?.()
}
const refresherRestore = () => {
selfOnRefresherRestore?.()
}
const refresherAbort = () => {
selfOnRefresherAbort?.()
}
const InfiniteScroll = ({
styleObj,
selfonScrollToLower,
selfOnScrollToUpper,
selfOnScroll,
selfOnRefresherPulling,
selfOnRefresherRefresh,
selfOnRefresherRestore,
selfOnRefresherAbort,
safeAreaInsetBottom = true,
enableLoadMoreStatus = true,
children,
lowerThresholdNum = 5,
paddingBottom = 0,
refresherTriggered = false,
refresherEnabled = false,
moreStatus = true,
statusMore = 0,
enableBackToTop = true,
emptySlot,
}: Params) => {
const scrollToLower = () => {
selfonScrollToLower?.()
}
const scrollToUpper = () => {
selfOnScrollToUpper?.()
}
const scroll = (e) => {
selfOnScroll?.(e)
}
const refresherPulling = () => {
selfOnRefresherPulling?.()
}
const refresherRefresh = () => {
selfOnRefresherRefresh?.()
}
const refresherRestore = () => {
selfOnRefresherRestore?.()
}
const refresherAbort = () => {
selfOnRefresherAbort?.()
}
// 返回顶部
const scrollTop = useMemo(() => {
if (statusMore == 0) {
return 0.1
}
}, [statusMore])
// 返回顶部
const scrollTop = useMemo(() => {
if (statusMore == 0) {
return 0.1
}
}, [statusMore])
const component = () => {
if (enableLoadMoreStatus) {
if (!moreStatus) {
return (
<View style={{ paddingBottom: `${paddingBottom}rpx` }} className={style.scrollViewCon}>
{children}
</View>
)
}
else {
return (
<>
{(statusMore == 2 || statusMore == 3) && (
<View style={{ paddingBottom: `${paddingBottom}rpx` }} className={style.scrollViewCon}>
{children}
<View className={style.infinite_scroll}>
{statusMore == 2
? (
<View className={style.loading_more}>
加载中
<DotLoading />
</View>
)
: (
<View className={style.noMore}>没有更多数据了</View>
)}
</View>
</View>
)}
{statusMore == 0 && <LoadingCard />}
{statusMore == 1 && (emptySlot || <Empty picUrl={SEARCH_EMPTY_IMAGE} text="暂无数据" />)}
</>
)
}
}
else {
const component = () => {
if (enableLoadMoreStatus) {
if (!moreStatus) {
return (
<View style={{ paddingBottom: `${paddingBottom}rpx` }} className={style.scrollViewCon}>
{children}
</View>
)
}
else {
return (
<>
{(statusMore == 2 || statusMore == 3) && (
<View style={{ paddingBottom: `${paddingBottom}rpx` }} className={style.scrollViewCon}>
{children}
<View className={style.infinite_scroll}>
{statusMore == 2
? (
<View className={style.loading_more}>
加载中
<DotLoading />
</View>
)
: (
<View className={style.noMore}>没有更多数据了</View>
)}
</View>
</View>
)}
{statusMore == 0 && <LoadingCard />}
{statusMore == 1 && (emptySlot || <Empty picUrl={SEARCH_EMPTY_IMAGE} text="暂无数据" />)}
</>
)
}
}
else {
return (
<View style={{ paddingBottom: `${paddingBottom}rpx` }} className={style.scrollViewCon}>
{children}
</View>
)
}
}
return (
<>
<ScrollView
id="infiniteScroll"
style={styleObj}
className={style.scroll_main}
scrollY
onScrollToLower={() => scrollToLower()}
onScrollToUpper={() => scrollToUpper()}
onScroll={e => scroll(e)}
lowerThreshold={lowerThresholdNum}
refresherEnabled={refresherEnabled}
refresherTriggered={refresherTriggered}
onRefresherPulling={() => refresherPulling()}
onRefresherRefresh={() => refresherRefresh()}
onRefresherRestore={() => refresherRestore()}
onRefresherAbort={() => refresherAbort()}
refresherBackground="#F8F8F8"
enableBackToTop={enableBackToTop}
scrollTop={scrollTop}
>
{component()}
{safeAreaInsetBottom && <View className="common_safe_area_y"></View>}
</ScrollView>
</>
)
},
return (
<>
<ScrollView
id="infiniteScroll"
style={styleObj}
className={style.scroll_main}
scrollY
onScrollToLower={() => scrollToLower()}
onScrollToUpper={() => scrollToUpper()}
onScroll={e => scroll(e)}
lowerThreshold={lowerThresholdNum}
refresherEnabled={refresherEnabled}
refresherTriggered={refresherTriggered}
onRefresherPulling={() => refresherPulling()}
onRefresherRefresh={() => refresherRefresh()}
onRefresherRestore={() => refresherRestore()}
onRefresherAbort={() => refresherAbort()}
refresherBackground="#F8F8F8"
enableBackToTop={enableBackToTop}
scrollTop={scrollTop}
>
{component()}
{safeAreaInsetBottom && <View className="common_safe_area_y"></View>}
</ScrollView>
</>
)
}
export default memo(
InfiniteScroll,
)
+6 -5
View File
@@ -1,13 +1,13 @@
import { View } from '@tarojs/components'
import { memo, useMemo } from 'react'
import style from './index.module.scss'
import style from './index.module.scss'
export default memo(({ width = 60, color = '#6190e8' }: { width?: number; color?: string }) => {
const Loading = ({ width = 60, color = '#6190e8' }: { width?: number; color?: string }) => {
const styleObj = useMemo(() => {
let obj = {}
if (width > 0) { obj = { width: `${width}rpx`, height: `${width}rpx` } }
if (color) { obj = { ...obj, borderColor: `${color} transparent transparent` } }
return obj
return obj
}, [width, color])
console.log('loading:::')
return (
@@ -18,5 +18,6 @@ export default memo(({ width = 60, color = '#6190e8' }: { width?: number; color?
<View style={styleObj} className={style.loading__ring}></View>
<View style={styleObj} className={style.loading__ring}></View>
</View>
)
})
)
}
export default memo(Loading)
+3 -2
View File
@@ -8,7 +8,7 @@ interface Params {
title?: string
loadingIcon?: boolean
}
export default memo((props: Params) => {
const LoadingCard = (props: Params) => {
console.log(props)
const {
title = '加载中...', // 显示的文字
@@ -24,4 +24,5 @@ export default memo((props: Params) => {
</View>
</>
)
})
}
export default memo(LoadingCard)
+4 -3
View File
@@ -1,6 +1,6 @@
import { MovableArea, MovableView, View } from '@tarojs/components'
import Taro, { useReady } from '@tarojs/taro'
import type { ReactElement } from 'react'
import type { ReactElement } from 'react'
import { useEffect, useRef, useState } from 'react'
import classnames from 'classnames'
import styles from './index.module.scss'
@@ -12,7 +12,7 @@ interface param {
children?: ReactElement|null
onClick?: () => void
}
export default ({ children = null, onClick }: param) => {
const MoveBtn = ({ children = null, onClick }: param) => {
// 获取购物车数据数量
const { getShopCount, commonData } = useCommonData()
@@ -46,4 +46,5 @@ export default ({ children = null, onClick }: param) => {
</MovableView>}
</MovableArea>
)
}
}
export default MoveBtn
+32 -32
View File
@@ -25,8 +25,7 @@ interface Param {
showStatus?: 'detail' | 'list' // 订单详情,订单列表
onClick?: (val: number) => void // 点击后触发的事件,返回订单状态
}
export default memo(({ orderInfo, showStatus = 'detail', onClick }: Param) => {
const OrderBtns = ({ orderInfo, showStatus = 'detail', onClick }: Param) => {
// 订单状态枚举
const {
SaleOrderStatusBooking,
@@ -161,28 +160,6 @@ export default memo(({ orderInfo, showStatus = 'detail', onClick }: Param) => {
const { ApplyGoods } = SUBSCRIPTION_MESSAGE_SCENE
const { openSubscriptionMessage } = UseSubscriptionMessage()
// 点击按钮操作
const submitBtns = throttle(async(val, index) => {
if (val == 1) {
cancelOrder()
}
else if (val == 6) {
receiveOrder()
}
else if (val == 5) {
applyProduct()
}
else if (val == 3) {
bigApplyRefurn()
}
else if (val == 8) {
applyRefund()
}
else {
onClick?.(val)
}
}, 800)
// 大货申请退款
const bigApplyRefurn = () => {
Taro.showModal({
@@ -191,7 +168,7 @@ export default memo(({ orderInfo, showStatus = 'detail', onClick }: Param) => {
if (res.confirm) {
await openSubscriptionMessage({ orderId: orderInfo?.orderId, scenes: ApplyGoods.value })
onClick?.(3)
}
}
else {
console.log('用户点击取消')
}
@@ -210,11 +187,11 @@ export default memo(({ orderInfo, showStatus = 'detail', onClick }: Param) => {
if (res.success) {
alert.success('取消成功')
onClick?.(1)
}
}
else {
alert.none(res.msg)
}
}
}
else if (res.cancel) {
console.log('用户点击取消')
}
@@ -234,12 +211,12 @@ export default memo(({ orderInfo, showStatus = 'detail', onClick }: Param) => {
if (res.success) {
onClick?.(6)
alert.success('收货成功')
}
}
else {
alert.error('收货失败')
}
alert.hideLoading()
}
}
else if (res.cancel) {
console.log('用户点击取消')
}
@@ -259,13 +236,13 @@ export default memo(({ orderInfo, showStatus = 'detail', onClick }: Param) => {
const res = await fetchDataApplyRefund({ sale_order_id: orderInfo?.orderId })
if (res.success) {
alert.success('申请成功')
}
}
else {
alert.error('申请失败')
}
alert.hideLoading()
onClick?.(8)
}
}
else if (res.cancel) {
console.log('用户点击取消')
}
@@ -286,6 +263,28 @@ export default memo(({ orderInfo, showStatus = 'detail', onClick }: Param) => {
return { top: `-${(orderBtnsShowList.length - 3) * 70 + 10}rpx`, left: `-${10}rpx` }
}, [orderBtnsShowList])
// 点击按钮操作
const submitBtns = throttle(async(val, index) => {
if (val == 1) {
cancelOrder()
}
else if (val == 6) {
receiveOrder()
}
else if (val == 5) {
applyProduct()
}
else if (val == 3) {
bigApplyRefurn()
}
else if (val == 8) {
applyRefund()
}
else {
onClick?.(val)
}
}, 800)
return (
<View className={styles.btns_list}>
{orderBtnsShowList.length > 3 && (
@@ -321,4 +320,5 @@ export default memo(({ orderInfo, showStatus = 'detail', onClick }: Param) => {
</View>
</View>
)
})
}
export default memo(OrderBtns)
+65 -65
View File
@@ -1,7 +1,7 @@
import { RootPortal, View } from '@tarojs/components'
import Taro from '@tarojs/taro'
import classnames from 'classnames'
import type { ReactNode } from 'react'
import type { ReactNode } from 'react'
import { memo, useEffect, useMemo, useRef, useState } from 'react'
import style from './index.module.scss'
import CloseBtnIcon from '@/components/closeBtn'
@@ -25,73 +25,73 @@ export interface Params extends PopupEvent {
safeAreaInsetBottom?: boolean // 是否为iphoneX提供小黑条适配
showOverLay?: boolean // 是否显示遮罩层
}
export default memo(
({
title = '标题',
show = false,
showTitle = true,
onClose,
isFixed = false,
showIconButton = false,
children,
position = 'bottom',
animationEnd,
customStyle = {},
safeAreaInsetBottom = true,
showOverLay = true,
overlayStyle,
}: Params) => {
const animationTime = useRef<any>(null)
useEffect(() => {
if (show) {
animationTime.current = setTimeout(() => {
animationEnd?.()
customStyle.overflow = 'unset'
}, 260)
}
else {
clearTimeout(animationTime.current)
}
}, [show])
const Popup = ({
title = '标题',
show = false,
showTitle = true,
onClose,
isFixed = false,
showIconButton = false,
children,
position = 'bottom',
animationEnd,
customStyle = {},
safeAreaInsetBottom = true,
showOverLay = true,
overlayStyle,
}: Params) => {
const animationTime = useRef<any>(null)
useEffect(() => {
if (show) {
animationTime.current = setTimeout(() => {
animationEnd?.()
customStyle.overflow = 'unset'
}, 260)
}
else {
clearTimeout(animationTime.current)
}
}, [show])
useEffect(() => {
return () => {
clearTimeout(animationTime.current)
}
}, [])
useEffect(() => {
return () => {
clearTimeout(animationTime.current)
}
}, [])
return (
<View className={style.drawer_main}>
<View catchMove className={classnames(style.drawer, show ? style.drawer_active : '')} style={customStyle}>
{/* 遮罩层 start */}
<View
className={classnames(style.drawer_mask, { [style.drawer_mask_active]: show, [style['drawer_mask--hidden']]: !showOverLay })}
onClick={onClose}
style={overlayStyle}
></View>
{/* 遮罩层 end */}
<View
style={{ position: `${isFixed == true ? 'fixed' : 'absolute'}` }}
className={classnames(style.drawer_container, style[`drawer_container_${position}`], {
[style.drawer_container_active]: show,
[style[`drawer_container_${position}-withShadow`]]: !showOverLay,
})}
onClick={e => e.stopPropagation()}
>
{showTitle && <View className={style.drawer_container_title}>{title}</View>}
{showIconButton && (
<View className={style.common_close_btn_icon}>
<CloseBtnIcon onClose={onClose} />
</View>
)}
<View id="drawerContainerContext" className={style.drawer_container_context}>
{children}
return (
<View className={style.drawer_main}>
<View catchMove className={classnames(style.drawer, show ? style.drawer_active : '')} style={customStyle}>
{/* 遮罩层 start */}
<View
className={classnames(style.drawer_mask, { [style.drawer_mask_active]: show, [style['drawer_mask--hidden']]: !showOverLay })}
onClick={onClose}
style={overlayStyle}
></View>
{/* 遮罩层 end */}
<View
style={{ position: `${isFixed == true ? 'fixed' : 'absolute'}` }}
className={classnames(style.drawer_container, style[`drawer_container_${position}`], {
[style.drawer_container_active]: show,
[style[`drawer_container_${position}-withShadow`]]: !showOverLay,
})}
onClick={e => e.stopPropagation()}
>
{showTitle && <View className={style.drawer_container_title}>{title}</View>}
{showIconButton && (
<View className={style.common_close_btn_icon}>
<CloseBtnIcon onClose={onClose} />
</View>
{safeAreaInsetBottom && <View className="common_safe_area_y"></View>}
)}
<View id="drawerContainerContext" className={style.drawer_container_context}>
{children}
</View>
{safeAreaInsetBottom && <View className="common_safe_area_y"></View>}
</View>
</View>
)
},
)
</View>
)
}
export default memo(Popup)
+5 -3
View File
@@ -11,7 +11,7 @@ interface Params {
productList?: any[]
popupShow?: (any) => void
}
export default ({ desStatus = true, productList = [], popupShow }: Params) => {
const Product = ({ desStatus = true, productList = [], popupShow }: Params) => {
const labAndImgObj = useCallback(
(item) => {
return { lab: item.lab, rgb: item.rgb, texture_url: item.texture_url }
@@ -20,9 +20,9 @@ export default ({ desStatus = true, productList = [], popupShow }: Params) => {
)
return (
<View className={styles.products_list}>
{productList?.map((item) => {
{productList?.map((item, key) => {
return (
<View className={styles.products_item} onClick={() => popupShow?.(item)}>
<View key={key} className={styles.products_item} onClick={() => popupShow?.(item)}>
<View className={styles.item_img}>
<LabAndImg value={labAndImgObj(item)} />
<View className={styles.num}>{item.product_color_count}色</View>
@@ -45,3 +45,5 @@ export default ({ desStatus = true, productList = [], popupShow }: Params) => {
</View>
)
}
export default Product
+91 -93
View File
@@ -1,6 +1,6 @@
import { View } from '@tarojs/components'
import classnames from 'classnames'
import type { ReactNode } from 'react'
import type { ReactNode } from 'react'
import { forwardRef, memo, useEffect, useImperativeHandle, useState } from 'react'
import IconFont from '../iconfont/iconfont'
import InputX from '../InputX/index'
@@ -26,104 +26,102 @@ interface Params {
handScan?: () => void
cursorSpacing?: Number
}
const Search = (
{
clickOnSearch, // 点击筛选按钮触发
changeOnSearch, // 输入文字触发
adjustPosition = false,
disabled = false, // 是否禁用
placeholder = '输入搜索内容',
showIcon = true, // 是否显示关闭图标
showBtn = false, // 是否显示搜索按钮
btnStyle = {},
placeIcon = 'inner', // 搜索图标位置:inner在里面,out在外面
btnTitle = '搜索', // 搜索文字
defaultValue = '', // 默认值
children,
customRightSlot,
showScan = false,
handScan,
cursorSpacing = 0,
}: Params,
ref,
) => {
const [inputCon, setInputCon] = useState('')
useEffect(() => {
setInputCon(defaultValue)
}, [defaultValue])
export default memo(
forwardRef(
(
{
clickOnSearch, // 点击筛选按钮触发
changeOnSearch, // 输入文字触发
adjustPosition = false,
disabled = false, // 是否禁用
placeholder = '输入搜索内容',
showIcon = true, // 是否显示关闭图标
showBtn = false, // 是否显示搜索按钮
btnStyle = {},
placeIcon = 'inner', // 搜索图标位置:inner在里面,out在外面
btnTitle = '搜索', // 搜索文字
defaultValue = '', // 默认值
children,
customRightSlot,
showScan = false,
handScan,
cursorSpacing = 0,
}: Params,
ref,
) => {
const [inputCon, setInputCon] = useState('')
useEffect(() => {
setInputCon(defaultValue)
}, [defaultValue])
const onInputEven = (e) => {
const value = e.detail.value
setInputCon(value)
changeOnSearch?.(value)
}
const onInputEven = (e) => {
const value = e.detail.value
setInputCon(value)
changeOnSearch?.(value)
}
const clearInput = () => {
setInputCon('')
changeOnSearch?.('')
}
useImperativeHandle(ref, () => ({
clearInput,
}))
const onSearch = () => {
clickOnSearch?.(inputCon)
}
useImperativeHandle(ref, () => ({
clearInput,
}))
const clearInput = () => {
setInputCon('')
changeOnSearch?.('')
}
const onSearch = () => {
clickOnSearch?.(inputCon)
}
return (
<>
<View className={styles.search_main}>
<View className={styles.search_con}>
{showIcon && (
<IconFont
name="icon-sousuo"
size={37}
color="#ababac"
customClassName={classnames(styles.icon_a_sousuo1_self, placeIcon == 'inner' ? styles.icon_inner : styles.icon_out)}
></IconFont>
)}
<View className={styles.input_bar}>
<InputX
cursorSpacing={cursorSpacing as any}
adjustPosition={adjustPosition}
placeholderStyle="color:#ABABAB; font-size:26rpx"
onConfirm={onSearch}
disabled={disabled}
value={inputCon}
placeholder={placeholder}
onInput={e => onInputEven(e)}
customClassName={classnames(placeIcon == 'out' && styles.input_out)}
customStyle={{ width: '100%' }}
/>
<View className={styles.search_closeBtn}>
{!!inputCon && <CloseBtn onClose={() => clearInput()} styleObj={{ width: '20rpx', height: '20rpx', backgroundColor: '#fff', border: '0' }} />}
</View>
{showScan && (
<View
onClick={() => {
handScan?.()
}}
>
<IconFont name="icon-saomiao" size={40} color="#337FFF"></IconFont>
</View>
)}
<View className={styles.customRightSlot}>{customRightSlot}</View>
</View>
return (
<>
<View className={styles.search_main}>
<View className={styles.search_con}>
{showIcon && (
<IconFont
name="icon-sousuo"
size={37}
color="#ababac"
customClassName={classnames(styles.icon_a_sousuo1_self, placeIcon == 'inner' ? styles.icon_inner : styles.icon_out)}
></IconFont>
)}
<View className={styles.input_bar}>
<InputX
cursorSpacing={cursorSpacing as any}
adjustPosition={adjustPosition}
placeholderStyle="color:#ABABAB; font-size:26rpx"
onConfirm={onSearch}
disabled={disabled}
value={inputCon}
placeholder={placeholder}
onInput={e => onInputEven(e)}
customClassName={classnames(placeIcon == 'out' && styles.input_out)}
customStyle={{ width: '100%' }}
/>
<View className={styles.search_closeBtn}>
{!!inputCon && <CloseBtn onClose={() => clearInput()} styleObj={{ width: '20rpx', height: '20rpx', backgroundColor: '#fff', border: '0' }} />}
</View>
{showBtn && (
<View style={btnStyle} className={styles.btn} onClick={onSearch}>
{btnTitle}
{showScan && (
<View
onClick={() => {
handScan?.()
}}
>
<IconFont name="icon-saomiao" size={40} color="#337FFF"></IconFont>
</View>
)}
{children}
<View className={styles.customRightSlot}>{customRightSlot}</View>
</View>
</>
)
},
</View>
{showBtn && (
<View style={btnStyle} className={styles.btn} onClick={onSearch}>
{btnTitle}
</View>
)}
{children}
</View>
</>
)
}
export default memo(
forwardRef(
Search,
),
)
+4 -4
View File
@@ -1,5 +1,5 @@
import { View } from '@tarojs/components'
import type { ReactNode } from 'react'
import type { ReactNode } from 'react'
import { memo, useMemo } from 'react'
import IconFont from '../iconfont/iconfont'
import InputX from '../InputX'
@@ -19,8 +19,7 @@ interface Params {
titleStyle?: Object
styleObj?: Object
}
export default memo((props: Params) => {
const SearchInput = (props: Params) => {
const {
showTitle = true,
title = '标题',
@@ -55,4 +54,5 @@ export default memo((props: Params) => {
{showIcon && <IconFont customClassName={styles.icon_more_self} name="icon-chakanquanbukehu" size={36} color="#333"></IconFont>}
</View>
)
})
}
export default memo(SearchInput)
+20 -21
View File
@@ -23,7 +23,7 @@ interface productType {
name: string
}
const SelectProduct = forwardRef((params: PropsType, ref) => {
const SelectProduct = (params: PropsType, ref) => {
const { selectColorId, noAll, onSelect } = params
const [selectId, setSelectId] = useState(selectColorId)
@@ -34,6 +34,19 @@ const SelectProduct = forwardRef((params: PropsType, ref) => {
const [productList, setProductList] = useState<productType[]>([])
const [showPopup, setShowPopup] = useState(false)
const changeName = (item) => {
console.log('changeName', item)
if (item) {
if (item.id) {
return formatHashTag(item.code, item.name)
}
else {
return item.name
}
}
}
const clickEvent = () => {
setShowPopup(true)
}
@@ -53,22 +66,6 @@ const SelectProduct = forwardRef((params: PropsType, ref) => {
onSelect && onSelect(item)
}
const changeName = (item) => {
console.log('changeName', item)
if (item) {
if (item.id) {
return formatHashTag(item.code, item.name)
}
else {
return item.name
}
}
}
useEffect(() => {
getProductList()
}, [])
const getProductList = async() => {
const res = await fetchData()
// !noAll && res.data.list?.unshift({ name: '全部', id: 0 })
@@ -76,7 +73,9 @@ const SelectProduct = forwardRef((params: PropsType, ref) => {
originList.current = [{ name: '全部', id: 0 }, ...res.data.list]
}
const [showPopup, setShowPopup] = useState(false)
useEffect(() => {
getProductList()
}, [])
const closeEven = () => {
setShowPopup(false)
@@ -118,7 +117,7 @@ const SelectProduct = forwardRef((params: PropsType, ref) => {
</View>
<Popup title="请选择面料名称" showTitle show={showPopup} onClose={closeEven} position="bottom" customStyle={{ zIndex: 9999 }}>
<View style={{ padding: '0 24rpx' }}>
<Search placeholder="请输入编号/面料" showBtn={false} changeOnSearch={getSearchData} debounceTime={350}></Search>
<Search placeholder="请输入编号/面料" showBtn={false} changeOnSearch={getSearchData}></Search>
</View>
<View className={styles.selectList}>
<ScrollView className={styles['selectList-scroll-view']} scrollY>
@@ -134,5 +133,5 @@ const SelectProduct = forwardRef((params: PropsType, ref) => {
</Popup>
</>
)
})
export default SelectProduct
}
export default forwardRef(SelectProduct)
+69 -67
View File
@@ -25,18 +25,52 @@ interface param {
intoStatus?: 'again' | 'shop'
default_sale_mode?: number // 面料类型(0:大货, 1:剪版,2:散剪
}
export default ({ show = false, onClose, intoStatus = 'shop', default_sale_mode }: param) => {
const ShopCart = ({ show = false, onClose, intoStatus = 'shop', default_sale_mode }: param) => {
const selectList = [
{ value: 0, title: '大货', unit: '条', eunit: 'kg', step: 1, digits: 0, minNum: 1, maxNum: 100000, defaultNum: 1 },
{ value: 1, title: '剪板', unit: '米', eunit: 'm', step: 1, digits: 2, minNum: 0.5, maxNum: 9.99, defaultNum: 1 },
{ value: 2, title: '散剪', unit: '米', eunit: 'kg', step: 1, digits: 2, minNum: 3, maxNum: 100000, defaultNum: 3 },
]
// 获取数据
const [list, setList] = useState<any[]>([])
const [loading, setLoading] = useState(false)
const { fetchData } = GetShoppingCartApi()
// 切换面料类型
const [selectIndex, setSelectIndex] = useState(default_sale_mode || 0)
const selectProduct = (index: number) => {
setSelectIndex(index)
}
// 初始化全部数据默认勾选
const [checkboxData, setCheckboxData] = useState<Record<number, true | false>>({})
const initStatus = useRef(false)
// 全选反选
const [selectStatus, setSelectStatus] = useState(false)
const initList = (color_list) => {
if (initStatus.current) {
color_list?.forEach((item) => {
if (selectIndex == item.sale_mode) { checkboxData[item.id] = true }
})
initStatus.current = false
}
setCheckboxData(() => checkboxData)
}
// 重置勾选数据
const resetList = () => {
list?.forEach((item) => {
if (selectIndex == item.sale_mode || selectIndex == -1) {
checkboxData[item.id] = true
}
else {
checkboxData[item.id] = false
}
})
setCheckboxData(() => ({ ...checkboxData }))
}
useEffect(() => {
setSelectIndex(() => default_sale_mode!)
}, [default_sale_mode])
@@ -46,26 +80,11 @@ export default ({ show = false, onClose, intoStatus = 'shop', default_sale_mode
setSelectStatus(true)
}, [selectIndex])
// 绑定业务员和电话号码
const [showBindSalesman, setShowBindSalesman] = useState(false)
// 获取购物车数据数量
const { setShopCount } = useCommonData()
// 重置勾选数据
const resetList = () => {
list?.map((item) => {
if (selectIndex == item.sale_mode || selectIndex == -1) {
checkboxData[item.id] = true
}
else {
checkboxData[item.id] = false
}
})
setCheckboxData(() => ({ ...checkboxData }))
}
// 获取数据
const [list, setList] = useState<any[]>([])
const [loading, setLoading] = useState(false)
const { fetchData } = GetShoppingCartApi()
const getShoppingCart = async() => {
const { data } = await fetchData()
const color_list = data.color_list || []
@@ -75,25 +94,12 @@ export default ({ show = false, onClose, intoStatus = 'shop', default_sale_mode
setLoading(false)
}
// 初始化全部数据默认勾选
const [checkboxData, setCheckboxData] = useState<Record<number, true | false>>({})
const initStatus = useRef(false)
const initList = (color_list) => {
if (initStatus.current) {
color_list?.map((item) => {
if (selectIndex == item.sale_mode) { checkboxData[item.id] = true }
})
initStatus.current = false
}
setCheckboxData(() => checkboxData)
}
// 显示是展示数据
useEffect(() => {
if (!show) {
setList([])
setSelectIndex(default_sale_mode || 0)
}
}
else {
setLoading(true)
initStatus.current = true
@@ -113,28 +119,19 @@ export default ({ show = false, onClose, intoStatus = 'shop', default_sale_mode
setShowPopup(show)
}, [show])
// 全选反选
const [selectStatus, setSelectStatus] = useState(false)
const selectAll = () => {
list.map((item) => {
list.forEach((item) => {
if (selectIndex == item.sale_mode || selectIndex == -1) { checkboxData[item.id] = !selectStatus }
})
setSelectStatus(!selectStatus)
setCheckboxData(() => ({ ...checkboxData }))
}
// checkbox选中回调
const selectCallBack = (item) => {
checkboxData[item.id] = true
checkSelect()
setCheckboxData(() => ({ ...checkboxData }))
}
// checkbox选中判断是否全部选中,全部选中后是全选,否则反选
const checkSelect = () => {
let list_count = 0
let select_count = 0
list?.map((item) => {
list?.forEach((item) => {
if (selectIndex == -1 || selectIndex == item.sale_mode) {
list_count++
if (checkboxData[item.id]) { select_count++ }
@@ -142,6 +139,12 @@ export default ({ show = false, onClose, intoStatus = 'shop', default_sale_mode
})
setSelectStatus(select_count == list_count)
}
// checkbox选中回调
const selectCallBack = (item) => {
checkboxData[item.id] = true
checkSelect()
setCheckboxData(() => ({ ...checkboxData }))
}
// checkbox关闭回调
const colseCallBack = (item) => {
@@ -156,6 +159,17 @@ export default ({ show = false, onClose, intoStatus = 'shop', default_sale_mode
setShowPopup(false)
}
// 获取面料选中的id
const selectIds = useRef<number[]>([])
const getSelectId = () => {
selectIds.current = []
list?.forEach((item) => {
if (selectIndex == -1 || selectIndex == item.sale_mode) {
checkboxData[item.id] && selectIds.current.push(item.id)
}
})
}
// 删除购物车内容
const { fetchData: delShopFetchData } = DelShoppingCartApi()
const delSelect = () => {
@@ -172,14 +186,14 @@ export default ({ show = false, onClose, intoStatus = 'shop', default_sale_mode
title: '成功',
icon: 'success',
})
}
}
else {
Taro.showToast({
title: res.msg,
icon: 'none',
})
}
}
}
else if (res.cancel) {
console.log('用户点击取消')
}
@@ -187,17 +201,6 @@ export default ({ show = false, onClose, intoStatus = 'shop', default_sale_mode
})
}
// 获取面料选中的id
const selectIds = useRef<number[]>([])
const getSelectId = () => {
selectIds.current = []
list?.map((item) => {
if (selectIndex == -1 || selectIndex == item.sale_mode) {
checkboxData[item.id] && selectIds.current.push(item.id)
}
})
}
// 格式化金额
const formatPirce = useCallback((price) => {
return Number(formatPriceDiv(price))
@@ -219,7 +222,7 @@ export default ({ show = false, onClose, intoStatus = 'shop', default_sale_mode
const product_list = new Set() // 面料
let color_count = 0 // 颜色数量
let all_count = 0 // 总数量
list.map((item) => {
list.forEach((item) => {
if (checkboxData[item.id]) {
estimate_amount += item.estimate_amount
product_list.add(item.product_id)
@@ -236,10 +239,10 @@ export default ({ show = false, onClose, intoStatus = 'shop', default_sale_mode
}, [list, checkboxData])
// 去结算
const { fetchData: useFetchData } = GetAdminUserInfoApi()
const { fetchData: FetchData } = GetAdminUserInfoApi()
const { fetchData: applyOrderAccessFetchData } = ApplyOrderAccessApi()
const orderDetail = throttle(async() => {
const res = await useFetchData()
const res = await FetchData()
if (res.data.order_access_status !== 3) {
if (res.data.order_access_status == 1) { applyOrderAccessFetchData() }
setShowBindSalesman(() => true)
@@ -249,14 +252,14 @@ export default ({ show = false, onClose, intoStatus = 'shop', default_sale_mode
getSelectId()
if (selectIds.current.length == 0) {
alert.error('请选择面料')
}
}
else {
const ids = selectIds.current.join('-')
setParam({ ids, sale_mode: selectIndex }) // 临时存储
closePopup()
if (intoStatus == 'again') {
goLink('/pages/order/comfirm', {}, 'redirectTo')
}
}
else {
goLink('/pages/order/comfirm')
}
@@ -277,9 +280,6 @@ export default ({ show = false, onClose, intoStatus = 'shop', default_sale_mode
}
}, 300)
// 绑定业务员和电话号码
const [showBindSalesman, setShowBindSalesman] = useState(false)
// 显示图片弹窗
const [showLabImage, setShowLabImage] = useState(false)
const [labImageValue, setLabImageValue] = useState()
@@ -309,7 +309,7 @@ export default ({ show = false, onClose, intoStatus = 'shop', default_sale_mode
<View
key={item.value}
onClick={() => selectProduct(item.value)}
className={classnames(styles.search_item, selectIndex == item.value && styles.search_item_select)}
className={classnames(styles.search_item, selectIndex == item.value && styles.search_item_select)}
>
{item.title}
</View>
@@ -325,7 +325,7 @@ export default ({ show = false, onClose, intoStatus = 'shop', default_sale_mode
return (
<View
key={item}
className={classnames(styles.product_item, selectIndex != -1 && selectIndex != item.sale_mode && styles.no_product_item_select)}
className={classnames(styles.product_item, selectIndex != -1 && selectIndex != item.sale_mode && styles.no_product_item_select)}
>
<View className={styles.checkbox}>
<MCheckbox
@@ -412,3 +412,5 @@ export default ({ show = false, onClose, intoStatus = 'shop', default_sale_mode
</View>
)
}
export default ShopCart
+7 -6
View File
@@ -34,7 +34,7 @@ interface prosObj {
hasBottom?: true | false // 默认不占位底部
onBlur?: (e: string, res: object) => void
}
export default memo(forwardRef((props: prosObj, ref) => {
const ShoppingCart = (props: prosObj, ref) => {
const {
showPopup = false,
closePopup,
@@ -105,7 +105,7 @@ export default memo(forwardRef((props: prosObj, ref) => {
return s
}
const rows = memo(({ id, index, style, data }: any) => {
const rows = ({ id, index, style, data }: any) => {
const item = data[index]
return (
<>
@@ -120,7 +120,8 @@ export default memo(forwardRef((props: prosObj, ref) => {
></Goods>
</>
)
})
}
const Rows = memo(rows)
return (
<Popup showTitle={false} show={showPopup} onClose={() => closePopup?.()}>
@@ -164,7 +165,6 @@ export default memo(forwardRef((props: prosObj, ref) => {
placeholder="请输入搜索布料"
showBtn={false}
changeOnSearch={getSearchData}
debounceTime={300}
adjustPosition
/>
</View>
@@ -181,7 +181,7 @@ export default memo(forwardRef((props: prosObj, ref) => {
itemSize={100} /* 列表单项的高度 */
overscanCount={1}
>
{rows}
{Rows}
</VirtualList>
</View>
@@ -212,4 +212,5 @@ export default memo(forwardRef((props: prosObj, ref) => {
</ScrollView>
</Popup>
)
}))
}
export default memo(forwardRef(ShoppingCart))
+15 -16
View File
@@ -1,9 +1,9 @@
import { ScrollView, View } from '@tarojs/components'
import Taro, { useReady } from '@tarojs/taro'
import type { ReactNode } from 'react'
import type { ReactNode } from 'react'
import React, { memo, useEffect, useMemo, useRef, useState } from 'react'
import classnames from 'classnames'
import type { StatusParam } from '../infiniteScroll'
import type { StatusParam } from '../infiniteScroll'
import InfiniteScroll from '../infiniteScroll'
import LoadingCard from '../loadingCard'
import styles from './index.module.scss'
@@ -21,8 +21,7 @@ interface Params {
hasMore?: true | false
statusMore?: StatusParam
}
export default memo(({
const SideBar = ({
list = [],
defaultValue = 0,
height = '100vh',
@@ -34,7 +33,7 @@ export default memo(({
selfOnScrolltolower,
hasMore = true,
statusMore = 0,
}: Params) => {
}: Params) => {
const num_half = useRef(0)
const [selected, setSelected] = useState(defaultValue)
@@ -44,6 +43,15 @@ export default memo(({
setSelected(defaultValue)
}, [defaultValue])
const computeSelectTab = (index) => {
if ((index + 1) > num_half.current) {
const num = index + 1 - num_half.current
setTabId(list[num].id.toString())
}
else {
setTabId(list[0].id.toString())
}
}
const init = () => {
const index = list?.findIndex((item) => {
return item.id == defaultValue
@@ -59,16 +67,6 @@ export default memo(({
computeSelectTab(index)
}
const computeSelectTab = (index) => {
if ((index + 1) > num_half.current) {
const num = index + 1 - num_half.current
setTabId(list[num].id.toString())
}
else {
setTabId(list[0].id.toString())
}
}
useEffect(() => {
Taro.nextTick(() => {
const query = Taro.createSelectorQuery()
@@ -127,4 +125,5 @@ export default memo(({
</>
)
})
}
export default memo(SideBar)
+5 -4
View File
@@ -9,7 +9,7 @@ interface params {
sortValue?: { desc: string; asc: string } // 排序规则,后端制定
}
type sortParam = 'none'|'top'|'bottom'
export default forwardRef(({ status = 'none', onChange, sortValue }: params, ref) => {
const SortBtn = ({ status = 'none', onChange, sortValue }: params, ref) => {
const [sortStatus, setSortStatus] = useState<sortParam>()
useEffect(() => {
setSortStatus(() => status)
@@ -19,11 +19,11 @@ export default forwardRef(({ status = 'none', onChange, sortValue }: params, ref
let value = ''
if (sortStatus == 'none') {
status = 'top'
value = sortValue?.asc!
value = sortValue?.asc as string
}
if (sortStatus == 'top') {
status = 'bottom'
value = sortValue?.desc!
value = sortValue?.desc as string
}
if (sortStatus == 'bottom') { status = 'none' }
setSortStatus(() => status)
@@ -42,4 +42,5 @@ export default forwardRef(({ status = 'none', onChange, sortValue }: params, ref
</View>
</>
)
})
}
export default forwardRef(SortBtn)
+3 -3
View File
@@ -73,10 +73,10 @@ const Table: FC<TablePropsType> = (props) => {
&& dataSource.list.map((source) => {
return (
<View className={classnames(styles.tr, styles['bg-line'])} key={source.key}>
{columns.map((column) => {
{columns.map((column, key) => {
if (column.render) {
return (
<View className={styles.td} style={{ width: column.width }}>
<View key={key} className={styles.td} style={{ width: column.width }}>
{/* 判断表头是不是有render 有就执行render */}
{column.render(source[column.dataIndex])}
</View>
@@ -84,7 +84,7 @@ const Table: FC<TablePropsType> = (props) => {
}
else {
return (
<View className={classnames(styles.td, getColumnStyle(column))} style={{ width: column.width }}>
<View key={key} className={classnames(styles.td, getColumnStyle(column))} style={{ width: column.width }}>
{
source[column.dataIndex] // 根据表头填数据
}
+4 -4
View File
@@ -1,5 +1,5 @@
import { ScrollView, View } from '@tarojs/components'
import type { ReactNode } from 'react'
import type { ReactNode } from 'react'
import { memo, useEffect, useState } from 'react'
import classnames from 'classnames'
import styles from './index.module.scss'
@@ -17,8 +17,7 @@ interface Params {
style?: Object
}
export default memo(({ list = [], defaultValue = 0, tabsOnClick, style = {} }: Params) => {
const Tabs = ({ list = [], defaultValue = 0, tabsOnClick, style = {} }: Params) => {
const [selected, setSelected] = useState(defaultValue)
const [tabId, setTabId] = useState('')
@@ -57,4 +56,5 @@ export default memo(({ list = [], defaultValue = 0, tabsOnClick, style = {} }: P
</View>
</>
)
})
}
export default memo(Tabs)
+6 -4
View File
@@ -11,7 +11,7 @@ interface Param {
defaultValue?: string
onlyRead?: false|true
}
export default memo(({ onChange, title = '', placeholder = '请输入', defaultValue, onlyRead = false }: Param) => {
const TextareaEnhance = ({ onChange, title = '', placeholder = '请输入', defaultValue, onlyRead = false }: Param) => {
const [descData, setDescData] = useState({
number: 0,
value: '',
@@ -38,11 +38,13 @@ export default memo(({ onChange, title = '', placeholder = '请输入', defaultV
<View className={styles.other_desc}>
<View className={styles.title}>{title}</View>
<View className={styles.textarea}>
{(descData.show && !onlyRead) && <Textarea autoFocus value={descData.value} onBlur={() => toggleShowRealTextarea(false)} className={styles.textarea_con} cursorSpacing={100} maxlength={descData.count} onInput={e => getDesc(e.detail.value)}></Textarea>
|| <View className={classnames(styles.textarea_con_pretend, descData.value && styles.textarea_con_pretend_ed)} onClick={() => toggleShowRealTextarea(true)}>{descData.value || placeholder}</View>
{(descData.show && !onlyRead)
? <Textarea autoFocus value={descData.value} onBlur={() => toggleShowRealTextarea(false)} className={styles.textarea_con} cursorSpacing={100} maxlength={descData.count} onInput={e => getDesc(e.detail.value)}></Textarea>
: <View className={classnames(styles.textarea_con_pretend, descData.value && styles.textarea_con_pretend_ed)} onClick={() => toggleShowRealTextarea(true)}>{descData.value || placeholder}</View>
}
<View className={styles.descDataNum}>{`${descData.number}/${descData.count}`}</View>
</View>
</View>
)
})
}
export default memo(TextareaEnhance)
+3 -3
View File
@@ -12,8 +12,7 @@ interface Props {
start?: DateArg
onSelectDate?: (any) => void
}
export default memo((props: Props) => {
const TimePicker = (props: Props) => {
const { start = '', end = '', onSelectDate } = props
const [time, setTime] = useState<any>({})
@@ -49,4 +48,5 @@ export default memo((props: Props) => {
</View> */}
</>
)
})
}
export default memo(TimePicker)
+3 -3
View File
@@ -11,8 +11,7 @@ interface Props {
start?: DateArg
onSelectDate?: (any) => void
}
export default memo((props: Props) => {
const TimePickerPopup = (props: Props) => {
const { showTime = false, closePopup, start = '', end = '', onSelectDate } = props
return (
@@ -20,4 +19,5 @@ export default memo((props: Props) => {
<TimePicker start={start} end={end} onSelectDate={onSelectDate}></TimePicker>
</Popup>
)
})
}
export default memo(TimePickerPopup)
+3 -3
View File
@@ -54,7 +54,7 @@ const popoverStyle = {
color: '#333333',
}
const ToolTip = forwardRef<ToolTipRef, ToolTipPropsType>((props, ref) => {
const ToolTip = (props: ToolTipPropsType, ref) => {
const id = useId()
const [, setForceUpdate] = useState({})
const { placement = 'top-start', defaultVisible = false, onVisibleChange, children, content = '请填入提示信息', customClassName, customStyle, customContentStyle } = props
@@ -326,6 +326,6 @@ const ToolTip = forwardRef<ToolTipRef, ToolTipPropsType>((props, ref) => {
</View>
</>
)
})
}
export default ToolTip
export default forwardRef<ToolTipRef, ToolTipPropsType>(ToolTip)
+13 -13
View File
@@ -13,11 +13,13 @@ interface ImageParam {
defaultList?: string[]
onlyRead?: boolean
}
const PictureItem = memo<ImageParam>(({ onChange, defaultList, onlyRead = false }) => {
const PictureItem = ({ onChange, defaultList, onlyRead = false }: ImageParam) => {
const { getWxPhoto, getChatPhoto } = useUploadCDNImg()
const [imageList, setImageLise] = useState<string[]>([])
// 筛选内容展示
const [showPopup, setshowPopup] = useState(false)
const [List, setList] = useState<any[]>([{ id: 1, name: '手机相册', check: false }, { id: 2, name: '从微信对话选择', check: false }])
useEffect(() => {
setImageLise(defaultList || [])
}, [defaultList])
@@ -29,17 +31,18 @@ const PictureItem = memo<ImageParam>(({ onChange, defaultList, onlyRead = false
// 上传图片逻辑
const handPic = async(id) => {
let list: any
// let resArr = List.filter(item => {
// return item.check
// })
if (id == 1) {
var list: any = await getWxPhoto('after-sale', 5)
}
list = await getWxPhoto('after-sale', 5)
}
else {
var list: any = await getChatPhoto('after-sale', 5)
list = await getChatPhoto('after-sale', 5)
}
const images: any[] = []
list?.map((item) => {
list?.forEach((item) => {
images.push(item.url)
})
setImageLise([...imageList, ...images])
@@ -67,15 +70,12 @@ 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) => {
if (item.id == it.id) {
it.check = true
}
}
else {
it.check = false
}
@@ -89,7 +89,7 @@ const PictureItem = memo<ImageParam>(({ onChange, defaultList, onlyRead = false
<>
<View className={styles.image_main}>
{imageList?.map((item, index) => (
<View className={styles.ImgItem}>
<View className={styles.ImgItem} key={index}>
<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>
@@ -119,6 +119,6 @@ const PictureItem = memo<ImageParam>(({ onChange, defaultList, onlyRead = false
</Popup>
</>
)
})
}
export default PictureItem
export default memo<ImageParam>(PictureItem)