useData.ts 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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`,
  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. function getPreViewCloud(musicId: string, partIndex = 0) {
  35. // GYM,GYT,KLX 区分 云教练
  36. const urlObj = {
  37. GYT: `${URL_TEACH_GYT}?id=${musicId}&modelType=practice&modeType=json&part-index=${partIndex}&Authorization=${getToken()}&isYjt=1&&isHideBack=false`,
  38. GYM: `${URL_TEACH_GYM}?t=${Date.now()}#/?id=${musicId}&Authorization=${getToken()}&platform=web&part-index=${partIndex}&isPreView=true&systemType=teacher`,
  39. KLX: `${URL_TEACH_KLX}?Authorization=${getToken()}&id=${musicId}&limitModel=practice&part-index=${partIndex}&isYjt=1&client=teacher`
  40. }
  41. return urlObj[userStoreHook.roles!]
  42. }
  43. return { loading, goToCloud, getPreViewCloud, isPracticeShow, practiceUrl, handlePracticeClose }
  44. }
  45. // function chunkArray(array: any[], size: number) {
  46. // const result = []
  47. // for (let i = 0; i < array.length; i += size) {
  48. // result.push(array.slice(i, i + size))
  49. // }
  50. // return result
  51. // }