useData.ts 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. // 处理 区分处理管乐迷 管乐团的数据
  2. // import { queryTree_gym } from "@/api/cloudPractice.api"
  3. import { URL_TEACH_GYM, URL_TEACH_GYT, URL_TEACH_KLX } from "@/config"
  4. import { getToken } from "@/libs/auth"
  5. // import { httpAjaxErrMsg, httpAjax } from "@/plugin/httpAjax"
  6. // import { CODE_ERR_CANCELED } from "@/libs/auth"
  7. // import { ElMessage } from "element-plus"
  8. import userStore from "@/store/modules/user"
  9. import { ref } from "vue"
  10. /**
  11. * 搜索数据
  12. */
  13. export const useFunction = () => {
  14. const userStoreHook = userStore()
  15. const loading = ref(false)
  16. /** 跳转云教练 */
  17. const isPracticeShow = ref(false)
  18. const practiceUrl = ref("")
  19. function goToCloud(musicId: string, partIndex = 0) {
  20. // GYM,GYT,KLX 区分 云教练
  21. const urlObj = {
  22. GYT: `${URL_TEACH_GYT}?id=${musicId}&modelType=practice&modeType=json&part-index=${partIndex}&Authorization=${getToken()}&isYjt=1&&isHideBack=false`,
  23. GYM: `${URL_TEACH_GYM}#/?id=${musicId}&Authorization=${getToken()}&platform=pc&part-index=${partIndex}&isYjt=1&isHideMusicList=true&systemType=teacher`,
  24. KLX: `${URL_TEACH_KLX}?Authorization=${getToken()}&id=${musicId}&limitModel=practice&part-index=${partIndex}&isYjt=1&client=teacher`
  25. }
  26. isPracticeShow.value = true
  27. practiceUrl.value = urlObj[userStoreHook.roles!]
  28. //window.open(urlObj[userStoreHook.roles!], "_blank")
  29. }
  30. function handlePracticeClose() {
  31. isPracticeShow.value = false
  32. practiceUrl.value = ""
  33. }
  34. return { loading, goToCloud, isPracticeShow, practiceUrl, handlePracticeClose }
  35. }
  36. // function chunkArray(array: any[], size: number) {
  37. // const result = []
  38. // for (let i = 0; i < array.length; i += size) {
  39. // result.push(array.slice(i, i + size))
  40. // }
  41. // return result
  42. // }