diff --git a/src/components/BasicShop/BasicComponents/Carousel/index.tsx b/src/components/BasicShop/BasicComponents/Carousel/index.tsx index 16af599..d2ea7c5 100644 --- a/src/components/BasicShop/BasicComponents/Carousel/index.tsx +++ b/src/components/BasicShop/BasicComponents/Carousel/index.tsx @@ -1,15 +1,19 @@ -import React, { memo } from 'react'; +import React, { memo, PropsWithChildren } from 'react'; import { Carousel } from 'zarm'; import styles from './index.less'; import { ICarouselConfig } from './schema'; import logo from '@/assets/01-轮播.png'; -const XCarousel = memo((props: ICarouselConfig) => { - const { direction, swipeable, autoPlay, isTpl, imgList } = props; +interface CarouselTypes extends ICarouselConfig { + isTpl: boolean; +} + +const XCarousel = memo((props: PropsWithChildren) => { + const { direction, swipeable, autoPlay, isTpl, imgList, round } = props; const contentRender = () => { return imgList.map((item, i) => { return ( -
+
0 ? item.imgUrl[0].url : ''} alt="" /> @@ -18,38 +22,25 @@ const XCarousel = memo((props: ICarouselConfig) => { }); }; return ( - <> +
{isTpl ? (
) : ( -
{ + // console.log(`onChange: ${index}`); }} + direction={direction} + swipeable={swipeable} + autoPlay={autoPlay} + loop > - { - // console.log(`onChange: ${index}`); - }} - direction={direction} - swipeable={swipeable} - autoPlay={autoPlay} - loop - > - {contentRender()} - -
+ {contentRender()} + )} - +
); }); diff --git a/src/components/BasicShop/BasicComponents/Carousel/schema.ts b/src/components/BasicShop/BasicComponents/Carousel/schema.ts index 9e2b065..cf0c9da 100644 --- a/src/components/BasicShop/BasicComponents/Carousel/schema.ts +++ b/src/components/BasicShop/BasicComponents/Carousel/schema.ts @@ -1,27 +1,31 @@ import { IDataListConfigType, - INumberConfigType, IRadioConfigType, ISwitchConfigType, + INumberConfigType, TDataListDefaultType, TRadioDefaultType, TSwitchDefaultType, + TNumberDefaultType, } from '@/core/FormComponents/types'; -import { baseConfig, baseDefault, ICommonBaseType } from '../../common'; + +import { serverUrl } from '@/utils/tool'; export type CarouselDirectionKeyType = 'down' | 'left'; export type TCarouselEditData = Array< - | INumberConfigType | IRadioConfigType | ISwitchConfigType | IDataListConfigType + | INumberConfigType >; -export interface ICarouselConfig extends ICommonBaseType { +export interface ICarouselConfig { direction: TRadioDefaultType; swipeable: TSwitchDefaultType; autoPlay: TSwitchDefaultType; imgList: TDataListDefaultType; + tplImg: string; + round: TNumberDefaultType; } export interface ICarouselSchema { @@ -31,8 +35,6 @@ export interface ICarouselSchema { const Carousel: ICarouselSchema = { editData: [ - ...baseConfig, - { key: 'direction', name: '方向', @@ -53,6 +55,11 @@ const Carousel: ICarouselSchema = { name: '是否可拖拽', type: 'Switch', }, + { + key: 'round', + name: '圆角', + type: 'Number', + }, { key: 'autoPlay', name: '是否自动播放', @@ -67,6 +74,7 @@ const Carousel: ICarouselSchema = { config: { direction: 'left', swipeable: false, + round: 0, autoPlay: false, imgList: [ { @@ -79,7 +87,7 @@ const Carousel: ICarouselSchema = { uid: '001', name: 'image.png', status: 'done', - url: 'http://49.234.61.19/uploads/1_1740bd7c3dc.png', + url: `${serverUrl}/uploads/1_1740bd7c3dc.png`, }, ], }, @@ -93,12 +101,12 @@ const Carousel: ICarouselSchema = { uid: '001', name: 'image.png', status: 'done', - url: 'http://49.234.61.19/uploads/2_1740bd8d525.png', + url: `${serverUrl}/uploads/2_1740bd8d525.png`, }, ], }, ], - ...baseDefault, + tplImg: `${serverUrl}/uploads/carousal_17442e1420f.png`, }, }; export default Carousel;