提交 e94ca786 作者: 翁进城

Merge remote-tracking branch 'origin/caoyun'

...@@ -20,7 +20,11 @@ import { ...@@ -20,7 +20,11 @@ import {
} from 'antd' } from 'antd'
import Image from 'next/image' import Image from 'next/image'
import errImg from '~/assets/errImg' import errImg from '~/assets/errImg'
import api, { GetWebDeviceDetailResult, GetWebDeviceWareSkuById } from './api' import api, {
GetWebDeviceDetailResult,
GetWebDeviceWareSkuById,
GetLeaseGoodsResult,
} from './api'
import { UserContext } from '~/lib/userProvider' import { UserContext } from '~/lib/userProvider'
import flowPat from './assets/flow-path.png' import flowPat from './assets/flow-path.png'
import { RangePickerProps } from 'antd/es/date-picker' import { RangePickerProps } from 'antd/es/date-picker'
...@@ -76,13 +80,15 @@ export default function EquipmentLeasingDetail() { ...@@ -76,13 +80,15 @@ export default function EquipmentLeasingDetail() {
const [form] = Form.useForm() const [form] = Form.useForm()
const [formDate] = Form.useForm() const [formDate] = Form.useForm()
const tagsData = [ const tagsData = [
{ label: '1-7天', disable: false }, { id: 0, label: '1-7天', disable: false },
{ label: '8-15天', disable: false }, { id: 1, label: '8-15天', disable: false },
{ label: '16-30天', disable: false }, { id: 2, label: '16-30天', disable: false },
{ label: '30天以上', disable: false }, { id: 3, label: '30天以上', disable: false },
] ]
const [discount, setDiscount] = useState<GetLeaseGoodsResult | null>()
const [selectedTags, setSelectedTags] = useState<number>() const [selectedTags, setSelectedTags] = useState<number>()
const [selectedTagsData, setSelectedTagsData] = useState<string>() const [selectedTagsData, setSelectedTagsData] = useState<number>()
const [shopDetail, setShopDetail] = useState<ShopDetail>() const [shopDetail, setShopDetail] = useState<ShopDetail>()
const showModal = () => { const showModal = () => {
...@@ -91,8 +97,9 @@ export default function EquipmentLeasingDetail() { ...@@ -91,8 +97,9 @@ export default function EquipmentLeasingDetail() {
if (wareSkuList?.length) { if (wareSkuList?.length) {
setSelectedTags(wareSkuList[0].id) setSelectedTags(wareSkuList[0].id)
form.setFieldValue('id', wareSkuList[0].id) form.setFieldValue('id', wareSkuList[0].id)
setSelectedTagsData('1-7天') setSelectedTagsData(0)
form.setFieldValue('date', '3-7天') form.setFieldValue('date', 0)
getPrice(0)
} }
} else { } else {
setNeedLogin(true) setNeedLogin(true)
...@@ -157,16 +164,30 @@ export default function EquipmentLeasingDetail() { ...@@ -157,16 +164,30 @@ export default function EquipmentLeasingDetail() {
} }
const handleChangeDate = ( const handleChangeDate = (
tag: string, tag: number,
checked: boolean, checked: boolean,
disable: boolean disable: boolean
) => { ) => {
if (checked && !disable) { if (checked && !disable) {
const nextSelectedTags = checked const nextSelectedTags = checked
? tag ? tag
: tagsData.filter((t) => t.label !== tag)[0].label : tagsData.filter((t) => t.id !== tag)[0].id
setSelectedTagsData(nextSelectedTags) setSelectedTagsData(nextSelectedTags)
form.setFieldValue('date', tag) form.setFieldValue('date', tag)
getPrice(tag)
}
}
const getPrice = (tag: number) => {
const Id = wareSkuList?.filter(
(item) => item.id === form.getFieldValue('id')
)[0].productSpec
if (Id) {
api
.GoodsPriceDetail({ leaseTerm: tag, productSpecId: Id })
.then((res) => {
setDiscount(res.result)
})
} }
} }
...@@ -307,7 +328,9 @@ export default function EquipmentLeasingDetail() { ...@@ -307,7 +328,9 @@ export default function EquipmentLeasingDetail() {
<div className="right"> <div className="right">
<div className="top"> <div className="top">
<span className="tag">¥</span> <span className="tag">¥</span>
<span className="money">{detail?.price || 0}</span> <span className="money">
{discount?.specPrice[0]?.price || 0}
</span>
<span className="unit">/天</span> <span className="unit">/天</span>
</div> </div>
<div className="bottom">渠道免押金</div> <div className="bottom">渠道免押金</div>
...@@ -348,10 +371,10 @@ export default function EquipmentLeasingDetail() { ...@@ -348,10 +371,10 @@ export default function EquipmentLeasingDetail() {
<Space size={[0, 8]} wrap> <Space size={[0, 8]} wrap>
{tagsData.map((tag) => ( {tagsData.map((tag) => (
<CheckableTag <CheckableTag
key={tag.label} key={tag.id}
checked={tag.label === selectedTagsData} checked={tag.id === selectedTagsData}
onChange={(checked) => onChange={(checked) =>
handleChangeDate(tag.label, checked, tag.disable) handleChangeDate(tag.id, checked, tag.disable)
} }
className={`tagsData ${ className={`tagsData ${
tag.disable ? 'disable tagsDisable' : '' tag.disable ? 'disable tagsDisable' : ''
...@@ -423,7 +446,12 @@ export default function EquipmentLeasingDetail() { ...@@ -423,7 +446,12 @@ export default function EquipmentLeasingDetail() {
<div className="bottom-item"> <div className="bottom-item">
<div className="label">租金合计</div> <div className="label">租金合计</div>
<div className="price"> <div className="price">
<div className="left">¥{detail?.price! * days! || 0}</div> <div className="left">
¥
{discount?.specPrice[0]?.price! *
days! *
form.getFieldValue('num') || 0}
</div>
{/* <div className="right">(日均175)</div> */} {/* <div className="right">(日均175)</div> */}
</div> </div>
</div> </div>
...@@ -435,6 +463,7 @@ export default function EquipmentLeasingDetail() { ...@@ -435,6 +463,7 @@ export default function EquipmentLeasingDetail() {
shopDetail={shopDetail} shopDetail={shopDetail}
days={days} days={days}
detailData={detail} detailData={detail}
discount={discount}
wareSkuList={wareSkuList?.filter( wareSkuList={wareSkuList?.filter(
(item) => item.id === form.getFieldValue('id') (item) => item.id === form.getFieldValue('id')
)} )}
......
...@@ -26,7 +26,7 @@ export interface GetLeaseGoodsResult { ...@@ -26,7 +26,7 @@ export interface GetLeaseGoodsResult {
productSpecId: number productSpecId: number
type: number | null type: number | null
leaseTerm: number leaseTerm: number
specPrice: PriceType specPrice: PriceType[]
} }
export interface GetWebDeviceDetailResult { export interface GetWebDeviceDetailResult {
id: number id: number
......
...@@ -5,7 +5,11 @@ import { Button, Radio, Space, Input, message, Modal, Image } from 'antd' ...@@ -5,7 +5,11 @@ import { Button, Radio, Space, Input, message, Modal, Image } from 'antd'
import api, { UserAddress, GetOrderForGoods } from './api' import api, { UserAddress, GetOrderForGoods } from './api'
import moment from 'moment' import moment from 'moment'
import { ShopDetail } from '../../[id].page' import { ShopDetail } from '../../[id].page'
import { GetWebDeviceDetailResult, GetWebDeviceWareSkuById } from '../../api' import {
GetWebDeviceDetailResult,
GetWebDeviceWareSkuById,
GetLeaseGoodsResult,
} from '../../api'
import { UserContext } from '~/lib/userProvider' import { UserContext } from '~/lib/userProvider'
const { TextArea } = Input const { TextArea } = Input
...@@ -15,11 +19,18 @@ interface PropsBox { ...@@ -15,11 +19,18 @@ interface PropsBox {
days?: number days?: number
shopDetail?: ShopDetail shopDetail?: ShopDetail
wareSkuList?: GetWebDeviceWareSkuById[] wareSkuList?: GetWebDeviceWareSkuById[]
discount?: GetLeaseGoodsResult | null
} }
export default function OrderForGoods(props: PropsBox) { export default function OrderForGoods(props: PropsBox) {
const { setIsorderForGoods, shopDetail, days, detailData, wareSkuList } = const {
props setIsorderForGoods,
shopDetail,
days,
detailData,
wareSkuList,
discount,
} = props
const [value, setValue] = useState(1) const [value, setValue] = useState(1)
const [areaValue, setAreaValue] = useState<string>() const [areaValue, setAreaValue] = useState<string>()
const [list, setList] = useState<Array<UserAddress> | null>() const [list, setList] = useState<Array<UserAddress> | null>()
...@@ -35,8 +46,8 @@ export default function OrderForGoods(props: PropsBox) { ...@@ -35,8 +46,8 @@ export default function OrderForGoods(props: PropsBox) {
const detailSumbit = () => { const detailSumbit = () => {
if (detailData && shopDetail && list && wareSkuList) { if (detailData && shopDetail && list && wareSkuList) {
const pushList = { const pushList = {
// actualPay: shopDetail.num * detailData.price!, actualPay:
actualPay: 100, discount?.specPrice[0].price! * shopDetail?.num! * days! || 0,
deposit: 0, deposit: 0,
endDate: moment(new Date(shopDetail.dateDetail[1])).format( endDate: moment(new Date(shopDetail.dateDetail[1])).format(
'YYYY-MM-DD' 'YYYY-MM-DD'
...@@ -48,13 +59,13 @@ export default function OrderForGoods(props: PropsBox) { ...@@ -48,13 +59,13 @@ export default function OrderForGoods(props: PropsBox) {
takeName: list[value].takeName, takeName: list[value].takeName,
takePhone: Number(list[value].takePhone), takePhone: Number(list[value].takePhone),
}, },
// rentPrice: shopDetail.num * detailData.price!, rentPrice:
rentPrice: 100, discount?.specPrice[0].price! * shopDetail?.num! * days! || 0,
returnDate: moment( returnDate: moment(
new Date(shopDetail.dateDetail[1]).getTime() + 864e5 new Date(shopDetail.dateDetail[1]).getTime() + 864e5
).format('YYYY-MM-DD'), ).format('YYYY-MM-DD'),
// shouldPay: shopDetail.num * detailData.price!, shouldPay:
shouldPay: 100, discount?.specPrice[0].price! * shopDetail?.num! * days! || 0,
specsId: wareSkuList[0].productSpec, specsId: wareSkuList[0].productSpec,
startDate: moment(new Date(shopDetail.dateDetail[0]!)).format( startDate: moment(new Date(shopDetail.dateDetail[0]!)).format(
'YYYY-MM-DD' 'YYYY-MM-DD'
...@@ -81,8 +92,6 @@ export default function OrderForGoods(props: PropsBox) { ...@@ -81,8 +92,6 @@ export default function OrderForGoods(props: PropsBox) {
} }
useEffect(() => { useEffect(() => {
console.log(days)
api api
.listUserAddress({}) .listUserAddress({})
.then((res) => { .then((res) => {
...@@ -219,7 +228,7 @@ export default function OrderForGoods(props: PropsBox) { ...@@ -219,7 +228,7 @@ export default function OrderForGoods(props: PropsBox) {
</div> </div>
</div> </div>
<div className="body-item" style={{ width: 130 }}> <div className="body-item" style={{ width: 130 }}>
{detailData?.price || 0} {discount?.specPrice[0].price || 0}
</div> </div>
<div className="body-item" style={{ width: 130 }}> <div className="body-item" style={{ width: 130 }}>
{shopDetail?.num || 1} {shopDetail?.num || 1}
...@@ -234,7 +243,7 @@ export default function OrderForGoods(props: PropsBox) { ...@@ -234,7 +243,7 @@ export default function OrderForGoods(props: PropsBox) {
)} )}
</div> </div>
<div className="body-item total-price" style={{ width: 135 }}> <div className="body-item total-price" style={{ width: 135 }}>
{detailData?.price! * shopDetail?.num! || 0} {discount?.specPrice[0].price! * shopDetail?.num! * days! || 0}
</div> </div>
</div> </div>
</div> </div>
...@@ -272,7 +281,9 @@ export default function OrderForGoods(props: PropsBox) { ...@@ -272,7 +281,9 @@ export default function OrderForGoods(props: PropsBox) {
<div className="detail"> <div className="detail">
<div className="top"> <div className="top">
<div className="label">实付款</div> <div className="label">实付款</div>
<div className="price">¥20000.00</div> <div className="price">
¥{discount?.specPrice[0].price! * shopDetail?.num! * days! || 0}
</div>
</div> </div>
<div className="bottom"> <div className="bottom">
<div className="value">寄送至</div> <div className="value">寄送至</div>
...@@ -309,7 +320,9 @@ export default function OrderForGoods(props: PropsBox) { ...@@ -309,7 +320,9 @@ export default function OrderForGoods(props: PropsBox) {
</Button>, </Button>,
]} ]}
> >
<div className="title">{detailData?.price! * days!}</div> <div className="title">
{discount?.specPrice[0].price! * shopDetail?.num! * days! || 0}
</div>
<div>云享飞账号: {userInfo?.uid}</div> <div>云享飞账号: {userInfo?.uid}</div>
<div>付款方式: 可用(¥{paymentDetail?.balance})</div> <div>付款方式: 可用(¥{paymentDetail?.balance})</div>
</Modal> </Modal>
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论