You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

90 lines
1.9 KiB

  1. <template>
  2. <div class="backToHomeBtn" @click="backToHome">
  3. <img
  4. src="https://d31zlh4on95l9h.cloudfront.net/images/9cbc5b2eb2327bd04d015c19d8c3f1f9.png"
  5. alt="返回首页"
  6. class="backImg"
  7. />
  8. <div class="backContent">返回首页</div>
  9. </div>
  10. </template>
  11. <script setup>
  12. import { computed } from "vue";
  13. // 默认的返回首页逻辑
  14. const backToHome = () => {
  15. const userAgent = navigator.userAgent;
  16. let isMobile =
  17. /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(
  18. userAgent
  19. );
  20. if (isMobile) {
  21. console.log("用户是移动端");
  22. // 调用原生方法跳转到首页
  23. if (typeof uni !== "undefined") {
  24. uni.postMessage({
  25. data: {
  26. val: {
  27. name: "JWopenView",
  28. extra: {
  29. data: {
  30. type: 3,
  31. },
  32. },
  33. },
  34. },
  35. });
  36. }
  37. } else {
  38. console.log("用户是pc端");
  39. const env = import.meta.env.VITE_ENV;
  40. console.log("当前的环境为:", env);
  41. if (env == "development" || env == "test") {
  42. window.parent.location.href =
  43. "http://121.89.234.155:8807/hljw/homepage?menu=999999991";
  44. } else {
  45. window.parent.location.href =
  46. "https://web.homilychart.com/product/hljw/homepage?token=" +
  47. encodeURIComponent(localStorage.getItem("localToken"));
  48. }
  49. }
  50. };
  51. </script>
  52. <style scoped>
  53. .backToHomeBtn {
  54. position: fixed;
  55. top: 20px;
  56. right: 20px;
  57. display: flex;
  58. flex-direction: column;
  59. justify-content: center;
  60. align-items: center;
  61. cursor: pointer;
  62. z-index: 20;
  63. }
  64. .backToHomeBtn:hover {
  65. transform: scale(1.05);
  66. }
  67. .backImg {
  68. width: 60%;
  69. height: auto;
  70. }
  71. .backContent {
  72. width: 100%;
  73. text-align: center;
  74. color: white;
  75. font-size: 12px;
  76. white-space: nowrap;
  77. }
  78. @media (max-width: 768px) {
  79. .backToHomeBtn {
  80. top: 0px;
  81. right: 0px;
  82. }
  83. }
  84. </style>