index.tsx 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. import { Button, showToast, Image } from 'vant'
  2. import { defineComponent, onMounted, reactive } from 'vue'
  3. import { useRoute } from 'vue-router'
  4. import styles from './index.module.less'
  5. import wxBg from './images/wx_bg.png'
  6. import { browser } from '@/helpers/utils'
  7. import student from './images/student-center.png'
  8. import teacher from './images/teacher-center.png'
  9. import manage from './images/manage-center.png'
  10. // 唤起前缀
  11. // BandMusicTeam:// 管乐团
  12. // BandMusicTeamTeacher://
  13. // BandMusicTeamManager://
  14. export default defineComponent({
  15. name: 'download',
  16. setup() {
  17. const route = useRoute()
  18. const state = reactive({
  19. wxStatus: false,
  20. type: 'student',
  21. buttonText: '下载管乐团学生端'
  22. })
  23. const onDownload = () => {
  24. if (browser().weixin) {
  25. state.wxStatus = true
  26. return
  27. }
  28. let urlIos = ''
  29. let urlAndroid = ''
  30. if (location.origin.indexOf('online.lexiaoya.cn') > -1) {
  31. if (state.type === 'student') {
  32. urlIos =
  33. 'https://apps.apple.com/cn/app/%E7%AE%A1%E4%B9%90%E5%9B%A2%E7%AE%A1%E7%90%86%E7%AB%AF/id1671473981?uo=4'
  34. urlAndroid = 'https://appstore.ks3-cn-beijing.ksyuncs.com/gyt-student.apk'
  35. } else if (state.type === 'teacher') {
  36. urlIos =
  37. 'https://apps.apple.com/cn/app/%E7%AE%A1%E4%B9%90%E5%9B%A2%E4%BC%B4%E5%AD%A6%E7%AB%AF/id1670584741?uo=4'
  38. urlAndroid = 'https://appstore.ks3-cn-beijing.ksyuncs.com/gyt-teacher.apk'
  39. } else if (state.type === 'manage') {
  40. urlIos =
  41. 'https://apps.apple.com/cn/app/%E7%AE%A1%E4%B9%90%E5%9B%A2%E7%AE%A1%E7%90%86%E7%AB%AF/id1671473981?uo=4'
  42. urlAndroid = 'https://appstore.ks3-cn-beijing.ksyuncs.com/gyt-manager.apk'
  43. }
  44. } else {
  45. if (state.type === 'student') {
  46. urlIos = 'https://www.pgyer.com/2Wg2'
  47. urlAndroid = 'https://www.pgyer.com/9NBz'
  48. } else if (state.type === 'teacher') {
  49. urlIos = 'https://www.pgyer.com/v5yB'
  50. urlAndroid = 'https://www.pgyer.com/BQeE'
  51. } else if (state.type === 'manage') {
  52. urlIos = 'https://www.pgyer.com/DGrR'
  53. urlAndroid = 'https://www.pgyer.com/TEWv'
  54. }
  55. }
  56. if (browser().ios || /(iPhone|iPad|iPod|iOS)/i.test(navigator.userAgent)) {
  57. window.location.href = urlIos
  58. } else if (/(Android)/i.test(navigator.userAgent)) {
  59. window.location.href = urlAndroid
  60. } else {
  61. showToast('请用手机或移动设备打开')
  62. }
  63. }
  64. onMounted(() => {
  65. const type: any = route.query.type
  66. state.type = type ? type : 'student'
  67. if (type === 'student') {
  68. state.buttonText = '下载管乐团学生端'
  69. } else if (type === 'teacher') {
  70. state.buttonText = '下载管乐团伴学端'
  71. } else if (type === 'manage') {
  72. state.buttonText = '下载管乐团管理端'
  73. }
  74. document.title = state.buttonText
  75. })
  76. return () => (
  77. <div class={[styles.downloadContainer]}>
  78. {state.type !== 'teacher' && state.type !== 'manage' && <Image src={student} />}
  79. {state.type === 'teacher' && <Image src={teacher} />}
  80. {state.type === 'manage' && <Image src={manage} />}
  81. <div class={styles.buttonGroup}>
  82. <Button round size="large" color="#FF8057" class={styles.btn} onClick={onDownload}>
  83. {state.buttonText}
  84. </Button>
  85. </div>
  86. {state.wxStatus && (
  87. <div
  88. class={styles.wxpopup}
  89. onClick={() => {
  90. state.wxStatus = false
  91. }}
  92. >
  93. <img src={wxBg} alt="" />
  94. </div>
  95. )}
  96. </div>
  97. )
  98. }
  99. })