index.tsx 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  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. import TheDown from '../TheDown'
  10. export const [footerAppShow, toggleFooterApp] = useToggle(false);
  11. export default defineComponent({
  12. name: "TheFooterApp",
  13. setup() {
  14. const route = useRoute();
  15. const downRef = ref()
  16. const firstShow = () => {
  17. if (route.name == "index") {
  18. toggleFooterApp(true);
  19. }
  20. };
  21. onMounted(() => {
  22. firstShow();
  23. window.addEventListener('error', (e) => {
  24. console.log(e)
  25. console.log(e.message)
  26. // console.log(e.source)
  27. console.log(e.lineno)
  28. console.log(e.colno)
  29. console.log(e.error)
  30. // 禁止默认错误提示
  31. e.preventDefault();
  32. }, true);
  33. });
  34. const btns = [
  35. {
  36. title: "酷乐秀",
  37. des: "学习海量优质乐谱",
  38. tag: "推荐",
  39. type: "ColexiuStudent",
  40. },
  41. {
  42. title: "酷乐秀学院",
  43. des: "我要提供优质内容",
  44. tag: "",
  45. type: "ColexiuTeacher",
  46. },
  47. ];
  48. const showTip = ref(false);
  49. const onTansfer = (type: any) => {
  50. if (isWeChat() || isDingTalk()) {
  51. showTip.value = true;
  52. return;
  53. }
  54. // ColexiuStudent 唤起学生端
  55. // ColexiuTeacher 唤起老师端
  56. const query = {
  57. url: "",
  58. action: "h5", // app, h5
  59. pageTag: 1, // 页面标识
  60. };
  61. try {
  62. const iosStr = encodeURIComponent(JSON.stringify(query));
  63. if (type == "ColexiuStudent") {
  64. if (/(iPhone|iPad|iPod|iOS)/i.test(navigator.userAgent)) {
  65. window.location.href = `ColexiuStudent://linkUrl=${iosStr}`;
  66. } else if (/(Android)/i.test(navigator.userAgent)) {
  67. window.location.href = `colexiustudent://html:8888/SplashActivity?url=${iosStr}`;
  68. } else {
  69. console.log("🚀 ", downRef.value)
  70. downRef.value?.downLoadApp('student')
  71. }
  72. } else {
  73. if (/(iPhone|iPad|iPod|iOS)/i.test(navigator.userAgent)) {
  74. window.location.href = `ColexiuTeacher://linkUrl=${iosStr}`;
  75. } else if (/(Android)/i.test(navigator.userAgent)) {
  76. window.location.href = `colexiuteacher://html:8888/SplashActivity?url=${iosStr}`;
  77. } else {
  78. console.log("🚀 ", downRef.value)
  79. downRef.value?.downLoadApp('teacher')
  80. }
  81. }
  82. } catch (error) {
  83. console.log(error)
  84. }
  85. };
  86. return () => (
  87. <>
  88. {showTip.value && (
  89. <div class={styles.wx_bg}>
  90. <img src={wx_bg} />
  91. </div>
  92. )}
  93. <div class={styles.theFooterApp} onClick={() => toggleFooterApp(true)}>
  94. <img class={styles.img} src={IconLogo1} />
  95. <span>打开APP看海量热门乐谱</span>
  96. </div>
  97. <Popup position="bottom" round v-model:show={footerAppShow.value} onClose={() => showTip.value = false}>
  98. <div class={styles.appContent}>
  99. <div class={styles.top}>
  100. <span>打开方式</span>
  101. <div class={styles.des} onClick={() => toggleFooterApp(false)}>
  102. <span>继续使用浏览器</span>
  103. <Icon name="play" size={10} />
  104. </div>
  105. </div>
  106. <div class={styles.content}>
  107. {btns.map((n) => (
  108. <div class={styles.item}>
  109. <img class={styles.itemLogo} src={IconLogo1} alt="" />
  110. <div class={styles.description}>
  111. <div class={styles.title}>
  112. {n.title}
  113. {n.tag && <span class={styles.tag}>{n.tag}</span>}
  114. </div>
  115. <div class={styles.des}>{n.des}</div>
  116. </div>
  117. <Button
  118. round
  119. type="primary"
  120. onClick={() => onTansfer(n.type)}
  121. >
  122. 打开
  123. </Button>
  124. </div>
  125. ))}
  126. </div>
  127. </div>
  128. </Popup>
  129. <TheDown ref={downRef} />
  130. </>
  131. );
  132. },
  133. });