index.tsx 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. import { Button, showToast, Image } from 'vant';
  2. import { defineComponent, onMounted, reactive } from 'vue';
  3. import styles from './index.module.less';
  4. import wxBg from './images/wx_bg.png';
  5. import { browser } from '@/helpers/utils';
  6. import student from './images/student-center.png';
  7. import request from '@/helpers/request';
  8. // 唤起前缀
  9. export default defineComponent({
  10. name: 'download',
  11. setup() {
  12. const state = reactive({
  13. wxStatus: false,
  14. androidUrl: ''
  15. });
  16. const onDownload = () => {
  17. if (browser().weixin) {
  18. state.wxStatus = true;
  19. return;
  20. }
  21. let urlIos = '';
  22. let urlAndroid = '';
  23. if (location.origin.indexOf('kt.colexiu.com') > -1) {
  24. urlIos =
  25. 'https://apps.apple.com/us/app/%E9%9F%B3%E4%B9%90%E6%95%B0%E5%AD%97%E8%AF%BE%E5%A0%82/id6452725878';
  26. urlAndroid = state.androidUrl; //'https://oss.dayaedu.com/appstore/kt_cooleshow_student.apk';
  27. } else {
  28. urlIos = 'https://www.pgyer.com/dzRRNN';
  29. urlAndroid = state.androidUrl; //'https://www.pgyer.com/2meenh';
  30. }
  31. if (
  32. browser().ios ||
  33. /(iPhone|iPad|iPod|iOS)/i.test(navigator.userAgent)
  34. ) {
  35. urlIos && (window.location.href = urlIos);
  36. } else if (/(Android)/i.test(navigator.userAgent)) {
  37. window.location.href = urlAndroid;
  38. } else {
  39. showToast('请用手机或移动设备打开');
  40. }
  41. };
  42. onMounted(async () => {
  43. try {
  44. const { data } = await request.get(
  45. '/edu-app/open/appVersionInfo/queryLatestByPlatform',
  46. {
  47. params: {
  48. platform: 'android-student',
  49. status: 'history'
  50. }
  51. }
  52. );
  53. state.androidUrl = data.downloadUrl;
  54. } catch {
  55. //
  56. }
  57. });
  58. return () => (
  59. <div class={[styles.downloadContainer]}>
  60. <Image src={student} />
  61. <div class={styles.buttonGroup}>
  62. <Button
  63. round
  64. size="large"
  65. class={styles.btn}
  66. onClick={onDownload}></Button>
  67. </div>
  68. {state.wxStatus && (
  69. <div
  70. class={styles.wxpopup}
  71. onClick={() => {
  72. state.wxStatus = false;
  73. }}>
  74. <img src={wxBg} alt="" />
  75. </div>
  76. )}
  77. </div>
  78. );
  79. }
  80. });