index.vue 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267
  1. <template>
  2. <div :class="{ fenghui: true, nozh: langSelect !== 'zh' }">
  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('fore25');
  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 langkeys = Object.keys(lang);
  60. // 如需要添加语言,需要在这里添加
  61. const langObjT = {
  62. zh: '中文',
  63. en: 'English',
  64. es: 'Español',
  65. }
  66. const langObj = langkeys.map((item) => {
  67. return { text: langObjT[item], value: item }
  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. font-display: swap;
  120. }
  121. html {
  122. font-size: 16px;
  123. }
  124. .fenghui {
  125. overflow-x: hidden;
  126. width: 100vw;
  127. max-width: 750px;
  128. margin: 0 auto;
  129. min-height: 100vh;
  130. font-weight: 400;
  131. position: relative;
  132. font-family: "Source Han Sans CN","Helvetica Neue",Helvetica,Arial,"Microsoft Yahei","Hiragino Sans GB","Heiti SC","WenQuanYi Micro Hei",sans-serif;
  133. text-align: left;
  134. .van-nav-bar__title {
  135. margin: 0;
  136. }
  137. .noClcik {
  138. position: relative;
  139. &::after {
  140. content: '';
  141. position: absolute;
  142. width: 100%;
  143. height: 100%;
  144. left: 0;
  145. top: 0;
  146. }
  147. }
  148. .languageList {
  149. padding: 10px 20px;
  150. font-size: 0.875rem;
  151. color: #cbc9d6;
  152. text-align: right;
  153. position: absolute;
  154. width: 100%;
  155. z-index: 1;
  156. .languageItem {
  157. position: relative;
  158. height: 2em;
  159. display: inline-block;
  160. margin-left: 15px;
  161. &-act {
  162. color: #fff;
  163. &::after {
  164. content: '';
  165. position: absolute;
  166. width: 90%;
  167. height: 1px;
  168. background: #fff;
  169. bottom: 0;
  170. left: 5%
  171. }
  172. }
  173. }
  174. }
  175. .swith {
  176. position: absolute;
  177. right: 10px;
  178. top: 10px;
  179. z-index: 999;
  180. color: #fff;
  181. .title {
  182. cursor: pointer;
  183. }
  184. }
  185. .upFileSubtitle {
  186. font-size: 0.875rem;
  187. color: #cbc9d6;
  188. }
  189. .navTitle {
  190. padding-left: 3em;
  191. font-size: 1.2rem;
  192. overflow: hidden;
  193. white-space: nowrap;
  194. text-overflow: ellipsis;
  195. }
  196. .form {
  197. font-size: 0.875rem !important;
  198. font-weight: 400;
  199. padding: 46px 0 11px 0;
  200. .van-cell {
  201. font-size: 1rem;
  202. }
  203. .van-nav-bar {
  204. .van-icon {
  205. color: #3D3D3D
  206. }
  207. }
  208. .van-field__label--top {
  209. width: 100% !important;
  210. .label {
  211. -moz-text-align-last: left;
  212. text-align-last: left;
  213. }
  214. }
  215. .van-radio-group--horizontal {
  216. padding: 0 16px;
  217. }
  218. .label {
  219. min-width: 4em;
  220. display: inline-block;
  221. text-align: justify;
  222. -moz-text-align-last: justify;
  223. text-align-last: justify;
  224. }
  225. .van-cell--“large” {
  226. padding: 16px 20px;
  227. }
  228. }
  229. }
  230. .nozh {
  231. font-family: Arial Hebrew;
  232. .text {
  233. padding-left: 15px;
  234. }
  235. }
  236. </style>