import { Button, Dialog } from 'vant'
import { defineComponent, ref, Ref, reactive } from 'vue'
import iconDemand from './imgs/demand.svg'
import styles from './index.module.less'
import qs from 'query-string'
import { postMessage } from "/src/utils/native-message"
import state from "/src/state"
import { permissionPopup } from "./permission"

export const confirmShow: Ref<boolean> = ref(false)

export default defineComponent({
  name: 'ColexiuDemand',
  setup() {
    const buy = async () => {
      let params: any = { orderType: 'MUSIC' }
      params.id = permissionPopup.musicId;
      postMessage({
        api: 'openWebView',
        content: {
          url: location.origin + '/' + state.systemType + '/#/orderDetail?' + qs.stringify(params),
          orientation: 1,
        },
      })
    }

    const close = () => {
      permissionPopup.show = false

    }

    return () => (
      <div style={{ position: 'relative' }}>
        <img class={styles.image} src={iconDemand} />
        <div class={styles.wrap}>
          <div class={styles.des}>
            <div class={styles.title}>该曲目为点播曲目</div>
            <div class={styles.sub}>
              点播价格{' '}
              <span style={{ color: '#FF4E19' }}>
                ¥{permissionPopup.musicPrice}
              </span>
              ，点播后可永久使用
            </div>
          </div>
          <div class={styles.btnWrap}>
            <Button class={[styles.btn, styles.tryoutBtn]} onClick={close}></Button>
            <Button class={[styles.btn, styles.demandBtn]} onClick={buy}></Button>
          </div>
        </div>
      </div>
    )
  },
})
