useData.ts 2.6 KB

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