import { defineComponent, reactive,watch } from 'vue'
import icon from '../videoDetailItem/images/icon.png'
import classes from './musicItem.module.less'
import music from '@/components/musicLIstItem/images/music.png'
import arrow from '@/components/musicLIstItem/images/arrow.png'
import { useRouter } from 'vue-router'
import { ElTooltip } from 'element-plus'
type Props = {
  id?: Number
  addName: String
  addUserAvatar: String
  musicSheetName: String
  subjectNames: String
  composer: String
  chargeType: String
}
const chargeTypes = {
  CHARGE: '点播',
  FREE: '免费',
  VIP: 'VIP'
}

export default defineComponent({
  name: 'musicItem',
  emits:['musicDetail'],
  props: {
    item: {
      type: Object as () => Props,
      default: () => ({})
    },
    onClick: {
      type: Function,
      default: (item: any) => {}
    }
  },
  setup(props: any,conent) {
    const router = useRouter()
    const state = reactive({
      item:props.item
    })

    watch(
      () => props.item,
      item => {
        state.item = item
      }
    )


    const gotoMusicDetail = () => {
      conent.emit('musicDetail',state.item.id)
      // router.push({path:'/muiscDetial',query:{id:state.item.id}})
    }
    return () => (
      <div
        onClick={() => {
          props.onClick(state.item)
        }}
      >
        <div class={classes.itemWrap} onClick={() => gotoMusicDetail()}>
          <div class={classes.left}>
            <div class={classes.imgWrap}>
              <img src={music} alt="" />
            </div>
            <div class={classes.textWrap}>

              <p>
                <ElTooltip placement="top" content={state.item.musicSheetName}>{state.item.musicSheetName}</ElTooltip>


              </p>
              <p>
              <span>作曲: {state.item.composer}</span>
              </p>
            </div>
          </div>
        </div>
      </div>
    )
  }
})
