transfer.tsx 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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. let 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. }
  33. const iosStr = encodeURIComponent(JSON.stringify(query))
  34. if (/(iPhone|iPad|iPod|iOS)/i.test(navigator.userAgent)) {
  35. // ColexiuStudent 唤起学生端
  36. // ColexiuTeacher 唤起老师端
  37. window.location.href = `ColexiuStudent://linkUrl=${iosStr}`
  38. } else if (/(Android)/i.test(navigator.userAgent)) {
  39. window.location.href = `colexiustudent://html:8888/SplashActivity?url=${iosStr}`
  40. } else {
  41. Toast('请用手机或移动设备打开')
  42. }
  43. },
  44. methods: {
  45. downLoadApp() {
  46. if (browser().weixin) {
  47. this.wxStatus = true
  48. return
  49. }
  50. // clx-teacher-domain.apk
  51. // clx-student-domain.apk
  52. if (
  53. browser().ios ||
  54. /(iPhone|iPad|iPod|iOS)/i.test(navigator.userAgent)
  55. ) {
  56. window.location.href =
  57. 'https://itunes.apple.com/cn/app/id1626971695?mt=8'
  58. } else if (/(Android)/i.test(navigator.userAgent)) {
  59. window.location.href =
  60. 'https://appstore.ks3-cn-beijing.ksyuncs.com/clx-student-domain.apk'
  61. } else {
  62. this.$toast('请用手机或移动设备打开')
  63. }
  64. }
  65. },
  66. render() {
  67. return (
  68. <div class={styles.downContainer}>
  69. <div class={styles.logo}>
  70. <img src={getAssetsHomeFile('logo.png')} alt="" />
  71. </div>
  72. <div class={styles.down}>
  73. <Button type="primary" round plain onClick={this.downLoadApp}>
  74. 点击下载App
  75. </Button>
  76. </div>
  77. <div class={styles.mainImg}>
  78. <img src={getAssetsHomeFile('student_bg.png')} alt="" />
  79. </div>
  80. {this.wxStatus && (
  81. <div
  82. class={styles.wxpopup}
  83. onClick={() => {
  84. this.wxStatus = false
  85. }}
  86. >
  87. <img src={getAssetsHomeFile('wx_bg.png')} alt="" />
  88. </div>
  89. )}
  90. </div>
  91. )
  92. }
  93. })