From 5c8c1649043f5e2984e1ac559b61a837558f39e1 Mon Sep 17 00:00:00 2001 From: xuan Date: Fri, 24 Mar 2023 15:00:36 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat(ID1000956):=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=E8=A1=A5?= =?UTF-8?q?=E5=85=85=E7=AB=8B=E5=8D=B3=E4=B8=8B=E5=8D=95=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 【【内部小程序】补充立即下单功能】 https://www.tapd.cn/53459131/prong/stories/view/1153459131001000956 --- build/project.config.json | 1 + config/pre.js | 1 - config/prod.js | 1 - src/api/order.ts | 16 ++ src/common/constant.ts | 11 +- .../BottomCustomer/index.module.scss | 60 ------- src/components/BottomCustomer/index.tsx | 35 ---- src/components/goodsItem/index.tsx | 13 +- src/components/shoppingCart/index.module.scss | 47 ++++- src/components/shoppingCart/index.tsx | 70 +++++--- .../components/shoppingCart/index.tsx | 1 - src/pages/shopping/index.tsx | 1 + src/pages/submitOrder/index.tsx | 160 +++++++++++++++--- 13 files changed, 261 insertions(+), 156 deletions(-) delete mode 100644 src/components/BottomCustomer/index.module.scss delete mode 100644 src/components/BottomCustomer/index.tsx diff --git a/build/project.config.json b/build/project.config.json index b397a5e..eed8038 100644 --- a/build/project.config.json +++ b/build/project.config.json @@ -32,6 +32,7 @@ "disableUseStrict": false, "useCompilerPlugins": false, "minifyWXML": true, + "condition": false, "ignoreUploadUnusedFiles": true }, "compileType": "miniprogram", diff --git a/config/pre.js b/config/pre.js index 61538f8..1f20b3e 100644 --- a/config/pre.js +++ b/config/pre.js @@ -4,7 +4,6 @@ module.exports = { env: { NODE_ENV: '"pre"', }, - outputRoot: 'dist', defineConstants: { CURRENT_BASE_URL: '"https://pre.zzfzyc.com/lymarket"', CURRENT_CAP_HTML_TO_IMAGE_BASE_URL: '"https://pre.zzfzyc.com"', diff --git a/config/prod.js b/config/prod.js index 5cf01c7..e0cd17a 100644 --- a/config/prod.js +++ b/config/prod.js @@ -4,7 +4,6 @@ module.exports = { env: { NODE_ENV: '"production"', }, - outputRoot: 'build', defineConstants: { CURRENT_BASE_URL: '"https://www.zzfzyc.com/lymarket"', CURRENT_CAP_HTML_TO_IMAGE_BASE_URL: '"https://www.zzfzyc.com"', diff --git a/src/api/order.ts b/src/api/order.ts index 3d0d067..dd7de15 100644 --- a/src/api/order.ts +++ b/src/api/order.ts @@ -248,3 +248,19 @@ export const RefuseAdjustPriceAudit = () => { method: 'put', }) } + +// 立即下单(预览) +export const SaleOrderPreViewBuyNow = () => { + return useRequest({ + url: '/v2/mp/saleOrder/preView/atOnce', + method: 'put', + }) +} + +// 立即下单(提交订单) +export const SaleOrderSubmitBuyNow = () => { + return useRequest({ + url: '/v2/mp/saleOrder/atOnce', + method: 'post', + }) +} diff --git a/src/common/constant.ts b/src/common/constant.ts index c305c85..ec7e9ea 100644 --- a/src/common/constant.ts +++ b/src/common/constant.ts @@ -1,21 +1,14 @@ -// export const BASE_URL = CURRENT_BASE_URL +export const BASE_URL = CURRENT_BASE_URL // export const BASE_URL = `http://192.168.0.75:50001/lymarket` // export const BASE_URL = `http://192.168.0.89:50001/lymarket` // export const BASE_URL = `http://10.0.0.5:50001/lymarket` // export const BASE_URL = `http://192.168.0.89:40001/lymarket` -// export const BASE_URL = `http://192.168.1.165:40001/lymarket` // 王霞 // export const BASE_URL = 'https://test.zzfzyc.com/lymarket' // 测试环境 -export const BASE_URL = 'https://pre.zzfzyc.com/lymarket' // 预发布 -// export const BASE_URL = `http://192.168.1.9:40001/lymarket` // 发 -// export const BASE_URL = `http://192.168.1.9:50005/lymarket` // 发 -// export const BASE_URL = `http://192.168.1.30:50001/lymarket` // 发 +// export const BASE_URL = 'https://pre.zzfzyc.com/lymarket' // 预发布 // export const BASE_URL = `https://dev.zzfzyc.com/lymarket` // 开发环境 // export const BASE_URL = 'https://www.zzfzyc.com/lymarket' // 正式环境 -// export const BASE_URL = `http://192.168.1.5:40001/lymarket` // 王霞 // export const BASE_URL = 'http://192.168.1.7:50002/lymarket' // 添 // export const BASE_URL = 'http://192.168.1.42:50002/lymarket' // 杰 -// export const BASE_URL = `http://192.168.1.95:40001/lymarket` // 华 -// export const BASE_URL = 'http://192.168.1.28:50002/lymarket' // 婷 // CDN // 生成密钥 diff --git a/src/components/BottomCustomer/index.module.scss b/src/components/BottomCustomer/index.module.scss deleted file mode 100644 index 09bc0fb..0000000 --- a/src/components/BottomCustomer/index.module.scss +++ /dev/null @@ -1,60 +0,0 @@ -.bottomBox { - width: 100%; - height: 132px; - background: #FFFFFF; - box-shadow: 0px -5px 20px -8px rgba(0, 0, 0, 0.06); - display: flex; - padding-top: 16px; - align-items: center; - justify-content: space-between; - overflow: hidden; - - .leftBottom { - display: flex; - align-items: center; - margin-left: 12px; - - .nowFont { - font-size: 28px; - font-family: PingFangSC-Regular, PingFang SC; - font-weight: 400; - color: #000000; - } - - .selctFont { - font-size: 28px; - font-family: PingFangSC-Regular, PingFang SC; - font-weight: 400; - color: #236AFF; - margin-left: 10px; - } - } - - .button { - margin-right: 50px; - width: 256px; - height: 80px; - background: #4581FF; - border-radius: 40px; - font-size: 32px; - font-family: PingFangSC-Medium, PingFang SC; - font-weight: 500; - color: #FFFFFF; - text-align: center; - line-height: 80px; - } - - .activeButton { - margin-right: 50px; - width: 256px; - height: 80px; - background: #68b4ff; - border-radius: 40px; - font-size: 32px; - font-family: PingFangSC-Medium, PingFang SC; - font-weight: 500; - color: #fff; - text-align: center; - line-height: 80px; - } -} \ No newline at end of file diff --git a/src/components/BottomCustomer/index.tsx b/src/components/BottomCustomer/index.tsx deleted file mode 100644 index 19ed10c..0000000 --- a/src/components/BottomCustomer/index.tsx +++ /dev/null @@ -1,35 +0,0 @@ -import { Button, View } from '@tarojs/components' -import Taro from '@tarojs/taro' -import { memo } from 'react' -import classnames from 'classnames' -import styles from './index.module.scss' - -interface prosObj { - isDisabled: boolean - handSure?: () => void - clientId?: Number - clientName?: string -} -const BottomCustomer = (props: prosObj) => { - const { - isDisabled = true, - handSure, - clientName = '', - } = props - const navTo = () => { - Taro.navigateTo({ - url: `/pages/customerPage/index?clientId=${props?.clientId}`, - }) - } - - return ( - - { navTo() }}> - 当前客户: - {clientName === '' ? '请选择客户 >' : `${clientName} >`} - - - - ) -} -export default memo(BottomCustomer) diff --git a/src/components/goodsItem/index.tsx b/src/components/goodsItem/index.tsx index 6e923ad..a3e4087 100644 --- a/src/components/goodsItem/index.tsx +++ b/src/components/goodsItem/index.tsx @@ -1,9 +1,10 @@ -import { Image, Input, ScrollView, View } from '@tarojs/components' +import { Image, Input, ScrollView, Text, View } from '@tarojs/components' import { memo, useCallback, useEffect, useMemo, useRef, useState } from 'react' import classnames from 'classnames' import styles from './index.module.scss' import LabAndImg from '@/components/LabAndImg' import { formatPriceDiv, formatWeightDiv } from '@/common/format' +import { EnumSaleMode } from '@/common/Enumerate' interface props { clickAdd: (any) => void @@ -87,15 +88,19 @@ const GoodsItem = (props: props) => { {valueInfo?.code} {valueInfo?.name} 剩:{valueInfo?.roll}件 { - modeFont === 0 && 空差:{formatWeightDiv(valueInfo?.weight_error) || 0}Kg + modeFont === EnumSaleMode.Bulk && 空差:{formatWeightDiv(valueInfo?.weight_error) || 0}Kg } { - modeFont === 0 && valueInfo?.last_bulk_price !== valueInfo?.bulk_price && ¥{modeFont === 0 ? formatPriceDiv(valueInfo?.last_bulk_price) : modeFont === 1 ? formatPriceDiv(valueInfo?.last_length_cut_price) : formatPriceDiv(valueInfo?.last_weight_cut_price)} {modeFont as any != 1 ? '/Kg' : '/m'} + (modeFont === EnumSaleMode.Bulk) && (valueInfo?.last_bulk_price !== valueInfo?.bulk_price) + ? + ¥{formatPriceDiv(valueInfo?.last_bulk_price)} /Kg + + : null } - ¥{modeFont === 0 ? formatPriceDiv(valueInfo?.bulk_price) : modeFont === 1 ? formatPriceDiv(valueInfo?.length_cut_price) : formatPriceDiv(valueInfo?.weight_cut_price)}{modeFont != 1 ? '/Kg' : '/m'} + ¥{modeFont === EnumSaleMode.Bulk ? formatPriceDiv(valueInfo?.bulk_price) : modeFont === EnumSaleMode.Plate ? formatPriceDiv(valueInfo?.length_cut_price) : formatPriceDiv(valueInfo?.weight_cut_price)}{modeFont !== EnumSaleMode.Plate ? '/Kg' : '/m'} { valueInfo.showInput diff --git a/src/components/shoppingCart/index.module.scss b/src/components/shoppingCart/index.module.scss index d6d40d8..c06747a 100644 --- a/src/components/shoppingCart/index.module.scss +++ b/src/components/shoppingCart/index.module.scss @@ -109,7 +109,7 @@ } .kongOne { - height: 200px; + height: 80px; } .loading_more { @@ -132,12 +132,51 @@ .noBottom { width: 100%; - position: fixed; - z-index: 999; - bottom: env(safe-area-inset-bottom); } } .scrllStyle { height: 75vh; } +// 底部按钮 +.bottomBox { + width: 100%; + padding: 20px 20px; + background: #ffffff; + box-shadow: 0px -5px 20px -8px rgba(0, 0, 0, 0.06); + display: flex; + padding-top: 16px; + align-items: center; + justify-content: space-between; + overflow: hidden; + box-sizing: border-box; + + .leftBottom { + width: 50%; + display: flex; + align-items: center; + + .nowFont { + font-size: 28px; + white-space: nowrap; + font-weight: 400; + color: #000000; + } + + .selctFont { + flex: 1 1 auto; + @include common_ellipsis(); + font-size: 28px; + font-weight: 400; + color: #236aff; + } + } + + .rightBottom { + width: 50%; + display: flex; + flex-flow: row nowrap; + justify-content: space-between; + align-items: center; + } +} diff --git a/src/components/shoppingCart/index.tsx b/src/components/shoppingCart/index.tsx index 6aa4b44..f103859 100644 --- a/src/components/shoppingCart/index.tsx +++ b/src/components/shoppingCart/index.tsx @@ -1,16 +1,18 @@ -import { ScrollView, View } from '@tarojs/components' -import { useDidShow } from '@tarojs/taro' +import { Button, ScrollView, View } from '@tarojs/components' +import Taro, { useDidShow } from '@tarojs/taro' import { forwardRef, memo, useCallback, useEffect, useImperativeHandle, useMemo, useRef, useState } from 'react' import classnames from 'classnames' import VirtualList from '@tarojs/components/virtual-list' import Divider from '../divider' +import NormalButton from '../normalButton' import styles from './index.module.scss' import Search from '@/components/search' import Popup from '@/components/popup' import Goods from '@/components/goodsItem' -import BottomCustomer from '@/components/BottomCustomer' import DotLoading from '@/components/dotLoading' -import { formatDateTime, formatHashTag, formatPriceDiv, formatRemoveHashTag, formatWeightDiv } from '@/common/format' +import { formatDateTime, formatHashTag, formatMeterMul, formatPriceDiv, formatRemoveHashTag, formatWeightDiv } from '@/common/format' +import { goLink } from '@/common/common' +import { EnumSaleMode } from '@/common/Enumerate' interface prosObj { showPopup?: false | true @@ -29,7 +31,7 @@ interface prosObj { name?: string } - modeFont: Number | string + modeFont: EnumSaleMode clientName: string clientId: Number hasBottom?: true | false // 默认不占位底部 @@ -48,7 +50,7 @@ const ShoppingCart = (props: prosObj, ref) => { getSearchData, handPlus, obj = {}, - modeFont = 0, + modeFont = EnumSaleMode.Bulk, clientName = '', clientId = -1, handSure, @@ -125,9 +127,36 @@ const ShoppingCart = (props: prosObj, ref) => { } const Rows = memo(rows) + const isDisabled = useMemo(() => { + return !(selectTotal > 0 && clientName !== '') + }, [selectTotal, clientName]) + + const navTo = () => { + Taro.navigateTo({ + url: `/pages/customerPage/index?clientId=${clientId}`, + }) + } + + const handBuyNow = () => { + console.log('goodList', goodList, modeFont) + const checkedGoodsKind = goodList.filter(item => item.showInput).map(item => ({ + id: item.id, + length: modeFont !== EnumSaleMode.Bulk ? formatMeterMul(item?.nums) : 0, + roll: modeFont === EnumSaleMode.Bulk ? item.nums : 0, + sale_price: formatPriceDiv(item?.sale_price), + })) + goLink('/pages/submitOrder/index', { + purchaser_id: clientId, + sale_mode: modeFont, + sale_order_product_color_list: JSON.stringify(checkedGoodsKind), + purchaser_name: clientName, + isBuyNew: true, + }) + } + return ( closePopup?.()}> - + {formatHashTag(obj?.code, obj?.name)} @@ -135,8 +164,6 @@ const ShoppingCart = (props: prosObj, ref) => { 已选 1 种面料,{selectTotal} 个颜色,共 {selectNums} {showModefont} - - 布料类型 {typeList.map((item, index) => { return ( @@ -176,7 +203,7 @@ const ShoppingCart = (props: prosObj, ref) => { { )} {!hasBottom && } - {/* */} - - 0 && clientName !== '')} - handSure={() => { - handSure() - }} - > - + + + + 当前客户: + {clientName === '' ? '请选择客户 >' : `${clientName} >`} + + + 立即购买 + 加入购物车 + + + ) } diff --git a/src/pages/addFabric/components/shoppingCart/index.tsx b/src/pages/addFabric/components/shoppingCart/index.tsx index 1da503c..3979375 100644 --- a/src/pages/addFabric/components/shoppingCart/index.tsx +++ b/src/pages/addFabric/components/shoppingCart/index.tsx @@ -8,7 +8,6 @@ import styles from './index.module.scss' import Divider from '@/components/divider' import Search from '@/components/search' import Popup from '@/components/popup' -import BottomCustomer from '@/components/BottomCustomer' import DotLoading from '@/components/dotLoading' import { formatDateTime, formatHashTag, formatPriceDiv, formatRemoveHashTag, formatWeightDiv } from '@/common/format' diff --git a/src/pages/shopping/index.tsx b/src/pages/shopping/index.tsx index a58e96c..580df1b 100644 --- a/src/pages/shopping/index.tsx +++ b/src/pages/shopping/index.tsx @@ -164,6 +164,7 @@ const ShoppingCartContainer: FC = () => { sale_mode: currentCheckedSaleMode, shopping_cart_product_color_list: JSON.stringify(checkedGoodsKind), purchaser_name: shoppingCartData?.list.find(item => item.purchaser_id === currentCheckedPurchaserId)?.purchaser_name, + isBuyNew: false, }) }, 400) diff --git a/src/pages/submitOrder/index.tsx b/src/pages/submitOrder/index.tsx index 0deb972..053d374 100644 --- a/src/pages/submitOrder/index.tsx +++ b/src/pages/submitOrder/index.tsx @@ -1,6 +1,7 @@ import type { CommonEvent } from '@tarojs/components' import { Input, Text, View } from '@tarojs/components' import Taro, { useDidShow, usePullDownRefresh, useRouter } from '@tarojs/taro' +import Big from 'big.js' import type { ReactNode } from 'react' import React, { memo, useCallback, useEffect, useMemo, useRef, useState } from 'react' import classnames from 'classnames' @@ -13,6 +14,8 @@ import { UseSubscriptionMessage } from '@/use/useCommon' import { MpSaleOrderPost, MpSaleOrderPreview, + SaleOrderPreViewBuyNow, + SaleOrderSubmitBuyNow, } from '@/api/order' import { alert } from '@/common/common' import { formatDateTime, formatMeterDiv, formatPriceDiv, formatPriceMul, formatRemoveHashTag, formatWeightDiv } from '@/common/format' @@ -71,10 +74,10 @@ interface PropGoods { obj: { sale_mode?: number | string } - updateList: (list: any[]) => void + updateData: (data: Record) => void } const GoodsItem = (props: PropGoods) => { - const { list = [], obj = {}, updateList } = props + const { list = [], obj = {}, updateData } = props const [goodsList, setGoodsList] = useState(list) @@ -122,6 +125,19 @@ const GoodsItem = (props: PropGoods) => { item.product_colors = item.product_colors.map((it) => { if (it.id === editPayload.current[0]) { it.sale_price = it.origin_price + formatPriceMul(value) + if (obj?.sale_mode === EnumSaleMode.Bulk) { + // 计算金额 + it.estimate_amount = formatPriceMul(Number(formatPriceDiv(it.sale_price)) * formatWeightDiv(it.estimate_weight) * it.roll) + } + else if (obj?.sale_mode === EnumSaleMode.Plate) { + // 剪板 + it.estimate_amount = formatPriceMul(Number(formatPriceDiv(it.sale_price)) * formatMeterDiv(it.length)) + } + else { + // 散剪 + it.estimate_amount = formatPriceMul(Number(formatPriceDiv(it.sale_price)) * formatMeterDiv(it.length) / formatMeterDiv(it.length_to_weight_rate)).toFixed(0) + console.log('estimate_amount', it.estimate_amount, formatPriceDiv(it.estimate_amount, 100, true)) + } } return it }) @@ -130,7 +146,11 @@ const GoodsItem = (props: PropGoods) => { }) setGoodsList(res) handleCancel() - updateList(res) + updateData({ + product_list: res, + // 计算总金额 + estimate_amount: res.reduce((acc, cur) => acc + cur.product_colors.reduce((a, c) => a + c.estimate_amount, 0), 0), + }) } // 批量调整点击确认 @@ -140,6 +160,18 @@ const GoodsItem = (props: PropGoods) => { if (item.id === editPayload.current[0]) { item.product_colors = item.product_colors.map((it) => { it.sale_price = it.origin_price + formatPriceMul(value) + if (obj?.sale_mode === EnumSaleMode.Bulk) { + // 计算金额 + it.estimate_amount = formatPriceMul(Number(formatPriceDiv(it.sale_price)) * formatWeightDiv(it.estimate_weight) * it.roll) + } + else if (obj?.sale_mode === EnumSaleMode.Plate) { + // 剪板 + it.estimate_amount = formatPriceMul(Number(formatPriceDiv(it.sale_price)) * formatMeterDiv(it.length)) + } + else { + // 散剪 + it.estimate_amount = formatPriceMul(Number(formatPriceDiv(it.sale_price)) * formatMeterDiv(it.length) / formatMeterDiv(it.length_to_weight_rate)) + } return it }) } @@ -147,7 +179,11 @@ const GoodsItem = (props: PropGoods) => { }) setGoodsList(res) handleCancel() - updateList(res) + updateData({ + product_list: res, + // 计算总金额 + estimate_amount: res.reduce((acc, cur) => acc + cur.product_colors.reduce((a, c) => a + c.estimate_amount, 0), 0), + }) } // 批量调整 const defaultValue = '-1.5' @@ -199,13 +235,31 @@ const GoodsItem = (props: PropGoods) => { {formatRemoveHashTag(it.code)}# {it.name} - x{obj?.sale_mode === EnumSaleMode.Bulk ? it.roll : formatMeterDiv(it.length)}{obj?.sale_mode === 0 ? '条' : 'm'} + x{obj?.sale_mode === EnumSaleMode.Bulk ? it.roll : formatMeterDiv(it.length)}{obj?.sale_mode === 0 ? '条' : '米'} - ¥{formatPriceDiv(it.sale_price)}/{obj?.sale_mode === EnumSaleMode.Plate ? 'm' : 'kg'} + ¥{formatPriceDiv(it.sale_price, 100, true)}/{obj?.sale_mode === EnumSaleMode.Plate ? 'm' : 'kg'} { - (obj?.sale_mode === EnumSaleMode.Bulk && it?.sale_price !== it?.standard_price) ? ¥{formatPriceDiv(it?.standard_price)}/kg : null + (obj?.sale_mode === EnumSaleMode.Bulk && it?.sale_price !== it?.standard_price) + ? + ¥{formatPriceDiv(it?.standard_price, 100, true)}/kg + + : null + } + { + (obj?.sale_mode === EnumSaleMode.Plate && it?.sale_price !== it?.standard_price) + ? + ¥{formatPriceDiv(it?.standard_price, 100, true)}/m + + : null + } + { + (obj?.sale_mode === EnumSaleMode.BulkCut && it?.sale_price !== it?.standard_price) + ? + ¥{formatPriceDiv(it?.standard_price, 100, true)}/kg + + : null } handleEdit(it.id, item.id)}> @@ -275,6 +329,8 @@ const SubmitOrder = () => { const [infoObj, setInfoObj] = useState({}) let selectId = -1 + const isBuyNew = useRef(false) + // 收货方法,1:自提,2物流 const [receivingStatus, setReceivingStatus] = useState(null) // 切换自提或者物流 @@ -314,7 +370,7 @@ const SubmitOrder = () => { // 获取订单详情 const getDetail = async() => { let arr: any[] = [] - setPusername(decodeURIComponent(router.params.purchaser_name)) + console.log('purchaser_name', router.params.purchaser_name) arr = JSON.parse(decodeURIComponent(router.params.shopping_cart_product_color_list)) const list: any[] = [] arr?.forEach((item) => { @@ -342,6 +398,40 @@ const SubmitOrder = () => { }) } + const { fetchData } = SaleOrderPreViewBuyNow() + // 立即购买 + const getOnceDetail = async() => { + const sale_order_product_color_list = JSON.parse(router?.params?.sale_order_product_color_list as string) || [] + if (sale_order_product_color_list?.length > 0) { + const arr: any[] = [] + const sale_mode = Number(router?.params.sale_mode) + sale_order_product_color_list.forEach((item) => { + arr.push({ + length: item?.length || 0, + roll: item.roll, + product_color_id: item.id, + sale_price: sale_mode === EnumSaleMode.Bulk ? item.bulk_price : sale_mode === EnumSaleMode.Plate ? item.length_cut_price : item.weight_cut_price, + }) + }) + const res = await fetchData({ + sale_mode, + sale_order_product_color_list: arr, + purchaser_id: Number(router?.params.purchaser_id), + }) + setInfoObj({ + ...res.data, + product_list: res.data.product_list?.map((item) => { + item.product_colors = item.product_colors.map((it) => { + // 用于存储原始价格,(单价/批量)调整价格 + it.origin_price = it.sale_price + return it + }) + return item + }), + }) + } + } + // 备注操作 const [showDesc, setShowDesc] = useState(false) const getRemark = useCallback(async(e) => { @@ -359,19 +449,34 @@ const SubmitOrder = () => { // 提交订单 const { fetchData: postFetch } = MpSaleOrderPost() + const { fetchData: postOnceFetch } = SaleOrderSubmitBuyNow() const handSure = () => { if (receivingStatus == 2 && !infoObj.address_id) { return alert.error('请选择地址') } const list: any[] = [] - infoObj.product_list.forEach((item) => { - item.product_colors.forEach((it) => { - list.push({ - sale_price: it.sale_price, - shopping_cart_product_color_id: Number(it.id), + if (!isBuyNew.current) { + infoObj.product_list.forEach((item) => { + item.product_colors.forEach((it) => { + list.push({ + sale_price: it.sale_price, + shopping_cart_product_color_id: Number(it.id), + }) }) }) - }) + } + else { + infoObj.product_list.forEach((item) => { + item.product_colors.forEach((it) => { + list.push({ + length: it.length, + roll: it.roll, + sale_price: it.sale_price, + product_color_id: Number(it.id), + }) + }) + }) + } const query = { address_id: Number(infoObj.address_id) ? Number(infoObj.address_id) : 0, list, @@ -392,7 +497,13 @@ const SubmitOrder = () => { title: '请稍等...', mask: true, }) - const res = await postFetch(query) + let res + if (isBuyNew.current) { + res = await postOnceFetch(query) + } + else { + res = await postFetch(query) + } if (res?.msg === 'success') { Taro.showToast({ title: '成功', @@ -462,13 +573,22 @@ const SubmitOrder = () => { useEffect(() => { getAddress() - getDetail() + console.log('isBuyNew', router.params.isBuyNew) + setPusername(decodeURIComponent(router.params.purchaser_name)) + isBuyNew.current = JSON.parse(router.params.isBuyNew) + // 判断立即购买 + if (isBuyNew.current) { + getOnceDetail() + } + else { + getDetail() + } }, []) - const updateList = (list: any[]) => { + const updateData = (data: Record) => { setInfoObj(val => ({ ...val, - product_list: list, + ...data, })) } @@ -492,7 +612,7 @@ const SubmitOrder = () => { - + 合计金额 @@ -513,7 +633,7 @@ const SubmitOrder = () => { {infoObj.product_list?.length} 种面料,{infoObj.total_colors} 种颜色,共 {infoObj.sale_mode === 0 ? infoObj.total_number : infoObj.total_number / 100} {infoObj.sale_mode === 0 ? '条' : 'm'} - handSure()}>提交订单 + 提交订单 setShowDesc(false)}>