✨ feat(ID1000956): 【内部小程序】补充立即下单功能
【【内部小程序】补充立即下单功能】 https://www.tapd.cn/53459131/prong/stories/view/1153459131001000956
This commit is contained in:
parent
488fc66481
commit
5c8c164904
@ -32,6 +32,7 @@
|
||||
"disableUseStrict": false,
|
||||
"useCompilerPlugins": false,
|
||||
"minifyWXML": true,
|
||||
"condition": false,
|
||||
"ignoreUploadUnusedFiles": true
|
||||
},
|
||||
"compileType": "miniprogram",
|
||||
|
||||
@ -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"',
|
||||
|
||||
@ -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"',
|
||||
|
||||
@ -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',
|
||||
})
|
||||
}
|
||||
|
||||
@ -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
|
||||
// 生成密钥
|
||||
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
@ -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 (
|
||||
<View className={styles.bottomBox}>
|
||||
<View className={styles.leftBottom} onClick={() => { navTo() }}>
|
||||
<View className={styles.nowFont}>当前客户:</View>
|
||||
<View className={styles.selctFont}>{clientName === '' ? '请选择客户 >' : `${clientName} >`}</View>
|
||||
</View>
|
||||
<Button className={classnames(isDisabled ? styles.activeButton : styles.button)} disabled={isDisabled} onClick={() => { handSure?.() }}> 加入购物车</Button >
|
||||
</View >
|
||||
)
|
||||
}
|
||||
export default memo(BottomCustomer)
|
||||
@ -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) => {
|
||||
<View className={styles.title}>{valueInfo?.code} {valueInfo?.name}</View>
|
||||
<View className={styles.productNums}>剩:{valueInfo?.roll}件</View>
|
||||
{
|
||||
modeFont === 0 && <View className={styles.productName}>空差:{formatWeightDiv(valueInfo?.weight_error) || 0}Kg</View>
|
||||
modeFont === EnumSaleMode.Bulk && <View className={styles.productName}>空差:{formatWeightDiv(valueInfo?.weight_error) || 0}Kg</View>
|
||||
}
|
||||
</View>
|
||||
<View className={styles.rightFontsbox}>
|
||||
<View className={styles.moneyFlex}>
|
||||
{
|
||||
modeFont === 0 && valueInfo?.last_bulk_price !== valueInfo?.bulk_price && <View className={styles.lastBox}>¥{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'}</View>
|
||||
(modeFont === EnumSaleMode.Bulk) && (valueInfo?.last_bulk_price !== valueInfo?.bulk_price)
|
||||
? <View className={styles.lastBox}>
|
||||
¥{formatPriceDiv(valueInfo?.last_bulk_price)} /Kg
|
||||
</View>
|
||||
: null
|
||||
}
|
||||
<View className={styles.money}>¥{modeFont === 0 ? formatPriceDiv(valueInfo?.bulk_price) : modeFont === 1 ? formatPriceDiv(valueInfo?.length_cut_price) : formatPriceDiv(valueInfo?.weight_cut_price)}{modeFont != 1 ? '/Kg' : '/m'}</View>
|
||||
<View className={styles.money}>¥{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'}</View>
|
||||
</View>
|
||||
{
|
||||
valueInfo.showInput
|
||||
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@ -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 (
|
||||
<Popup showTitle={false} show={showPopup} onClose={() => closePopup?.()}>
|
||||
<ScrollView className={styles.scrllStyle} scrollY>
|
||||
<ScrollView className={styles.scrllStyle} id="scroll" scrollY>
|
||||
<View className={styles.shopcartBox}>
|
||||
<View className={styles.topTitle}>
|
||||
{formatHashTag(obj?.code, obj?.name)}
|
||||
@ -135,8 +164,6 @@ const ShoppingCart = (props: prosObj, ref) => {
|
||||
<View className={styles.selectFont}>
|
||||
已选 1 种面料,{selectTotal} 个颜色,共 {selectNums} {showModefont}
|
||||
</View>
|
||||
<Divider direction="horizontal" customStyles={{ margin: '12px 0' }}></Divider>
|
||||
<View className={styles.typeFont}>布料类型</View>
|
||||
<View className={styles.flexType}>
|
||||
{typeList.map((item, index) => {
|
||||
return (
|
||||
@ -176,7 +203,7 @@ const ShoppingCart = (props: prosObj, ref) => {
|
||||
<View className={styles.scrollviewBig}>
|
||||
<VirtualList
|
||||
className={styles.scrollview}
|
||||
height={300} /* 列表的高度 */
|
||||
height={400} /* 列表的高度 */
|
||||
width="100%" /* 列表的宽度 */
|
||||
itemData={goodList} /* 渲染列表的数据 */
|
||||
itemCount={goodList.length + 0} /* 渲染列表的长度 */
|
||||
@ -197,19 +224,20 @@ const ShoppingCart = (props: prosObj, ref) => {
|
||||
</View>
|
||||
)}
|
||||
{!hasBottom && <View style={{ height: '100rpx' }}></View>}
|
||||
{/* <View className={classnames(hasBottom === true ? styles.posBox : styles.noBottom)}> */}
|
||||
<View className={styles.noBottom}>
|
||||
<BottomCustomer
|
||||
clientName={clientName}
|
||||
clientId={clientId}
|
||||
isDisabled={!(selectTotal > 0 && clientName !== '')}
|
||||
handSure={() => {
|
||||
handSure()
|
||||
}}
|
||||
></BottomCustomer>
|
||||
</View>
|
||||
</View>
|
||||
</ScrollView>
|
||||
<View className={styles.noBottom}>
|
||||
<View className={styles.bottomBox}>
|
||||
<View className={styles.leftBottom} onClick={navTo}>
|
||||
<View className={styles.nowFont}>当前客户:</View>
|
||||
<View className={styles.selctFont}>{clientName === '' ? '请选择客户 >' : `${clientName} >`}</View>
|
||||
</View>
|
||||
<View className={styles.rightBottom}>
|
||||
<NormalButton round type="primary" disabled={isDisabled} onClick={handBuyNow}>立即购买</NormalButton>
|
||||
<NormalButton round type="primary" disabled={isDisabled} onClick={handSure}>加入购物车</NormalButton>
|
||||
</View>
|
||||
</View >
|
||||
</View>
|
||||
</Popup>
|
||||
)
|
||||
}
|
||||
|
||||
@ -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'
|
||||
|
||||
|
||||
@ -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)
|
||||
|
||||
|
||||
@ -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<string, any>) => 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) => {
|
||||
<View>
|
||||
<View className={styles.item_right_top}>
|
||||
<View className={styles.itemName}>{formatRemoveHashTag(it.code)}# {it.name}</View>
|
||||
<View className={styles.itemNums}>x{obj?.sale_mode === EnumSaleMode.Bulk ? it.roll : formatMeterDiv(it.length)}{obj?.sale_mode === 0 ? '条' : 'm'}</View>
|
||||
<View className={styles.itemNums}>x{obj?.sale_mode === EnumSaleMode.Bulk ? it.roll : formatMeterDiv(it.length)}{obj?.sale_mode === 0 ? '条' : '米'}</View>
|
||||
</View>
|
||||
<View className={styles.item_right_Bottom}>
|
||||
<View className={styles.flexBox}>
|
||||
<View className={styles.itemMoney}>¥{formatPriceDiv(it.sale_price)}/{obj?.sale_mode === EnumSaleMode.Plate ? 'm' : 'kg'}</View>
|
||||
<View className={styles.itemMoney}>¥{formatPriceDiv(it.sale_price, 100, true)}/{obj?.sale_mode === EnumSaleMode.Plate ? 'm' : 'kg'}</View>
|
||||
{
|
||||
(obj?.sale_mode === EnumSaleMode.Bulk && it?.sale_price !== it?.standard_price) ? <View className={styles.lastBox}>¥{formatPriceDiv(it?.standard_price)}/kg</View> : null
|
||||
(obj?.sale_mode === EnumSaleMode.Bulk && it?.sale_price !== it?.standard_price)
|
||||
? <View className={styles.lastBox}>
|
||||
¥{formatPriceDiv(it?.standard_price, 100, true)}/kg
|
||||
</View>
|
||||
: null
|
||||
}
|
||||
{
|
||||
(obj?.sale_mode === EnumSaleMode.Plate && it?.sale_price !== it?.standard_price)
|
||||
? <View className={styles.lastBox}>
|
||||
¥{formatPriceDiv(it?.standard_price, 100, true)}/m
|
||||
</View>
|
||||
: null
|
||||
}
|
||||
{
|
||||
(obj?.sale_mode === EnumSaleMode.BulkCut && it?.sale_price !== it?.standard_price)
|
||||
? <View className={styles.lastBox}>
|
||||
¥{formatPriceDiv(it?.standard_price, 100, true)}/kg
|
||||
</View>
|
||||
: null
|
||||
}
|
||||
<View onClick={() => handleEdit(it.id, item.id)}>
|
||||
<IconFont name="icon-bianji1" color="#3d85ff"></IconFont>
|
||||
@ -275,6 +329,8 @@ const SubmitOrder = () => {
|
||||
const [infoObj, setInfoObj] = useState<any>({})
|
||||
let selectId = -1
|
||||
|
||||
const isBuyNew = useRef(false)
|
||||
|
||||
// 收货方法,1:自提,2物流
|
||||
const [receivingStatus, setReceivingStatus] = useState<any>(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<string, any>) => {
|
||||
setInfoObj(val => ({
|
||||
...val,
|
||||
product_list: list,
|
||||
...data,
|
||||
}))
|
||||
}
|
||||
|
||||
@ -492,7 +612,7 @@ const SubmitOrder = () => {
|
||||
</View>
|
||||
</DefaultBoxWithMemo>
|
||||
<View className={styles.productBox}>
|
||||
<GoodsItemWithMemo list={infoObj?.product_list} obj={infoObj} updateList={updateList}></GoodsItemWithMemo>
|
||||
<GoodsItemWithMemo list={infoObj?.product_list} obj={infoObj} updateData={updateData} ></GoodsItemWithMemo>
|
||||
<View className={styles.flexMoney}>
|
||||
<View className={styles.flexTotalBox}>
|
||||
<View className={styles.totalFont}>合计金额</View>
|
||||
@ -513,7 +633,7 @@ const SubmitOrder = () => {
|
||||
</View>
|
||||
<View className={styles.bottomFlex}>{infoObj.product_list?.length} 种面料,{infoObj.total_colors} 种颜色,共 {infoObj.sale_mode === 0 ? infoObj.total_number : infoObj.total_number / 100} {infoObj.sale_mode === 0 ? '条' : 'm'}</View>
|
||||
</View>
|
||||
<View className={styles.rightBottom} onClick={() => handSure()}>提交订单</View>
|
||||
<View className={styles.rightBottom} onClick={handSure}>提交订单</View>
|
||||
</View>
|
||||
|
||||
<Popup show={showDesc} showTitle={false} onClose={() => setShowDesc(false)}>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user