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.

94 lines
1.8 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.postMessage(
  46. {
  47. type: 'NAVIGATE_TO_HOMEPAGE',
  48. menu: '999999991'
  49. },
  50. '*'
  51. )
  52. }
  53. }
  54. };
  55. </script>
  56. <style scoped>
  57. .backToHomeBtn {
  58. position: fixed;
  59. top: 20px;
  60. right: 20px;
  61. display: flex;
  62. flex-direction: column;
  63. justify-content: center;
  64. align-items: center;
  65. cursor: pointer;
  66. z-index: 20;
  67. }
  68. .backToHomeBtn:hover {
  69. transform: scale(1.05);
  70. }
  71. .backImg {
  72. width: 60%;
  73. height: auto;
  74. }
  75. .backContent {
  76. width: 100%;
  77. text-align: center;
  78. color: white;
  79. font-size: 12px;
  80. white-space: nowrap;
  81. }
  82. @media (max-width: 768px) {
  83. .backToHomeBtn {
  84. top: 0px;
  85. right: 0px;
  86. }
  87. }
  88. </style>