From 739367022bb2ddb32dcb71b9378e17b3c77d72ba Mon Sep 17 00:00:00 2001 From: xuan Date: Wed, 1 Mar 2023 11:35:10 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9E=20fix(ID1001405):=20=E3=80=90?= =?UTF-8?q?=E5=86=85=E9=83=A8=E5=B0=8F=E7=A8=8B=E5=BA=8F=E3=80=91-?= =?UTF-8?q?=E3=80=90=E9=A2=86=E5=8F=96=E8=89=B2=E5=8D=A1=E3=80=91--?= =?UTF-8?q?=E5=B7=B2=E6=9C=89=E9=BB=98=E8=AE=A4=E5=9C=B0=E5=9D=80=EF=BC=8C?= =?UTF-8?q?=E6=89=8B=E5=8A=A8=E9=80=89=E6=8B=A9=E5=9C=B0=E5=9D=80=E5=90=8E?= =?UTF-8?q?=EF=BC=8C=E8=BF=98=E6=98=AF=E6=98=BE=E7=A4=BA=E9=BB=98=E8=AE=A4?= =?UTF-8?q?=E5=9C=B0=E5=9D=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 【【内部小程序】-【领取色卡】--已有默认地址,手动选择地址后,还是显示默认地址】 https://www.tapd.cn/53459131/bugtrace/bugs/view/1153459131001001405 --- project.private.config.json | 14 +++++++ src/pages/getColorCard/addColorCard/index.tsx | 35 +++++++++++----- .../sampleCutting/addSampleCutting/index.tsx | 42 +++++++++---------- 3 files changed, 59 insertions(+), 32 deletions(-) diff --git a/project.private.config.json b/project.private.config.json index 61eebd9..b643435 100644 --- a/project.private.config.json +++ b/project.private.config.json @@ -86,6 +86,20 @@ "query": "id=45", "launchMode": "default", "scene": null + }, + { + "name": "", + "pathName": "pages/getColorCard/addColorCard/index", + "query": "", + "launchMode": "default", + "scene": null + }, + { + "name": "", + "pathName": "pages/sampleCutting/addSampleCutting/index", + "query": "", + "launchMode": "default", + "scene": null } ] } diff --git a/src/pages/getColorCard/addColorCard/index.tsx b/src/pages/getColorCard/addColorCard/index.tsx index 9ad899f..814057d 100644 --- a/src/pages/getColorCard/addColorCard/index.tsx +++ b/src/pages/getColorCard/addColorCard/index.tsx @@ -166,7 +166,11 @@ const AddColorCard = () => { clientName: currPage.data?.clientName, clientPhone: currPage.data?.clientPhone, }) - getAddressList(currPage.data?.clientId) + // 当前客户不是已选客户 重新获取默认地址 + console.log(clientInfo.clientId, currPage.data?.clientId) + if (clientInfo.clientId !== currPage.data?.clientId) { + getDefaultAddressList(currPage.data?.clientId) + } } // 默认客户 if (currPage.data?.clientId == null) { @@ -177,6 +181,9 @@ const AddColorCard = () => { clientPhone: clientList.length > 0 ? clientList[0]?.phone : '', } }) + if (clientList.length > 0) { + getDefaultAddressList(clientList[0]?.id) + } } }) @@ -258,20 +265,26 @@ const AddColorCard = () => { } const { fetchData: addressListApi } = MpPurchaserAddressList() - const getAddressList = async(purchaser_id: number) => { + // 获取默认地址 + const getDefaultAddressList = async(purchaser_id: number) => { const res = await addressListApi({ purchaser_id }) if (res.success) { const { list } = res.data + let defaultAddress = list?.find((item) => { return item.is_default }) + if (!defaultAddress) { + defaultAddress = list?.[0] + } setAddressInfo(val => ({ ...val, - province_name: list?.[0]?.province_name || '', - address_id: list?.[0]?.id || '', - city_name: list?.[0]?.city_name || '', - address_detail: list?.[0]?.address_detail || '', - district_name: list?.[0]?.district_name || '', - target_user_name: list?.[0]?.name || '', - purchaser_phone: list?.[0]?.phone || '', + province_name: defaultAddress.province_name || '', + address_id: defaultAddress.id || '', + city_name: defaultAddress.city_name || '', + address_detail: defaultAddress.address_detail || '', + district_name: defaultAddress.district_name || '', + target_user_name: defaultAddress.name || '', + purchaser_phone: defaultAddress.phone || '', })) + currPage.data.addressObj = defaultAddress } } @@ -293,10 +306,10 @@ const AddColorCard = () => { { clientInfo.clientId !== -1 ? (<> - + {clientInfo.clientName} - + {clientInfo.clientPhone} diff --git a/src/pages/sampleCutting/addSampleCutting/index.tsx b/src/pages/sampleCutting/addSampleCutting/index.tsx index 7e818ec..6e5b20f 100644 --- a/src/pages/sampleCutting/addSampleCutting/index.tsx +++ b/src/pages/sampleCutting/addSampleCutting/index.tsx @@ -91,20 +91,10 @@ const AddColorCard = () => { // 提交订单 const handleSubmitOrder = async() => { if (!addressInfo.address_id) { - Taro.showToast({ - title: '请选择地址', - icon: 'none', - duration: 2000, - }) - return + return alert.none('请选择地址') } if (!clientInfo.clientId) { - Taro.showToast({ - title: '请选择客户', - icon: 'none', - duration: 2000, - }) - return + return alert.none('请选择客户') } const productColorList: any[] = [] order.forEach((item) => { @@ -210,7 +200,9 @@ const AddColorCard = () => { clientName: currPage.data?.clientName, clientPhone: currPage.data?.clientPhone, }) - getAddressList(currPage.data?.clientId) + if (clientInfo.clientId !== currPage.data?.clientId) { + getDefaultAddressList(currPage.data?.clientId) + } } // 默认客户 if (currPage.data?.clientId == null) { @@ -221,6 +213,9 @@ const AddColorCard = () => { clientPhone: clientList.length > 0 ? clientList[0]?.phone : '', } }) + if (clientList.length > 0) { + getDefaultAddressList(clientList[0]?.id) + } } }) @@ -316,20 +311,25 @@ const AddColorCard = () => { } const { fetchData: addressListApi } = MpPurchaserAddressList() - const getAddressList = async(purchaser_id: number) => { + const getDefaultAddressList = async(purchaser_id: number) => { const res = await addressListApi({ purchaser_id }) if (res.success) { const { list } = res.data + let defaultAddress = list?.find((item) => { return item.is_default }) + if (!defaultAddress) { + defaultAddress = list?.[0] + } setAddressInfo(val => ({ ...val, - province_name: list?.[0]?.province_name || '', - address_id: list?.[0]?.id || '', - city_name: list?.[0]?.city_name || '', - address_detail: list?.[0]?.address_detail || '', - district_name: list?.[0]?.district_name || '', - target_user_name: list?.[0]?.name || '', - purchaser_phone: list?.[0]?.phone || '', + province_name: defaultAddress.province_name || '', + address_id: defaultAddress.id || '', + city_name: defaultAddress.city_name || '', + address_detail: defaultAddress.address_detail || '', + district_name: defaultAddress.district_name || '', + target_user_name: defaultAddress.name || '', + purchaser_phone: defaultAddress.phone || '', })) + currPage.data.addressObj = defaultAddress } }