import React from 'react';
import { View, Text, Image } from '@tarojs/components';
const iconArrow = 'https://wanmi-b2b-x-site.oss-cn-shanghai.aliyuncs.com/pandora-ui/assets/templates/images/block/icon-arrow.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: 3,
  },
  state: {},
  meta: {},
}

/**
 * 区块-含数字的重复块
 */
const BlockRepeatNumber: React.FC<Props> = ({title, times}) => {
  return (
    <View className='wm-pure-text'>
      {title && (
        <View className='wm-block-title'>
          <Text className='text'>热门兑换</Text>
          <View className='right'>
            <Text className='arrow-text'>更多</Text>
            <Image className='arrow' src={iconArrow} />
          </View>
        </View>
      )}
      <View className='items'>
        {Array(times).fill(0).map((_key, idx) => (
          <View className='item'>
            <Text className='main-text'>￥1000</Text>
            <Text className='sub-text'>余额</Text>
          </View>
        ))}
      </View>
    </View>
  );
};

export default connect(BlockRepeatNumber, defaultValue);
