transfer.tsx 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. import { browser } from '@/helpers/utils'
  2. import { Button, showToast, Image } from 'vant'
  3. import { defineComponent } from 'vue'
  4. import styles from './index.module.less'
  5. import wxBg from './images/wx_bg.png'
  6. import qs from 'query-string'
  7. import OSticky from '@/components/o-sticky'
  8. import student from './images/student-center.png'
  9. import teacher from './images/teacher-center.png'
  10. import manage from './images/manage-center.png'
  11. export default defineComponent({
  12. name: 'download-transfer',
  13. data() {
  14. return {
  15. wxStatus: false,
  16. type: 'student',
  17. buttonText: '下载管乐团学生端'
  18. }
  19. },
  20. mounted() {
  21. const { pn, url, action, pageTag, ...rest } = this.$route.query
  22. const { origin, pathname } = location
  23. let tempPathname = pathname
  24. let beforeIos = 'BandMusicTeam://linkUrl='
  25. let beforeAndroid = 'orchestrastudent://html:8888/SplashActivity?url='
  26. if (pn === 's') {
  27. this.type = 'student'
  28. this.buttonText = '下载管乐团学生端'
  29. tempPathname = '/orchestra-student/'
  30. beforeIos = 'BandMusicTeam://linkUrl='
  31. beforeAndroid = 'orchestrastudent://html:8888/SplashActivity?url='
  32. } else if (pn === 't') {
  33. this.type = 'teacher'
  34. this.buttonText = '下载管乐团伴学端'
  35. tempPathname = '/orchestra-teacher/'
  36. beforeIos = 'BandMusicTeamTeacher://linkUrl='
  37. beforeAndroid = 'orchestrateacher://html:8888/SplashActivity?url='
  38. } else if (pn === 'm') {
  39. this.type = 'manage'
  40. this.buttonText = '下载管乐团管理端'
  41. tempPathname = '/orchestra-school/'
  42. beforeIos = 'BandMusicTeamManager://linkUrl='
  43. beforeAndroid = 'orchestramanager://html:8888/SplashActivity?url='
  44. }
  45. let str = origin + tempPathname + '#/'
  46. // 判断是否有跳转连接, 如果连接和动作没有时, 则不跳转
  47. if (!url && !action) {
  48. return
  49. }
  50. // 处理参数
  51. const formatParams = qs.stringify({
  52. ...rest
  53. })
  54. str += url + (formatParams ? '?' + formatParams : '')
  55. const query = {
  56. url: str,
  57. action: action || 'h5', // app, h5
  58. pageTag: pageTag || 1 // 页面标识
  59. // params: {}
  60. } as any
  61. const iosStr = encodeURIComponent(JSON.stringify(query))
  62. console.log(query, 'iosStr')
  63. if (/(iPhone|iPad|iPod|iOS)/i.test(navigator.userAgent)) {
  64. /*
  65. 唤起前缀 IOS
  66. BandMusicTeam:// 管乐团
  67. BandMusicTeamTeacher://
  68. BandMusicTeamManager:// */
  69. /*
  70. 唤起前缀 ANDROID
  71. orchestrastudent://html:8888/SplashActivity?url=
  72. orchestrateacher://html:8888/SplashActivity?url=
  73. orchestramanager://html:8888/SplashActivity?url=
  74. */
  75. window.location.href = beforeIos + iosStr
  76. } else if (/(Android)/i.test(navigator.userAgent)) {
  77. window.location.href = beforeAndroid + iosStr
  78. } else {
  79. showToast('请用手机或移动设备打开')
  80. }
  81. },
  82. methods: {
  83. onDownload() {
  84. if (browser().weixin) {
  85. this.wxStatus = true
  86. return
  87. }
  88. let urlIos = ''
  89. let urlAndroid = ''
  90. if (location.origin.indexOf('online.lexiaoya.cn') > -1) {
  91. if (this.type === 'student') {
  92. urlIos =
  93. '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'
  94. urlAndroid = 'https://appstore.ks3-cn-beijing.ksyuncs.com/gyt-student.apk'
  95. } else if (this.type === 'teacher') {
  96. urlIos =
  97. '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'
  98. urlAndroid = 'https://appstore.ks3-cn-beijing.ksyuncs.com/gyt-teacher.apk'
  99. } else if (this.type === 'manage') {
  100. urlIos =
  101. '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'
  102. urlAndroid = 'https://appstore.ks3-cn-beijing.ksyuncs.com/gyt-manager.apk'
  103. }
  104. } else {
  105. if (this.type === 'student') {
  106. urlIos = 'https://www.pgyer.com/2Wg2'
  107. urlAndroid = 'https://www.pgyer.com/9NBz'
  108. } else if (this.type === 'teacher') {
  109. urlIos = 'https://www.pgyer.com/v5yB'
  110. urlAndroid = 'https://www.pgyer.com/BQeE'
  111. } else if (this.type === 'manage') {
  112. urlIos = 'https://www.pgyer.com/DGrR'
  113. urlAndroid = 'https://www.pgyer.com/TEWv'
  114. }
  115. }
  116. if (browser().ios || /(iPhone|iPad|iPod|iOS)/i.test(navigator.userAgent)) {
  117. window.location.href = urlIos
  118. } else if (/(Android)/i.test(navigator.userAgent)) {
  119. window.location.href = urlAndroid
  120. } else {
  121. showToast('请用手机或移动设备打开')
  122. }
  123. }
  124. },
  125. render() {
  126. return (
  127. <div class={[styles.downloadContainer]}>
  128. {/* <Image src={student} /> */}
  129. {this.type !== 'teacher' && this.type !== 'manage' && <Image src={student} />}
  130. {this.type === 'teacher' && <Image src={teacher} />}
  131. {this.type === 'manage' && <Image src={manage} />}
  132. <div class={styles.buttonGroup}>
  133. <Button round size="large" color="#FF8057" class={styles.btn} onClick={this.onDownload}>
  134. {this.buttonText}
  135. </Button>
  136. </div>
  137. {this.wxStatus && (
  138. <div
  139. class={styles.wxpopup}
  140. onClick={() => {
  141. this.wxStatus = false
  142. }}
  143. >
  144. <img src={wxBg} alt="" />
  145. </div>
  146. )}
  147. </div>
  148. )
  149. }
  150. })