🦄 refactor:订单详情对接修改地址

This commit is contained in:
Haiyi 2022-09-16 11:43:51 +08:00
parent 52c4d92433
commit 7ddb3bf784
8 changed files with 192 additions and 100 deletions

View File

@ -4,13 +4,7 @@ export default defineAppConfig({
'pages/index/index', 'pages/index/index',
'pages/order/index', 'pages/order/index',
'pages/shopping/index', 'pages/shopping/index',
'pages/searchPage/index',
'pages/customerPage/index',
'pages/saleuserPage/index',
'pages/user/index', 'pages/user/index',
'pages/orderDetails/index',
'pages/addressManager/index',
'pages/addAddress/index',
'pages/login/index', 'pages/login/index',
], ],
window: { window: {
@ -53,10 +47,46 @@ export default defineAppConfig({
{ {
root: 'pages/colorRelated', root: 'pages/colorRelated',
pages: [ pages: [
'sampleComparison/index', 'sampleComparison/index',
'takeColor/index', 'takeColor/index',
'findColor/index' 'findColor/index'
], ],
}, },
{
root: "pages/addAddress",
pages: [
"index"
]
},
{
root: "pages/addressManager",
pages: [
"index"
]
},
{
root: "pages/customerPage",
pages: [
"index"
]
},
{
root: "pages/orderDetails",
pages: [
"index"
]
},
{
root: "pages/saleuserPage",
pages: [
"index"
]
},
{
root: "pages/searchPage",
pages: [
"index"
]
},
], ],
}) })

View File

