index.tsx 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. import { defineComponent, onMounted, ref } from "vue";
  2. import styles from "./index.module.less";
  3. import IconLogo1 from "../../assets/logo-1.png";
  4. import { Button, Icon, Popup } from "vant";
  5. import { useToggle } from "@vant/use";
  6. import { useRoute } from "vue-router";
  7. import { isDingTalk, isWeChat } from "@/helpers/utils";
  8. import wx_bg from "@/assets/wx_bg.png";
  9. export const [footerAppShow, toggleFooterApp] = useToggle(false);
  10. export default defineComponent({
  11. name: "TheFooterApp",
  12. setup() {
  13. const route = useRoute();
  14. const firstShow = () => {
  15. if (route.name == "index") {
  16. toggleFooterApp(true);
  17. }
  18. };
  19. onMounted(() => {
  20. firstShow();
  21. });
  22. const btns = [
  23. {
  24. title: "酷乐秀",
  25. des: "学习海量优质乐谱",
  26. tag: "推荐",
  27. type: "ColexiuStudent",
  28. },
  29. {
  30. title: "酷乐秀学院",
  31. des: "我要提供优质内容",
  32. tag: "",
  33. type: "ColexiuTeacher",
  34. },
  35. ];
  36. const showTip = ref(false);
  37. const onTansfer = (type: any) => {
  38. if (isWeChat() || isDingTalk()) {
  39. showTip.value = true;
  40. return;
  41. }
  42. // ColexiuStudent 唤起学生端
  43. // ColexiuTeacher 唤起老师端
  44. const query = {
  45. url: "",
  46. action: "h5", // app, h5
  47. pageTag: 1, // 页面标识
  48. };
  49. try {
  50. const iosStr = encodeURIComponent(JSON.stringify(query));
  51. if (type == "ColexiuStudent") {
  52. if (/(iPhone|iPad|iPod|iOS)/i.test(navigator.userAgent)) {
  53. window.location.href = `ColexiuStudent://linkUrl=${iosStr}`;
  54. } else if (/(Android)/i.test(navigator.userAgent)) {
  55. window.location.href = `colexiustudent://html:8888/SplashActivity?url=${iosStr}`;
  56. }
  57. } else {
  58. if (/(iPhone|iPad|iPod|iOS)/i.test(navigator.userAgent)) {
  59. window.location.href = `ColexiuTeacher://linkUrl=${iosStr}`;
  60. } else if (/(Android)/i.test(navigator.userAgent)) {
  61. window.location.href = `colexiuteacher://html:8888/SplashActivity?url=${iosStr}`;
  62. }
  63. }
  64. } catch (error) {}
  65. };
  66. return () => (
  67. <>
  68. {showTip.value && (
  69. <div class={styles.wx_bg}>
  70. <img src={wx_bg} />
  71. </div>
  72. )}
  73. <div class={styles.theFooterApp} onClick={() => toggleFooterApp(true)}>
  74. <img class={styles.img} src={IconLogo1} />
  75. <span>打开APP看海量热门乐谱</span>
  76. </div>
  77. <Popup position="bottom" round v-model:show={footerAppShow.value}>
  78. <div class={styles.appContent}>
  79. <div class={styles.top}>
  80. <span>打开方式</span>
  81. <div class={styles.des} onClick={() => toggleFooterApp(false)}>
  82. <span>继续使用浏览器</span>
  83. <Icon name="play" size={10} />
  84. </div>
  85. </div>
  86. <div class={styles.content}>
  87. {btns.map((n) => (
  88. <div class={styles.item}>
  89. <img class={styles.itemLogo} src={IconLogo1} alt="" />
  90. <div class={styles.description}>
  91. <div class={styles.title}>
  92. {n.title}
  93. {n.tag && <span class={styles.tag}>{n.tag}</span>}
  94. </div>
  95. <div class={styles.des}>{n.des}</div>
  96. </div>
  97. <Button
  98. round
  99. type="primary"
  100. onClick={() => onTansfer(n.type)}
  101. >
  102. 打开
  103. </Button>
  104. </div>
  105. ))}
  106. </div>
  107. </div>
  108. </Popup>
  109. </>
  110. );
  111. },
  112. });