import React from 'react';
import { View, Text, Image } from '@tarojs/components';
const iconBlock = 'https://wanmi-b2b-x-site.oss-cn-shanghai.aliyuncs.com/pandora-ui/assets/templates/images/block/icon-block.png';
import {CompDefault, MetaProps} from "../data-channel";
import connect from "../connect";

export interface Props extends MetaProps {
  // 是否包含标题
  title: boolean;
  // 重复次数
  times: number;
}

export interface State {}

const defaultValue: CompDefault<Props, State> = {
  props: {
    title: true,
    times: 6,
  },
  state: {},
  meta: {},
}

/**
 * 区块-图文重复块
 */
const BlockRepeatImage: React.FC<Props> = ({ title, times }) => {
  return (
    <View className='wm-image-text'>
      {title && (
        <View className='wm-block-title'>
          <Text className='text'>{title}</Text>
        </View>
      )}
      <View className='items'>
        {Array(times).fill(0).map((_key, idx) => (
          <View className='item'>
            <Image className='icon' src={iconBlock} />
            <Text className='sub-text'>积分商城</Text>
          </View>
        ))}
      </View>
    </View>
  );
};

export default connect(BlockRepeatImage, defaultValue);
