transfer.tsx 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. import { browser } from '@/helpers/utils'
  2. import { url } from 'inspector'
  3. import { Button, Toast } from 'vant'
  4. import { defineComponent } from 'vue'
  5. import styles from './index.module.less'
  6. export const getAssetsHomeFile = (fileName: string) => {
  7. const path = `./images/${fileName}`
  8. const modules = import.meta.globEager('./images/*')
  9. return modules[path].default
  10. }
  11. export default defineComponent({
  12. name: 'transfer',
  13. data() {
  14. return {
  15. wxStatus: false
  16. }
  17. },
  18. mounted() {
  19. const { origin, pathname } = location
  20. let str = origin + pathname + '#/'
  21. const params = this.$route.query
  22. // 判断是否有跳转连接, 如果连接和动作没有时, 则不跳转
  23. if (!params.url && !params.action) {
  24. return
  25. }
  26. str += params.url
  27. const query = {
  28. url: str,
  29. action: params.action || 'h5', // app, h5
  30. pageTag: params.pageTag || 1 // 页面标识
  31. // params: {}
  32. } as any
  33. // 唤起直播间
  34. if (params.liveRoomId) {
  35. query.params = '' as any
  36. query.params = JSON.stringify({ liveRoomId: params.liveRoomId })
  37. }
  38. const iosStr = encodeURIComponent(JSON.stringify(query))
  39. if (/(iPhone|iPad|iPod|iOS)/i.test(navigator.userAgent)) {
  40. // ColexiuStudent 唤起学生端
  41. // ColexiuTeacher 唤起老师端
  42. window.location.href = `ColexiuStudent://linkUrl=${iosStr}`
  43. } else if (/(Android)/i.test(navigator.userAgent)) {
  44. window.location.href = `colexiustudent://html:8888/SplashActivity?url=${iosStr}`
  45. } else {
  46. Toast('请用手机或移动设备打开')
  47. }
  48. },
  49. methods: {
  50. downLoadApp() {
  51. if (browser().weixin) {
  52. this.wxStatus = true
  53. return
  54. }
  55. // clx-teacher-domain.apk
  56. // clx-student-domain.apk
  57. if (
  58. browser().ios ||
  59. /(iPhone|iPad|iPod|iOS)/i.test(navigator.userAgent)
  60. ) {
  61. window.location.href =
  62. 'https://itunes.apple.com/cn/app/id1626971695?mt=8'
  63. } else if (/(Android)/i.test(navigator.userAgent)) {
  64. window.location.href =
  65. 'https://appstore.ks3-cn-beijing.ksyuncs.com/clx-student-domain.apk'
  66. } else {
  67. this.$toast('请用手机或移动设备打开')
  68. }
  69. }
  70. },
  71. render() {
  72. return (
  73. <div class={styles.downContainer}>
  74. <div class={styles.logo}>
  75. <img src={getAssetsHomeFile('logo.png')} alt="" />
  76. </div>
  77. <div class={styles.down}>
  78. <Button type="primary" round plain onClick={this.downLoadApp}>
  79. 点击下载App
  80. </Button>
  81. </div>
  82. <div class={styles.mainImg}>
  83. <img src={getAssetsHomeFile('student_bg.png')} alt="" />
  84. </div>
  85. {this.wxStatus && (
  86. <div
  87. class={styles.wxpopup}
  88. onClick={() => {
  89. this.wxStatus = false
  90. }}
  91. >
  92. <img src={getAssetsHomeFile('wx_bg.png')} alt="" />
  93. </div>
  94. )}
  95. </div>
  96. )
  97. }
  98. })