import { orderStatus } from '@/views/order-detail/orderStatus'
import { postMessage } from '@/helpers/native-message'
import { Dialog } from 'vant'
import qs from 'query-string'
import { browser } from '@/helpers/utils'

const browserInfo = browser()

export const getRandomKey = () => {
  const key = '' + new Date().getTime() + Math.floor(Math.random() * 1000000)
  return key
}

export const musicBuy = (item: any, callBack?: any, moreQuery = {}) => {
  const behaviorId = localStorage.getItem('behaviorId') || ''
  const url = qs.stringifyUrl({
    url: location.origin + '/accompany',
    query: {
      id: item.id,
      behaviorId,
      client: browserInfo.isStudent ? 'student' : 'teacher',
      ...moreQuery
    }
  })
  console.log(url)
  postMessage({
    api: 'openAccompanyWebView',
    content: {
      url,
      // url: 'http://192.168.3.13:3000/colexiu.html?id=' + item.id,
      orientation: 0,
      isHideTitle: true,
      statusBarTextColor: false,
      isOpenLight: true
    }
  })
}
