index.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. <template>
  2. <div class="fenghui">
  3. <div class="swith" :style="componentId !== '' ? 'color: #000000' : ''">
  4. <div class="title" @click="showLange = true">
  5. {{ langObjT[langSelect] }}
  6. <van-icon name="arrow-down" />
  7. </div>
  8. <van-popup v-model:show="showLange" destroy-on-close round position="bottom">
  9. <van-picker :model-value="[langSelect]" :columns="langObj" @cancel="showLange = false"
  10. @confirm="langChange" />
  11. </van-popup>
  12. </div>
  13. <Introduction v-if="!componentId" :langType="langSelect" @checkVerificationCode="checkVerificationCode" />
  14. <!-- 动态组件 -->
  15. <Fore25 ref="fore25" v-if="componentId === 'fore25'" :langType="langSelect" @closeComponent="closeComponent" />
  16. <Chin25 ref="chin25" v-if="componentId === 'chin25'" :langType="langSelect" @closeComponent="closeComponent" />
  17. <Work25 ref="work25" v-if="componentId === 'work25'" :langType="langSelect" @closeComponent="closeComponent" />
  18. </div>
  19. </template>
  20. <script setup>
  21. // import { ref, reactive, computed } from 'vue';
  22. import { ref } from 'vue';
  23. import Introduction from './introduction.vue';
  24. import Fore25 from './form.vue';
  25. import Chin25 from './form1.vue';
  26. import Work25 from './form2.vue';
  27. const langSelect = ref(localStorage.getItem('langSelect') || 'zh');
  28. const componentId = ref('');
  29. const showLange = ref(false);
  30. const fore25 = ref(null); // 引入子组件的实例,用于调用子组件的方法
  31. const chin25 = ref(null); // 引入子组件的实例,用于调用子组件的方法
  32. const work25 = ref(null); // 引入子组件的实例,用于调用子组件的方法
  33. const langObj = [
  34. { text: '中文', value: 'zh' },
  35. { text: 'English', value: 'en' },
  36. ]
  37. const langObjT = {
  38. zh: 'English',
  39. en: '中文',
  40. }
  41. const checkVerificationCode = (code) => {
  42. componentId.value = code;
  43. }
  44. const closeComponent = () => {
  45. componentId.value = '';
  46. }
  47. const langChange = ({ selectedValues }) => {
  48. langSelect.value = selectedValues[0];
  49. localStorage.setItem('langSelect', selectedValues[0]);
  50. // const cardTypeList = ref(lang.value[langSelect.value].cardTypeList)
  51. // const countryOrRegionList = ref(lang.value[langSelect.value].countryOrRegionList)
  52. if (componentId.value === 'fore25') {
  53. fore25.value.reset(); // 调用子组件的方法
  54. } else if (componentId.value === 'chin25') {
  55. chin25.value.reset(); // 调用子组件的方法
  56. } else if (componentId.value === 'work25') {
  57. work25.value.reset(); // 调用子组件的方法
  58. }
  59. showLange.value = false;
  60. };
  61. </script>
  62. <style lang="scss">
  63. .fenghui {
  64. overflow-x: hidden;
  65. width: 100vw;
  66. max-width: 750px;
  67. margin: 0 auto;
  68. min-height: 100vh;
  69. font-weight: 400;
  70. position: relative;
  71. font-family: Source Han Sans CN !important;
  72. text-align: left;
  73. .swith {
  74. position: absolute;
  75. right: 10px;
  76. top: 10px;
  77. z-index: 999;
  78. color: #fff;
  79. .title {
  80. cursor: pointer;
  81. }
  82. }
  83. .form {
  84. font-size: 14px;
  85. font-weight: 400 !important;
  86. padding: 11px 0;
  87. .label {
  88. min-width: 4em;
  89. display: inline-block;
  90. text-align: justify;
  91. -moz-text-align-last: justify;
  92. text-align-last: justify;
  93. }
  94. }
  95. }
  96. </style>