Commit 0f791c39 authored by 卢均锐's avatar 卢均锐

feat: c端装修推荐商品分类设置及回显

-修改部分c端装修相关设置组件因频繁发送changeProps导致卡死
parent 54a09984
......@@ -445,6 +445,25 @@ export const paramsClient = (templateId: any, pageConfig: PageConfigType) => {
}
}
break;
case '10':
_params.adornContent.suggestProduct = {
sort: 1,
style: 0,
status: true,
details: [],
};
if (pageConfig['10'].childNodes?.length) {
const _list = pageConfig['10'].childNodes;
for (let key in pageConfig['10'].childNodes) {
_params.adornContent.suggestProduct.details.push({
title: pageConfig[_list[key]]?.props?.title,
explain: pageConfig[_list[key]]?.props?.explain,
type: pageConfig[_list[key]]?.props?.type,
num: pageConfig[_list[key]]?.props?.num,
});
}
}
break;
case '12':
_params.adornContent.bottom = {
sort: 1,
......
......@@ -825,7 +825,8 @@ export const suggestProductConfig = {
componentName: 'SuggestProduct.Items',
props: {},
childComponentName: 'SuggestProduct.Commodity',
addBtnText: '添加商品',
maxLength: 50,
// addBtnText: '添加商品',
childNodes: [],
},
},
......
......@@ -806,6 +806,28 @@ const mobileClientEdit: React.FC<ShopPreviewPropsType> = (props) => {
if (appConfig?.adornContent?.suggestProduct) {
// 商品推荐
const _details = appConfig?.adornContent?.suggestProduct?.details;
if (_details.length > 0) {
_details?.forEach((item, index) => {
const _newKey = `10-${Number(index) + 1}`;
!_suggestProductConfig['10'].childNodes.includes(_newKey) && _suggestProductConfig['10'].childNodes.push(_newKey)
_suggestProductConfig[_newKey] = {
key: _newKey,
title: item?.title || '商品容器',
canEdit: true,
canHide: false,
componentName: 'SuggestProduct.Items',
props: {
...item,
isnull: false
},
childComponentName: 'SuggestProduct.Commodity',
maxLength: item?.num ? item?.num : 50,
// addBtnText: '添加商品',
childNodes: [],
}
})
}
}
!_mallLayoutConfig['0'].childNodes.includes('10') && _mallLayoutConfig['0'].childNodes.push('10');
......
......@@ -101,13 +101,13 @@ const BannerClient: React.FC<BannerClientProps> = (props: BannerClientProps) =>
}, [type])
const _isNull = (list) => {
let _flag = true;
let _number = 0;
for (let key in list) {
if (list[key]) {
_flag = false
_number += 1
}
}
return _flag;
return _number === list.length ? false : true;
}
useEffect(() => {
......@@ -119,7 +119,7 @@ const BannerClient: React.FC<BannerClientProps> = (props: BannerClientProps) =>
id && _fetch?.({ id: id }).then((res) => {
if (res.code === 1000) {
setRecord(res.data)
}else{
} else {
setRecord('');
}
}).catch(_ => setRecord(''));
......@@ -188,7 +188,7 @@ const BannerClient: React.FC<BannerClientProps> = (props: BannerClientProps) =>
if (property === 2 && type === 5) {
return false
}
if(!type){
if (!type) {
return false
}
return true;
......@@ -257,7 +257,7 @@ const BannerClient: React.FC<BannerClientProps> = (props: BannerClientProps) =>
<div className={styles['banner']}>
<div className={styles['banner-box']}>
<div className={styles['banner-box-label']}>名称</div>
<Input key={`${selectedKey}-name`} defaultValue={name} onChange={_onChangeName} />
<Input key={`${selectedKey}-name`} defaultValue={name} onBlur={_onChangeName} />
</div>
<div className={styles['banner-box']}>
<div className={styles['banner-box-label']}>图片</div>
......
......@@ -69,13 +69,13 @@ const BottomNavigationClient: React.FC<BottomNavigationClientProps> = (props: Bo
const { defaultIcon, selectIcon, name, type, selectedKey } = props;
const _isNull = (list) => {
let _flag = true;
let _number = 0;
for (let key in list) {
if (list[key]) {
_flag = false
_number += 1
}
}
return _flag;
return _number === list.length ? false : true;
}
const _onChangeName = (e: any) => {
......@@ -108,7 +108,7 @@ const BottomNavigationClient: React.FC<BottomNavigationClientProps> = (props: Bo
<div className={styles['bottomNavigationClient']}>
<div className={styles['bottomNavigationClient-box']}>
<div className={styles['bottomNavigationClient-box-label']}>名称</div>
<Input key={`${selectedKey}-name`} defaultValue={name} onChange={_onChangeName} />
<Input key={`${selectedKey}-name`} defaultValue={name} onBlur={_onChangeName} />
</div>
<div className={styles['bottomNavigationClient-box']}>
<div className={styles['bottomNavigationClient-box-label']}>链接</div>
......
......@@ -24,7 +24,7 @@ const CouponsModal: React.FC<CouponsModalProps> = (props: CouponsModalProps) =>
<div className={styles['couponsModal']}>
<div className={styles['couponsModal-box']}>
<div className={styles['couponsModal-box-label']}>标题</div>
<Input key={`${selectedKey}-title`} defaultValue={title} onChange={_onChangeTitle} />
<Input key={`${selectedKey}-title`} defaultValue={title} onBlur={_onChangeTitle} />
</div>
</div>
);
......
......@@ -50,11 +50,11 @@ const MarketingCardHeader: React.FC<MarketingCardHeaderProps> = (props: Marketin
<div className={styles['marketingCardHeader']}>
<div className={styles['marketingCardHeader-box']}>
<div className={styles['marketingCardHeader-box-label']}>标题</div>
<Input key={`${selectedKey}-title`} defaultValue={title || _defaultInfo?.title} onChange={_onChangeTitle} />
<Input key={`${selectedKey}-title`} defaultValue={title || _defaultInfo?.title} onBlur={_onChangeTitle} />
</div>
<div className={styles['marketingCardHeader-box']}>
<div className={styles['marketingCardHeader-box-label']}>标题说明</div>
<Input key={`${selectedKey}-explain`} defaultValue={explain || _defaultInfo?.explain} onChange={_onChangeExplain} />
<Input key={`${selectedKey}-explain`} defaultValue={explain || _defaultInfo?.explain} onBlur={_onChangeExplain} />
</div>
<div className={styles['marketingCardHeader-box']}>
<div className={styles['marketingCardHeader-box-label']}>图标</div>
......
......@@ -17,13 +17,13 @@ interface SuggestProductProps {
const SuggestProduct: React.FC<SuggestProductProps> = (props: SuggestProductProps) => {
const { title, explain, type, num, customize, selectedKey } = props;
const _isNull = (list) => {
let _flag = true;
let _number = 0;
for (let key in list) {
if (list[key]) {
_flag = false
_number += 1
}
}
return _flag;
return _number === list.length ? false : true;
}
const _onChangeTitle = (e: any) => {
......@@ -44,14 +44,16 @@ const SuggestProduct: React.FC<SuggestProductProps> = (props: SuggestProductProp
const _onChangeType = (e: any) => {
const _val = e.target.value;
changeProps({
props: Object.assign({ ...props }, { type: _val, isnull: _isNull([title, explain, _val]) })
props: Object.assign({ ...props }, { type: _val, isnull: _isNull([title, explain, _val]) }),
addBtnText:_val === 3 ? '添加商品' : '',
});
}
const _onChangeNum = (e: any) => {
const _val = e.target.value.replace(/[^\d]/g,'');
changeProps({
props: Object.assign({ ...props }, { num: _val, isnull: _isNull([title, explain, _val]) })
props: Object.assign({ ...props }, { num: _val, isnull: _isNull([title, explain, _val]) }),
maxLength: _val
});
}
......@@ -59,11 +61,11 @@ const SuggestProduct: React.FC<SuggestProductProps> = (props: SuggestProductProp
<div className={styles['suggestProduct']}>
<div className={styles['suggestProduct-box']}>
<div className={styles['suggestProduct-box-label']}>标题</div>
<Input key={`${selectedKey}-title`} defaultValue={title} onChange={_onChangeTitle} maxLength={8} />
<Input key={`${selectedKey}-title`} defaultValue={title} onBlur={_onChangeTitle} maxLength={8} />
</div>
<div className={styles['suggestProduct-box']}>
<div className={styles['suggestProduct-box-label']}>标题说明</div>
<Input key={`${selectedKey}-explain`} defaultValue={explain} onChange={_onChangeExplain} maxLength={16} />
<Input key={`${selectedKey}-explain`} defaultValue={explain} onBlur={_onChangeExplain} maxLength={16} />
</div>
<div className={styles['suggestProduct-box']}>
<div className={styles['suggestProduct-box-label']}>商品展示</div>
......@@ -77,7 +79,7 @@ const SuggestProduct: React.FC<SuggestProductProps> = (props: SuggestProductProp
</div>
<div className={styles['suggestProduct-box']}>
<div className={styles['suggestProduct-box-label']}>展示数量</div>
<Input key={`${selectedKey}-num`} defaultValue={num} onChange={_onChangeNum} />
<Input key={`${selectedKey}-num`} defaultValue={num} onBlur={_onChangeNum} />
</div>
</div>
)
......
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