From 7ddb3bf784d37eb10ae8412d2e6b30deeec2de6b Mon Sep 17 00:00:00 2001 From: Haiyi <1021441632@qq.com> Date: Fri, 16 Sep 2022 11:43:51 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=A6=84=20refactor:=E8=AE=A2=E5=8D=95?= =?UTF-8?q?=E8=AF=A6=E6=83=85=E5=AF=B9=E6=8E=A5=E4=BF=AE=E6=94=B9=E5=9C=B0?= =?UTF-8?q?=E5=9D=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app.config.ts | 46 +++++++-- src/components/AddressList/index.tsx | 41 ++++++-- src/components/shoppingCart/index.tsx | 96 ++++++++++--------- src/pages/addressManager/index.tsx | 5 +- .../components/BottomApply/index.tsx | 4 +- .../addressDetailBox/index.module.scss | 2 + .../components/addressDetailBox/index.tsx | 46 +++++---- src/pages/orderDetails/index.tsx | 52 +++++++--- 8 files changed, 192 insertions(+), 100 deletions(-) diff --git a/src/app.config.ts b/src/app.config.ts index be9bc84..3b8282a 100644 --- a/src/app.config.ts +++ b/src/app.config.ts @@ -4,13 +4,7 @@ export default defineAppConfig({ 'pages/index/index', 'pages/order/index', 'pages/shopping/index', - 'pages/searchPage/index', - 'pages/customerPage/index', - 'pages/saleuserPage/index', 'pages/user/index', - 'pages/orderDetails/index', - 'pages/addressManager/index', - 'pages/addAddress/index', 'pages/login/index', ], window: { @@ -53,10 +47,46 @@ export default defineAppConfig({ { root: 'pages/colorRelated', pages: [ - 'sampleComparison/index', - 'takeColor/index', + 'sampleComparison/index', + 'takeColor/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" + ] + }, ], }) diff --git a/src/components/AddressList/index.tsx b/src/components/AddressList/index.tsx index a4d047b..4acab3b 100644 --- a/src/components/AddressList/index.tsx +++ b/src/components/AddressList/index.tsx @@ -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({}) // 列表选择 - 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 ( - + { state?.data?.list?.length > 0 ? state?.data?.list?.map((item, index) => { @@ -106,7 +131,7 @@ const AddressList = memo((props: Params) => { item.is_default && {item.phone.replace(item.phone.substring(3, 7), "****")} } - e.stopPropagation()} url={`/pages/addAddress/index?type=edit&id=${item.id}&&purchaser_id=${642}`} hoverClass="none" className="address-edit"> + e.stopPropagation()} url={`/pages/addAddress/index?type=edit&id=${item.id}&&purchaser_id=${Number(router.params.purchaser_id)}`} hoverClass="none" className="address-edit"> @@ -117,7 +142,7 @@ const AddressList = memo((props: Params) => { } - {addButtonEnabled && 添加收货地址} + {addButtonEnabled && 添加收货地址} ) }) diff --git a/src/components/shoppingCart/index.tsx b/src/components/shoppingCart/index.tsx index 48be533..8787f52 100644 --- a/src/components/shoppingCart/index.tsx +++ b/src/components/shoppingCart/index.tsx @@ -104,56 +104,58 @@ export default memo(forwardRef((props: prosObj, ref) => { return ( closePopup?.()}> - - {obj?.code}# {obj?.name} - 已选 1 种面料,{selectTotal} 个颜色,共 {selectNums} {showModefont} - - 布料类型 - + + + {obj?.code}# {obj?.name} + 已选 1 种面料,{selectTotal} 个颜色,共 {selectNums} {showModefont} + + 布料类型 + + { + typeList.map((item, index) => { + return ( + { handCheck?.(item) }} key={index} className={classnames(item.checked ? styles.activemodeFont : styles.modeFont)}>{item.name} + ) + }) + } + + + + 颜色分类({goodList?.length}) + {modeFont == 0 ? '大货' : modeFont == 1 ? '剪版' : '散剪'}单位:{showModefont} + + + + { - typeList.map((item, index) => { - return ( - { handCheck?.(item) }} key={index} className={classnames(item.checked ? styles.activemodeFont : styles.modeFont)}>{item.name} - ) - }) + goodList.length > 0 && <> + + + {rows} + + + + + + } + { + goodList.length === 0 && <> + 加载中 + + } + + 0 && clientName !== '' ? false : true} handSure={() => { handSure() }}> + - - - 颜色分类({goodList?.length}) - {modeFont == 0 ? '大货' : modeFont == 1 ? '剪版' : '散剪'}单位:{showModefont} - - - - - { - goodList.length > 0 && <> - - - {rows} - - - - - - - } - { - goodList.length === 0 && <> - 加载中 - - } - - 0 && clientName !== '' ? false : true} handSure={() => { handSure() }}> - - + ) diff --git a/src/pages/addressManager/index.tsx b/src/pages/addressManager/index.tsx index 64c258b..6a370ee 100644 --- a/src/pages/addressManager/index.tsx +++ b/src/pages/addressManager/index.tsx @@ -1,14 +1,15 @@ import AddressList from "@/components/AddressList" 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 "./index.scss" export default () => { + const router = useRouter() return ( - + ) } \ No newline at end of file diff --git a/src/pages/orderDetails/components/BottomApply/index.tsx b/src/pages/orderDetails/components/BottomApply/index.tsx index 345909d..1f1deef 100644 --- a/src/pages/orderDetails/components/BottomApply/index.tsx +++ b/src/pages/orderDetails/components/BottomApply/index.tsx @@ -83,7 +83,9 @@ export default memo((props: prosObj) => { showTake && handSureGoods?.()}>确认收货 } - + { + !showTuihuo && !showTuikuan && !showTake && 暂无更多 + } ) }) \ No newline at end of file diff --git a/src/pages/orderDetails/components/addressDetailBox/index.module.scss b/src/pages/orderDetails/components/addressDetailBox/index.module.scss index 7dc24e0..3c97015 100644 --- a/src/pages/orderDetails/components/addressDetailBox/index.module.scss +++ b/src/pages/orderDetails/components/addressDetailBox/index.module.scss @@ -41,6 +41,8 @@ /*这里设置几行*/ overflow: hidden; margin-right: 41px; + display: flex; + align-items: center; } .icon_more { diff --git a/src/pages/orderDetails/components/addressDetailBox/index.tsx b/src/pages/orderDetails/components/addressDetailBox/index.tsx index 2721a5c..08d7249 100644 --- a/src/pages/orderDetails/components/addressDetailBox/index.tsx +++ b/src/pages/orderDetails/components/addressDetailBox/index.tsx @@ -6,14 +6,16 @@ import styles from './index.module.scss' interface propsObj { receivingStatus: Number | null, onReceivingStatus?: (any, Number) => void, - obj: any + obj: any, + navSelect?: (any) => void } export default memo((props: propsObj) => { const { receivingStatus = 2, onReceivingStatus, - obj = {} + obj = {}, + navSelect } = props const addressInfo = useMemo(() => { if (receivingStatus == 1) { @@ -21,37 +23,39 @@ export default memo((props: propsObj) => { } else { return obj.province_name + obj.city_name + obj.district_name } - }, [receivingStatus]) + }, [obj, receivingStatus]) - const addressPone = useMemo(() => { - if (receivingStatus == 1) { - return 13242128982 - } else { - return obj.purchaser_phone - } - }, [receivingStatus]) + // const addressPone = useMemo(() => { + // if (receivingStatus == 1) { + // return 13242128982 + // } else { + // return obj.purchaser_phone + // } + // }, [obj,receivingStatus]) - const addressUser = useMemo(() => { - if (receivingStatus == 1) { - return '谭先生' - } else { - return obj.target_user_name - } - }, [receivingStatus]) + // const addressUser = useMemo(() => { + // if (receivingStatus == 1) { + // return '谭先生' + // } else { + // return obj.target_user_name + // } + // }, [obj,receivingStatus]) return ( - + navSelect?.(obj)}> {addressInfo} - + { + receivingStatus !== 1 && + } - {addressUser} - {addressPone} + {receivingStatus === 1 ? '谭先生' : obj.target_user_name} + {receivingStatus === 1 ? 13242128982 : obj.purchaser_phone} diff --git a/src/pages/orderDetails/index.tsx b/src/pages/orderDetails/index.tsx index e66fc26..f444a74 100644 --- a/src/pages/orderDetails/index.tsx +++ b/src/pages/orderDetails/index.tsx @@ -29,14 +29,30 @@ import PayPopup from '../order/components/PayPopup' export default () => { const router = useRouter() - useEffect(() => { + // useEffect(() => { + // getDetail() + // }, []) + useDidShow(() => { getDetail() - }, []) - + }) //页面下拉刷新 usePullDownRefresh(() => { 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 [infoObj, setInfoObj] = useState({}) //获取订单详情 @@ -73,14 +89,9 @@ export default () => { }) } - //收货方法,1:自提,2物流 - const [receivingStatus, setReceivingStatus] = useState(null) - //切换自提或者物流 - const onReceivingStatus = debounce((e, value) => { - e.stopPropagation() - setReceivingStatus(value) - }, 300) - + // useEffect(() => { + // setReceivingStatus(receivingStatus) + // }, [receivingStatus]) //订单信息文字数组 const [orderMsg, setOrderMsg] = useState([ { @@ -459,6 +470,16 @@ export default () => { const [showPay, setShowPay] = 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 ( @@ -466,7 +487,12 @@ export default () => { { infoObj.status === 10 && refresh()} /> } - onReceivingStatus(e, value)}> + handSelect(obj)} + obj={infoObj} + receivingStatus={receivingStatus} + onReceivingStatus={(e, value) => onReceivingStatus(e, value)} + > { > {infoObj.purchaser_name} - {1310154151} + {infoObj.purchaser_phone} {infoObj.total_fabrics} 种面料,{infoObj.total_colors} 个颜色,共 {infoObj.sale_mode === 0 ? infoObj.total_number : infoObj.total_number / 100} {infoObj.sale_mode === 0 ? '条' : 'm'}