@ -4,15 +4,16 @@ import { memo, useEffect, useState } from "react"
import "./index.scss" import "./index.scss"
import { mppurchaseraddresslist } from "@/api/addressList" import { mppurchaseraddresslist } from "@/api/addressList"
import { alert } from "@/common/common" import { alert } from "@/common/common"
import Taro, { showModal, useDidShow } from "@tarojs/taro" import Taro, { showModal, useDidShow, useRouter } from "@tarojs/taro"
import { mpsaleOrderaddress } from '@/api/order'
interface Params { interface Params {
refresherEnabled?: boolean,//是否开启刷新 refresherEnabled?: boolean,//是否开启刷新
onSelect?: (item: any, index: number) => void,//列表选择 onSelect?: (item: any, index: number) => void,//列表选择
addButtonEnabled?: boolean, //是否显示添加按钮 addButtonEnabled?: boolean, //是否显示添加按钮
focusBorderEnabled?: boolean, //焦点显示蓝色边框 focusBorderEnabled?: boolean, //焦点显示蓝色边框
id?: number, //默认选择值, id?: number, //默认选择值,
purchaser_id: Number purchaser_id: Number,
// handSelect?: (any) => void
} }
// 地址列表 // 地址列表
@ -52,8 +53,33 @@ const AddressList = memo((props: Params) => {
const data = Array.from({ length: 15 }); const data = Array.from({ length: 15 });
// 焦点 // 焦点
const [focusId, setFocusId] = useState(); const [focusId, setFocusId] = useState();
const router = useRouter()
const [addressObj, setAddressObj] = useState<any>({})
// 列表选择 // 列表选择
const handleSelect = (item: any, index: number) => { const { fetchData: selectFetch } = mpsaleOrderaddress()
const handleSelect = async (item: any, index: number) => {
Taro.showLoading({
title: '请稍等...',
mask: true
})
const res = await selectFetch({ address_id: item.id, id: Number(router.params.orderId), shipment_mode: 2 })
if (res.msg === 'success') {
Taro.hideLoading()
Taro.showToast({
title: '成功',
icon: 'success'
})
Taro.navigateBack({
delta: 1
})
} else {
Taro.hideLoading()
Taro.showToast({
title: res.msg,
icon: 'error'
})
}
props.onSelect && props.onSelect(item, index); props.onSelect && props.onSelect(item, index);
if (focusBorderEnabled) { if (focusBorderEnabled) {
setFocusId(item?.id); setFocusId(item?.id);
@ -78,11 +104,10 @@ const AddressList = memo((props: Params) => {
// } // }
// })) // }))
// } // }
return ( return (
<View className="address-scroll-view"> <View className="address-scroll-view">
<ScrollView scrollY refresherEnabled={props.refresherEnabled} enhanced refresherTriggered={refreshState} onRefresherRefresh={handleRefresh}> <ScrollView scrollY refresherEnabled={props.refresherEnabled} enhanced refresherTriggered={refreshState} onRefresherRefresh={handleRefresh}>
<View className="address-scroll-view-content"> <View className="address-scroll-view-content" >
{ {
state?.data?.list?.length > 0 ? state?.data?.list?.length > 0 ?
state?.data?.list?.map((item, index) => { state?.data?.list?.map((item, index) => {
@ -106,7 +131,7 @@ const AddressList = memo((props: Params) => {
item.is_default && <Text className="address-list-phone">{item.phone.replace(item.phone.substring(3, 7), "****")}</Text> item.is_default && <Text className="address-list-phone">{item.phone.replace(item.phone.substring(3, 7), "****")}</Text>
} }
</View> </View>
<Navigator onClick={e => e.stopPropagation()} url={`/pages/addAddress/index?type=edit&id=${item.id}&&purchaser_id=${642}`} hoverClass="none" className="address-edit"> <Navigator onClick={e => e.stopPropagation()} url={`/pages/addAddress/index?type=edit&id=${item.id}&&purchaser_id=${Number(router.params.purchaser_id)}`} hoverClass="none" className="address-edit">
<Text className="iconfont icon-bianji"></Text> <Text className="iconfont icon-bianji"></Text>
</Navigator> </Navigator>
</View> </View>
@ -117,7 +142,7 @@ const AddressList = memo((props: Params) => {
} }
</View> </View>
</ScrollView> </ScrollView>
{addButtonEnabled && <Navigator url={`/pages/addAddress/index?type=add&purchaser_id=${642}`} hoverClass="none" className="add-address"></Navigator>} {addButtonEnabled && <Navigator url={`/pages/addAddress/index?type=add&purchaser_id=${Number(router.params.purchaser_id)}`} hoverClass="none" className="add-address"></Navigator>}
</View> </View>
) )
}) })

View File

@ -104,56 +104,58 @@ export default memo(forwardRef((props: prosObj, ref) => {
return ( return (
<Popup showTitle={false} show={showPopup} onClose={() => closePopup?.()}> <Popup showTitle={false} show={showPopup} onClose={() => closePopup?.()}>
<View className={styles.shopcartBox}> <ScrollView style={{ height: '1000rpx' }} scrollY>
<View className={styles.topTitle}>{obj?.code}# {obj?.name}</View> <View className={styles.shopcartBox}>
<View className={styles.selectFont}> 1 {selectTotal} {selectNums} {showModefont}</View> <View className={styles.topTitle}>{obj?.code}# {obj?.name}</View>
<View className={styles.line}></View> <View className={styles.selectFont}> 1 {selectTotal} {selectNums} {showModefont}</View>
<View className={styles.typeFont}></View> <View className={styles.line}></View>
<View className={styles.flexType}> <View className={styles.typeFont}></View>
<View className={styles.flexType}>
{
typeList.map((item, index) => {
return (
<View onClick={() => { handCheck?.(item) }} key={index} className={classnames(item.checked ? styles.activemodeFont : styles.modeFont)}>{item.name}</View>
)
})
}
</View>
<View className={styles.line}></View>
<View className={styles.flexFonts}>
<View className={styles.kingFont}>({goodList?.length})</View>
<View className={styles.danwei}>{modeFont == 0 ? '大货' : modeFont == 1 ? '剪版' : '散剪'}{showModefont}</View>
</View>
<View className={styles.searchBox}>
<Search placeholder='请输入搜索布料' showBtn={false} changeOnSearch={getSearchData} debounceTime={300} />
</View>
{ {
typeList.map((item, index) => { goodList.length > 0 && <>
return ( <View className={styles.scrollviewBig}>
<View onClick={() => { handCheck?.(item) }} key={index} className={classnames(item.checked ? styles.activemodeFont : styles.modeFont)}>{item.name}</View> <VirtualList
) className={styles.scrollview}
}) height={300} /* 列表的高度 */
width='100%' /* 列表的宽度 */
itemData={goodList} /* 渲染列表的数据 */
itemCount={goodList.length + 0} /* 渲染列表的长度 */
itemSize={100} /* 列表单项的高度 */
overscanCount={1}>
{rows}
</VirtualList>
</View>
<View className={styles.kongOne}></View>
</>
} }
{
goodList.length === 0 && <>
<View className={styles.loading_more}><DotLoading /></View>
</>
}
<View className={styles.posBox}>
<BottomCustomer clientName={clientName} clientId={clientId} isDisabled={selectTotal > 0 && clientName !== '' ? false : true} handSure={() => { handSure() }}></BottomCustomer>
</View>
</View> </View>
<View className={styles.line}></View> </ScrollView>
<View className={styles.flexFonts}>
<View className={styles.kingFont}>({goodList?.length})</View>
<View className={styles.danwei}>{modeFont == 0 ? '大货' : modeFont == 1 ? '剪版' : '散剪'}{showModefont}</View>
</View>
<View className={styles.searchBox}>
<Search placeholder='请输入搜索布料' showBtn={false} changeOnSearch={getSearchData} debounceTime={300} />
</View>
{
goodList.length > 0 && <>
<View className={styles.scrollviewBig}>
<VirtualList
className={styles.scrollview}
height={300} /* 列表的高度 */
width='100%' /* 列表的宽度 */
itemData={goodList} /* 渲染列表的数据 */
itemCount={goodList.length + 0} /* 渲染列表的长度 */
itemSize={100} /* 列表单项的高度 */
overscanCount={1}>
{rows}
</VirtualList>
</View>
<View className={styles.kongOne}></View>
</>
}
{
goodList.length === 0 && <>
<View className={styles.loading_more}><DotLoading /></View>
</>
}
<View className={styles.posBox}>
<BottomCustomer clientName={clientName} clientId={clientId} isDisabled={selectTotal > 0 && clientName !== '' ? false : true} handSure={() => { handSure() }}></BottomCustomer>
</View>
</View>
</Popup> </Popup>
) )

View File

@ -1,14 +1,15 @@
import AddressList from "@/components/AddressList" import AddressList from "@/components/AddressList"
import { Button, ScrollView, Text, View } from "@tarojs/components" import { Button, ScrollView, Text, View } from "@tarojs/components"
import { stopPullDownRefresh, usePullDownRefresh } from "@tarojs/taro" import { stopPullDownRefresh, useDidShow, usePullDownRefresh, useRouter } from "@tarojs/taro"
import { useState } from "react" import { useState } from "react"
import "./index.scss" import "./index.scss"
export default () => { export default () => {
const router = useRouter()
return ( return (
<View className="address-manager"> <View className="address-manager">
<AddressList refresherEnabled={true} purchaser_id={642} /> <AddressList refresherEnabled={true} purchaser_id={router.params.purchaser_id as any} />
</View> </View>
) )
} }

View File

@ -83,7 +83,9 @@ export default memo((props: prosObj) => {
showTake && <View className={styles.tuikuan} onClick={() => handSureGoods?.()}></View> showTake && <View className={styles.tuikuan} onClick={() => handSureGoods?.()}></View>
} }
{
!showTuihuo && !showTuikuan && !showTake && <View className={styles.title} ></View>
}
</> </>
) )
}) })

View File

@ -41,6 +41,8 @@
/*这里设置几行*/ /*这里设置几行*/
overflow: hidden; overflow: hidden;
margin-right: 41px; margin-right: 41px;
display: flex;
align-items: center;
} }
.icon_more { .icon_more {

View File

@ -6,14 +6,16 @@ import styles from './index.module.scss'
interface propsObj { interface propsObj {
receivingStatus: Number | null, receivingStatus: Number | null,
onReceivingStatus?: (any, Number) => void, onReceivingStatus?: (any, Number) => void,
obj: any obj: any,
navSelect?: (any) => void
} }
export default memo((props: propsObj) => { export default memo((props: propsObj) => {
const { const {
receivingStatus = 2, receivingStatus = 2,
onReceivingStatus, onReceivingStatus,
obj = {} obj = {},
navSelect
} = props } = props
const addressInfo = useMemo(() => { const addressInfo = useMemo(() => {
if (receivingStatus == 1) { if (receivingStatus == 1) {
@ -21,37 +23,39 @@ export default memo((props: propsObj) => {
} else { } else {
return obj.province_name + obj.city_name + obj.district_name return obj.province_name + obj.city_name + obj.district_name
} }
}, [receivingStatus]) }, [obj, receivingStatus])
const addressPone = useMemo(() => { // const addressPone = useMemo(() => {
if (receivingStatus == 1) { // if (receivingStatus == 1) {
return 13242128982 // return 13242128982
} else { // } else {
return obj.purchaser_phone // return obj.purchaser_phone
} // }
}, [receivingStatus]) // }, [obj,receivingStatus])
const addressUser = useMemo(() => { // const addressUser = useMemo(() => {
if (receivingStatus == 1) { // if (receivingStatus == 1) {
return '谭先生' // return '谭先生'
} else { // } else {
return obj.target_user_name // return obj.target_user_name
} // }
}, [receivingStatus]) // }, [obj,receivingStatus])
return ( return (
<View className={styles.addressBox}> <View className={styles.addressBox}>
<View className={styles.topBox}> <View className={styles.topBox} onClick={() => navSelect?.(obj)}>
<View className={styles.cirle}> <View className={styles.cirle}>
<View className={classnames('iconfont', 'icon-dingwei', styles.dingwei)}></View> <View className={classnames('iconfont', 'icon-dingwei', styles.dingwei)}></View>
</View> </View>
<View className={styles.address}>{addressInfo}</View> <View className={styles.address}>{addressInfo}</View>
<View className={classnames('iconfont', 'icon-chakanquanbukehu', styles.icon_more)}></View> {
receivingStatus !== 1 && <View className={classnames('iconfont', 'icon-chakanquanbukehu', styles.icon_more)}></View>
}
</View> </View>
<View className={styles.line}></View> <View className={styles.line}></View>
<View className={styles.bottom}> <View className={styles.bottom}>
<View className={styles.name}>{addressUser}</View> <View className={styles.name}>{receivingStatus === 1 ? '谭先生' : obj.target_user_name}</View>
<View className={styles.phone}>{addressPone}</View> <View className={styles.phone}>{receivingStatus === 1 ? 13242128982 : obj.purchaser_phone}</View>
<View className={styles.reatBox}> <View className={styles.reatBox}>
<View className={styles.updateBtn}> <View className={styles.updateBtn}>
<View className={styles.updateBtn_list}> <View className={styles.updateBtn_list}>

View File

@ -29,14 +29,30 @@ import PayPopup from '../order/components/PayPopup'
export default () => { export default () => {
const router = useRouter() const router = useRouter()
useEffect(() => { // useEffect(() => {
// getDetail()
// }, [])
useDidShow(() => {
getDetail() getDetail()
}, []) })
//页面下拉刷新 //页面下拉刷新
usePullDownRefresh(() => { usePullDownRefresh(() => {
getDetail() getDetail()
}) })
//收货方法,1:自提2物流
const [receivingStatus, setReceivingStatus] = useState(null)
//切换自提或者物流
const onReceivingStatus = debounce((e, value) => {
if (infoObj.status === 8 || infoObj.status === 9 || infoObj.status === 4 || infoObj.status === 5) {
alert.error('不允许更改')
return false
}
e.stopPropagation()
setReceivingStatus(value)
}, 300)
const { fetchData: infoFetch } = mpsaleOrder() const { fetchData: infoFetch } = mpsaleOrder()
const [infoObj, setInfoObj] = useState<any>({}) const [infoObj, setInfoObj] = useState<any>({})
//获取订单详情 //获取订单详情
@ -73,14 +89,9 @@ export default () => {
}) })
} }
//收货方法,1:自提2物流 // useEffect(() => {
const [receivingStatus, setReceivingStatus] = useState(null) // setReceivingStatus(receivingStatus)
//切换自提或者物流 // }, [receivingStatus])
const onReceivingStatus = debounce((e, value) => {
e.stopPropagation()
setReceivingStatus(value)
}, 300)
//订单信息文字数组 //订单信息文字数组
const [orderMsg, setOrderMsg] = useState<any[]>([ const [orderMsg, setOrderMsg] = useState<any[]>([
{ {
@ -459,6 +470,16 @@ export default () => {
const [showPay, setShowPay] = useState(false) const [showPay, setShowPay] = useState(false)
//显示线下汇款 //显示线下汇款
const [showOffline, setShowOffine] = useState(false) const [showOffline, setShowOffine] = useState(false)
//选择地址
const handSelect = (obj) => {
if (receivingStatus === 1 || (infoObj.status === 8 || infoObj.status === 9 || infoObj.status === 4 || infoObj.status === 5)) {
alert.error('不允许更改')
return false
}
Taro.navigateTo({
url: '/pages/addressManager/index?orderId=' + obj.id + '&purchaser_id=' + obj.purchaser_id
})
}
return ( return (
<View className={styles.mainBox}> <View className={styles.mainBox}>
@ -466,7 +487,12 @@ export default () => {
{ {
infoObj.status === 10 && <AdvanceOrderState orderInfo={infoObj} onRefresh={() => refresh()} /> infoObj.status === 10 && <AdvanceOrderState orderInfo={infoObj} onRefresh={() => refresh()} />
} }
<AddressDetailBox obj={infoObj} receivingStatus={receivingStatus} onReceivingStatus={(e, value) => onReceivingStatus(e, value)}></AddressDetailBox> <AddressDetailBox
navSelect={(obj) => handSelect(obj)}
obj={infoObj}
receivingStatus={receivingStatus}
onReceivingStatus={(e, value) => onReceivingStatus(e, value)}
></AddressDetailBox>
<DefaultBox <DefaultBox
showMode={true} showMode={true}
title={'客户信息'} title={'客户信息'}
@ -474,7 +500,7 @@ export default () => {
> >
<View className={styles.pussBox}> <View className={styles.pussBox}>
<View className={styles.pussName}>{infoObj.purchaser_name}</View> <View className={styles.pussName}>{infoObj.purchaser_name}</View>
<View className={styles.pussPhone}>{1310154151}</View> <View className={styles.pussPhone}>{infoObj.purchaser_phone}</View>
</View> </View>
</DefaultBox> </DefaultBox>
<View className={styles.total}> {infoObj.total_fabrics} {infoObj.total_colors} {infoObj.sale_mode === 0 ? infoObj.total_number : infoObj.total_number / 100} {infoObj.sale_mode === 0 ? '条' : 'm'}</View> <View className={styles.total}> {infoObj.total_fabrics} {infoObj.total_colors} {infoObj.sale_mode === 0 ? infoObj.total_number : infoObj.total_number / 100} {infoObj.sale_mode === 0 ? '条' : 'm'}</View>