import { View } from '@tarojs/components' import Taro, { useDidShow, usePullDownRefresh, useRouter } from '@tarojs/taro' import React, { ReactNode, memo, useCallback, useEffect, useMemo, useRef, useState } from 'react' import classnames from 'classnames' import styles from './index.module.scss' import Tabs from './components/tabs' import Form from './components/form' import TagPopup from './components/tagPopup' import Popup from '@/components/popup' import { debounce } from '@/common/util' import { alert, goLink } from '@/common/common' import { formatDateTime, formatPriceDiv, formatWeightDiv } from '@/common/format' import AddressList from '@/components/AddressList' import { MpPurchaser } from '@/api/customer' const CustomerDetails = () => { const router = useRouter() const [status, setstatus] = useState(1) const [infoObj, setinfoObj] = useState() const { fetchData: getDesc } = MpPurchaser() // 顶部栏 const AddressListRef = useRef() const [TarBarList, setTarBarList] = useState([{ id: 1, name: '基础信息', showBorder: true }, { id: 2, name: '收货地址', showBorder: false }]) const handChose = (item) => { TarBarList.forEach((it) => { if (it.id === item.id) { it.showBorder = true } else { it.showBorder = false } setTarBarList([...TarBarList]) setstatus(item.id) // pageNum.current.page = 1 // setOrderData(() => ({ list: [], total: 0 })) // setSearchField((val) => ({ ...val, size: 10, status: item.id })) }) if (item.id == 2) { Taro.nextTick(() => { AddressListRef.current?.getData() }) } } const [showPopup, setshowPopup] = useState(false) const TagPopupRef = useRef() const handShow = () => { TagPopupRef?.current?.modeList.map((it) => { infoObj?.label_list?.forEach((item) => { if (it.id == item.label_id) { it.checked = true } }) return it }) TagPopupRef.current.setModeList([...TagPopupRef.current.modeList]) setshowPopup(true) } const getInfo = async() => { Taro.showLoading({ title: '请稍等...', mask: true, }) const res = await getDesc({ id: router.params.purchaser_id }) setinfoObj(res.data) Taro.hideLoading() setshowPopup(false) } useDidShow(() => { getInfo() }) return ( {infoObj?.name?.[0]} {infoObj?.name} {infoObj?.phone} {infoObj?.purchaser_type_name || '暂无'} {infoObj?.sale_user_name || '暂无'} { infoObj?.label_list?.map((item, key) => { return ( {item.label_name} ) }) } handShow()}> + 标签 goLink(`/pages/customerEditor/index?id=${router.params.purchaser_id}&type=edit`)}>{'编辑 >'} handChose?.(item)}> { status === 1 &&
} { status === 2 && } setshowPopup(false)} diseShow={() => getInfo()}>
) } export default CustomerDetails