Нема описа
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.

Register.vue 5.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  1. <template>
  2. <div class="login-container">
  3. <div class="login-content">
  4. <div class="login-box">
  5. <div class="login-header">
  6. <img src="../../assets/logo.png" alt="logo" class="logo" />
  7. <h2>请填写您的信息</h2>
  8. <p class="subtitle">用于记录考试参与情况</p>
  9. </div>
  10. <van-form @submit="onSubmit" class="login-form">
  11. <van-cell-group inset>
  12. <van-field
  13. v-model="formData.userCode"
  14. name="userCode"
  15. placeholder="请输入您的工号"
  16. :rules="[{ required: true, message: '请输入工号' }]"
  17. >
  18. <template #left-icon>
  19. <van-icon name="idcard-o" />
  20. </template>
  21. </van-field>
  22. <van-field
  23. v-model="formData.userName"
  24. name="userName"
  25. placeholder="请输入您的姓名"
  26. :rules="[{ required: true, message: '请输入姓名' }]"
  27. >
  28. <template #left-icon>
  29. <van-icon name="contact" />
  30. </template>
  31. </van-field>
  32. </van-cell-group>
  33. <div class="submit-btn">
  34. <van-button
  35. round
  36. block
  37. type="primary"
  38. native-type="submit"
  39. :loading="isLoading"
  40. >
  41. 确认进入
  42. </van-button>
  43. </div>
  44. </van-form>
  45. </div>
  46. </div>
  47. </div>
  48. </template>
  49. <script setup lang="ts">
  50. import { ref } from 'vue'
  51. import { useRouter, useRoute } from 'vue-router'
  52. import { showToast } from 'vant'
  53. import axios from '@/axios'
  54. const router = useRouter()
  55. const route = useRoute()
  56. const isLoading = ref(false)
  57. const formData = ref({
  58. userCode: '',
  59. userName: ''
  60. })
  61. async function onSubmit() {
  62. if (!formData.value.userCode.trim() || !formData.value.userName.trim()) {
  63. showToast('请完整填写工号和姓名')
  64. return
  65. }
  66. try {
  67. isLoading.value = true
  68. const userId=ref('C19810FBCBD111B2B2FA58EA818C71F9')
  69. var url = 'framework/SysLogin/queryPublicKeyToken'
  70. // var url = 'framework/SysLogin/queryPublicKey'
  71. var param = {
  72. param: userId.value
  73. }
  74. await axios.post(url, param).then(response => {
  75. localStorage.setItem('publicKey', response.data.data.publicKey)
  76. localStorage.setItem('userId', response.data.data.id)
  77. localStorage.setItem('userCode', formData.value.userCode.trim())
  78. localStorage.setItem('userName', response.data.data.userName)
  79. localStorage.setItem('userDesc', formData.value.userName.trim())
  80. localStorage.setItem('userType', response.data.data.userType)
  81. localStorage.setItem('token', response.data.data.token)
  82. localStorage.setItem('belongId', response.data.data.belongId)
  83. })
  84. showToast({
  85. type: 'success',
  86. message: '信息提交成功'
  87. })
  88. // 跳回原扫码页面(/fcbkdatistart),保留原始 query 参数
  89. // 注意:route.query 中应包含 examId, testRole 等参数(如果从该页跳转而来)
  90. // 如果不是从 fcbkdatistart 进来的,可默认跳首页或提示
  91. const targetPath = '/sgsafeh5/fcbkdatistart'
  92. const originalQuery = route.query // 如果是从 fcbkdatistart 跳过来的,query 会保留
  93. console.log("携带参数:",originalQuery);
  94. debugger
  95. // 更健壮的方式:检查是否有必要参数,否则跳首页
  96. if (originalQuery.examId) {
  97. await router.replace({ path: targetPath, query: originalQuery })
  98. } else {
  99. }
  100. } catch (error) {
  101. console.error('游客信息提交失败:', error)
  102. showToast('提交失败,请重试')
  103. } finally {
  104. isLoading.value = false
  105. }
  106. }
  107. </script>
  108. <style lang="scss" scoped>
  109. /* 样式保持不变,仅微调标题 */
  110. .login-container {
  111. height: 100vh;
  112. width: 100vw;
  113. display: flex;
  114. align-items: center;
  115. justify-content: center;
  116. background: linear-gradient(135deg, #1890ff 0%, #1d39c4 100%);
  117. position: relative;
  118. overflow: hidden;
  119. &::before {
  120. content: '';
  121. position: absolute;
  122. width: 200%;
  123. height: 200%;
  124. top: -50%;
  125. left: -50%;
  126. background: url('@/assets/login-bg.svg') repeat;
  127. opacity: 0.1;
  128. animation: move 10s linear infinite;
  129. }
  130. }
  131. .login-content {
  132. position: relative;
  133. z-index: 1;
  134. width: 100%;
  135. padding: 20px;
  136. }
  137. .login-box {
  138. width: 100%;
  139. max-width: 400px;
  140. margin: 0 auto;
  141. padding: 30px 24px;
  142. background: rgba(255, 255, 255, 0.9);
  143. backdrop-filter: blur(10px);
  144. border-radius: 16px;
  145. box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
  146. .login-header {
  147. text-align: center;
  148. margin-bottom: 32px;
  149. .logo {
  150. width: 64px;
  151. height: 64px;
  152. margin-bottom: 16px;
  153. }
  154. h2 {
  155. font-size: 24px;
  156. color: #1a1a1a;
  157. margin: 0 0 8px;
  158. font-weight: 600;
  159. }
  160. .subtitle {
  161. font-size: 14px;
  162. color: #666;
  163. margin: 0;
  164. }
  165. }
  166. :deep(.van-cell-group) {
  167. background: transparent;
  168. .van-field {
  169. background: rgba(255, 255, 255, 0.8);
  170. border-radius: 8px;
  171. margin-bottom: 16px;
  172. &:last-child {
  173. margin-bottom: 0;
  174. }
  175. .van-field__left-icon {
  176. margin-right: 8px;
  177. color: #666;
  178. }
  179. }
  180. }
  181. .submit-btn {
  182. margin-top: 24px;
  183. .van-button {
  184. height: 44px;
  185. font-size: 16px;
  186. background: linear-gradient(135deg, #1890ff 0%, #1d39c4 100%);
  187. border: none;
  188. &--loading {
  189. opacity: 0.8;
  190. }
  191. }
  192. }
  193. }
  194. @keyframes move {
  195. 0% {
  196. transform: translate(0, 0);
  197. }
  198. 100% {
  199. transform: translate(-50%, -50%);
  200. }
  201. }
  202. @media screen and (max-width: 480px) {
  203. .login-box {
  204. padding: 24px 16px;
  205. .login-header h2 {
  206. font-size: 20px;
  207. }
  208. }
  209. }
  210. </style>