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

This commit is contained in:
xuan 2022-12-05 16:30:09 +08:00
parent d93b66e7d5
commit 639112c038
114 changed files with 2209 additions and 2161 deletions

3
global.d.ts vendored
View File

@ -20,3 +20,6 @@ declare namespace NodeJS {
declare const CURRENT_VERSION: string
declare const CURRENT_GITHASH: string
declare const CURRENT_ENV: string
declare const CURRENT_BASE_URL: string
declare const CURRENT_CAP_HTML_TO_IMAGE_BASE_URL: string
declare const CURRENT_PAY_H5_CODE_URL: string

View File

@ -1,13 +1,13 @@
import Taro, { onAppShow, useDidShow } from '@tarojs/taro'
import type { FC } from 'react'
import { Provider } from 'react-redux'
import configStore from './store'
import { shareShop } from './common/util'
import ContextBlueTooth from '@/use/contextBlueTooth'
import './app.scss'
import Taro, { onAppShow, useDidShow } from '@tarojs/taro'
import { shareShop } from './common/util'
const store = configStore()
const App: FC = (params) => {
const App: FC = (params: { children?: React.ReactNode }) => {
Taro.showShareMenu({
withShareTicket: true,
})

View File

@ -1,21 +1,6 @@
import Taro from '@tarojs/taro'
import Qs from 'qs'
/**
*
* @param path
* @param params
* @param type false true tabbar页面
*/
type ParamLink = 'navigateTo' | 'switchTab' | 'reLaunch' | 'redirectTo'
export const goLink = (path = '', params: object | null = null, way: ParamLink = 'navigateTo') => {
if (path) {
// let params_str = Qs_.stringify(params || {}, { encode: false })
// path = params_str ? path + '?' + params_str : path
path = setUrlQuery({ url: path, query: params })
Taro[way]({ url: path })
}
}
const setUrlQuery = (options: { url: string; query: object | null }) => {
let { url, query } = options
if (!url) { return '' }
@ -35,6 +20,21 @@ const setUrlQuery = (options: { url: string; query: object | null }) => {
}
return url
}
/**
*
* @param path
* @param params
* @param type false true tabbar页面
*/
type ParamLink = 'navigateTo' | 'switchTab' | 'reLaunch' | 'redirectTo'
export const goLink = (path = '', params: object | null = null, way: ParamLink = 'navigateTo') => {
if (path) {
// let params_str = Qs_.stringify(params || {}, { encode: false })
// path = params_str ? path + '?' + params_str : path
path = setUrlQuery({ url: path, query: params })
Taro[way]({ url: path })
}
}
/**
*
* @param object

View File

@ -1,4 +1,4 @@
export const BASE_URL = CURRENT_BASE_URL
// export const BASE_URL = CURRENT_BASE_URL
// export const BASE_URL = `http://192.168.0.75:50001/lymarket`
// export const BASE_URL = `http://192.168.0.89:50001/lymarket`
// export const BASE_URL = `http://10.0.0.5:50001/lymarket`
@ -13,7 +13,7 @@ export const BASE_URL = CURRENT_BASE_URL
// export const BASE_URL = `https://www.zzfzyc.com/lymarket` // 正式环境
// export const BASE_URL = `http://192.168.1.5:40001/lymarket` // 王霞
// export const BASE_URL = `http://192.168.1.7:50002/lymarket` // 添
// export const BASE_URL = `http://192.168.1.28:50002/lymarket` // 婷
export const BASE_URL = 'http://192.168.1.28:50002/lymarket' // 婷
// export const BASE_URL = `http://192.168.1.42:50002/lymarket` // 杰
// CDN

View File

@ -27,7 +27,29 @@ export const formatHashTag = (code = '', name = '', mode = 'both') => {
}
const Digit = 10 * 10
/**
* 精度
* @param {*} num
* @param {*} precision
* @returns
*/
export const strip = (num, precision = 12) => {
return +parseFloat(num.toPrecision(precision))
}
/**
*
* @param {千位分割付} number
* @returns
*/
export const numberWithCommas = ({ number = 0, digit = 2 }) => {
if (!Number.isNaN(Number(number))) {
// return parseFloat(number).toFixed(digit).replace(/^\B(?<!\.\d*)(?=(\d{3})+(?!\d))$/g, ",");
return parseFloat(number).toLocaleString('zh', { minimumFractionDigits: digit })
}
else {
return 0.0
}
}
/**
* 重量 进退位 单位
*/
@ -96,26 +118,6 @@ export const formatDateTime = (val, fmt = 'YYYY-MM-DD HH:mm:ss') => {
}
}
/**
* 精度
* @param {*} num
* @param {*} precision
* @returns
*/
export const strip = (num, precision = 12) => {
return +parseFloat(num.toPrecision(precision))
}
/**
* 转换金额单位
* @param {*} num 金额 / 数值
* @param {*} digit 转换单位
* @returns
*/
export const formatMillionYuan = (num, digit = 10000) => {
return num / digit > 1 ? { num: toDecimal2(num / digit), million: true } : { num, million: false }
}
/**
* 数值保留两位小数
* @param {*} x
@ -123,7 +125,7 @@ export const formatMillionYuan = (num, digit = 10000) => {
*/
export const toDecimal2 = (x) => {
let f = parseFloat(x)
if (isNaN(f)) {
if (Number.isNaN(f)) {
return 0
}
f = `${f}`
@ -139,7 +141,15 @@ export const toDecimal2 = (x) => {
}
return f
}
/**
* 转换金额单位
* @param {*} num 金额 / 数值
* @param {*} digit 转换单位
* @returns
*/
export const formatMillionYuan = (num, digit = 10000) => {
return num / digit > 1 ? { num: toDecimal2(num / digit), million: true } : { num, million: false }
}
/**
* 格式化图片路径
* @param {*} url
@ -173,18 +183,3 @@ export const isLabImage = (imgurl, rgb, suffix = '!w200') => {
return { status: 3, value: `${IMG_CND_Prefix}/mall/no_img.png` }
}
}
/**
*
* @param {千位分割付} number
* @returns
*/
export const numberWithCommas = ({ number = 0, digit = 2 }) => {
if (!isNaN(Number(number))) {
// return parseFloat(number).toFixed(digit).replace(/^\B(?<!\.\d*)(?=(\d{3})+(?!\d))$/g, ",");
return parseFloat(number).toLocaleString('zh', { minimumFractionDigits: digit })
}
else {
return 0.0
}
}

View File

@ -46,7 +46,7 @@ export const getFilterData = (val = {}, arr: string[] = []) => {
for (const key in val) {
if (val[key] !== undefined && val[key] !== null && val[key] !== '' && !arr.includes(key)) {
if (typeof val[key] == 'number') {
if (!isNaN(val[key])) {
if (!Number.isNaN(val[key])) {
res[key] = val[key]
}
}
@ -66,7 +66,7 @@ export const copyObject = (object) => {
if (object.constructor == Object) {
const keys = Object.keys(object)
const newObject = {}
keys.map((key) => {
keys.forEach((key) => {
newObject[key] = copyObject(object[key])
})
return newObject

View File

@ -1,10 +1,10 @@
import { Button, Navigator, ScrollView, Text, View } from '@tarojs/components'
import Taro, { showModal } from '@tarojs/taro'
import { memo, useEffect, useState } from 'react'
import './index.scss'
import { addressDeleteApi, addressListApi } from '@/api/addressManager'
import { alert } from '@/common/common'
import Taro, { showModal } from '@tarojs/taro'
interface Params{
refresherEnabled?: boolean// 是否开启刷新
@ -15,9 +15,12 @@ interface Params{
}
// 地址列表
const AddressList = memo((props: Params) => {
const AddressList = (props: Params) => {
const { addButtonEnabled = true, focusBorderEnabled = false } = props
const { fetchData, state } = addressListApi()
// 焦点
const [focusId, setFocusId] = useState()
// 获取数据
const getData = async() => {
const result = await fetchData()
@ -50,8 +53,6 @@ const AddressList = memo((props: Params) => {
setRefreshState(false)
}
const data = Array.from({ length: 15 })
// 焦点
const [focusId, setFocusId] = useState()
// 列表选择
const handleSelect = (item: any, index: number) => {
props.onSelect && props.onSelect(item, index)
@ -90,7 +91,7 @@ const AddressList = memo((props: Params) => {
// data.length>0?
// data.map((item,index)=>{
return (
<View onLongPress={() => handleDelete(item)} onClick={() => handleSelect(item, index)} className={`address-list ${focusId == item.id && 'address-active'}`}>
<View key={item.id} onLongPress={() => handleDelete(item)} onClick={() => handleSelect(item, index)} className={`address-list ${focusId == item.id && 'address-active'}`}>
<View className="address-user">
{item.name}
{
@ -122,6 +123,6 @@ const AddressList = memo((props: Params) => {
{addButtonEnabled && <Navigator url="/pages/addressAdd/index?type=add" hoverClass="none" className="add-address"></Navigator>}
</View>
)
})
}
export default AddressList
export default memo(AddressList)

View File

@ -16,9 +16,7 @@ interface ListParams {
contentStyle?: object
required?: boolean
}
// 表单列表
const FromList = memo((props: ListParams) => {
const FromList = (props: ListParams) => {
const { type = 'input', value = '', style = {}, labelStyle = {}, contentStyle = {}, required = false } = props
return (
@ -65,7 +63,6 @@ const FromList = memo((props: ListParams) => {
</View>
</View>
)
})
}
const A = () => {}
export default FromList
export default memo(FromList)

View File

@ -16,9 +16,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 (
@ -62,7 +60,6 @@ const FromList = memo((props: ListParams) => {
</View>
</View>
)
})
}
const A = () => {}
export default FromList
export default memo(FromListCertification)

View File

@ -10,20 +10,22 @@ 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 refreshDataRef = useRef({})
// 渲染(数据)
const [data, setData] = useState({
list: [],
total: 0,
})
// 加载刷新数据
const [refreshData, setRefreshData] = useState({
refreshStatus: false,
moreStatus: false,
page: 1,
size: 10,
loading: false,
})
const getData = async(startStatus, endStatus) => {
const tRefreshDataRef = refreshDataRef.current as any
setRefreshData({
@ -70,20 +72,7 @@ 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
@ -133,3 +132,5 @@ export default (props: Params) => {
</InfiniteScroll>
)
}
export default InfiniteScrollPaging

View File

@ -18,7 +18,7 @@ interface Param {
round?: boolean
name?: string
}
export default memo(({ value, onClick, showStatus = false, round = false, name = '' }: Param) => {
const LabAndImg = ({ value, onClick, showStatus = false, round = false, name = '' }: Param) => {
const [imgs, setImgs] = useState<string>('')
// lab是否都是0
@ -76,4 +76,5 @@ export default memo(({ value, onClick, showStatus = false, round = false, name =
<LabAndImgShow value={value} show={labAndImgShow} onClose={closeLabAndImgShow} />
</>
)
})
}
export default memo(LabAndImg)

View File

@ -15,13 +15,7 @@ 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
@ -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

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)

View File

@ -14,7 +14,7 @@ interface ReasonInfoParam {
onClose?: () => void // 关闭
onAdd?: (val: any) => void
}
export default memo(({ show = false, onClose, onAdd }: ReasonInfoParam) => {
const AddCollection = ({ show = false, onClose, onAdd }: ReasonInfoParam) => {
// 获取列表
const [list, setList] = useState([])
const { fetchData: fetchDataList } = FavoriteListApi()
@ -42,8 +42,8 @@ export default memo(({ show = false, onClose, onAdd }: ReasonInfoParam) => {
</View>
</View>
<ScrollView scrollY className={styles.scrollView}>
{list?.map((item: any) => (
<View onClick={() => onAdd?.(item)} className={styles.collection_item}>
{list?.map((item: any, index) => (
<View key={index} onClick={() => onAdd?.(item)} className={styles.collection_item}>
<View className={styles.name}>
{item.name}
<Text>{item.product_color_list?.length || 0}</Text>
@ -55,4 +55,5 @@ export default memo(({ show = false, onClose, onAdd }: ReasonInfoParam) => {
</View>
</Popup>
)
})
}
export default memo(AddCollection)

View File

@ -27,8 +27,7 @@ interface AddresParam {
parent_id?: number
}
export default memo(({
const Address = ({
addressOnSelect,
addressOnChange,
addressOnClose,
@ -64,52 +63,22 @@ export default memo(({
// 获取地址
const { fetchData } = GetAddressListApi()
useEffect(() => {
getProvince()
}, [])
// 选中内容
const selectItem = (item) => {
setSelectId(item.id)
if (selectIndex == 0) {
setSelectArr([{ name: item.name, id: item.id, level: item.level }])
getCity(item.id)
setAreaStatus(false)
setCityStatus(false)
// 获取省市区宽度
const getDomDes = (id) => {
setTimeout(() => {
const query = Taro.createSelectorQuery()
query.select(id).boundingClientRect((rect) => {
const left = rect.left
const clientWidth = rect.width
console.log(clientWidth)
setBottomStyle({
width: `${clientWidth}px`,
left: `${left}px`,
})
}).exec()
}, 100)
}
else if (selectIndex == 1) {
setSelectArr([selectArr[0], { name: item.name, id: item.id, level: item.level }])
area(item.id)
}
else {
setSelectArr([selectArr[0], selectArr[1], { name: item.name, id: item.id, level: item.level }])
getDomDes('#address_tab_2')
}
}
// 地址数据
useEffect(() => {
if (selectArr && selectArr.length > 0) { addressOnChange?.(selectArr) }
}, [selectArr])
// 选中标题
const onSelectIndex = (index) => {
setSelectIndex(index)
const selectid = selectArr[index] ? selectArr[index].id : 0
setSelectId(selectid as number)
if (index == 0) {
getProvince()
}
else if (index == 1) {
const id = selectArr[0]?.id
getCity(id)
}
else {
const id = selectArr[1]?.id
area(id)
}
}
// 获取省
const getProvince = async() => {
const res = await fetchData({ parent_id: 1 })
@ -160,28 +129,54 @@ export default memo(({
addressOnClose?.()
addressOnSelect?.(selectArr)
}
// 获取省市区宽度
const getDomDes = (id) => {
setTimeout(() => {
const query = Taro.createSelectorQuery()
query.select(id).boundingClientRect((rect) => {
const left = rect.left
const clientWidth = rect.width
console.log(clientWidth)
setBottomStyle({
width: `${clientWidth}px`,
left: `${left}px`,
})
}).exec()
}, 100)
// 选中标题
const onSelectIndex = (index) => {
setSelectIndex(index)
const selectid = selectArr[index] ? selectArr[index].id : 0
setSelectId(selectid as number)
if (index == 0) {
getProvince()
}
else if (index == 1) {
const id = selectArr[0]?.id
getCity(id)
}
else {
const id = selectArr[1]?.id
area(id)
}
}
// 点击标题栏
const selectTab = (index) => {
onSelectIndex(index)
getDomDes(`#address_tab_${index}`)
}
useEffect(() => {
getProvince()
}, [])
// 选中内容
const selectItem = (item) => {
setSelectId(item.id)
if (selectIndex == 0) {
setSelectArr([{ name: item.name, id: item.id, level: item.level }])
getCity(item.id)
setAreaStatus(false)
setCityStatus(false)
}
else if (selectIndex == 1) {
setSelectArr([selectArr[0], { name: item.name, id: item.id, level: item.level }])
area(item.id)
}
else {
setSelectArr([selectArr[0], selectArr[1], { name: item.name, id: item.id, level: item.level }])
getDomDes('#address_tab_2')
}
}
// 地址数据
useEffect(() => {
if (selectArr && selectArr.length > 0) { addressOnChange?.(selectArr) }
}, [selectArr])
return (
<>
@ -200,9 +195,9 @@ export default memo(({
<View className={styles.address_list}>
<ScrollView scrollY className={styles.address_scroll}>
<View className={styles.address_scroll_list}>
{list.map((item) => {
{list.map((item, index) => {
return (
<View onClick={() => selectItem(item)} className={classnames(styles.address_list_item, { [styles.addresst_select]: (selectId == item.id) })}>
<View key={index} onClick={() => selectItem(item)} className={classnames(styles.address_list_item, { [styles.addresst_select]: (selectId == item.id) })}>
<View className={styles.address_list_item_name}>{item.name}</View>
{(selectArr[selectIndex]?.id == item.id) && <View className={`iconfont icon-tick ${styles.address_iconfont}`}></View>}
</View>
@ -215,4 +210,5 @@ export default memo(({
</Drawer>
</>
)
})
}
export default memo(Address)

View File

@ -19,8 +19,7 @@ interface Param {
onClick?: (val: number) => void // 点击后触发的事件,返回订单状态
fixedBottom?: true | false // 是否固定在底部
}
export default memo(({ orderInfo, onClick, fixedBottom = true }: Param) => {
const AfterOrderBtns = ({ orderInfo, onClick, fixedBottom = true }: Param) => {
// 售后订单状态
const { ReturnStageApplying, ReturnStageWaitCheck, ReturnStageReturned, ReturnStageQualityCheckPendingRefund, ReturnStageServiceOrderPendingRefund }
= AFTER_ORDER_STATUS
@ -90,19 +89,6 @@ export default memo(({ orderInfo, onClick, fixedBottom = true }: Param) => {
})
}, [orderInfo])
// 点击按钮操作
const submitBtns = throttle((val, index) => {
if (val == 1) {
cancelOrder({ title: '要取消退货吗?', val })
}
else if (val == 6) {
cancelOrder({ title: '要取消退款吗?', val })
}
else {
onClick?.(val)
}
}, 600)
// 取消退货/退款
const { fetchData: returnApplyOrderCancelFetchData } = ReturnApplyOrderCancelApi()
const cancelOrder = ({ title = '', val }) => {
@ -125,7 +111,18 @@ 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)
}
}, 600)
// 显示更多按钮
const [showMore, setShowMore] = useState(false)
const styleTop = useMemo(() => {
@ -174,4 +171,5 @@ export default memo(({ orderInfo, onClick, fixedBottom = true }: Param) => {
)}
</>
)
})
}
export default memo(AfterOrderBtns)

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])}`
@ -26,4 +26,5 @@ export default memo(({ number = 0, status = 1 }: Param) => {
{priceDom()}
</View>
)
})
}
export default memo(AmountShow)

View File

@ -12,16 +12,12 @@ 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)
@ -39,7 +35,9 @@ export default (props: params) => {
const showDot = useMemo(() => {
return list.length > 1
}, [list])
useEffect(() => {
getData()
}, [])
return (
<View className={styles.swiper_con} style={style}>
<Swiper className={styles.xswiper} indicatorColor="#ccc" indicatorActiveColor="#fff" circular indicatorDots={showDot} autoplay>
@ -56,3 +54,5 @@ export default (props: params) => {
</View>
)
}
export default Banner

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: '是否拨打服务热线',
@ -48,3 +48,5 @@ export default ({ show, onClose }: params) => {
</>
)
}
export default BindSalesmanPopup

View File

@ -8,7 +8,7 @@ import SearchInput from '@/components/searchInput'
import Popup from '@/components/bluetooth/Popup'
import useCheckAuthorize from '@/use/useCheckAuthorize'
export default memo(() => {
const LinkBlueTooth = () => {
const { state, init, startScan, connect, disconnect } = useBluetooth()
const { check } = useCheckAuthorize({ scope: 'scope.bluetooth', msg: '请开启小程序蓝牙权限' })
@ -40,6 +40,9 @@ export default memo(() => {
}
const [popupShow, setPopupShow] = useState(false)
const onFindEven = () => {
if (!state.discovering && !state.connected && !state.connecting) { startScan() }
}
// 显示设备列表
const onFindDevice = () => {
check().then((res) => {
@ -55,9 +58,6 @@ export default memo(() => {
}
})
}
const onFindEven = () => {
if (!state.discovering && !state.connected && !state.connecting) { startScan() }
}
// 断开链接
const onDisconnect = () => {
@ -72,9 +72,11 @@ export default memo(() => {
<View className={styles.bluetooth_link} onClick={onFindDevice}>
<View className={classnames(styles.link_status, linkStatus == 3 && styles.link_statused, linkStatus == 2 && styles.link_statused_no)}></View>
{
linkStatus == 1 && <View className={classnames(styles.link_name, styles.link_name_no)}></View>
|| linkStatus == 2 && <View className={classnames(styles.link_name, styles.link_name_no_link)}></View>
|| linkStatus == 3 && <View className={classnames(styles.link_name)}>{linkName}</View>
linkStatus == 1
? <View className={classnames(styles.link_name, styles.link_name_no)}></View>
: linkStatus == 2
? <View className={classnames(styles.link_name, styles.link_name_no_link)}></View>
: linkStatus == 3 ? <View className={classnames(styles.link_name)}>{linkName}</View> : null
}
</View>
</SearchInput>
@ -90,4 +92,5 @@ export default memo(() => {
</>
)
})
}
export default memo(LinkBlueTooth)

View File

@ -12,8 +12,7 @@ interface params {
onOff: () => void
onFind: () => void
}
export default memo(({ state, show = false, onClose, onLink, onOff, onFind }: params) => {
const Bluetooth = ({ state, show = false, onClose, onLink, onOff, onFind }: params) => {
const [popupShow, setPopupShow] = useState(show)
useEffect(() => {
setPopupShow(show)
@ -31,27 +30,33 @@ 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) => {
(state.devices && state.devices.length > 0)
? state?.devices.map((item, key) => {
return (
<View className={style.item} onClick={() => onLink(item)}>
<View key={key} 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>
(!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}>
: <View className={style.noDevice}>
{
(!state.discovering) && <>
(!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>
}
</View>
@ -60,9 +65,11 @@ export default memo(({ state, show = false, onClose, onLink, onOff, onFind }: pa
</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 +77,5 @@ export default memo(({ state, show = false, onClose, onLink, onOff, onFind }: pa
}
</>
)
})
}
export default memo(Bluetooth)

View File

@ -9,7 +9,7 @@ interface params {
status?: false | true // 是否选中
disabled?: false | true // 是否禁用
}
export default forwardRef(({ onSelect, onClose, status = false, disabled = false }: params, ref) => {
const Checkbox = ({ onSelect, onClose, status = false, disabled = false }: params, ref) => {
const [selected, SetSelected] = useState(false)
const onSelectEven = () => {
if (disabled) { return false }
@ -37,4 +37,5 @@ export default forwardRef(({ onSelect, onClose, status = false, disabled = false
</View>
</>
)
})
}
export default forwardRef(Checkbox)

View File

@ -6,8 +6,7 @@ interface Params {
onClose?: () => void
styleObj?: Object
}
export default memo(({ onClose, styleObj = {} }: Params) => {
const CloseBtn = ({ onClose, styleObj = {} }: Params) => {
return (
<View
style={styleObj}
@ -17,4 +16,5 @@ export default memo(({ onClose, styleObj = {} }: Params) => {
<Text className={`iconfont icon-qingkong ${style.icon_a_btn}`}></Text>
</View>
)
})
}
export default memo(CloseBtn)

View File

@ -16,11 +16,8 @@ interface params {
disabled?: true | false // 是否禁用
returnZero?: true | false // 少于最小值时是否归0
}
export default memo((props: params) => {
return <Counter {...props}></Counter>
})
const Counter = memo((props: params) => {
const CounterDisplayName = (props: params) => {
const {
minNum = 0,
maxNum = 10000,
@ -35,6 +32,22 @@ const Counter = memo((props: params) => {
disabled = false,
} = props
const [value, setValue] = useState<any>({ count: defaultNum })
// 保留小数
const formatDigits = (num) => {
num = `${num}`
if (num.includes('.')) {
const res = num.split('.')
if (digits > 0) {
const last_num = res[1].substr(0, digits)
return `${res[0]}.${last_num}`
}
else {
return res[0]
}
}
return parseFloat(num)
}
useEffect(() => {
setValue({ count: defaultNum })
}, [defaultNum])
@ -63,23 +76,6 @@ const Counter = memo((props: params) => {
onClickBtn?.(parseFloat(num_res))
}
// 保留小数
const formatDigits = (num) => {
num = `${num}`
if (num.includes('.')) {
const res = num.split('.')
if (digits > 0) {
const last_num = res[1].substr(0, digits)
return `${res[0]}.${last_num}`
}
else {
return res[0]
}
}
return parseFloat(num)
}
// 检查数据
const checkData = (val) => {
const num = parseFloat(val)
@ -93,14 +89,14 @@ const Counter = memo((props: params) => {
if (res === '') {
onChange?.(minNum)
}
else if (!isNaN(Number(res))) {
else if (!Number.isNaN(Number(res))) {
let count = formatDigits(res)
count = checkData(count)
onChange?.(parseFloat(count as string))
}
else {
const num = parseFloat(res)
if (!isNaN(num)) {
if (!Number.isNaN(num)) {
let count = formatDigits(num)
count = checkData(count)
onChange?.(count as number)
@ -117,7 +113,7 @@ const Counter = memo((props: params) => {
onBlue?.(minNum)
setValue({ count: minNum })
}
else if (!isNaN(num)) {
else if (!Number.isNaN(num)) {
let count = formatDigits(num)
count = checkData(count)
setValue({ count })
@ -142,4 +138,9 @@ const Counter = memo((props: params) => {
</View>
</View>
)
})
}
const Counter = memo(CounterDisplayName)
const CounterWithMemo = (props: params) => {
return <Counter {...props}></Counter>
}
export default memo(CounterWithMemo)

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)

View File

@ -17,7 +17,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 EstimeatedAmount = ({ 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 +28,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 +38,14 @@ 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(EstimeatedAmount)

View File

@ -11,7 +11,7 @@ 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: '',
@ -145,4 +145,5 @@ export default memo(({ onClose, onFiltr, show = false, onRest }: params) => {
</View>
</Popup>
)
})
}
export default memo(Filter)

View File

@ -10,7 +10,7 @@ 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,7 +64,7 @@ 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 {
@ -167,3 +167,5 @@ export default ({ onClose, onFiltr, show = false }: params) => {
</Popup>
)
}
export default FilterV2

View File

@ -25,7 +25,7 @@ interface Params {
refresherTriggered?: true|false
refresherEnabled?: true|false
}
export default memo(({
const InfiniteScroll = ({
styleObj,
selfonScrollToLower,
selfOnScrollToUpper,
@ -91,18 +91,20 @@ export default memo(({
refresherBackground="#F8F8F8"
scrollTop={scrollTop}
>
{!moreStatus && <>
{!moreStatus
? <>
<View style={{ paddingBottom: `${paddingBottom}rpx` }} className={style.scrollViewCon}>
{children}
</View>
</>
|| <>
: <>
{(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>
(statusMore == 2)
? <View className={style.loading_more}><DotLoading /></View>
: <View className={style.noMore}></View>
}
</View>
</View>
@ -115,4 +117,5 @@ export default memo(({
</ScrollView>
</>
)
})
}
export default memo(InfiniteScroll)

View File

@ -2,7 +2,7 @@ import { View } from '@tarojs/components'
import { memo, useMemo } from 'react'
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` } }
@ -19,4 +19,5 @@ export default memo(({ width = 60, color = '#6190e8' }: { width?: number; color?
<View style={styleObj} className={style.loading__ring}></View>
</View>
)
})
}
export default memo(Loading)

View File

@ -8,7 +8,7 @@ interface Params {
title?: string
loadingIcon?: false|true
}
export default memo(({
const LoadingCard = ({
styleLoading = {},
title = '加载中...', // 显示的文字
loadingIcon = true, // 是否显示加载图标
@ -22,4 +22,5 @@ export default memo(({
</View>
</>
)
})
}
export default memo(LoadingCard)

View File

@ -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()
@ -53,3 +53,5 @@ export default ({ children = null, onClick }: param) => {
</MovableArea>
)
}
export default MoveBtn

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({
@ -285,7 +262,27 @@ export default memo(({ orderInfo, showStatus = 'detail', onClick }: Param) => {
const styleTop = useMemo(() => {
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 +318,5 @@ export default memo(({ orderInfo, showStatus = 'detail', onClick }: Param) => {
</View>
</View>
)
})
}
export default memo(OrderBtns)

View File

@ -16,7 +16,7 @@ export interface Params {
position?: 'bottom'|'top'|'right' // 弹出位置
animationEnd?: () => void // 弹出动画结束
}
export default memo((
const Popup = (
{
title = '标题',
show = false,
@ -72,4 +72,5 @@ export default memo((
</View>
</>
)
})
}
export default memo(Popup)

View File

@ -10,7 +10,7 @@ interface Params {
desStatus?: true | false
productList?: any[]
}
export default ({ desStatus = true, productList = [] }: Params) => {
const Product = ({ desStatus = true, productList = [] }: Params) => {
const labAndImgObj = useCallback(
(item) => {
return { lab: item.lab, rgb: item.rgb, texture_url: item.texture_url }
@ -21,7 +21,7 @@ export default ({ desStatus = true, productList = [] }: Params) => {
<View className={styles.products_list}>
{productList?.map((item) => {
return (
<View className={styles.products_item} onClick={() => goLink(`/pages/details/index?id=${item.id}`)}>
<View key={item.id} className={styles.products_item} onClick={() => goLink(`/pages/details/index?id=${item.id}`)}>
<View className={styles.item_img}>
<LabAndImg value={labAndImgObj(item)} />
<View className={styles.num}>{item.product_color_count}</View>
@ -44,3 +44,5 @@ export default ({ desStatus = true, productList = [] }: Params) => {
</View>
)
}
export default Product

View File

@ -20,10 +20,7 @@ interface Params {
defaultValue?: string
borderRadius?: string
}
export default memo(
forwardRef(
(
const Search = (
{
clickOnSearch, // 点击筛选按钮触发
changeOnSearch, // 输入文字触发
@ -39,7 +36,7 @@ export default memo(
borderRadius = '50rpx',
}: Params,
ref,
) => {
) => {
const [inputCon, setInputCon] = useState('')
const debounceTimeRef = useRef(0)
useEffect(() => {
@ -50,15 +47,6 @@ export default memo(
debounceTimeRef.current = debounceTime
}, [debounceTime])
const onInputEven = (e) => {
const value = e.detail.value
changeData(value)
}
useImperativeHandle(ref, () => ({
clearInput,
}))
const clearInput = () => {
setInputCon('')
changeOnSearch?.('')
@ -68,11 +56,16 @@ export default memo(
setInputCon(value)
changeOnSearch?.(value)
}, debounceTimeRef.current)
const onInputEven = (e) => {
const value = e.detail.value
changeData(value)
}
const onSearch = () => {
clickOnSearch?.(inputCon)
}
useImperativeHandle(ref, () => ({
clearInput,
}))
return (
<>
<View className={styles.search_main}>
@ -113,6 +106,9 @@ export default memo(
</View>
</>
)
},
}
export default memo(
forwardRef(
Search,
),
)

View File

@ -17,8 +17,7 @@ interface Params {
titleStyle?: Object
styleObj?: Object
}
export default memo((props: Params) => {
const SearchInput = (props: Params) => {
const {
showTitle = true,
title = '标题',
@ -60,4 +59,5 @@ export default memo((props: Params) => {
{showIcon && <View className={`iconfont icon-jiantou ${styles.icon_more_self}`}></View>}
</View>
)
})
}
export default memo(SearchInput)

View File

@ -15,8 +15,7 @@ interface param {
onChangeCount: (val: any) => any
item: any
}
export default memo((props: param) => {
const ProductItem = (props: param) => {
const { onChangeCount, onChangeSelect, item, sale_model } = props
const selectCallBack = useCallback(() => {
@ -99,4 +98,5 @@ export default memo((props: param) => {
</View>
</View>
)
})
}
export default memo(ProductItem)

View File

@ -25,7 +25,7 @@ interface param {
intoStatus?: 'again' | 'shop'
default_sale_mode?: number // 面料类型0大货 1剪版2散剪
}
export default ({ show = false, onClose, intoStatus = 'shop', default_sale_mode }: param) => {
const ShowCartCopy = ({ 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 },
@ -416,3 +416,5 @@ export default ({ show = false, onClose, intoStatus = 'shop', default_sale_mode
</View>
)
}
export default ShowCartCopy

View File

@ -38,7 +38,7 @@ interface modelClassType {
defaultNum: number
eunit: string
}
export default ({ show = false, onClose, intoStatus = 'shop', default_sale_mode }: param) => {
const ShopCart = ({ show = false, onClose, intoStatus = 'shop', default_sale_mode }: param) => {
const selectList: modelClassType[] = [
{ 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 },
@ -58,13 +58,6 @@ export default ({ show = false, onClose, intoStatus = 'shop', default_sale_mode
}
}, [default_sale_mode])
useEffect(() => {
startTransition(() => {
resetList()
setSelectStatus(true)
})
}, [selectIndex])
// 获取购物车数据数量
const { getShopCount } = useCommonData()
@ -72,12 +65,6 @@ export default ({ show = false, onClose, intoStatus = 'shop', default_sale_mode
const [list, setList] = useState<Record<number, any>>({})
const [loading, setLoading] = useState(false)
const { fetchData: getShoppingFetchData } = GetShoppingCartApi()
const getShoppingCart = async() => {
const { data } = await getShoppingFetchData()
const color_list = data.color_list || []
initList(color_list)
setLoading(false)
}
// 更新单条数据
const getShoppingCartInfo = async(item) => {
@ -106,7 +93,7 @@ export default ({ show = false, onClose, intoStatus = 'shop', default_sale_mode
// 初始化全部数据默认勾选
const initList = (color_list) => {
const obj = {}
color_list?.map((item) => {
color_list?.forEach((item) => {
item.selected = selectIndex == item.sale_mode
const { unit, eunit, step, digits, minNum, maxNum } = selectList[item.sale_mode]
item = { ...item, unit, eunit, step, digits, minNum, maxNum }
@ -114,10 +101,15 @@ export default ({ show = false, onClose, intoStatus = 'shop', default_sale_mode
})
setList(() => ({ ...obj }))
}
const getShoppingCart = async() => {
const { data } = await getShoppingFetchData()
const color_list = data.color_list || []
initList(color_list)
setLoading(false)
}
// 重置勾选数据
const resetList = () => {
Object.values(list)?.map((item) => {
Object.values(list)?.forEach((item) => {
if (selectIndex == item.sale_mode) {
item.selected = true
}
@ -129,6 +121,8 @@ export default ({ show = false, onClose, intoStatus = 'shop', default_sale_mode
setList(() => ({ ...list }))
}
// 绑定业务员和电话号码
const [showBindSalesman, setShowBindSalesman] = useState(false)
// 显示时展示数据
useEffect(() => {
if (!show) {
@ -150,7 +144,7 @@ export default ({ show = false, onClose, intoStatus = 'shop', default_sale_mode
// 全选反选
const [selectStatus, setSelectStatus] = useState(false)
const selectAll = () => {
Object.values(list)?.map((item) => {
Object.values(list)?.forEach((item) => {
if (selectIndex == item.sale_mode) {
item.selected = !selectStatus
list[item.id] = { ...item }
@ -164,7 +158,7 @@ export default ({ show = false, onClose, intoStatus = 'shop', default_sale_mode
useEffect(() => {
let list_count = 0
let select_count = 0
Object.values(list)?.map((item) => {
Object.values(list)?.forEach((item) => {
if (selectIndex == item.sale_mode) {
list_count++
if (item.selected) { select_count++ }
@ -172,7 +166,18 @@ export default ({ show = false, onClose, intoStatus = 'shop', default_sale_mode
})
setSelectStatus(select_count == list_count)
}, [list])
// 计数组件-当后端修改完成才修改前端显示
const { fetchData: fetchDataUpdateShoppingCart } = UpdateShoppingCartApi()
const getInputValue = debounce(async(item) => {
const res = await fetchDataUpdateShoppingCart({ id: item.id, roll: item.roll, length: item.length })
if (res.success) {
console.log('item修改', item)
getShoppingCartInfo(item)
}
else {
setList(e => ({ ...e }))
}
}, 300)
// 修改数量
const onChangeCount = useCallback((item) => {
getInputValue(item)
@ -188,7 +193,16 @@ export default ({ show = false, onClose, intoStatus = 'shop', default_sale_mode
onClose?.()
setShowPopup(false)
}
// 获取面料选中的id
const selectIds = useRef<number[]>([])
const getSelectId = () => {
selectIds.current = []
Object.values(list)?.forEach((item) => {
if (selectIndex == item.sale_mode) {
item.selected && selectIds.current.push(item.id)
}
})
}
// 删除购物车内容
const { fetchData: delShopFetchData } = DelShoppingCartApi()
const delSelect = () => {
@ -221,24 +235,13 @@ export default ({ show = false, onClose, intoStatus = 'shop', default_sale_mode
})
}
// 获取面料选中的id
const selectIds = useRef<number[]>([])
const getSelectId = () => {
selectIds.current = []
Object.values(list)?.map((item) => {
if (selectIndex == item.sale_mode) {
item.selected && selectIds.current.push(item.id)
}
})
}
// 预估金额和总条数
const estimatePrice = useMemo(() => {
let estimate_amount = 0
const product_list = new Set() // 面料
let color_count = 0 // 颜色数量
let all_count = 0 // 总数量
Object.values(list)?.map((item) => {
Object.values(list)?.forEach((item) => {
if (item.selected) {
estimate_amount += item.estimate_amount
product_list.add(item.product_id)
@ -256,10 +259,10 @@ export default ({ show = false, onClose, intoStatus = 'shop', default_sale_mode
}, [list])
// 去结算
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)
@ -283,22 +286,6 @@ export default ({ show = false, onClose, intoStatus = 'shop', default_sale_mode
}
}, 500)
// 计数组件-当后端修改完成才修改前端显示
const { fetchData: fetchDataUpdateShoppingCart } = UpdateShoppingCartApi()
const getInputValue = debounce(async(item) => {
const res = await fetchDataUpdateShoppingCart({ id: item.id, roll: item.roll, length: item.length })
if (res.success) {
console.log('item修改', item)
getShoppingCartInfo(item)
}
else {
setList(e => ({ ...e }))
}
}, 300)
// 绑定业务员和电话号码
const [showBindSalesman, setShowBindSalesman] = useState(false)
// 显示图片弹窗
const [showLabImage, setShowLabImage] = useState(false)
const [labImageValue, setLabImageValue] = useState()
@ -314,7 +301,12 @@ export default ({ show = false, onClose, intoStatus = 'shop', default_sale_mode
onClose?.()
goLink('/pages/index/index', null, 'switchTab')
}, [])
useEffect(() => {
startTransition(() => {
resetList()
setSelectStatus(true)
})
}, [selectIndex])
return (
<View className={styles.shop_cart_main}>
<Popup showTitle={false} show={showPopup} onClose={() => closePopup()}>
@ -346,7 +338,7 @@ export default ({ show = false, onClose, intoStatus = 'shop', default_sale_mode
<InfiniteScroll moreStatus={false}>
<View className={styles.product_list}>
{listData?.map((item) => {
return <ProductItem sale_model={selectIndex} onChangeCount={onChangeCount} onChangeSelect={onChangeSelect} item={item} />
return <ProductItem key={item.id} sale_model={selectIndex} onChangeCount={onChangeCount} onChangeSelect={onChangeSelect} item={item} />
})}
</View>
</InfiniteScroll>
@ -388,3 +380,4 @@ export default ({ show = false, onClose, intoStatus = 'shop', default_sale_mode
</View>
)
}
export default ShopCart

View File

@ -24,9 +24,7 @@ interface Params {
statusMore?: StatusParam
selectClass?: (val: number) => void
}
export default memo(
({
const SideBar = ({
list = [],
defaultValue = 0,
height = '100vh',
@ -39,33 +37,12 @@ export default memo(
hasMore = true,
statusMore = 0,
selectClass,
}: Params) => {
}: Params) => {
const num_half = useRef(0)
const [selected, setSelected] = useState(defaultValue)
const [tabId, setTabId] = useState('')
useEffect(() => {
setSelected(defaultValue)
}, [defaultValue])
const init = () => {
const index = list?.findIndex((item) => {
return item.id == defaultValue
})
if (index !== -1) {
computeSelectTab(index)
}
}
const clickEvent = ({ item, index }: { item; index: number }) => {
setSelected(item.id)
sideBarOnClick?.(item)
computeSelectTab(index)
setClassId(-1)
selectClass?.(-1)
}
const computeSelectTab = (index) => {
if (index + 1 > num_half.current) {
const num = index + 1 - num_half.current
@ -76,25 +53,6 @@ export default memo(
}
}
useEffect(() => {
Taro.nextTick(() => {
const query = Taro.createSelectorQuery()
query
.select('.side_bar_select')
.boundingClientRect((rect) => {
console.log('rect::', rect)
const clientHeight = rect.height
const clientWidth = rect.width
const ratio = 750 / clientWidth
const height = clientHeight * ratio
num_half.current = Math.ceil(height / 2 / heightItem)
console.log('num_half::', num_half)
init()
})
.exec()
})
}, [])
// 二级面料系列分类
const [openClass, setOpenClass] = useState(false)
const [classList, setClassList] = useState([])
@ -118,6 +76,43 @@ export default memo(
setClassId(() => id)
}
const init = () => {
const index = list?.findIndex((item) => {
return item.id == defaultValue
})
if (index !== -1) {
computeSelectTab(index)
}
}
const clickEvent = ({ item, index }: { item; index: number }) => {
setSelected(item.id)
sideBarOnClick?.(item)
computeSelectTab(index)
setClassId(-1)
selectClass?.(-1)
}
useEffect(() => {
setSelected(defaultValue)
}, [defaultValue])
useEffect(() => {
Taro.nextTick(() => {
const query = Taro.createSelectorQuery()
query
.select('.side_bar_select')
.boundingClientRect((rect) => {
console.log('rect::', rect)
const clientHeight = rect.height
const clientWidth = rect.width
const ratio = 750 / clientWidth
const height = clientHeight * ratio
num_half.current = Math.ceil(height / 2 / heightItem)
console.log('num_half::', num_half)
init()
})
.exec()
})
}, [])
return (
<>
<View className={classnames(styles.sideBar_main, 'side_bar_select')}>
@ -155,5 +150,7 @@ export default memo(
</View>
</>
)
},
}
export default memo(
SideBar,
)

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)

View File

@ -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)

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)

View File

@ -1,12 +1,10 @@
import { Button, ScrollView, Text, View } from '@tarojs/components'
import { stopPullDownRefresh, usePullDownRefresh } from '@tarojs/taro'
import { useState } from 'react'
import { View } from '@tarojs/components'
import useLogin from '@/use/useLogin'
import AddressList from '@/components/AddressList'
import './index.scss'
export default () => {
const AddressManager = () => {
useLogin()
return (
<View className="address-manager">
@ -14,3 +12,4 @@ export default () => {
</View>
)
}
export default AddressManager

View File

@ -23,7 +23,7 @@ interface Param {
onSelectChange?: (val: { color_id: number; length: number; status: true|false; sale_order_detail_id: number }) => void
}
const kindeList: FC<Param> = memo(({ order, onSelectChange }) => {
const KindeList: FC<Param> = ({ order, onSelectChange }) => {
// checkbox选中回调
const selectCallBack = (colorItem) => {
onSelectChange?.({ color_id: colorItem.product_color_id, length: colorItem.length, sale_order_detail_id: colorItem.sale_order_detail_id, status: true })
@ -36,13 +36,13 @@ const kindeList: FC<Param> = memo(({ order, onSelectChange }) => {
return (
<View className={styles.apply_after_sales_list}>
{order?.av_return_product?.map(item => <View className={styles.apply_after_sales_item} >
{order?.av_return_product?.map((item, index) => <View className={styles.apply_after_sales_item} key={index}>
<View className={styles.apply_after_sales_title}>
<View className={styles.tag}>{order.sale_mode_name}</View>
<View className={styles.title}>{formatHashTag(item.product_code, item.product_name)}</View>
</View>
<View className={styles.color_list}>
{item?.av_product_color?.map(colorItem => <View className={styles.color_item}>
{item?.av_product_color?.map((colorItem, key) => <View className={styles.color_item} key={key}>
<View className={styles.image}><Image src={formatImgUrl('')} /></View>
<View className={styles.name_and_number}><Text>{`${colorItem.product_color_code} ${colorItem.product_color_name}`}</Text><Text>x {colorItem.length / 100} m</Text></View>
<MCheckbox status={item.select} onSelect={() => selectCallBack(colorItem)} onClose={() => colseCallBack(colorItem)} />
@ -51,6 +51,6 @@ const kindeList: FC<Param> = memo(({ order, onSelectChange }) => {
</View>)}
</View>
)
})
}
export default kindeList
export default memo(KindeList)

View File

@ -23,7 +23,7 @@ interface Param {
onNumChange?: (val: any) => void
}
const kindeList: FC<Param> = memo(({ order, onNumChange }) => {
const KindeList: FC<Param> = ({ order, onNumChange }) => {
// 计步器返回值
const getCounterChange = useCallback((colorItem) => {
return (number) => {
@ -33,13 +33,13 @@ const kindeList: FC<Param> = memo(({ order, onNumChange }) => {
return (
<View className={styles.apply_after_sales_list}>
{order?.av_return_product?.map(item => <View className={styles.apply_after_sales_item}>
{order?.av_return_product?.map((item, index) => <View className={styles.apply_after_sales_item} key={index}>
<View className={styles.apply_after_sales_title}>
<View className={styles.tag}>{order.sale_mode_name}</View>
<View className={styles.title}>{formatHashTag(item.product_code, item.product_name)}</View>
</View>
<View className={styles.color_list}>
{item?.av_product_color?.map(colorItem => <View className={styles.color_item}>
{item?.av_product_color?.map((colorItem, key) => <View className={styles.color_item} key={key}>
<View className={styles.image}><Image src={formatImgUrl('')} /></View>
<View className={styles.name_and_number}><Text>{`${colorItem.product_color_code} ${colorItem.product_color_name}`}</Text><Text>x {colorItem.roll}</Text></View>
<View className={styles.btn_count}>
@ -50,6 +50,6 @@ const kindeList: FC<Param> = memo(({ order, onNumChange }) => {
</View>)}
</View>
)
})
}
export default kindeList
export default memo(KindeList)

View File

@ -7,7 +7,7 @@ import styles from './index.module.scss'
interface Param {
onChange: (val: string) => void
}
export default memo(({ onChange }: Param) => {
const OtherReason = ({ onChange }: Param) => {
const [descData, setDescData] = useState({
number: 0,
value: '',
@ -31,11 +31,13 @@ export default memo(({ onChange }: Param) => {
<View className={styles.other_desc}>
<View className={styles.title}></View>
<View className={styles.textarea}>
{descData.show && <Textarea autoFocus value={descData.value} onBlur={() => toggleShowRealTextarea(false)} className={styles.textarea_con} cursorSpacing={100} maxlength={descData.count} onInput={e => getDesc(e)}></Textarea>
|| <View className={classnames(styles.textarea_con_pretend, descData.value && styles.textarea_con_pretend_ed)} onClick={() => toggleShowRealTextarea(true)}>{descData.value || '一般情况下选填,当退货说明=“其它问题”时,必填'}</View>
{descData.show
? <Textarea autoFocus value={descData.value} onBlur={() => toggleShowRealTextarea(false)} className={styles.textarea_con} cursorSpacing={100} maxlength={descData.count} onInput={e => getDesc(e)}></Textarea>
: <View className={classnames(styles.textarea_con_pretend, descData.value && styles.textarea_con_pretend_ed)} onClick={() => toggleShowRealTextarea(true)}>{descData.value || '一般情况下选填,当退货说明=“其它问题”时,必填'}</View>
}
<View className={styles.descDataNum}>{`${descData.number}/${descData.count}`}</View>
</View>
</View>
)
})
}
export default memo(OtherReason)

View File

@ -17,7 +17,7 @@ interface ReasonInfoParam {
defaultValue?: number // 默认选中
dataLength?: number // 可显示的数据列数
}
export default memo(({ show = false, onClose, title = '', list = [], onSelect, onHeaderSelect, defaultValue, dataLength = 1 }: ReasonInfoParam) => {
const ReasonPopup = ({ show = false, onClose, title = '', list = [], onSelect, onHeaderSelect, defaultValue, dataLength = 1 }: ReasonInfoParam) => {
const [initList, setInitList] = useState<typeof list>([])
useEffect(() => {
@ -59,4 +59,5 @@ export default memo(({ show = false, onClose, title = '', list = [], onSelect, o
</View>
</Popup>
)
})
}
export default memo(ReasonPopup)

View File

@ -19,11 +19,8 @@ enum returnStatus {
goods_status = 2, // 状况
return_explain = 3, // 说明
}
export default () => {
const ApplyAfterSales = () => {
useLogin()
useDidShow(() => {
getSaleOrderPreView()
})
const router = useRouter()
const orderId = useRef<number>(Number(router.params.id))
@ -50,13 +47,9 @@ export default () => {
}
}
// 监听获取到的数据
useEffect(() => {
if (orderDetail) {
formatData()
}
}, [orderDetail])
useDidShow(() => {
getSaleOrderPreView()
})
// 格式化数据格式
const [formatDetailOrder, setFormatDetailOrder] = useState<any>() // 格式化后的数据
const formatData = () => {
@ -88,7 +81,12 @@ export default () => {
}
setSubmitData(e => ({ ...e, roll_list: Object.values(roll_list.current) }))
}, [])
// 监听获取到的数据
useEffect(() => {
if (orderDetail) {
formatData()
}
}, [orderDetail])
// 散剪和剪板
const getSelectChange = useCallback((val) => {
if (val.status) {
@ -144,9 +142,6 @@ export default () => {
const onShowReason = () => {
setShowReason(true)
}
useEffect(() => {
getReturnReason()
}, [])
// 请求获取到的数据
const [returnGoodsInfo, setReturnGoodsInfo] = useState([])
@ -157,6 +152,9 @@ export default () => {
const res = await fetchDataReturnReason()
setReturnGoodsInfo(e => res.data?.list)
}
useEffect(() => {
getReturnReason()
}, [])
// 售后退货说明
const { fetchData: fetchDataReturnExplain } = ReturnExplainApi()
const getReturnExplain = async(id) => {
@ -273,3 +271,5 @@ export default () => {
</View>
)
}
export default ApplyAfterSales

View File

@ -11,7 +11,7 @@ interface params {
onClose?: () => void
saleMan?: string
}
export default ({ show = false, saleMan = '', onClose }: params) => {
const SuccessBind = ({ show = false, saleMan = '', onClose }: params) => {
const onClick = async() => {
onClose?.()
goLink('/pages/index/index', {}, 'switchTab')
@ -37,3 +37,5 @@ export default ({ show = false, saleMan = '', onClose }: params) => {
</>
)
}
export default SuccessBind

View File

@ -11,13 +11,9 @@ import CloseBtn from '@/components/closeBtn'
import { BindInvitationInfoApi, GetInvitationInfoApi } from '@/api/user'
import { debounce, getFilterData, throttle } from '@/common/util'
export default () => {
const BindSalesman = () => {
useLogin()
useEffect(() => {
onClipboardData()
}, [])
const [submitData, setSubmitData] = useState({
invitation_code: '',
})
@ -71,7 +67,9 @@ export default () => {
},
})
}
useEffect(() => {
onClipboardData()
}, [])
return (
<View className={styles.bindSalesmanPage_main}>
<View className={styles.header_image}>
@ -113,3 +111,5 @@ export default () => {
</View>
)
}
export default BindSalesman

View File

@ -1,14 +1,13 @@
import { Text, View } from '@tarojs/components'
import { forwardRef, useEffect, useImperativeHandle, useState } from 'react'
import Popup from '@/components/popup'
import './SelectEnterpriseType.scss'
import { forwardRef, useEffect, useImperativeHandle, useState } from 'react'
import { certificationTypeListApi } from '@/api/certification'
interface Params{
confirm?: (selected: any) => void // 确定
}
export default forwardRef((props: Params, ref) => {
const SelectEnterpriseType = (props: Params, ref) => {
const [modalShow, setModalShow] = useState(false)
// 获取认证信息
const { fetchData, state } = certificationTypeListApi()
@ -53,4 +52,5 @@ export default forwardRef((props: Params, ref) => {
</Popup>
</View>
)
})
}
export default forwardRef(SelectEnterpriseType)

View File

@ -13,22 +13,9 @@ import { IMG_CND_Prefix } from '@/common/constant'
import { useSelector } from '@/reducers/hooks'
import useLogin from '@/use/useLogin'
export default () => {
const Certification = () => {
const { getAdminUserInfo } = useLogin()
const { adminUserInfo } = useSelector(state => state.userInfo)
useEffect(() => {
initalFormData()
}, [])
// 获取认证信息
const { fetchData: getFromData } = certificationDetailApi()
const initalFormData = async() => {
const detail = await getFromData()
setFormData({
...detail.data ?? {},
legal_person_identity_url: detail?.data?.legal_person_identity_url ?? [],
// business_license_url: "https://test.cdn.zzfzyc.com/mall/827082e888860dd9da10f0fbb0ac3cf023081456.png"
} as any)
}
// 保存
const [formData, setFormData] = useState({
authentication_type: 0,
@ -40,6 +27,20 @@ export default () => {
legal_person_identity_url: [],
name: '',
})
// 获取认证信息
const { fetchData: getFromData } = certificationDetailApi()
const initalFormData = async() => {
const detail = await getFromData()
setFormData({
...detail.data ?? {},
legal_person_identity_url: detail?.data?.legal_person_identity_url ?? [],
// business_license_url: "https://test.cdn.zzfzyc.com/mall/827082e888860dd9da10f0fbb0ac3cf023081456.png"
} as any)
}
useEffect(() => {
initalFormData()
}, [])
const rules = {
// authentication_type: [{
// message: "请选择认证类型"
@ -201,3 +202,5 @@ export default () => {
</View>
)
}
export default Certification

View File

@ -11,12 +11,15 @@ import { DelFavoriteProductApi, DetailFavoriteProductApi, MoveFavoriteProductApi
import MCheckbox from '@/components/checkbox'
import AddCollection from '@/components/addCollection'
export default () => {
const CollectionClass = () => {
const router = useRouter()
// 获取收藏夹面料
const { fetchData: fetchDataDetailFavoriteProduct } = DetailFavoriteProductApi()
const [colorInfo, setColorInfo] = useState<any>({})
// 获取搜索数据
const [searchData, setSearchData] = useState({ id: 0, code_or_name: '' })
const getFavoriteInfo = async() => {
const res = await fetchDataDetailFavoriteProduct(searchData)
if (res.success) {
@ -27,8 +30,6 @@ export default () => {
}
}
// 获取搜索数据
const [searchData, setSearchData] = useState({ id: 0, code_or_name: '' })
const onSearch = useCallback((e) => {
setSearchData(val => ({ ...val, code_or_name: e }))
}, [])
@ -53,15 +54,6 @@ export default () => {
// 全选反选
const [allSelectStatus, setAllSelectStatus] = useState(false)
const selectCallBack = useCallback(() => {
setAllSelectStatus(() => true)
setSelectStatus(1)
}, [])
const colseCallBack = useCallback(() => {
setAllSelectStatus(() => false)
setSelectStatus(3)
}, [])
const [selectStatus, setSelectStatus] = useState<1 | 2 | 3>(3)
useEffect(() => {
if (colorInfo.product_color_list?.length) {
@ -84,7 +76,14 @@ export default () => {
const closeCollection = useCallback(() => {
setCollectionShow(false)
}, [])
const selectCallBack = useCallback(() => {
setAllSelectStatus(() => true)
setSelectStatus(1)
}, [])
const colseCallBack = useCallback(() => {
setAllSelectStatus(() => false)
setSelectStatus(3)
}, [])
// 移动面料
const { fetchData: fetchDataMoveFavoriteProduct } = MoveFavoriteProductApi()
const onAdd = async(val) => {
@ -145,3 +144,5 @@ export default () => {
</View>
)
}
export default CollectionClass

View File

@ -17,7 +17,7 @@ interface ReasonInfoParam {
name: string
} // 默认数据
}
export default memo(({ show = false, onClose, onSuccess, defaultValue }: ReasonInfoParam) => {
const CreatePopup = ({ show = false, onClose, onSuccess, defaultValue }: ReasonInfoParam) => {
const submitData = useRef({
name: '',
remark: '',
@ -36,7 +36,7 @@ export default memo(({ show = false, onClose, onSuccess, defaultValue }: ReasonI
}
useEffect(() => {
submitData.current = { name: defaultValue?.name!, remark: defaultValue?.remark! }
submitData.current = { name: defaultValue?.name as string, remark: defaultValue?.remark as string }
}, [defaultValue])
return (
<Popup show={show} title="新建收藏夹" onClose={onClose}>
@ -71,4 +71,5 @@ export default memo(({ show = false, onClose, onSuccess, defaultValue }: ReasonI
</View>
</Popup>
)
})
}
export default memo(CreatePopup)

View File

@ -13,7 +13,7 @@ interface Params {
selectStatus?: 1|2|3 // 1全选2不做处理3全清空
openCheckBox?: true|false // 是否开启选择
}
export default ({ productList, onSelectIds, selectStatus = 2, openCheckBox = false }: Params) => {
const Product = ({ productList, onSelectIds, selectStatus = 2, openCheckBox = false }: Params) => {
const [list, setList] = useState<any[]>([])
useEffect(() => {
setList(() => productList || [])
@ -21,22 +21,12 @@ export default ({ productList, onSelectIds, selectStatus = 2, openCheckBox = fal
useEffect(() => {
if (list.length && selectStatus != 2) {
list.map((item) => {
list.forEach((item) => {
item.check = (selectStatus == 1)
})
setList(() => [...list])
}
}, [selectStatus])
const onChangeSelect = (item) => {
if (item.check) {
onClose(item)
}
else {
onSelect(item)
}
}
// 选中和取消选中
const onSelect = (item) => {
item.check = true
@ -46,11 +36,19 @@ export default ({ productList, onSelectIds, selectStatus = 2, openCheckBox = fal
item.check = false
setList(() => ([...list]))
}
const onChangeSelect = (item) => {
if (item.check) {
onClose(item)
}
else {
onSelect(item)
}
}
// 监听数据变化
useEffect(() => {
const ids: number[] = []
list.map((item) => {
list.forEach((item) => {
if (item.check) { ids.push(item.product_id) }
})
onSelectIds?.(ids)
@ -58,8 +56,8 @@ export default ({ productList, onSelectIds, selectStatus = 2, openCheckBox = fal
return (
<View className={styles.products_list}>
{list?.map((item) => {
return <View className={styles.products_item} onClick={() => openCheckBox ? onChangeSelect(item) : goLink(`/pages/details/index?id=${item.product_id}`)}>
{list?.map((item, index) => {
return <View key={index} className={styles.products_item} onClick={() => openCheckBox ? onChangeSelect(item) : goLink(`/pages/details/index?id=${item.product_id}`)}>
{openCheckBox && <View className={styles.checkbox} onClick={e => e.stopPropagation()}>
<MCheckbox status={item.check} onSelect={() => onSelect(item)} onClose={() => onClose(item)} />
</View>}
@ -81,3 +79,5 @@ export default ({ productList, onSelectIds, selectStatus = 2, openCheckBox = fal
</View>
)
}
export default Product

View File

@ -16,7 +16,7 @@ interface ReasonInfoParam {
onDelete?: () => void // 删除
}
export default memo(({ show = false, onClose, onUpdate, onBatchManagement, onDelete }: ReasonInfoParam) => {
const UpdatePopup = ({ show = false, onClose, onUpdate, onBatchManagement, onDelete }: ReasonInfoParam) => {
const onClickEven = (val) => {
if (val == 1) {
onUpdate?.()
@ -46,4 +46,5 @@ export default memo(({ show = false, onClose, onUpdate, onBatchManagement, onDel
</View>
</Popup>
)
})
}
export default memo(UpdatePopup)

View File

@ -1,4 +1,5 @@
import Taro, { useDidHide, useDidShow } from '@tarojs/taro'
import { Text, View } from '@tarojs/components'
import classnames from 'classnames'
import { useCallback, useEffect, useRef, useState } from 'react'
import Product from './components/product'
@ -10,25 +11,15 @@ 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 { View, Text } from '@tarojs/components'
export default () => {
const Collection = () => {
useLogin()
const changeOpenCon = (item) => {
item.openStatus = !item.openStatus
setList(e => [...e])
}
useDidShow(() => {
getFavoriteList()
})
// 获取搜索数据
const [searchData, setSearchData] = useState('')
const onSearch = useCallback((e) => {
setSearchData(() => e)
}, [])
useEffect(() => {
getFavoriteList()
}, [searchData])
// 获取列表
const [list, setList] = useState([])
@ -37,18 +28,32 @@ export default () => {
const res = await fetchDataList(getFilterData({ name: searchData }))
setList(() => res.data.list)
}
const changeOpenCon = (item) => {
item.openStatus = !item.openStatus
setList(e => [...e])
}
useDidShow(() => {
getFavoriteList()
})
// 创建收藏夹
const [collectioinShow, setCollectioinShow] = useState(false)
const closeCollection = useCallback(() => {
setCollectioinShow(false)
}, [])
// 更多编辑
const [initData, setInitData] = useState({
remark: '',
name: '',
id: 0,
})
const creatShow = () => {
setCollectioinShow(true)
setInitData(() => ({ remark: '', name: '', id: 0 }))
}
useEffect(() => {
getFavoriteList()
}, [searchData])
// 新增
const { fetchData } = CreateFavoriteApi()
const onCreate = async(submitData) => {
@ -63,12 +68,6 @@ export default () => {
}
}
// 更多编辑
const [initData, setInitData] = useState({
remark: '',
name: '',
id: 0,
})
const selectInfo = useRef<any>(null)
const [updateShow, setUpdateShow] = useState(false)
const closeUpdate = useCallback(() => {
@ -149,7 +148,7 @@ export default () => {
<View className={styles.miconfont_con} onClick={creatShow}><Text className={classnames(styles.miconfont, 'iconfont icon-jia')}></Text></View>
</View>
<View className={styles.class_list}>
{list?.map((item: any) => <View className={styles.class_item}>
{list?.map((item: any, key) => <View className={styles.class_item} key={key}>
<View key={item.id} className={styles.class_title} onClick={() => changeOpenCon(item)}>
<Text className={classnames(styles.miconfont_left, 'iconfont icon-a-moreback', item.openStatus ? styles.miconfont_open : styles.miconfont_close)}></Text>
<View className={styles.title}>{item.name}
@ -167,3 +166,5 @@ export default () => {
</View>
)
}
export default Collection

View File

@ -9,26 +9,12 @@ import { companyDetailApi, companyUpdateApi } from '@/api/company'
import './index.scss'
import useLogin from '@/use/useLogin'
export default () => {
const Company = () => {
useLogin()
const [showSiteModal, setShowSiteModal] = useState(false)
const handleSelectSite = () => {
setShowSiteModal(true)
}
// 获取公司信息
const { fetchData: getFromData } = companyDetailApi()
const getData = async() => {
const result = await getFromData()
console.log(result.data, '===')
setFormData({
...result.data,
})
}
useEffect(() => {
getData()
}, [])
// 保存
const [formData, setFormData] = useState({
address_detail: '',
@ -46,6 +32,21 @@ export default () => {
site: '',
siteArray: [],
})
// 获取公司信息
const { fetchData: getFromData } = companyDetailApi()
const getData = async() => {
const result = await getFromData()
console.log(result.data, '===')
setFormData({
...result.data,
})
}
useEffect(() => {
getData()
}, [])
const rules = {
company_name: [{
message: '请输入公司名称',
@ -145,7 +146,9 @@ export default () => {
<Button style={{ background: hozon ? '#007aff' : '' }} hoverClass="none" className="save-button" onClick={handleSave}></Button>
{/* <Address addressOnClose={()=>setShowSiteModal(false)} show={showSiteModal}/> */}
<Address addressOnSelect={handleSetSite} defaultValue={[{ name: '广东省', id: 193, level: 2 }, { name: '佛山市', id: 202, level: 3 }, { name: '高明区', id: 204, level: 4 }]} addressOnClose={() => setShowSiteModal(false)} show={showSiteModal} />
<Address addressOnSelect={handleSetSite} defaultValue={[{ name: '广东省', id: 193, level: 2 }, { name: '佛山市', id: 202, level: 3 }, { name: '高明区', id: 204, level: 4 }]} addressOnClose={() => setShowSiteModal(false)} show={showSiteModal} />
</View>
)
}
export default Company

View File

@ -1,7 +1,7 @@
import { Button, Canvas, Navigator, ScrollView, Text, View } from '@tarojs/components'
import Taro, { useReady } from '@tarojs/taro'
import { useEffect, useState } from 'react'
import React, { useEffect, useState } from 'react'
import AddressList from '@/components/AddressList'
import { creditInfoApi } from '@/api/creditLine'
import './index.scss'
@ -10,156 +10,11 @@ import { formatDateTime, formatPriceDiv } from '@/common/fotmat'
import Message from '@/components/Message'
import useLogin from '@/use/useLogin'
export default () => {
useLogin()
const userInfo = useSelector(state => state.userInfo)
useEffect(() => {
getData()
}, [])
const { fetchData, state } = creditInfoApi()
const [data, setData] = useState({
credit_quota_used_line: [0, '00'],
credit_quota_line: [0, '00'],
credit_quota_available_line: [0, '00'],
progress: 0,
create_time: '',
quota_status_name: '',
quota_status: '',
credit_quota_start_time: '',
credit_quota_end_time: '',
})
const [style, setStyle] = useState({
type: {},
cir: {
color: '',
background: { start: [], end: [] },
},
available: {},
bottomTitle: {},
})
// 获取数据
const getData = async() => {
const result = await fetchData()
const credit_quota_used_line = convertPrice(formatPriceDiv(result.data.credit_quota_used_line))
const credit_quota_line = convertPrice(formatPriceDiv(result.data.credit_quota_line))
const credit_quota_available_line = convertPrice(formatPriceDiv(result.data.credit_quota_available_line))
const progress = credit_quota_available_line[0] == 0 && credit_quota_line[0] == 0 ? 100 : ((credit_quota_available_line[0] ?? 0) / (credit_quota_line[0] ?? 0) * 100).toFixed(0)
switch (Number(result.data.quota_status)) {
case 0:// 暂未开通
setStyle({
type: { background: '#e4e4ff', color: '#1818B4' },
cir: {
color: '#707070',
background: { start: ['#727272', '#CDCDCD'] as any, end: ['#CDCDCD', '#EEEEEE'] as any },
},
available: { color: '#707070', textDecoration: 'line-through' },
bottomTitle: { color: '#cccccc' },
})
break
case 1:// 申请中
setStyle({
type: { background: '#cde5ff', color: '#007AFF' },
cir: {
color: '#707070',
background: { start: ['#727272', '#CDCDCD'] as any, end: ['#CDCDCD', '#EEEEEE'] as any },
},
available: { color: '#707070', textDecoration: 'line-through' },
bottomTitle: { color: '#cccccc' },
})
break
case 2:// 生效中
setStyle({
type: { background: '#cde5ff', color: '#007AFF' },
cir: {
color: '#007aff',
background: { start: ['#047CFF', '#51A4FF'] as any, end: ['#87C0FF', '#57A8FF'] as any },
},
available: { color: '#007aff' },
bottomTitle: { color: '#007AFF' },
})
break
case 3:// 已失效
setStyle({
type: { background: '#f6f6f6', color: '#ABABAB' },
cir: {
color: '#707070',
background: { start: ['#727272', '#CDCDCD'] as any, end: ['#CDCDCD', '#EEEEEE'] as any },
},
available: { color: '#707070', textDecoration: 'line-through' },
bottomTitle: { color: '#cccccc' },
})
break
case 4:// 失效待还款
setStyle({
type: { background: '#FFE6CE', color: '#EE7500' },
cir: {
color: '#707070',
background: { start: ['#EF7907', '#FAC897'] as any, end: ['#FAC897', '#FFE6CE'] as any },
},
available: { color: '#EE7500' },
bottomTitle: { color: '#007AFF' },
})
break
}
setData({
...result.data,
progress,
credit_quota_used_line,
credit_quota_line,
credit_quota_available_line,
credit_quota_start_time: formatDateTime(result.data?.credit_quota_start_time, 'YYYY-MM-DD'),
credit_quota_end_time: formatDateTime(result.data?.credit_quota_end_time, 'YYYY-MM-DD'),
})
}
const convertPrice = (data) => {
const t = data.toString().split('.')
t[1] = t[1] ? t[1].padEnd(2, 0) : '00'
return t
}
return (
<View className="credit-line">
<Message text="暂不支持线上申请授权,请联系平台客服。" />
<View className="credit-line-card">
<View className="credit-line-card-top">
<View><Progress progress={data.progress} style={style} /></View>
<View className="credit-line-card-top-info">
<View className="credit-line-card-top-info-title"></View>
<View className="credit-line-card-top-info-price" style={style.available}><Text>¥</Text>{Number(data.credit_quota_available_line[0])?.toLocaleString()}<Text>.{data.credit_quota_available_line[1]}</Text></View>
<View className="credit-line-card-top-info-date">: {data?.credit_quota_start_time} {data?.credit_quota_end_time}</View>
</View>
<View className="credit-line-card-top-status" style={style.type}>{data.quota_status_name}</View>
</View>
<View className="credit-line-card-bottom">
<View className="credit-line-card-bottom-item">
<View className="credit-line-card-bottom-item-title">
<Text style={style.bottomTitle} className="iconfont icon-yucunkuan"></Text>
<View></View>
</View>
<View className="credit-line-card-bottom-item-price"><Text>¥</Text>{Number(data.credit_quota_line[0])?.toLocaleString()}<Text>.{data.credit_quota_line[1]}</Text></View>
</View>
<Navigator hoverClass="none" url="/pages/creditUsed/index" className="credit-line-card-bottom-item">
<View className="credit-line-card-bottom-item-title">
<Text style={style.bottomTitle} className="iconfont icon-tick-pressed"></Text>
<View></View>
<Text className="iconfont icon-a-moreback miconfont"></Text>
</View>
<View className="credit-line-card-bottom-item-price"><Text>¥</Text>{Number(data?.credit_quota_used_line[0])?.toLocaleString()}<Text>.{data.credit_quota_used_line[1]}</Text></View>
</Navigator>
</View>
</View>
</View>
)
interface ProgressType {
progress: number
style: Record<string, any>
}
const Progress = (props) => {
useEffect(() => {
if (props.progress != 0) {
getCanvas()
}
}, [props.progress])
const Progress = (props: ProgressType) => {
const getCanvas = () => {
// const percentage = props.progress??0;
const percentage = props.progress || 0
@ -247,5 +102,156 @@ const Progress = (props) => {
useReady(() => {
getCanvas()
})
useEffect(() => {
if (props.progress != 0) {
getCanvas()
}
}, [props.progress])
return <Canvas type="2d" id="myCanvas" />
}
const CreditLine = () => {
useLogin()
const userInfo = useSelector(state => state.userInfo)
const { fetchData, state } = creditInfoApi()
const [data, setData] = useState({
credit_quota_used_line: [0, '00'],
credit_quota_line: [0, '00'],
credit_quota_available_line: [0, '00'],
progress: 0,
create_time: '',
quota_status_name: '',
quota_status: '',
credit_quota_start_time: '',
credit_quota_end_time: '',
})
const [style, setStyle] = useState({
type: {},
cir: {
color: '',
background: { start: [], end: [] },
},
available: {},
bottomTitle: {},
})
// 获取数据
const getData = async() => {
const convertPrice = (data) => {
const t = data.toString().split('.')
t[1] = t[1] ? t[1].padEnd(2, 0) : '00'
return t
}
const result = await fetchData()
const credit_quota_used_line = convertPrice(formatPriceDiv(result.data.credit_quota_used_line))
const credit_quota_line = convertPrice(formatPriceDiv(result.data.credit_quota_line))
const credit_quota_available_line = convertPrice(formatPriceDiv(result.data.credit_quota_available_line))
const progress = credit_quota_available_line[0] == 0 && credit_quota_line[0] == 0 ? 100 : ((credit_quota_available_line[0] ?? 0) / (credit_quota_line[0] ?? 0) * 100).toFixed(0)
switch (Number(result.data.quota_status)) {
case 0:// 暂未开通
setStyle({
type: { background: '#e4e4ff', color: '#1818B4' },
cir: {
color: '#707070',
background: { start: ['#727272', '#CDCDCD'] as any, end: ['#CDCDCD', '#EEEEEE'] as any },
},
available: { color: '#707070', textDecoration: 'line-through' },
bottomTitle: { color: '#cccccc' },
})
break
case 1:// 申请中
setStyle({
type: { background: '#cde5ff', color: '#007AFF' },
cir: {
color: '#707070',
background: { start: ['#727272', '#CDCDCD'] as any, end: ['#CDCDCD', '#EEEEEE'] as any },
},
available: { color: '#707070', textDecoration: 'line-through' },
bottomTitle: { color: '#cccccc' },
})
break
case 2:// 生效中
setStyle({
type: { background: '#cde5ff', color: '#007AFF' },
cir: {
color: '#007aff',
background: { start: ['#047CFF', '#51A4FF'] as any, end: ['#87C0FF', '#57A8FF'] as any },
},
available: { color: '#007aff' },
bottomTitle: { color: '#007AFF' },
})
break
case 3:// 已失效
setStyle({
type: { background: '#f6f6f6', color: '#ABABAB' },
cir: {
color: '#707070',
background: { start: ['#727272', '#CDCDCD'] as any, end: ['#CDCDCD', '#EEEEEE'] as any },
},
available: { color: '#707070', textDecoration: 'line-through' },
bottomTitle: { color: '#cccccc' },
})
break
case 4:// 失效待还款
setStyle({
type: { background: '#FFE6CE', color: '#EE7500' },
cir: {
color: '#707070',
background: { start: ['#EF7907', '#FAC897'] as any, end: ['#FAC897', '#FFE6CE'] as any },
},
available: { color: '#EE7500' },
bottomTitle: { color: '#007AFF' },
})
break
}
setData({
...result.data,
progress,
credit_quota_used_line,
credit_quota_line,
credit_quota_available_line,
credit_quota_start_time: formatDateTime(result.data?.credit_quota_start_time, 'YYYY-MM-DD'),
credit_quota_end_time: formatDateTime(result.data?.credit_quota_end_time, 'YYYY-MM-DD'),
})
}
useEffect(() => {
getData()
}, [])
return (
<View className="credit-line">
<Message text="暂不支持线上申请授权,请联系平台客服。" />
<View className="credit-line-card">
<View className="credit-line-card-top">
<View><Progress progress={data.progress} style={style} /></View>
<View className="credit-line-card-top-info">
<View className="credit-line-card-top-info-title"></View>
<View className="credit-line-card-top-info-price" style={style.available}><Text>¥</Text>{Number(data.credit_quota_available_line[0])?.toLocaleString()}<Text>.{data.credit_quota_available_line[1]}</Text></View>
<View className="credit-line-card-top-info-date">: {data?.credit_quota_start_time} {data?.credit_quota_end_time}</View>
</View>
<View className="credit-line-card-top-status" style={style.type}>{data.quota_status_name}</View>
</View>
<View className="credit-line-card-bottom">
<View className="credit-line-card-bottom-item">
<View className="credit-line-card-bottom-item-title">
<Text style={style.bottomTitle} className="iconfont icon-yucunkuan"></Text>
<View></View>
</View>
<View className="credit-line-card-bottom-item-price"><Text>¥</Text>{Number(data.credit_quota_line[0])?.toLocaleString()}<Text>.{data.credit_quota_line[1]}</Text></View>
</View>
<Navigator hoverClass="none" url="/pages/creditUsed/index" className="credit-line-card-bottom-item">
<View className="credit-line-card-bottom-item-title">
<Text style={style.bottomTitle} className="iconfont icon-tick-pressed"></Text>
<View></View>
<Text className="iconfont icon-a-moreback miconfont"></Text>
</View>
<View className="credit-line-card-bottom-item-price"><Text>¥</Text>{Number(data?.credit_quota_used_line[0])?.toLocaleString()}<Text>.{data.credit_quota_used_line[1]}</Text></View>
</Navigator>
</View>
</View>
</View>
)
}
export default CreditLine

View File

@ -1,15 +1,15 @@
import InfiniteScrollPaging from '@/components/InfiniteScrollPaging'
import { Button, Canvas, ScrollView, Text, View } from '@tarojs/components'
import Taro, { useReady } from '@tarojs/taro'
import { useCallback, useEffect, useMemo, useRef, useState } from 'react'
import { creditListApi } from '@/api/creditLine'
import './index.scss'
import classnames from 'classnames'
import { creditListApi } from '@/api/creditLine'
import InfiniteScrollPaging from '@/components/InfiniteScrollPaging'
import { formatDateTime, formatPriceDiv, toDecimal2 } from '@/common/fotmat'
import { dataLoadingStatus, getFilterData } from '@/common/util'
import useLogin from '@/use/useLogin'
export default () => {
const CreditUsed = () => {
useLogin()
const { fetchData, state } = creditListApi()
// 渲染(数据)
@ -172,3 +172,5 @@ export default () => {
// </View>
// )
// }
export default CreditUsed

View File

@ -8,7 +8,7 @@ import { formatPriceDiv, toDecimal2 } from '@/common/fotmat'
import Message from '@/components/Message'
import useLogin from '@/use/useLogin'
export default () => {
const DepositBeforehand = () => {
useLogin()
const { fetchData, state } = depositInfoApi()
const getData = async() => {
@ -65,3 +65,5 @@ export default () => {
</View>
)
}
export default DepositBeforehand

View File

@ -8,7 +8,35 @@ import { creditListApi } from '@/api/creditLine'
import './index.scss'
import useLogin from '@/use/useLogin'
export default () => {
const TimeLine = () => {
return (
<View className="deposit-timeline">
<View className="deposit-timeline-item">
<View className="deposit-timeline-item-left"></View>
<View className="deposit-timeline-item-right">
<View className="deposit-timeline-item-title"></View>
<View className="deposit-timeline-item-date">2022-04-24 16:10:11</View>
</View>
</View>
<View className="deposit-timeline-item">
<View className="deposit-timeline-item-left"></View>
<View className="deposit-timeline-item-right">
<View className="deposit-timeline-item-title"></View>
</View>
</View>
<View className="deposit-timeline-item">
<View className="deposit-timeline-item-success">
<Text className="iconfont icon-tick" />
</View>
<View className="deposit-timeline-item-right">
<View className="deposit-timeline-item-title"></View>
<View className="deposit-timeline-item-date">2022-04-24 16:10:11</View>
</View>
</View>
</View>)
}
const DepositBeforehandDetail = () => {
useLogin()
return (
<View className="deposit-detail">
@ -58,30 +86,4 @@ export default () => {
)
}
const TimeLine = () => {
return (
<View className="deposit-timeline">
<View className="deposit-timeline-item">
<View className="deposit-timeline-item-left"></View>
<View className="deposit-timeline-item-right">
<View className="deposit-timeline-item-title"></View>
<View className="deposit-timeline-item-date">2022-04-24 16:10:11</View>
</View>
</View>
<View className="deposit-timeline-item">
<View className="deposit-timeline-item-left"></View>
<View className="deposit-timeline-item-right">
<View className="deposit-timeline-item-title"></View>
</View>
</View>
<View className="deposit-timeline-item">
<View className="deposit-timeline-item-success">
<Text className="iconfont icon-tick" />
</View>
<View className="deposit-timeline-item-right">
<View className="deposit-timeline-item-title"></View>
<View className="deposit-timeline-item-date">2022-04-24 16:10:11</View>
</View>
</View>
</View>)
}
export default DepositBeforehandDetail

View File

@ -8,7 +8,7 @@ import './index.scss'
import { formatDateTime, formatPriceDiv } from '@/common/fotmat'
import useLogin from '@/use/useLogin'
export default () => {
const DepositList = () => {
useLogin()
const { fetchData, state } = depositListApi()
// 渲染(数据)
@ -56,3 +56,5 @@ export default () => {
</View>
)
}
export default DepositList

View File

@ -15,9 +15,19 @@ interface params {
unit?: string
otherData?: any
}
export default ({ minNum = 0, maxNum = 100, step = 1, digits = 0, defaultNum = 0, onChange, onBlue, onClickBtn, unit = '', otherData }: params) => {
const Counter = ({ minNum = 0, maxNum = 100, step = 1, digits = 0, defaultNum = 0, onChange, onBlue, onClickBtn, unit = '', otherData }: params) => {
const [value, setValue] = useState<any>({ count: defaultNum })
// 保留小数
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 = () => {
const { count } = value
let num_res = Big(count).add(step).toNumber()
@ -36,18 +46,6 @@ export default ({ minNum = 0, maxNum = 100, step = 1, digits = 0, defaultNum = 0
onClickBtn?.(parseFloat(num_res), otherData)
}
// 保留小数
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)
@ -62,7 +60,7 @@ export default ({ minNum = 0, maxNum = 100, step = 1, digits = 0, defaultNum = 0
setValue({ ...value, count: minNum })
onChange?.(minNum, otherData)
}
else if (!isNaN(Number(res))) {
else if (!Number.isNaN(Number(res))) {
let count = formatDigits(res)
count = checkData(count)
setValue({ ...value, count })
@ -70,7 +68,7 @@ export default ({ minNum = 0, maxNum = 100, step = 1, digits = 0, defaultNum = 0
}
else {
const num = parseFloat(res)
if (!isNaN(num)) {
if (!Number.isNaN(num)) {
let count = formatDigits(num)
count = checkData(count)
setValue({ ...value, count })
@ -85,7 +83,7 @@ export default ({ minNum = 0, maxNum = 100, step = 1, digits = 0, defaultNum = 0
const onBluerEven = () => {
const num = parseFloat(value.count)
if (!isNaN(num)) {
if (!Number.isNaN(num)) {
let count = formatDigits(num)
count = checkData(count)
setValue({ ...value, count })
@ -111,3 +109,5 @@ export default ({ minNum = 0, maxNum = 100, step = 1, digits = 0, defaultNum = 0
</View>
)
}
export default Counter

View File

@ -25,7 +25,7 @@ interface param {
title?: string
productId?: number
}
export default memo(({ show = false, onClose, title = '', productId = 0 }: param) => {
const OrderCount = ({ show = false, onClose, title = '', productId = 0 }: param) => {
const { adminUserInfo } = useSelector(state => state.userInfo)
const [selectList, _] = useState([
@ -46,39 +46,11 @@ export default memo(({ show = false, onClose, title = '', productId = 0 }: param
},
])
const [selectIndex, setSelectIndex] = useState(0)
const selectProduct = (index: number) => {
condition.current.code_or_name = null
getColorList()
setSelectIndex(() => index)
}
// 重置数据
useEffect(() => {
setSearchShow(false)
}, [selectIndex])
// 获取面料颜色列表
const { fetchData: colorFetchData, state: colorState } = GetColorList()
const [list, setList] = useState<any[]>([])
const condition = useRef({ physical_warehouse: adminUserInfo?.physical_warehouse, sale_mode: selectIndex, product_id: 0, code_or_name: null })
const getColorList = async() => {
const { data } = await colorFetchData(getFilterData(condition.current))
const lists = initList(data.list)
setList(() => [...lists])
}
const [showPopup, setShowPopup] = useState(false)
// 显示获取
useEffect(() => {
if (show) {
setSelectIndex(0)
condition.current.code_or_name = null
setSearchShow(false)
condition.current.product_id = productId
getColorList()
}
setShowPopup(show)
}, [show])
// 初始化列表数据
const initList = useCallback((list) => {
@ -89,6 +61,18 @@ export default memo(({ show = false, onClose, title = '', productId = 0 }: param
})
return newList
}, [])
const getColorList = async() => {
const { data } = await colorFetchData(getFilterData(condition.current))
const lists = initList(data.list)
setList(() => [...lists])
}
const [showPopup, setShowPopup] = useState(false)
const selectProduct = (index: number) => {
condition.current.code_or_name = null
getColorList()
setSelectIndex(() => index)
}
// 卸载数据
useEffect(() => {
@ -115,7 +99,7 @@ export default memo(({ show = false, onClose, title = '', productId = 0 }: param
let kindCount = 0
const color_list: any[] = []
let color_list_info = {}
list.map((item) => {
list.forEach((item) => {
if (item.count > 0) {
sumCount = Big(sumCount).add(item.count).toNumber()
kindCount++
@ -147,7 +131,21 @@ export default memo(({ show = false, onClose, title = '', productId = 0 }: param
const changeSearchShow = () => {
setSearchShow(true)
}
// 显示获取
useEffect(() => {
if (show) {
setSelectIndex(0)
condition.current.code_or_name = null
setSearchShow(false)
condition.current.product_id = productId
getColorList()
}
setShowPopup(show)
}, [show])
// 重置数据
useEffect(() => {
setSearchShow(false)
}, [selectIndex])
// 添加购物车
const { getShopCount } = useCommonData()
const { getSelfUserInfo } = UseLogin()
@ -228,9 +226,7 @@ export default memo(({ show = false, onClose, title = '', productId = 0 }: param
const closeLabImgShow = useCallback(() => {
setShowLabImage(() => false)
}, [])
// 虚拟滚动
const Rows = memo(({ id, index, style, data }: any) => {
const Rows = ({ id, index, style, data }: any) => {
const item = data[index]
return (
<>
@ -269,7 +265,9 @@ export default memo(({ show = false, onClose, title = '', productId = 0 }: param
)) || <View className={styles.item}></View>}
</>
)
})
}
// 虚拟滚动
const RowsWithMemo = memo(Rows)
const [virtualHeight, setVirtualheight] = useState(400)
const getHeight = () => {
@ -341,7 +339,7 @@ export default memo(({ show = false, onClose, title = '', productId = 0 }: param
itemSize={100} /* 列表单项的高度 */
overscanCount={1}
>
{Rows}
{RowsWithMemo}
</VirtualList>
<View className="common_safe_area_y"></View>
</View>
@ -367,4 +365,5 @@ export default memo(({ show = false, onClose, title = '', productId = 0 }: param
</View>
</View>
)
})
}
export default memo(OrderCount)

View File

@ -7,7 +7,7 @@ export interface colorParams {
show?: false|true
onClose?: () => void
}
export default ({ value, show = false, onClose }: colorParams) => {
const Preview = ({ value, show = false, onClose }: colorParams) => {
return (
<>
{show && <View className={styles.main} catch-move="true" onClick={() => onClose?.()}>
@ -19,3 +19,5 @@ export default ({ value, show = false, onClose }: colorParams) => {
</>
)
}
export default Preview

View File

@ -3,7 +3,7 @@ import { memo } from 'react'
import styles from './index.module.scss'
import LabAndImg from '@/components/LabAndImg'
export default memo(() => {
const ProductItem = () => {
return (
<View>
<View className={styles.item} key={item.id}>
@ -43,4 +43,5 @@ export default memo(() => {
</View>
</View>
)
})
}
export default memo(ProductItem)

View File

@ -8,8 +8,7 @@ interface item { title: string; img: string; url: string; id: number }
interface params {
list?: item[]
}
export default ({ list = [] }: params) => {
const SwiperComp = ({ list = [] }: params) => {
const [pageIndex, setPageIndex] = useState(1)
const pageRef = useRef<any>(null)
@ -36,9 +35,9 @@ export default ({ list = [] }: params) => {
<View className={styles.swiper}>
{list.length > 0 && (
<Swiper className={styles.swiper_item} circular onAnimationFinish={e => swiperChange(e)}>
{list?.map((item) => {
{list?.map((item, key) => {
return (
<SwiperItem>
<SwiperItem key={key}>
<View className={styles.image_item} onClick={onShowImage}>
<Image mode="aspectFill" src={formatImgUrl(item, '!w400')}></Image>
</View>
@ -55,3 +54,5 @@ export default ({ list = [] }: params) => {
</View>
)
}
export default SwiperComp

View File

@ -26,13 +26,19 @@ interface Params {
swiperOnClick?: (val: item) => void
style?: Object
}
export default (props: Params) => {
const Details = (props: Params) => {
const { getPhoneNumber, userInfo } = useLogin()
// 获取参数(有两种参数1.商品id, 2.页面分享)
const router = useRouter()
const [params, setParams] = useState({ id: '', share: null })
// 解析短码参数
const { fetchData: fetchDataAnalysisShortCode } = AnalysisShortCodeApi()
const analysisShortCode = async() => {
const res = await fetchDataAnalysisShortCode({ md5_key: router.params.share })
setParams({ id: res.data.product_id, share: res.data })
}
// 判断是否是分享过来的参数
const judgeParam = async() => {
if (router.params.id) {
@ -42,29 +48,9 @@ export default (props: Params) => {
analysisShortCode()
}
}
// 解析短码参数
const { fetchData: fetchDataAnalysisShortCode } = AnalysisShortCodeApi()
const analysisShortCode = async() => {
const res = await fetchDataAnalysisShortCode({ md5_key: router.params.share })
setParams({ id: res.data.product_id, share: res.data })
}
// 获取购物车数据数量
const { getShopCount, commonData } = useCommonData()
useDidShow(() => {
judgeParam()
setShowCart(false)
getShopCount()
})
useEffect(() => {
if (params.id) {
getProductDetail()
}
}, [params])
// 获取数据
const [productInfo, setProductInfo] = useState<any>({})
const { fetchData } = GetProductDetailApi()
@ -74,13 +60,6 @@ export default (props: Params) => {
Taro.stopPullDownRefresh()
}
useEffect(() => {
if (productInfo.code) {
getShortCode()
setCollectStatus(() => productInfo.is_favorite)
}
}, [productInfo])
// 面料名称
const productName = useMemo(() => {
return formatHashTag(productInfo.code, productInfo.name)
@ -112,7 +91,17 @@ export default (props: Params) => {
const img = formatImgUrl(shareImg, '!w400')
setSortCode({ ...userObj.sort_code, shareShortDetail: { title: productName as string, code: resDetail.md5_key, img } })
}
useDidShow(() => {
judgeParam()
setShowCart(false)
getShopCount()
})
useEffect(() => {
if (params.id) {
getProductDetail()
}
}, [params])
// 授权手机号和下单
const placeOrder = async(status = 'to_phone', e: any = {}) => {
if (!productInfo.id) { return false }
@ -136,14 +125,7 @@ export default (props: Params) => {
const [collectStatus, setCollectStatus] = useState(false)
const [collectionShow, setCollectionShow] = useState(false)
const { fetchData: addFavoritefetchData } = AddFavoriteApi()
const openCollection = () => {
if (productInfo.is_favorite) {
delFavoriteProduct()
}
else {
setCollectionShow(true)
}
}
const onAdd = useCallback(
async(val) => {
const res = await addFavoritefetchData({ favorite_id: val.id, product_id: Number(params.id) })
@ -160,6 +142,13 @@ export default (props: Params) => {
},
[params],
)
useEffect(() => {
if (productInfo.code) {
getShortCode()
setCollectStatus(() => productInfo.is_favorite)
}
}, [productInfo])
const closeCollection = useCallback(() => {
setCollectionShow(false)
}, [])
@ -173,7 +162,14 @@ export default (props: Params) => {
alert.none('已取消收藏')
}
}
const openCollection = () => {
if (productInfo.is_favorite) {
delFavoriteProduct()
}
else {
setCollectionShow(true)
}
}
// 页面下拉刷新
usePullDownRefresh(() => {
getProductDetail()
@ -288,3 +284,5 @@ export default (props: Params) => {
</View>
)
}
export default Details

View File

@ -7,7 +7,7 @@ interface Param {
onSelect?: (val: number) => void
defaultValue?: 0|1|2
}
export default memo(({ onSelect, defaultValue = 0 }: Param) => {
const ShipmentMode = ({ onSelect, defaultValue = 0 }: Param) => {
// 收货方法 0:没选择, 1:自提2物流
const shipmentMode = useRef([
{ value: 1, label: '上门自提', selected: false },
@ -24,9 +24,10 @@ export default memo(({ onSelect, defaultValue = 0 }: Param) => {
return (
<View className={styles.order_title}>
<Text></Text>
{shipmentMode.current.map((item) => {
return <View className={classnames(styles.order_status, (selectValue == item.value) && styles.order_status_selected)} onClick={() => selectShipmentMode(item.value)}>{item.label}</View>
{shipmentMode.current.map((item, key) => {
return <View key={key} className={classnames(styles.order_status, (selectValue == item.value) && styles.order_status_selected)} onClick={() => selectShipmentMode(item.value)}>{item.label}</View>
})}
</View>
)
})
}
export default memo(ShipmentMode)

View File

@ -10,7 +10,7 @@ import { getParam } from '@/common/system'
import { EditSaleOrderAddressApi, EditSaleOrderShipmentModeApi } from '@/api/order'
import useLogin from '@/use/useLogin'
export default () => {
const EditOrder = () => {
useLogin()
// 获取临时传递的数据
const params = getParam()
@ -91,3 +91,5 @@ export default () => {
</View>
)
}
export default EditOrder

View File

@ -1,12 +1,12 @@
import { Image, View } from '@tarojs/components'
import styles from './index.module.scss'
export default () => {
const Product = () => {
return (
<View className={styles.products_list}>
{new Array(10).fill('').map((item) => {
{new Array(10).fill('').map((item, index) => {
return (
<View className={styles.products_item}>
<View key={index} className={styles.products_item}>
<View className={styles.item_img}>
<Image src="https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fimg.jj20.com%2Fup%2Fallimg%2Ftp01%2F1ZZQ214233446-0-lp.jpg&refer=http%3A%2F%2Fimg.jj20.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1651827249&t=b2fc2a3672dc8ced9e0f37ce7e2ff901" />
<View className={styles.num}>230</View>
@ -28,3 +28,5 @@ export default () => {
</View>
)
}
export default Product

View File

@ -13,7 +13,7 @@ interface Param {
type ParamProduct = Omit<Param, 'open'>
export default (option: Param) => {
const ProductClass = (option: Param) => {
const { open = false, onOpenClick, onSelect, list, defaultSelectId } = option
const getSelect = useCallback((id) => {
onSelect?.(id)
@ -100,8 +100,9 @@ const ProductClassBlock = (option: ParamProduct & { open: boolean }) => {
<View className={styles.product_class_block_con}>
<ScrollView scrollY className={styles.product_class_scroll}>
<View className={styles.product_class_list}>
{list?.map(item => (
{list?.map((item, index) => (
<View
key={index}
className={classnames(styles.product_class_item, item.id == selectInfo ? styles.product_class_item_selected : '')}
onClick={() => clickEvent(item)}
>
@ -119,3 +120,5 @@ const ProductClassBlock = (option: ParamProduct & { open: boolean }) => {
</>
)
}
export default ProductClass

View File

@ -14,23 +14,8 @@ import { GetProductKindListApi, GetProductListApi } from '@/api/material'
import useLogin from '@/use/useLogin'
import { dataLoadingStatus } from '@/common/util'
export default () => {
const Index = () => {
useLogin()
useEffect(() => {
categoryList()
}, [])
// 获取面料种类
const [kindData, setKindData] = useState<any>({ list: [], defaultId: 0 })
const { fetchData } = GetProductKindListApi()
const categoryList = async() => {
const res = await fetchData()
if (res.data?.list) {
setKindData({ ...kindData, list: res.data.list, defaultId: res.data.list[0].id })
setFiltrate({ ...filtrate, product_kind_id: res.data.list[0].id })
product_kind_id_ref.current = res.data.list[0].id
}
}
// 获取面料列表
const product_kind_id_ref = useRef(0)
@ -39,16 +24,6 @@ export default () => {
const [filtrate, setFiltrate] = useState({ product_kind_id: 0, size: 5, page: 1 })
const pageNum = useRef({ size: filtrate.size, page: filtrate.page })
const { fetchData: productFetchData, state: productState } = GetProductListApi()
// 获取数据方法
const getProductList = async() => {
const { data, total } = await productFetchData(filtrate)
setProductData({ ...productData, list: data.list, total })
setRefresherTriggeredStatus(() => false)
}
// 监听查询条件
useEffect(() => {
if (filtrate.product_kind_id) { getProductList() }
}, [filtrate])
// 点击面料类型
const getProductKindId = useCallback((e) => {
@ -95,7 +70,30 @@ export default () => {
product_kind_id_next_ref.current = id
setFiltrate(list => ({ ...list, size: 5, product_kind_id: kind_id }))
}, [])
// 获取面料种类
const [kindData, setKindData] = useState<any>({ list: [], defaultId: 0 })
const { fetchData } = GetProductKindListApi()
const categoryList = async() => {
const res = await fetchData()
if (res.data?.list) {
setKindData({ ...kindData, list: res.data.list, defaultId: res.data.list[0].id })
setFiltrate({ ...filtrate, product_kind_id: res.data.list[0].id })
product_kind_id_ref.current = res.data.list[0].id
}
}
// 获取数据方法
const getProductList = async() => {
const { data, total } = await productFetchData(filtrate)
setProductData({ ...productData, list: data.list, total })
setRefresherTriggeredStatus(() => false)
}
// 监听查询条件
useEffect(() => {
if (filtrate.product_kind_id) { getProductList() }
}, [filtrate])
useEffect(() => {
categoryList()
}, [])
return (
<MoveBtn onClick={() => setShowShopCart(!showShopCart)}>
<View className={styles.main}>
@ -130,3 +128,5 @@ export default () => {
</MoveBtn>
)
}
export default Index

View File

@ -17,7 +17,7 @@ import { SUBSCRIPTION_MESSAGE_SCENE } from '@/common/enum'
import { UseSubscriptionMessage } from '@/use/useCommon'
import { throttle } from '@/common/util'
export default () => {
const Comfirm = () => {
const [showDesc, setShowDesc] = useState(false)
// 下单信息
interface OrderParams { address_id?: number; remark?: string; sale_mode?: number; shipment_mode?: number; list?: any[] }
@ -30,6 +30,15 @@ export default () => {
}
const param = getParam()
const idsAndSaleModel = useRef<orderPreParam>({ shopping_cart_product_color_list: [], sale_mode: 0 })
// 获取销售预览订单
const [preViewOrder, setPreViewOrder] = useState<any>() // 获取到的原始数据
const { fetchData } = SaleOrderPreViewApi()
const getSaleOrderPreView = async() => {
if (idsAndSaleModel.current.shopping_cart_product_color_list?.length > 0) {
const res = await fetchData(idsAndSaleModel.current)
setPreViewOrder(res.data)
}
}
useDidShow(async() => {
idsAndSaleModel.current = { shopping_cart_product_color_list: [], sale_mode: 0 } // 初始化
idsAndSaleModel.current.sale_mode = Number(param?.sale_mode)
@ -42,29 +51,6 @@ export default () => {
setSubmitOrderData(val => ({ ...val, sale_mode: param?.sale_mode }))
})
// 获取销售预览订单
const [preViewOrder, setPreViewOrder] = useState<any>() // 获取到的原始数据
const { fetchData } = SaleOrderPreViewApi()
const getSaleOrderPreView = async() => {
if (idsAndSaleModel.current.shopping_cart_product_color_list?.length > 0) {
const res = await fetchData(idsAndSaleModel.current)
setPreViewOrder(res.data)
}
}
// 监听获取到的数据
useEffect(() => {
if (preViewOrder) {
formatData()
getDataList()
setSubmitOrderData(val => ({
...val,
address_id: preViewOrder.default_address.id,
shipment_mode: preViewOrder.shipment_mode || 2,
}))
}
}, [preViewOrder])
// 格式化数据格式
const [formatPreViewOrder, setFormatPreViewOrder] = useState<any>() // 格式化后的数据
const formatData = () => {
@ -105,8 +91,8 @@ export default () => {
// 获取提交格式数据列表
const getDataList = () => {
const list: { shopping_cart_product_color_id: number }[] = []
preViewOrder.product_list?.map((item) => {
item.product_colors?.map((colorItem) => {
preViewOrder.product_list?.forEach((item) => {
item.product_colors?.forEach((colorItem) => {
list.push({ shopping_cart_product_color_id: colorItem.id })
})
})
@ -178,7 +164,18 @@ export default () => {
usePullDownRefresh(() => {
getSaleOrderPreView()
})
// 监听获取到的数据
useEffect(() => {
if (preViewOrder) {
formatData()
getDataList()
setSubmitOrderData(val => ({
...val,
address_id: preViewOrder.default_address.id,
shipment_mode: preViewOrder.shipment_mode || 2,
}))
}
}, [preViewOrder])
return (
<View className={styles.order_main}>
<AddressInfoDetail orderInfo={defaultAddress} onSelect={getAddress} onChangeShipmentMode={selectShipmentMode} status={1} />
@ -208,3 +205,5 @@ export default () => {
</View>
)
}
export default Comfirm

View File

@ -19,14 +19,9 @@ interface Param {
defaultValue?: AddressInfoParam|null // 默认值
disabled?: false|true // true禁用后只用于展示
}
export default memo(({ onSelect, defaultValue = null, disabled = false }: Param) => {
const AddressInfo = ({ onSelect, defaultValue = null, disabled = false }: Param) => {
const [showAddressList, setShowAddressList] = useState(false)
useEffect(() => {
setUserInfo(() => defaultValue)
}, [defaultValue])
// 选择地址
const [userInfo, setUserInfo] = useState<any>()
const getAddress = useCallback((val) => {
@ -43,16 +38,19 @@ export default memo(({ onSelect, defaultValue = null, disabled = false }: Param)
const changeShow = () => {
if (!disabled) { setShowAddressList(() => true) }
}
useEffect(() => {
setUserInfo(() => defaultValue)
}, [defaultValue])
return (
<View>
<View className={styles.order_address} onClick={() => changeShow()}>
<View className={classnames(styles.order_address_icon, 'iconfont icon-daohang')}></View>
{!userInfo
&& <>
? <>
<View className={styles.order_address_text_no}></View>
<View className={classnames(styles.order_address_more_icon, 'iconfont icon-a-moreback')}></View>
</>
|| <>
: <>
<View className={styles.order_address_text_con}>
<View className={styles.order_address_text_name}>
<Text>{userInfo?.name}</Text>
@ -71,4 +69,5 @@ export default memo(({ onSelect, defaultValue = null, disabled = false }: Param)
</Popup>}
</View>
)
})
}
export default memo(AddressInfo)

View File

@ -46,35 +46,15 @@ const {
SaleOrderStatusRefund,
SaleOrderStatusCancel,
} = ORDER_STATUS
export default memo(
forwardRef(({ onSelect, onChangeShipmentMode, orderInfo, status = 2, disabled = false, onLogistics }: Param, ref) => {
const AddressInfoDetail = ({ onSelect, onChangeShipmentMode, orderInfo, status = 2, disabled = false, onLogistics }: Param, ref) => {
const [addressInfo, setAddressInfo] = useState<any>()
useEffect(() => {
if (orderInfo) {
setReceivingStatus(() => orderInfo.shipment_mode || 2)
setAddressInfo(() => orderInfo)
}
}, [orderInfo])
const { fetchData: addressFetchData } = EditSaleOrderAddressApi()
// 打开地址列表
const [showAddressList, setShowAddressList] = useState(false)
const changeShow = () => {
if (receivingStatus == 2 && !logisticsShow && limitEdit()) { setShowAddressList(() => true) }
}
// 把内部方法提供给外部
useImperativeHandle(ref, () => ({
changeShow,
}))
// 收货方法,1:自提2物流
const [receivingStatus, setReceivingStatus] = useState(2)
const { fetchData: shipmentModeFetchData } = EditSaleOrderShipmentModeApi()
const onReceivingStatus = async(value, e) => {
e.stopPropagation()
if (limitEdit()) { changeReceivingStatus(value) }
}
// 当没有地址时获取地址列表中的第一个数据
const { fetchData: addressListFetchData } = addressListApi()
@ -102,6 +82,7 @@ export default memo(
return false
}
}
const { fetchData: shipmentModeFetchData } = EditSaleOrderShipmentModeApi()
const changeReceivingStatus = debounce(async(value) => {
if (!orderInfo || value == receivingStatus) { return false }
@ -128,7 +109,6 @@ export default memo(
// 修改地址
const [addressId, setAddressId] = useState(0)
const { fetchData: addressFetchData } = EditSaleOrderAddressApi()
const getAddress = async(value) => {
if (!orderInfo) { return false }
if (status == 1) {
@ -164,7 +144,10 @@ export default memo(
if (!res && status != 1) { alert.none('该订单状态不能修改地址!') }
return status == 1 ? true : res
}
const onReceivingStatus = async(value, e) => {
e.stopPropagation()
if (limitEdit()) { changeReceivingStatus(value) }
}
// 根据订单状态判断是否显示物流
const logisticsShowList = [
SaleOrderStatusWaitingReceipt.value,
@ -175,7 +158,9 @@ export default memo(
const logisticsShow = useMemo(() => {
return logisticsShowList.includes(orderInfo?.status as number)
}, [orderInfo])
const changeShow = () => {
if (receivingStatus == 2 && !logisticsShow && limitEdit()) { setShowAddressList(() => true) }
}
// 地址格式
const formatAddress = useMemo(() => {
if (receivingStatus == 2) {
@ -185,7 +170,16 @@ export default memo(
return addressInfo?.take_goods_address
}
}, [receivingStatus, addressInfo])
useEffect(() => {
if (orderInfo) {
setReceivingStatus(() => orderInfo.shipment_mode || 2)
setAddressInfo(() => orderInfo)
}
}, [orderInfo])
// 把内部方法提供给外部
useImperativeHandle(ref, () => ({
changeShow,
}))
return (
<View>
<View className={styles.order_address} onClick={() => changeShow()}>
@ -235,5 +229,7 @@ export default memo(
</Popup>
</View>
)
}),
}
export default memo(
forwardRef(AddressInfoDetail),
)

View File

@ -23,8 +23,7 @@ interface Param {
status: number // 订单状态
}
}
export default memo(({ orderInfo, onRefresh }: Param) => {
const AdvanceOrderState = ({ orderInfo, onRefresh }: Param) => {
const { showTime, onStart, timeStatus } = useTimeCountDown()
// 订单状态枚举
@ -68,4 +67,5 @@ export default memo(({ orderInfo, onRefresh }: Param) => {
</View>
</View>
)
})
}
export default memo(AdvanceOrderState)

View File

@ -7,7 +7,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])}`
@ -25,4 +25,5 @@ export default memo(({ number = 0, status = 1 }: Param) => {
{priceDom()}
</View>
)
})
}
export default memo(AmountShow)

View File

@ -14,7 +14,7 @@ interface Param {
orderId?: number
onSuccess?: () => void
}
export default memo(({ show, onClose, orderId, onSuccess }: Param) => {
const ApplyRefund = ({ show, onClose, orderId, onSuccess }: Param) => {
// 提交的数据
const submitData = useRef({
return_explain: 0,
@ -22,13 +22,6 @@ export default memo(({ show, onClose, orderId, onSuccess }: Param) => {
reason_describe: '',
})
useEffect(() => {
if (show && orderId) {
submitData.current.sale_order_id = orderId
refundExplain()
}
}, [orderId, show])
// 申请退款
const { fetchData } = ApplyRefundApi()
const getApplyRefund = async() => {
@ -51,12 +44,6 @@ export default memo(({ show, onClose, orderId, onSuccess }: Param) => {
const res = await refundExplainFetchdata()
setList(() => res.data.list)
}
const [reason, setReason] = useState({ id: 0, name: '' })
const reasonSelect = useCallback((e) => {
setReason({ ...reason, name: e.name, id: e.id })
submitData.current.return_explain = e.id
closeReason()
}, [])
// 备注
const getOtherReason = useCallback((val) => {
@ -68,7 +55,12 @@ export default memo(({ show, onClose, orderId, onSuccess }: Param) => {
const closeReason = useCallback(() => {
setShowReason(false)
}, [])
const [reason, setReason] = useState({ id: 0, name: '' })
const reasonSelect = useCallback((e) => {
setReason({ ...reason, name: e.name, id: e.id })
submitData.current.return_explain = e.id
closeReason()
}, [])
// 提交
const onSubmit = (val) => {
if (val == 2) {
@ -83,7 +75,12 @@ export default memo(({ show, onClose, orderId, onSuccess }: Param) => {
}
}
}
useEffect(() => {
if (show && orderId) {
submitData.current.sale_order_id = orderId
refundExplain()
}
}, [orderId, show])
return (
<>
<Popup show={show} title="申请退款" onClose={onClose}>
@ -111,4 +108,5 @@ export default memo(({ show, onClose, orderId, onSuccess }: Param) => {
<ReasonPopup defaultValue={reason.id} show={showReason} onClose={closeReason} list={list} title="退款说明" onSelect={reasonSelect} />
</>
)
})
}
export default memo(ApplyRefund)

View File

@ -17,7 +17,7 @@ interface Param {
messageWidth?: number
messageShow?: true|false
}
export default memo(({ number = 0, titleStatus = true, title = '', messageTitle = '', numberStatus = 1, messageHeight = 70, messageWidth = 430, messageShow = false }: Param) => {
const EstimatedAmount = ({ number = 0, titleStatus = true, title = '', messageTitle = '', numberStatus = 1, messageHeight = 70, messageWidth = 430, messageShow = false }: Param) => {
const [show, setShow] = useState(messageShow)
const onClose = () => {
setShow(false)
@ -28,14 +28,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 +38,14 @@ 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}>
@ -61,4 +61,5 @@ export default memo(({ number = 0, titleStatus = true, title = '', messageTitle
</View>
</>
)
})
}
export default memo(EstimatedAmount)

View File

@ -28,8 +28,7 @@ interface Param {
order: OrderParam
comfirm?: boolean // 是否是确认订单页面使用
}
export default memo(({ order, comfirm = false }: Param) => {
const KindList = ({ order, comfirm = false }: Param) => {
const {
SaleOrderStatusBooking, // 待接单
SaleOrderStatusArranging, // 配布中
@ -239,4 +238,5 @@ export default memo(({ order, comfirm = false }: Param) => {
</View>
</>
)
})
}
export default memo(KindList)

View File

@ -9,7 +9,7 @@ interface param {
children?: ReactElement | null
orderInfo?: any
}
export default ({ children = null, orderInfo }: param) => {
const MovableAreaBtn = ({ children = null, orderInfo }: param) => {
const [screenHeight, setScreenHeight] = useState(0)
const screenWidthRef = useRef(0)
useLayoutEffect(() => {
@ -38,3 +38,5 @@ export default ({ children = null, orderInfo }: param) => {
</MovableArea>
)
}
export default MovableAreaBtn

View File

@ -17,7 +17,7 @@ interface Param {
transfer_remittance_account: string
}
}
export default memo(({ show = true, onClose, offlineInfo }: Param) => {
const OfflinePay = ({ show = true, onClose, offlineInfo }: Param) => {
// 复制功能
const clipboardData = () => {
Taro.setClipboardData({
@ -53,4 +53,5 @@ export default memo(({ show = true, onClose, offlineInfo }: Param) => {
</View>
)
})
}
export default memo(OfflinePay)

View File

@ -24,8 +24,7 @@ interface Param {
account_period_time?: string // 还款日期
}
}
export default memo(({ orderInfo = { logistics_details: [], payment_method: 0, status: 0 }, onRefresh }: Param) => {
const OrderState = ({ orderInfo = { logistics_details: [], payment_method: 0, status: 0 }, onRefresh }: Param) => {
useEffect(() => {
console.log('orderInfo33::', orderInfo)
}, [orderInfo])
@ -51,7 +50,7 @@ export default memo(({ orderInfo = { logistics_details: [], payment_method: 0, s
<>
{(dataList?.length > 0) && <View className={styles.order_flow_state}>
<View className={classnames(styles.order_status_list, showMore && styles.order_status_list_show)}>
{dataList.map((item, index) => <View className={styles.order_status_item}>
{dataList.map((item, index) => <View className={styles.order_status_item} key={index}>
{(dataList.length > 1) && <View className={classnames(styles.order_status_tail, (index == 0) && styles.order_status_tail_end)}></View>}
{(dataList.length != (index + 1)) && <View className={styles.order_status_line}></View>}
<View className={styles.order_status_content}>
@ -62,7 +61,7 @@ export default memo(({ orderInfo = { logistics_details: [], payment_method: 0, s
</View>)}
</View>
{(dataList.length > 2) && <View className={styles.more} onClick={() => changeMore()}>
<Text>{showMore && '收起详情' || '点击查看详情'}</Text>
<Text>{showMore ? '收起详情' : '点击查看详情'}</Text>
<Text className={classnames('iconfont icon-a-moreback', styles.miconfonts, showMore && styles.open_miconfonts)}></Text>
</View>}
<View className={styles.image_tag}>
@ -76,4 +75,5 @@ export default memo(({ orderInfo = { logistics_details: [], payment_method: 0, s
</View>}
</>
)
})
}
export default memo(OrderState)

View File

@ -7,7 +7,7 @@ import { REFUND_STATUS_ORDER } from '@/common/enum'
interface Param {
status?: number
}
export default memo(({ status = 0 }: Param) => {
const OrderStatusTag = ({ status = 0 }: Param) => {
const {
ReturnApplyOrderTypeAdvanceReceiptRefund, // 预收退款
ReturnApplyOrderTypeReturnForRefund, // 退货退款
@ -21,4 +21,5 @@ export default memo(({ status = 0 }: Param) => {
</View>}
</>
)
})
}
export default memo(OrderStatusTag)

View File

@ -34,7 +34,7 @@ interface OrderInfo {
}
type PayStatus = 1 | 2 | 3 | 4 | 5 | null // 1:预存款, 2:账期3线下汇款 4扫码支付, 5:货到付款
export default memo(({ show = false, onClose, orderInfo, onSubmitSuccess }: Param) => {
const Payment = ({ show = false, onClose, orderInfo, onSubmitSuccess }: Param) => {
// 支付方式枚举
const { PaymentMethodPreDeposit, PaymentMethodAccountPeriod, PaymentMethodCashOnDelivery } = PAYMENT_METHOD
// 订单状态枚举
@ -264,4 +264,5 @@ export default memo(({ show = false, onClose, orderInfo, onSubmitSuccess }: Para
<ScanPay orderInfo={onlinePayData} show={scanPayShow} onClose={() => setScanPayShow(false)} />
</View>
)
})
}
export default memo(Payment)

View File

@ -13,7 +13,7 @@ interface ReasonInfoParam {
onSelect?: (val: object) => void // 选择
defaultValue?: number // 默认选中
}
export default memo(({ show = false, onClose, title = '', list = [], onSelect, defaultValue }: ReasonInfoParam) => {
const ReasonPopup = ({ show = false, onClose, title = '', list = [], onSelect, defaultValue }: ReasonInfoParam) => {
return (
<Popup showIconButton={false} show={show} title={title} onClose={onClose} >
<View className={styles.reason_return_con}>
@ -26,4 +26,5 @@ export default memo(({ show = false, onClose, title = '', list = [], onSelect, d
</View>
</Popup>
)
})
}
export default memo(ReasonPopup)

View File

@ -8,17 +8,13 @@ interface Param {
onSave?: (val: string) => void
defaultValue?: string
}
export default ({ onBlur, onSave, defaultValue = '' }: Param) => {
const Remark = ({ onBlur, onSave, defaultValue = '' }: Param) => {
const [descData, setDescData] = useState({
number: 0,
value: '',
count: 200,
})
useEffect(() => {
getDesc(defaultValue)
}, [defaultValue])
const getDesc = (value) => {
let res = value
if (value.length > descData.count) {
@ -30,6 +26,9 @@ export default ({ onBlur, onSave, defaultValue = '' }: Param) => {
const setSave = () => {
onSave?.(descData.value)
}
useEffect(() => {
getDesc(defaultValue)
}, [defaultValue])
return (
<View className={styles.order_popup}>
<View className={styles.order_popup_title}></View>
@ -41,3 +40,4 @@ export default ({ onBlur, onSave, defaultValue = '' }: Param) => {
</View>
)
}
export default Remark

View File

@ -19,7 +19,7 @@ interface Param {
onSubmit?: () => void
id?: number
}
export default memo(({ show, onClose, onSubmit, id }: Param) => {
const ReturnRecord = ({ show, onClose, onSubmit, id }: Param) => {
// 搜索参数
const searchField = useRef({
page: 1,
@ -27,13 +27,6 @@ export default memo(({ show, onClose, onSubmit, id }: Param) => {
sale_order_id: 0,
})
useEffect(() => {
if (show && id) {
searchField.current.sale_order_id = id
getOrderList()
}
}, [show, id])
const userInfo = useSelector(state => state.userInfo)
// 获取售后订单列表
@ -88,7 +81,12 @@ export default memo(({ show, onClose, onSubmit, id }: Param) => {
setScrollStatus(false)
}
}, [])
useEffect(() => {
if (show && id) {
searchField.current.sale_order_id = id
getOrderList()
}
}, [show, id])
// 数据加载状态
const statusMore = useMemo(() => {
return dataLoadingStatus({ list: orderData.list, total: orderData.total, status: orderState.loading })
@ -162,4 +160,5 @@ export default memo(({ show, onClose, onSubmit, id }: Param) => {
</Popup>
</>
)
})
}
export default memo(ReturnRecord)

View File

@ -30,14 +30,32 @@ interface ListParam {
total_price: string
weight_error: string
}
export default memo(({ show = true, onClose, company, orderInfo }: Param) => {
const ScanPay = ({ show = true, onClose, company, orderInfo }: Param) => {
const [detail, setDetail] = useState<any>()
// 收货地址
const address = (addressInfo) => {
if (addressInfo?.shipment_mode == 2) {
return addressInfo?.province_name ? addressInfo.province_name + addressInfo.city_name + addressInfo.district_name + addressInfo.address_detail : ''
}
else {
return addressInfo?.take_goods_address
}
}
// 收件人
const userName = (addressInfo) => {
return addressInfo?.shipment_mode == 2 ? orderInfo.target_user_name : ''
}
// 手机号
const userPhone = (addressInfo) => {
return addressInfo?.shipment_mode == 2 ? orderInfo.target_user_phone : orderInfo.take_goods_phone
}
useEffect(() => {
if (orderInfo) {
const lists: ListParam[] = []
orderInfo.product_list?.map((pitem) => {
pitem?.product_colors?.map((citem) => {
orderInfo.product_list?.forEach((pitem) => {
pitem?.product_colors?.forEach((citem) => {
lists.push({
product_code: formatRemoveHashTag(pitem.code),
product_name: pitem.name,
@ -96,26 +114,6 @@ export default memo(({ show = true, onClose, company, orderInfo }: Param) => {
}
}, [orderInfo, show])
// 收货地址
const address = (addressInfo) => {
if (addressInfo?.shipment_mode == 2) {
return addressInfo?.province_name ? addressInfo.province_name + addressInfo.city_name + addressInfo.district_name + addressInfo.address_detail : ''
}
else {
return addressInfo?.take_goods_address
}
}
// 收件人
const userName = (addressInfo) => {
return addressInfo?.shipment_mode == 2 ? orderInfo.target_user_name : ''
}
// 手机号
const userPhone = (addressInfo) => {
return addressInfo?.shipment_mode == 2 ? orderInfo.target_user_phone : orderInfo.take_goods_phone
}
// 获取支付二维码
const [payCodeImage, setPayCodeImage] = useState<string>('')
const fileData = useRef({
@ -148,10 +146,6 @@ export default memo(({ show = true, onClose, company, orderInfo }: Param) => {
scope: 'scope.writePhotosAlbum',
msg: '您没授权,无法保存图片',
})
const saveImageCheck = async() => {
const res = await check()
res && saveImage()
}
// 保存图片
const saveImage = () => {
@ -166,7 +160,10 @@ export default memo(({ show = true, onClose, company, orderInfo }: Param) => {
},
})
}
const saveImageCheck = async() => {
const res = await check()
res && saveImage()
}
// 预览图片
const showImage = () => {
console.log('fileData.current.filePath::', fileData.current.filePath)
@ -201,4 +198,5 @@ export default memo(({ show = true, onClose, company, orderInfo }: Param) => {
</Popup>
</View>
)
})
}
export default memo(ScanPay)

View File

@ -29,9 +29,80 @@ interface ListParam {
total_price: string
weight_error: string
}
export default memo(({ show = true, onClose, company, orderInfo }: Param) => {
const ScanPayCheck = ({ show = true, onClose, company, orderInfo }: Param) => {
const [detail, setDetail] = useState<any>()
// 收货地址
const address = (addressInfo) => {
if (addressInfo?.shipment_mode == 2) {
return addressInfo?.province_name ? addressInfo.province_name + addressInfo.city_name + addressInfo.district_name + addressInfo.address_detail : ''
}
else {
return addressInfo?.take_goods_address
}
}
// 收件人
const userName = (addressInfo) => {
return addressInfo?.shipment_mode == 2 ? orderInfo.target_user_name : ''
}
// 手机号
const userPhone = (addressInfo) => {
return addressInfo?.shipment_mode == 2 ? orderInfo.target_user_phone : orderInfo.take_goods_phone
}
// 获取支付二维码
const [payCodeImage, setPayCodeImage] = useState<string>('')
const fileData = useRef({
filePath: '',
base64: '',
})
const { fetchData, state } = GetPayCode()
const getCore = async() => {
const res = await fetchData(detail)
const base64 = res.data.base64
setPayCodeImage(() => base64)
const time = new Date().valueOf()
const [, format, bodyData] = /data:image\/(\w+);base64,(.*)/.exec(base64) || []
const filePath = `${Taro.env.USER_DATA_PATH}/img${time}.${format}`
fileData.current.filePath = filePath
fileData.current.base64 = bodyData
const save = Taro.getFileSystemManager()
save.writeFile({
filePath: fileData.current.filePath,
data: fileData.current.base64,
encoding: 'base64',
})
}
// 保存图片
const saveImage = () => {
alert.loading('正在保存图片')
Taro.saveImageToPhotosAlbum({
filePath: fileData.current.filePath,
success() {
alert.success('图片保存成功')
},
fail(err) {
console.log('err::', err)
},
})
}
// 检查是否开启保存图片权限
const { check } = useCheckAuthorize({ scope: 'scope.writePhotosAlbum', msg: '您没授权,无法保存图片' })
const saveImageCheck = async() => {
const res = await check()
res && saveImage()
}
// 预览图片
const showImage = () => {
console.log('fileData.current.filePath::', fileData.current.filePath)
Taro.previewImage({
current: fileData.current.filePath, // 当前显示
urls: [fileData.current.filePath], // 需要预览的图片http链接列表
})
}
useEffect(() => {
if (show) {
getCore()
@ -41,8 +112,8 @@ export default memo(({ show = true, onClose, company, orderInfo }: Param) => {
useEffect(() => {
if (orderInfo) {
const lists: ListParam[] = []
orderInfo.product_list?.map((pitem) => {
pitem?.product_colors?.map((citem) => {
orderInfo.product_list?.forEach((pitem) => {
pitem?.product_colors?.forEach((citem) => {
lists.push({
product_code: formatRemoveHashTag(pitem.code),
product_name: pitem.name,
@ -98,81 +169,6 @@ export default memo(({ show = true, onClose, company, orderInfo }: Param) => {
}))
}
}, [orderInfo])
// 收货地址
const address = (addressInfo) => {
if (addressInfo?.shipment_mode == 2) {
return addressInfo?.province_name ? addressInfo.province_name + addressInfo.city_name + addressInfo.district_name + addressInfo.address_detail : ''
}
else {
return addressInfo?.take_goods_address
}
}
// 收件人
const userName = (addressInfo) => {
return addressInfo?.shipment_mode == 2 ? orderInfo.target_user_name : ''
}
// 手机号
const userPhone = (addressInfo) => {
return addressInfo?.shipment_mode == 2 ? orderInfo.target_user_phone : orderInfo.take_goods_phone
}
// 获取支付二维码
const [payCodeImage, setPayCodeImage] = useState<string>('')
const fileData = useRef({
filePath: '',
base64: '',
})
const { fetchData, state } = GetPayCode()
const getCore = async() => {
const res = await fetchData(detail)
const base64 = res.data.base64
setPayCodeImage(() => base64)
const time = new Date().valueOf()
const [, format, bodyData] = /data:image\/(\w+);base64,(.*)/.exec(base64) || []
const filePath = `${Taro.env.USER_DATA_PATH}/img${time}.${format}`
fileData.current.filePath = filePath
fileData.current.base64 = bodyData
const save = Taro.getFileSystemManager()
save.writeFile({
filePath: fileData.current.filePath,
data: fileData.current.base64,
encoding: 'base64',
})
}
// 检查是否开启保存图片权限
const { check } = useCheckAuthorize({ scope: 'scope.writePhotosAlbum', msg: '您没授权,无法保存图片' })
const saveImageCheck = async() => {
const res = await check()
res && saveImage()
}
// 保存图片
const saveImage = () => {
alert.loading('正在保存图片')
Taro.saveImageToPhotosAlbum({
filePath: fileData.current.filePath,
success() {
alert.success('图片保存成功')
},
fail(err) {
console.log('err::', err)
},
})
}
// 预览图片
const showImage = () => {
console.log('fileData.current.filePath::', fileData.current.filePath)
Taro.previewImage({
current: fileData.current.filePath, // 当前显示
urls: [fileData.current.filePath], // 需要预览的图片http链接列表
})
}
// 复制功能
return (
<View className={styles.scanPay_main}>
@ -194,4 +190,5 @@ export default memo(({ show = true, onClose, company, orderInfo }: Param) => {
</Popup>
</View>
)
})
}
export default memo(ScanPayCheck)

View File

@ -6,7 +6,7 @@ import styles from './index.module.scss'
interface Param {
onSelect?: (val: number) => void
}
export default memo(({ onSelect }: Param) => {
const ShipmentMode = ({ onSelect }: Param) => {
// 收货方法 1:自提2物流
const shipmentMode = useRef([
{ value: 1, label: '上门自提', selected: false },
@ -20,9 +20,10 @@ export default memo(({ onSelect }: Param) => {
return (
<View className={styles.order_title}>
<Text></Text>
{shipmentMode.current.map((item) => {
return <View className={classnames(styles.order_status, (selectValue == item.value) && styles.order_status_selected)} onClick={() => selectShipmentMode(item.value)}>{item.label}</View>
{shipmentMode.current.map((item, key) => {
return <View key={key} className={classnames(styles.order_status, (selectValue == item.value) && styles.order_status_selected)} onClick={() => selectShipmentMode(item.value)}>{item.label}</View>
})}
</View>
)
})
}
export default memo(ShipmentMode)

View File

@ -10,7 +10,7 @@ interface Param {
priceTitle: string // 描述
}
export default memo(({ style, number = 0, priceTitle = '' }: Param) => {
const SubmitOrderBtn = ({ style, number = 0, priceTitle = '' }: Param) => {
const priceDom = useCallback(() => {
const res = number.toFixed(2).split('.')
const int_num = `${parseInt(res[0])}`
@ -36,4 +36,5 @@ export default memo(({ style, number = 0, priceTitle = '' }: Param) => {
</View>
</>
)
})
}
export default memo(SubmitOrderBtn)

View File

@ -8,7 +8,7 @@ interface Param {
onCheck?: () => void
onCustom?: () => void
}
export default memo(({ onCheck, onCustom }: Param) => {
const WeightMemo = ({ onCheck, onCustom }: Param) => {
return (
<View className={styles.weight_memo}>
<View className={styles.weight_memo_item} onClick={() => onCheck?.()}>
@ -33,4 +33,5 @@ export default memo(({ onCheck, onCustom }: Param) => {
</View>
</View>
)
})
}
export default memo(WeightMemo)

View File

@ -1,4 +1,3 @@
import useLogin from '@/use/useLogin'
import { MovableArea, Text, View } from '@tarojs/components'
import Taro, { useDidShow, usePullDownRefresh, useRouter } from '@tarojs/taro'
import classnames from 'classnames'
@ -14,6 +13,7 @@ import Remark from './components/remark'
import ReturnRecord from './components/returnRecord'
import ScanPayCheck from './components/scanPayCheck'
import styles from './index.module.scss'
import useLogin from '@/use/useLogin'
import ShopCart from '@/components/shopCart'
import SearchInput from '@/components/searchInput'
import Popup from '@/components/popup'
@ -25,14 +25,11 @@ import { SubscriptionMessageApi } from '@/api/user'
import { AddShoppingCartApi } from '@/api/shopCart'
import { EditSaleOrderRemarkApi, GetSaleOrderDetailApi } from '@/api/order'
export default () => {
const Order = () => {
useLogin()
const [showDesc, setShowDesc] = useState(false)
const router = useRouter()
const orderId = useRef<number>(Number(router.params.id))
useDidShow(() => {
getSaleOrderPreView()
})
// 订单状态枚举
const {
@ -50,6 +47,13 @@ export default () => {
const firstOpen = useRef(true)
const [orderDetail, setOrderDetail] = useState<any>() // 获取到的原始数据
const { fetchData: getOrderFetchData } = GetSaleOrderDetailApi()
const [orderRemark, setOrderRemark] = useState('')
// 去付款
const [payMentShow, setPayMentShow] = useState(false)
const toPay = () => {
setPayMentShow(true)
}
const getSaleOrderPreView = async() => {
if (orderId.current) {
const res = await getOrderFetchData({ id: orderId.current })
@ -65,11 +69,6 @@ export default () => {
// Taro.hideToast()
}
// 监听获取到的数据
useEffect(() => {
if (orderDetail) { formatData() }
}, [orderDetail])
// 格式化数据格式
const [formatDetailOrder, setFormatDetailOrder] = useState<any>() // 格式化后的数据
const formatData = () => {
@ -116,7 +115,6 @@ export default () => {
// 订单备注
const { fetchData: remarkFetchData } = EditSaleOrderRemarkApi()
const [orderRemark, setOrderRemark] = useState('')
const getRemark = useCallback(async(e) => {
setOrderRemark(() => e)
const res = await remarkFetchData({ remark: e, id: orderId.current })
@ -143,12 +141,6 @@ export default () => {
setShowDesc(() => true)
}
// 去付款
const [payMentShow, setPayMentShow] = useState(false)
const toPay = () => {
setPayMentShow(true)
}
// 打开地址修改
const addressRef = useRef<any>(null)
@ -162,53 +154,24 @@ export default () => {
getSaleOrderPreView()
}, [orderDetail])
// 获取底部按钮点击, 获取按钮状态
const orderStateClick = useCallback(
(val) => {
if (val == 1 || val == 6 || val == 8) {
getSaleOrderPreView()
}
else if (val == 2) {
// 待付款
toPay()
}
else if (val == 3) {
// 申请退款
if (!orderDetail?.av_return_roll) { return alert.none('该订单已申请过退款') }
setRefundShow(true)
}
else if (val == 7) {
// 再购
addShopCart()
}
else if (val == 9) {
// 售后记录
onReturnRecordShow()
}
else if (val == 10) {
setShowScanPayCheck(true)
}
},
[orderDetail],
)
// 页面下拉刷新
usePullDownRefresh(() => {
getSaleOrderPreView()
})
useDidShow(() => {
getSaleOrderPreView()
})
// 关闭支付弹窗
const closePayShow = useCallback(() => {
setPayMentShow(() => false)
}, [orderDetail])
// 支付成功
const onPaySuccess = useCallback(() => {
alert.success('支付成功')
getSaleOrderPreView()
closePayShow()
}, [orderDetail])
// 关闭支付弹窗
const closePayShow = useCallback(() => {
setPayMentShow(() => false)
}, [orderDetail])
// 按钮所需数据
const orderInfo = useMemo(() => {
return {
@ -251,7 +214,7 @@ export default () => {
const { fetchData: addFetchData } = AddShoppingCartApi()
const addShopCart = async() => {
const color_list: { product_color_id: number; roll?: number; length?: number }[] = []
orderDetail?.product_list.map((pitem) => {
orderDetail?.product_list.forEach((pitem) => {
pitem?.product_colors.map((citem) => {
if (orderDetail?.sale_mode == 0) {
return color_list.push({ product_color_id: citem.id, roll: citem.roll })
@ -278,7 +241,10 @@ export default () => {
})
}
}
// 监听获取到的数据
useEffect(() => {
if (orderDetail) { formatData() }
}, [orderDetail])
// 显示售后记录
const [returnRecordShow, setReturnRecordShow] = useState(false)
const onReturnRecordShow = useCallback(() => {
@ -290,7 +256,35 @@ export default () => {
// 显示
const [showScanPayCheck, setShowScanPayCheck] = useState(false)
// 获取底部按钮点击, 获取按钮状态
const orderStateClick = useCallback(
(val) => {
if (val == 1 || val == 6 || val == 8) {
getSaleOrderPreView()
}
else if (val == 2) {
// 待付款
toPay()
}
else if (val == 3) {
// 申请退款
if (!orderDetail?.av_return_roll) { return alert.none('该订单已申请过退款') }
setRefundShow(true)
}
else if (val == 7) {
// 再购
addShopCart()
}
else if (val == 9) {
// 售后记录
onReturnRecordShow()
}
else if (val == 10) {
setShowScanPayCheck(true)
}
},
[orderDetail],
)
return (
<MovableAreaBtn orderInfo={orderDetail}>
<View className={styles.order_main}>
@ -352,3 +346,4 @@ export default () => {
</MovableAreaBtn>
)
}
export default Order

View File

@ -39,7 +39,7 @@ interface Param {
}
onClickBtn?: (val: { status: number; orderInfo: Param['value'] }) => void
}
export default memo(({ value, onClickBtn }: Param) => {
const Order = ({ value, onClickBtn }: Param) => {
const userInfo = useSelector(state => state.userInfo)
// 对应数量
const formatCount = useCallback(
@ -161,4 +161,5 @@ export default memo(({ value, onClickBtn }: Param) => {
<OrderBtns orderInfo={orderInfo} onClick={orderBtnsClick} showStatus="list" />
</View>
)
})
}
export default memo(Order)

View File

@ -8,7 +8,7 @@ interface Param {
defaultId?: number
onSelect?: (val: number) => void
}
export default memo(({ list = [], defaultId = -1, onSelect }: Param) => {
const OrderStatusList = ({ list = [], defaultId = -1, onSelect }: Param) => {
const [selectInfo, setSelectInfo] = useState({
selected: -1, // 当前选中的id
tabId: '', // 需要滚动到的id
@ -49,4 +49,5 @@ export default memo(({ list = [], defaultId = -1, onSelect }: Param) => {
</ScrollView>
</View>
)
})
}
export default memo(OrderStatusList)

Some files were not shown because too many files have changed in this diff Show More