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.

97 lines
1.9 KiB

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