🦄 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
+33 -8
View File
@@ -4,15 +4,16 @@ import { memo, useEffect, useState } from "react"
import "./index.scss"
import { mppurchaseraddresslist } from "@/api/addressList"
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 {
refresherEnabled?: boolean,//是否开启刷新
onSelect?: (item: any, index: number) => void,//列表选择
addButtonEnabled?: boolean, //是否显示添加按钮
focusBorderEnabled?: boolean, //焦点显示蓝色边框
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 [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);
if (focusBorderEnabled) {
setFocusId(item?.id);
@@ -78,11 +104,10 @@ const AddressList = memo((props: Params) => {
// }
// }))
// }
return (
<View className="address-scroll-view">
<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?.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>
}
</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>
</Navigator>
</View>
@@ -117,7 +142,7 @@ const AddressList = memo((props: Params) => {
}
</View>
</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>
)
})
+49 -47
View File
@@ -104,56 +104,58 @@ export default memo(forwardRef((props: prosObj, ref) => {
return (
<Popup showTitle={false} show={showPopup} onClose={() => closePopup?.()}>
<View className={styles.shopcartBox}>
<View className={styles.topTitle}>{obj?.code}# {obj?.name}</View>
<View className={styles.selectFont}>已选 1 种面料,{selectTotal} 个颜色,共 {selectNums} {showModefont}</View>
<View className={styles.line}></View>
<View className={styles.typeFont}>布料类型</View>
<View className={styles.flexType}>
<ScrollView style={{ height: '1000rpx' }} scrollY>
<View className={styles.shopcartBox}>
<View className={styles.topTitle}>{obj?.code}# {obj?.name}</View>
<View className={styles.selectFont}>已选 1 种面料,{selectTotal} 个颜色,共 {selectNums} {showModefont}</View>
<View className={styles.line}></View>
<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) => {
return (
<View onClick={() => { handCheck?.(item) }} key={index} className={classnames(item.checked ? styles.activemodeFont : styles.modeFont)}>{item.name}</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>
<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>
{
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>
</ScrollView>
</Popup>
)