index.tsx 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. import { Button, showToast, Image } from 'vant';
  2. import { defineComponent, 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. // 唤起前缀
  8. export default defineComponent({
  9. name: 'download',
  10. setup() {
  11. const state = reactive({
  12. wxStatus: false
  13. });
  14. const onDownload = () => {
  15. if (browser().weixin) {
  16. state.wxStatus = true;
  17. return;
  18. }
  19. let urlIos = '';
  20. let urlAndroid = '';
  21. if (location.origin.indexOf('online.lexiaoya.cn') > -1) {
  22. urlIos =
  23. 'https://apps.apple.com/cn/app/%E7%AE%A1%E4%B9%90%E5%9B%A2/id1671474346?uo=4 ';
  24. urlAndroid =
  25. 'https://appstore.ks3-cn-beijing.ksyuncs.com/gyt-student.apk';
  26. } else {
  27. urlIos = 'https://www.pgyer.com/dzRRNN';
  28. urlAndroid = 'https://www.pgyer.com/2meenh';
  29. }
  30. if (
  31. browser().ios ||
  32. /(iPhone|iPad|iPod|iOS)/i.test(navigator.userAgent)
  33. ) {
  34. urlIos && (window.location.href = urlIos);
  35. } else if (/(Android)/i.test(navigator.userAgent)) {
  36. window.location.href = urlAndroid;
  37. } else {
  38. showToast('请用手机或移动设备打开');
  39. }
  40. };
  41. return () => (
  42. <div class={[styles.downloadContainer]}>
  43. <Image src={student} />
  44. <div class={styles.buttonGroup}>
  45. <Button
  46. round
  47. size="large"
  48. class={styles.btn}
  49. onClick={onDownload}></Button>
  50. </div>
  51. {state.wxStatus && (
  52. <div
  53. class={styles.wxpopup}
  54. onClick={() => {
  55. state.wxStatus = false;
  56. }}>
  57. <img src={wxBg} alt="" />
  58. </div>
  59. )}
  60. </div>
  61. );
  62. }
  63. });