FooterNew.vue 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297
  1. <script setup>
  2. import { ref, watch, onBeforeUnmount } from 'vue';
  3. import { complaintsEmail, accessibilityEmail } from '@/config/contact.js';
  4. const dialogVisible = ref(false);
  5. const dialogType = ref(1);
  6. import { onLanguageChange, getCurrentLanguage } from '@/utils/language.js';
  7. // 当前语言(可在模板或逻辑中使用)
  8. const currentLanguage = ref(getCurrentLanguage());
  9. // 直接注册语言变更监听,保存取消监听的函数以便在卸载时移除
  10. const _unregisterLanguageChange = onLanguageChange((lang) => {
  11. currentLanguage.value = lang;
  12. });
  13. const openDialog = (type) => {
  14. dialogType.value = type;
  15. dialogVisible.value = true;
  16. };
  17. const closeDialog = () => {
  18. dialogVisible.value = false;
  19. };
  20. // 防止弹窗打开时背景页面滚动:通过给 body 添加/移除类来控制 overflow
  21. const toggleBodyNoScroll = (enable) => {
  22. try {
  23. if (enable) document.body.classList.add('no-scroll');
  24. else document.body.classList.remove('no-scroll');
  25. } catch (e) {
  26. // 在某些 SSR 环境或测试环境中 document 可能未定义,忽略错误
  27. // console.warn('toggleBodyNoScroll error', e);
  28. }
  29. };
  30. watch(dialogVisible, (val) => {
  31. toggleBodyNoScroll(val);
  32. });
  33. onBeforeUnmount(() => {
  34. // 确保组件卸载时移除类
  35. toggleBodyNoScroll(false);
  36. // 取消语言变更监听
  37. try {
  38. if (typeof _unregisterLanguageChange === 'function') _unregisterLanguageChange();
  39. } catch (e) {
  40. console.warn('Error unregistering language change listener', e);
  41. }
  42. });
  43. </script>
  44. <template>
  45. <div class="footerBox">
  46. <div></div>
  47. <div>
  48. <div class="footerContainer">
  49. <div @click="openDialog(1)">{{ $t('message.mianze') }}</div>
  50. <div>|</div>
  51. <div @click="openDialog(3)">{{ $t('message.wzasm') }}</div>
  52. <div>|</div>
  53. <div @click="openDialog(5)">{{ $t('message.siyin') }}</div>
  54. <div>|</div>
  55. <div>{{ $t('message.banquansuoyou') }}</div>
  56. </div>
  57. <div class="footerFooter">{{ $t('message.tishi') }}</div>
  58. <div class="awardContainer">
  59. <img src="../../../assets/images/newIndex/award.jpg" alt="">
  60. <img src="../../../assets/images/newIndex/award1.png" alt="">
  61. </div>
  62. </div>
  63. </div>
  64. <!-- 弹窗 -->
  65. <div v-if="dialogVisible" class="footer-dialog-mask">
  66. <div class="footer-dialog">
  67. <span class="footer-dialog-close" @click="closeDialog">×</span>
  68. <div class="footer-dialog-content">
  69. <template v-if="dialogType === 1">
  70. <!-- 这里填写第1个弹窗内容 -->
  71. <div>
  72. <div>{{ $t("message.mianzeshengming") }}</div>
  73. <div v-if="currentLanguage !== 'en'">{{ $t("message.mianzeshengmingE") }}</div>
  74. <p>{{ $t("message.mianzeContent1") }}</p>
  75. <p>{{ $t("message.mianzeContent2") }}</p>
  76. <p>{{ $t("message.mianzeContent3") }}</p>
  77. <p>{{ $t("message.mianzeContent4") }}</p>
  78. </div>
  79. </template>
  80. <template v-else-if="dialogType === 3">
  81. <!-- 这里填写第3个弹窗内容 -->
  82. <div>{{ $t("message.wzasm") }}</div>
  83. <p v-if="currentLanguage !== 'en'">Accessibility</p>
  84. <p>{{ $t('message.wzasmContent1', { email: accessibilityEmail }) }}</p>
  85. </template>
  86. <template v-else-if="dialogType === 5">
  87. <!-- 这里填写第5个弹窗内容 -->
  88. <div>{{ $t("message.yinsizhengce") }}</div>
  89. <p v-if="currentLanguage !== 'en'">{{ $t("message.yinsizhengceE") }}</p>
  90. <p v-for="i in 34" :key="i">{{ $t(`message.yinsizhengceContent${i}`) }}</p>
  91. </template>
  92. </div>
  93. </div>
  94. </div>
  95. </template>
  96. <style>
  97. /* 当弹窗打开时禁止背景滚动 */
  98. body.no-scroll {
  99. overflow: hidden !important;
  100. touch-action: none;
  101. }
  102. .awardContainer{
  103. margin-top:2rem;
  104. display: flex;
  105. justify-content: center;
  106. >img{
  107. width: 25%;
  108. margin-right: 1.5rem;
  109. }
  110. @media screen and (min-width: 767px) {
  111. display: none;
  112. }
  113. }
  114. .footerBox {
  115. display: flex;
  116. justify-content: center;
  117. font-weight: 700;
  118. color: #666;
  119. padding: 2rem;
  120. >div:nth-child(1) {
  121. height: 3.4rem;
  122. border-left: 0.4rem solid #F7B334;
  123. margin-right: 5.3rem;
  124. margin-top: 2px;
  125. }
  126. @media screen and (max-width: 767px) {
  127. >div:nth-child(1) {
  128. display: none;
  129. height: 2rem;
  130. border-left: 0.4rem solid #F7B334;
  131. margin-right: 1.3rem;
  132. margin-top: 2px;
  133. }
  134. >div:nth-child(2) {
  135. width: 90%;
  136. }
  137. }
  138. }
  139. .footerContainer {
  140. width: 100%;
  141. display: flex;
  142. justify-content: center;
  143. align-items: center;
  144. font-size: 1rem;
  145. >div:nth-child(1),
  146. >div:nth-child(5),
  147. >div:nth-child(3) {
  148. cursor: pointer;
  149. }
  150. >div:nth-child(2) {
  151. margin: 0px 1rem;
  152. }
  153. >div:nth-child(4) {
  154. margin: 0px 1rem;
  155. }
  156. >div:nth-child(6) {
  157. margin: 0px 1rem;
  158. }
  159. @media screen and (min-width: 1024px) {
  160. >div:nth-child(2) {
  161. margin: 0px 1rem;
  162. }
  163. >div:nth-child(4) {
  164. margin: 0px 1rem;
  165. }
  166. >div:nth-child(6) {
  167. margin: 0px 1rem;
  168. }
  169. }
  170. @media screen and (max-width: 767px) {
  171. display: block;
  172. align-items: left;
  173. justify-content: left;
  174. >div:nth-child(even) {
  175. display: none;
  176. }
  177. /* 每行前面都加一个小竖线 */
  178. >div:nth-child(odd)::before {
  179. content: '';
  180. display: inline-block;
  181. width: 0.2rem;
  182. height: 1.2rem;
  183. background-color: #F7B334;
  184. margin-right: 1rem;
  185. vertical-align: middle;
  186. }
  187. >div {
  188. margin-top: 1rem;
  189. }
  190. }
  191. }
  192. .footerFooter {
  193. width: 100%;
  194. font-size: 1rem;
  195. margin-top: 1rem;
  196. }
  197. .footerFooter::before {
  198. @media screen and (max-width: 767px) {
  199. content: '';
  200. display: inline-block;
  201. width: 0.2rem;
  202. height: 1.2rem;
  203. background-color: #F7B334;
  204. margin-right: 1rem;
  205. vertical-align: middle;
  206. }
  207. }
  208. /* 弹窗样式 */
  209. .footer-dialog-mask {
  210. position: fixed;
  211. z-index: 99999;
  212. left: 0;
  213. top: 0;
  214. right: 0;
  215. bottom: 0;
  216. background: rgba(0, 0, 0, 0.35);
  217. display: flex;
  218. align-items: center;
  219. justify-content: center;
  220. }
  221. .footer-dialog {
  222. background: #fff;
  223. border-radius: 12px;
  224. width: 50vw;
  225. max-width: 900px;
  226. max-height: 60vh;
  227. position: relative;
  228. box-shadow: 0 4px 32px rgba(0, 0, 0, 0.18);
  229. padding: 3rem 1.5rem 2.5rem;
  230. display: flex;
  231. flex-direction: column;
  232. @media screen and (max-width: 767px) {
  233. width: 80vw;
  234. }
  235. }
  236. .footer-dialog-close {
  237. position: absolute;
  238. right: 1.2rem;
  239. top: 1.2rem;
  240. font-size: 1.5rem;
  241. color: #888;
  242. cursor: pointer;
  243. z-index: 2;
  244. font-weight: bold;
  245. transition: color 0.2s;
  246. }
  247. .footer-dialog-close:hover {
  248. color: #c9082c;
  249. }
  250. .footer-dialog-content {
  251. flex: 1;
  252. overflow-y: auto;
  253. margin-top: 1rem;
  254. font-size: 1.1rem;
  255. color: #333;
  256. >div {
  257. font-size: 1.3rem;
  258. >p {
  259. font-size: 1rem;
  260. }
  261. }
  262. }
  263. </style>