index.vue 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  1. <template>
  2. <div :class="{ fenghui: true, en: langSelect === 'en' }">
  3. <div class="languageList">
  4. <div @click="() => langChange({ selectedValues: [item.value] })"
  5. :class="{ languageItem: true, 'languageItem-act': langSelect === item.value }" v-for="item in langObj"
  6. v-text="item.text" :key="item.value"></div>
  7. </div>
  8. <div class="swith" v-show="componentId" :style="componentId !== '' ? 'position: fixed; color: #000000' : ''">
  9. <div class="title" @click="showLange = true">
  10. {{ langObjT[langSelect] }}
  11. <van-icon name="arrow-down" />
  12. </div>
  13. <van-popup v-model:show="showLange" destroy-on-close round position="bottom">
  14. <van-picker :confirm-button-text="lang[langSelect].confirm"
  15. :cancel-button-text="lang[langSelect].cancel" :model-value="[langSelect]" :columns="langObj"
  16. @cancel="showLange = false" @confirm="langChange" />
  17. </van-popup>
  18. </div>
  19. <Introduction v-if="!componentId" :langType="langSelect" @saveData="saveData" />
  20. <!-- 动态组件 -->
  21. <Fore25 ref="fore25" v-if="componentId === 'fore25'" :verificationCode="verificationCode" :langType="langSelect"
  22. @closeComponent="closeComponent" />
  23. <Chin25 ref="chin25" v-if="componentId === 'chin25'" :verificationCode="verificationCode" :langType="langSelect"
  24. @closeComponent="closeComponent" />
  25. <Work25 ref="work25" v-if="componentId === 'work25'" :verificationCode="verificationCode" :langType="langSelect"
  26. @closeComponent="closeComponent" />
  27. <Fore25-recurrence ref="fore25Recurrence" v-if="componentId === 'fore25Recurrence'" :subData="subData"
  28. :verificationCode="verificationCode" :langType="langSelect" @closeComponent="closeComponent" />
  29. <Chin25-recurrence ref="chin25Recurrence" v-if="componentId === 'chin25Recurrence'" :subData="subData"
  30. :verificationCode="verificationCode" :langType="langSelect" @closeComponent="closeComponent" />
  31. <Work25-recurrence ref="work25Recurrence" v-if="componentId === 'work25Recurrence'" :subData="subData"
  32. :verificationCode="verificationCode" :langType="langSelect" @closeComponent="closeComponent" />
  33. </div>
  34. </template>
  35. <script setup>
  36. // import { ref, reactive, computed } from 'vue';
  37. import { ref } from 'vue';
  38. import Introduction from './introduction.vue';
  39. import Fore25 from './form.vue';
  40. import Chin25 from './form1.vue';
  41. import Work25 from './form2.vue';
  42. import Fore25Recurrence from './formRecurrence.vue';
  43. import Chin25Recurrence from './form1Recurrence.vue';
  44. import Work25Recurrence from './form2Recurrence.vue';
  45. import lang from './lang';
  46. const langSelect = ref(localStorage.getItem('langSelect') || 'zh');
  47. const componentId = ref('');
  48. const verificationCode = ref('');
  49. const showLange = ref(false);
  50. const fore25 = ref(null); // 引入子组件的实例,用于调用子组件的方法
  51. const chin25 = ref(null); // 引入子组件的实例,用于调用子组件的方法
  52. const work25 = ref(null); // 引入子组件的实例,用于调用子组件的方法
  53. const fore25Recurrence = ref(null); // 引入子组件的实例,用于调用子组件的方法
  54. const chin25Recurrence = ref(null); // 引入子组件的实例,用于调用子组件的方法
  55. const work25Recurrence = ref(null); // 引入子组件的实例,用于调用子组件的方法
  56. let langDefaute = true;
  57. let langDefauteType = langSelect.value;
  58. const subData = ref({})
  59. const langObj = [
  60. { text: '中文', value: 'zh' },
  61. { text: 'English', value: 'en' },
  62. // { text: 'Español', value: 'es' },
  63. ]
  64. const langObjT = {
  65. zh: '中文',
  66. en: 'English',
  67. es: 'Español',
  68. }
  69. const saveData = (code, verification, data) => {
  70. if (code !== undefined) {
  71. componentId.value = code;
  72. if (langDefaute) {
  73. // 语言初始状态,需要判定是否是外国人的界面,是的话,需要设置英语
  74. const langList = ['fore25', 'fore25Recurrence']
  75. langSelect.value = langList.includes(componentId.value) && langDefauteType !== undefined ? 'en' : langDefauteType
  76. }
  77. }
  78. if (verification !== undefined) verificationCode.value = verification;
  79. if (data !== undefined) subData.value = data;
  80. }
  81. const closeComponent = () => {
  82. componentId.value = '';
  83. if (langDefaute) langSelect.value = langDefauteType
  84. }
  85. const langChange = ({ selectedValues }) => {
  86. langSelect.value = selectedValues[0];
  87. langDefaute = false;
  88. localStorage.setItem('langSelect', selectedValues[0]);
  89. switch (componentId.value) {
  90. case 'fore25':
  91. fore25.value.reset(); // 调用子组件的方法
  92. break;
  93. case 'chin25':
  94. chin25.value.reset(); // 调用子组件的方法
  95. break;
  96. case 'work25':
  97. work25.value.reset(); // 调用子组件的方法
  98. break;
  99. case 'fore25Recurrence':
  100. fore25Recurrence.value.reset(); // 调用子组件的方法
  101. break;
  102. case 'chin25Recurrence':
  103. chin25Recurrence.value.reset(); // 调用子组件的方法
  104. break;
  105. case 'work25Recurrence':
  106. work25Recurrence.value.reset(); // 调用子组件的方法
  107. break;
  108. }
  109. showLange.value = false;
  110. };
  111. </script>
  112. <style lang="scss">
  113. // 引入自定义字体
  114. @font-face {
  115. font-family: 'Source Han Sans CN';
  116. src: url('https://cxzx.smcic.net/topic/tool/pkg/SourceHanSerifCN.otf') format('truetype');
  117. font-weight: normal;
  118. font-style: normal;
  119. }
  120. html {
  121. font-size: 16px;
  122. }
  123. .fenghui {
  124. overflow-x: hidden;
  125. width: 100vw;
  126. max-width: 750px;
  127. margin: 0 auto;
  128. min-height: 100vh;
  129. font-weight: 400;
  130. position: relative;
  131. font-family: Source Han Sans CN;
  132. text-align: left;
  133. .van-nav-bar__title {
  134. margin: 0;
  135. }
  136. .languageList {
  137. display: flex;
  138. justify-content: space-between;
  139. padding: 10px 20px;
  140. font-size: 0.875rem;
  141. color: #cbc9d6;
  142. text-align: center;
  143. position: absolute;
  144. width: 100%;
  145. z-index: 1;
  146. .languageItem {
  147. flex: 1;
  148. position: relative;
  149. height: 2em;
  150. &-act {
  151. color: #fff;
  152. &::after {
  153. content: '';
  154. position: absolute;
  155. width: 90%;
  156. height: 1px;
  157. background: #fff;
  158. bottom: 0;
  159. left: 5%
  160. }
  161. }
  162. }
  163. }
  164. .swith {
  165. position: absolute;
  166. right: 10px;
  167. top: 10px;
  168. z-index: 999;
  169. color: #fff;
  170. .title {
  171. cursor: pointer;
  172. }
  173. }
  174. .upFileSubtitle {
  175. font-size: 0.875rem;
  176. color: #cbc9d6;
  177. }
  178. .form {
  179. font-size: 0.875rem !important;
  180. font-weight: 400;
  181. padding: 46px 0 11px 0;
  182. .van-cell {
  183. font-size: 1rem;
  184. }
  185. .van-nav-bar {
  186. .van-icon {
  187. color: #3D3D3D
  188. }
  189. }
  190. .van-field__label--top {
  191. width: 100% !important;
  192. }
  193. .van-radio-group--horizontal {
  194. padding: 0 16px;
  195. }
  196. .label {
  197. min-width: 4em;
  198. display: inline-block;
  199. text-align: justify;
  200. -moz-text-align-last: justify;
  201. text-align-last: justify;
  202. }
  203. .van-cell--“large” {
  204. padding: 16px 20px;
  205. }
  206. }
  207. }
  208. .en {
  209. font-family: Arial Hebrew;
  210. ;
  211. }
  212. </style>