Commit ed8dfc6f authored by 卢均锐's avatar 卢均锐

feat: 完善c端首页装修的优惠券弹窗设置及回显

parent 4dc52a80
......@@ -105,8 +105,8 @@ const CouponsDrawer: React.FC<CouponsDrawerProps> = (props: CouponsDrawerProps)
key: 'belongName',
render: (text: any, record: any) => (
<Space direction='vertical'>
<StatusTag title={record.type === 1 ? '平台' : '商家'} type={record.type === 1 ? 'success' : 'primary'} />
{record.type === 2 && <Typography.Text type='secondary'>{text}</Typography.Text>}
<StatusTag title={record.belongType === 1 ? '平台' : '商家'} type={record.belongType === 1 ? 'success' : 'primary'} />
{record.belongType === 2 && <Typography.Text type='secondary'>{text}</Typography.Text>}
</Space>
)
},
......
......@@ -38,13 +38,15 @@ export const paramsClient = (templateId: any, pageConfig: PageConfigType) => {
title: pageConfig['11-1-1']?.props?.title,
explain: pageConfig['11-1-1']?.props?.explain,
icon: pageConfig['11-1-1']?.props?.icon,
id: []
id: [],
},
};
if (pageConfig['11-1-2'].childNodes?.length) {
const _list = pageConfig['11-1-2'].childNodes;
for (let key in _list) {
_params.adornContent.specialOffer.details.id.push(pageConfig[_list[key]]?.props?.id);
_params.adornContent.specialOffer.details.id.push(
pageConfig[_list[key]]?.props?.id,
);
}
}
break;
......@@ -80,9 +82,10 @@ export const paramsClient = (templateId: any, pageConfig: PageConfigType) => {
if (pageConfig['13'].childNodes?.length) {
const _list = pageConfig['13'].childNodes;
for (let key in _list) {
_params.adornContent.coupon.details.id.push(
pageConfig[_list[key]]?.props?.id,
);
_params.adornContent.coupon.details.id.push({
id: pageConfig[_list[key]]?.props?.id,
belongType: pageConfig[_list[key]]?.props?.belongType,
});
}
}
break;
......
......@@ -2,6 +2,7 @@ import React, { useEffect, useState } from 'react';
import { BrickProvider } from '@lingxi-disign/react';
import { updatePageConfig } from '@lingxi-disign/core';
import { message } from 'antd';
import moment from 'moment';
import cloneDeep from 'lodash/cloneDeep';
import { PublicApi } from '@/services/api';
......@@ -177,11 +178,11 @@ const mobileClientEdit: React.FC<ShopPreviewPropsType> = (props) => {
_marketingConfig_1['11-1-1'].props.icon = _details.icon;
const _ids = _details.id.join(',');
if (_ids.length > 0) {
const _detailData = await PublicApi.getMarketingPlatformActivityGoodsAdorn({ ids: _ids})
const _detailData = await PublicApi.getMarketingPlatformActivityGoodsAdorn({ ids: _ids })
if (_detailData.code === 1000) {
_detailData.data?.forEach((item, index) => {
const _newKey = `11-1-2-${Number(index) + 1}`;
_marketingConfig_1['11-1-2'].childNodes.push(_newKey);
!_marketingConfig_1['11-1-2'].childNodes.includes(_newKey) && _marketingConfig_1['11-1-2'].childNodes.push(_newKey)
_marketingConfig_1[_newKey] = {
key: _newKey,
title: item.productName,
......@@ -388,12 +389,30 @@ const mobileClientEdit: React.FC<ShopPreviewPropsType> = (props) => {
// 优惠券弹窗
const _details = appConfig?.adornContent?.coupon?.details;
_couponsModalConfig['13'].props.title = _details.title;
// if (_details.id.length > 0) {
// for (let key in _details.id) {
// const _childKey: any = `13-${Number(key) + 1}`;
// !_couponsModalConfig['13'].childNodes.includes(_childKey) && _couponsModalConfig['13'].childNodes.push(_childKey)
// }
// }
if (_details.id.length > 0) {
const _couponList = _details.id?.map((item) => { return { couponType: item.belongType, id: item.id } });
const _couponListData = await PublicApi.postMarketingCouponPlatformActivityPageSelectDetail({ couponList: _couponList });
if (_couponListData.code === 1000) {
_couponListData.data?.forEach((item, index) => {
const _newKey: any = `13-${Number(index) + 1}`;
!_couponsModalConfig['13'].childNodes.includes(_newKey) && _couponsModalConfig['13'].childNodes.push(_newKey)
_couponsModalConfig[_newKey] = {
key: _newKey,
title: item.name,
componentName: 'CouponsModal.CouponsItem',
props: {
...item,
expiredDay: moment(item?.releaseTimeEnd || moment()).diff(moment(), 'days'),
isnull: false
}
}
})
}
for (let key in _details.id) {
const _childKey: any = `13-${Number(key) + 1}`;
!_couponsModalConfig['13'].childNodes.includes(_childKey) && _couponsModalConfig['13'].childNodes.push(_childKey)
}
}
}
!_mallLayoutConfig['0'].childNodes.includes('13') && _mallLayoutConfig['0'].childNodes.push('13');
......
......@@ -14,13 +14,13 @@ import styles from './index.less';
interface MarketingCardCouponProps {
id?: number,
type?: number,
belongType?: number,
// 当前选中组件的key
selectedKey?: any,
}
const MarketingCardCoupon: React.FC<MarketingCardCouponProps> = (props: MarketingCardCouponProps) => {
const { id, type, selectedKey } = props;
const { id, belongType, selectedKey } = props;
const [drawerVisible, setDrawerVisible] = useState(false);
const [record, setRecord] = useState<any>();
const _onClose = () => {
......@@ -28,15 +28,17 @@ const MarketingCardCoupon: React.FC<MarketingCardCouponProps> = (props: Marketin
}
useEffect(() => {
if (id && id != record?.id) {
PublicApi.postMarketingCouponPlatformActivityPageSelectDetail({ couponList: [{ couponType: type, id: id }] }).then((res) => {
PublicApi.postMarketingCouponPlatformActivityPageSelectDetail({ couponList: [{ couponType: belongType, id: id }] }).then((res) => {
if (res.code === 1000) {
setRecord(res.data[0]);
}else{
setRecord('')
}
}).catch(err => console.log(err))
}).catch(_ => setRecord(''))
}else if(!id){
setRecord('');
}
}, [id, type])
}, [id, belongType])
const _onChooseConfirm = (record) => {
setRecord(record);
changeProps({
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment