import { defineComponent, PropType } from 'vue';
import styles from './index.module.less';
import iconTop from './image/icon-top.png';
import iconLock from './image/icon-lock.png';
import { Image, Loading } from 'vant';

export default defineComponent({
  name: 'CourseItem',
  props: {
    list: {
      type: Array as PropType<any[]>,
      default: () => []
    },
    term: {
      type: String as PropType<any>,
      defaut: 0
    }
  },
  emits: ['itemClick'],
  setup(prop, { emit }) {
    return () => (
      <div class={styles.content}>
        <div class={styles.wrap}>
          {prop.list.map((item: any) => {
            return (
              <div
                class={[styles.item, 'courseItem']}
                onClick={() => emit('itemClick', item)}>
                <div class={styles.cover}>
                  <div class={styles.coverImg}>
                    <img
                      src={
                        item.coverImg ||
                        'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAUEAAAGJCAMAAAAja3HaAAAAbFBMVEXy8O3h4eDb29qcnJvV1dTg397d3dzX19bZ2diwsK+rq6qjo6LQ0M/ExMPIx8aurq3w7uu7u7rKysmgoJ/MzMu0tLOoqKempqXS0tHl5OLOzs2/v769vby4uLe2trXt7OmysrHBwcDr6efo5+Uqwd7AAAAGe0lEQVR42uzBgQAAAACAoP2pF6kCAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABm39yWXAWBKKoUIEkBUcpM4SVjNP//j6dBI/GSTHw5L/SaW9WEp1W76cYQBEEQBEEQBEEQBEEQBEEQBEEQBEEQBEH+G3n34FSWRqu+UdrIjHd5gnxJDvJsqbVSoK8p2qIobkXRalp1CfKFPpa57E0CwSDQ9rq0GUkfmMM/yIeKCVsbEwxO8lhaPR4DVvKfex+jsq7LUSDQ90pLgcX7HXk+gD8nMBjUtXgkyPf+rAWD5WxQiwGr9msePKMUBPoi9gYNQX/fk6cCBFLrBXqDtRhw9zvQgUHgwmBNKgzgkQ6ckmw26LZBy3HwOxJAECgWBiXDAj6SwJQQZ5AC0hukFQbwiEDGZ4O+FUuBATxADhW8NGgZntyONWHOOZm2QQsG8fHLIaAJs6XBDHvwMYHVyiBNUeABchA4GhSTQcpQ4AF/0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NeAV3i9XxulTWmZyExxP53u7oWgsC1CYn11+xd4jKeREX3dcjr//PycgcvlAgYnhYVnzOwNjL5SxyswSX9PjvuS0+XsDQL+tSmer/y6n5GbjvnCcA4G33Lxv71CKG7vFv7C99KlijiBQHO6zHhnn7nD12tincBo2/CIvJ4v+5zcz19S71dFkripbucNl7dsdF57EvEeONKff86BPZ0fnJ6ayEv4H3v3lpwgDABQtK3TVzIFOlFC67O4/z1WrR++UPudczJkAXf4IIEJWy/T9ki4V70xK3Utd6j5Djm3t4RwoW39IeDW1zjHzTjX/k2DTSddkZvS55qXRTyyy7mdB7S7rOHnzR2413dtvCLvqx57rwpeC5/pZzGlFLfjTnlV+nP0if49piExXQpY6o70kGZdp9FG2l3phlh/PHCi6RdpdEU6CBsK3k69Zj2uz7vt2x3GDZ2z9Ab0T1Ua3ZDqzg81hi0fq0m6li98Vl2hL4Xv1bzOQx7ol+t55fSPOzxXqxxP68UYJkXv5P/T8m0aYhrtpRymBX4dDQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAL/twSEBAAAAgKD/r71hAAAAAABYCnSmwzA7AlR3AAAAAElFTkSuQmCC'
                      }
                      onLoad={(e: Event) => {
                        if (e.target) {
                          (e.target as any).style.opacity = 1;
                        }
                      }}
                    />
                  </div>
                  {/* <div class={styles.coverNum}>
                    {item.courseNumName
                      ? item.courseNumName
                      : `共${item.courseNum}课`}
                  </div> */}
                </div>
                <div class={[styles.name, 'van-ellipsis']}>{item.name}</div>
              </div>
            );
          })}
        </div>
      </div>
    );
  }
});
