loginIndex.vue 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304
  1. <template>
  2. <el-row>
  3. <el-col :span="24" class="main animate__animated animate__backInRight">
  4. <el-col :span="24" class="one">
  5. <el-col :span="24" class="w_1200">
  6. <el-col :span="24" class="one_1">
  7. <el-col :span="12" class="left">
  8. <el-col :span="3" class="image">
  9. <el-image :src="webInfos.logo_url"></el-image>
  10. </el-col>
  11. <el-col :span="21" class="other">
  12. <el-col :span="24" class="zhTitle textOver">
  13. {{ webInfos.zhTitle }}
  14. </el-col>
  15. <el-col :span="24" class="enTitle textOver">
  16. {{ webInfos.enTitle }}
  17. </el-col>
  18. </el-col>
  19. </el-col>
  20. <el-col :span="12" class="right"></el-col>
  21. </el-col>
  22. </el-col>
  23. </el-col>
  24. <el-col :span="24" class="two">
  25. <el-col :span="24" class="w_1200">
  26. <el-col :span="14" class="left">
  27. <el-col :span="24" class="txt">{{ webInfos.one_title }}</el-col>
  28. <el-col :span="24" class="txt">{{ webInfos.two_title }}</el-col>
  29. <el-col :span="24" class="txt">{{ webInfos.thr_title }}</el-col>
  30. <el-col :span="24" class="txt">{{ webInfos.four_title }}</el-col>
  31. </el-col>
  32. <el-col :span="10" class="right">
  33. <el-col :span="24" class="login">
  34. <el-col :span="24" class="login_1">
  35. <el-image :src="webInfos.user_url"></el-image>
  36. <span>欢迎登录</span>
  37. </el-col>
  38. <el-col :span="24" class="login_2">
  39. <el-form ref="ruleFormRef" size="default" :model="form" :rules="rules">
  40. <el-form-item label="" prop="account">
  41. <el-input v-model="form.account" placeholder="请输入账号">
  42. <template #prefix>
  43. <el-icon><User /></el-icon>
  44. </template>
  45. </el-input>
  46. </el-form-item>
  47. <el-form-item label="" prop="password">
  48. <el-input v-model="form.password" type="password" show-password placeholder="请输入密码">
  49. <template #prefix>
  50. <el-icon><Unlock /></el-icon>
  51. </template>
  52. </el-input>
  53. </el-form-item>
  54. <el-form-item label="" prop="type">
  55. <el-select v-model="form.type" clearable placeholder="请选择用户类型" style="width: 100%">
  56. <el-option v-for="t in typeList" :key="t.value" :label="t.label" :value="t.value" />
  57. </el-select>
  58. </el-form-item>
  59. <el-form-item label="" prop="code">
  60. <el-input v-model="form.code" placeholder="请输入验证码">
  61. <template #prefix>
  62. <el-icon><Key /></el-icon>
  63. </template>
  64. <template #append>
  65. <component :is="validcode" @toCode="toCode"></component>
  66. </template>
  67. </el-input>
  68. </el-form-item>
  69. <el-col :span="24" class="btn">
  70. <el-button type="warning">
  71. <el-icon><Burger /></el-icon>
  72. <span>依托单位账号密码找回</span>
  73. </el-button>
  74. <el-button type="primary">
  75. <el-icon><User /></el-icon>
  76. <span>个人账号密码找回</span>
  77. </el-button>
  78. </el-col>
  79. <el-col :span="24" class="save">
  80. <el-button type="primary" size="large" @click="toSave(ruleFormRef)">登录</el-button>
  81. </el-col>
  82. </el-form>
  83. </el-col>
  84. <el-col :span="24" class="login_3">
  85. <span>还没有账号?</span>
  86. <el-button type="danger" size="small" plain @click="toRegister">去注册</el-button>
  87. </el-col>
  88. </el-col>
  89. </el-col>
  90. </el-col>
  91. </el-col>
  92. <el-col :span="24" class="thr">
  93. <el-col :span="24" class="w_1200"><p v-html="webInfos.content"></p></el-col>
  94. </el-col>
  95. </el-col>
  96. </el-row>
  97. </template>
  98. <script setup lang="ts">
  99. // 组件
  100. import validcode from '@common/src/components/ValidCode.vue'
  101. // 基础
  102. import { webInfo } from '@common/src/layout/site'
  103. import type { Ref } from 'vue'
  104. import { reactive, ref, onMounted } from 'vue'
  105. import type { FormInstance, FormRules } from 'element-plus'
  106. import { ElMessage } from 'element-plus'
  107. import router from '@/router'
  108. // 接口
  109. import { AdminStore } from '@common/src/stores/users/admin' //管理员
  110. import { UnitStore } from '@common/src/stores/users/unit' //依托单位
  111. import { UsersStore } from '@common/src/stores/users/users' //个人
  112. import type { IQueryResult } from '@/util/types.util'
  113. const adminAxios = AdminStore()
  114. const unitAxios = UnitStore()
  115. const usersAxios = UsersStore()
  116. // 平台信息
  117. const webInfos: Ref<any> = ref(webInfo)
  118. // 登录
  119. const ruleFormRef = ref<FormInstance>()
  120. const form = reactive({ account: '', password: '', type: '', code: '' })
  121. const rules = reactive<FormRules>({
  122. account: [{ required: true, message: '请输入账号', trigger: 'blur' }],
  123. password: [{ required: true, message: '请输入密码', trigger: 'blur' }],
  124. type: [{ required: true, message: '请选择用户类型', trigger: 'change' }],
  125. code: [{ required: true, message: '请输入验证码', trigger: 'blur' }]
  126. })
  127. // 验证码
  128. const code: Ref<any> = ref('')
  129. // 字典
  130. const typeList: Ref<any> = ref([
  131. { label: '依托单位账号', value: '0' },
  132. { label: '个人账号', value: '1' }
  133. // { label: '管理员', value: '2' }
  134. ])
  135. onMounted(() => {})
  136. // 验证码
  137. const toCode = (e) => {
  138. code.value = e
  139. }
  140. // 提交登录
  141. const toSave = async (formEl: FormInstance | undefined) => {
  142. if (!formEl) return
  143. await formEl.validate(async (valid, fields) => {
  144. if (valid) {
  145. if (form.code.toLowerCase() !== code.value.toLowerCase()) {
  146. ElMessage({ message: '验证码错误', type: 'error' })
  147. return
  148. }
  149. delete form.code
  150. let res: IQueryResult
  151. if (form.type == '0') {
  152. delete form.type
  153. res = await unitAxios.login(form)
  154. } else if (form.type == '1') {
  155. delete form.type
  156. res = await usersAxios.login(form)
  157. } else if (form.type == '2') {
  158. delete form.type
  159. res = await adminAxios.login(form)
  160. }
  161. if (res.errcode == '0') {
  162. ElMessage({ message: '登录成功', type: 'success' })
  163. localStorage.setItem('token', `${res.data}`)
  164. // window.location.href = `http://basic.waityou24.cn/admin`
  165. window.location.href = `/admin`
  166. } else {
  167. ElMessage({ message: `${res.errmsg}`, type: 'error' })
  168. }
  169. } else {
  170. console.log('error submit!', fields)
  171. }
  172. })
  173. }
  174. // 去注册
  175. const toRegister = () => {
  176. router.push({ path: '/register' })
  177. }
  178. </script>
  179. <style scoped lang="less">
  180. .main {
  181. display: flex;
  182. flex-direction: column;
  183. height: 100%;
  184. .one {
  185. .one_1 {
  186. display: flex;
  187. padding: 10px 0;
  188. .left {
  189. display: flex;
  190. align-items: center;
  191. .image {
  192. text-align: center;
  193. .el-image {
  194. :deep(.el-image__inner) {
  195. width: 50px;
  196. height: 50px;
  197. }
  198. }
  199. }
  200. .other {
  201. .zhTitle {
  202. font-size: 30px;
  203. font-family: cursive;
  204. font-weight: 700;
  205. }
  206. .enTitle {
  207. font-size: 12px;
  208. text-transform: capitalize;
  209. }
  210. }
  211. }
  212. .right {
  213. text-align: right;
  214. }
  215. }
  216. }
  217. .two {
  218. background: url('@/assets/bg.jpg');
  219. background-size: 100% 100%;
  220. background-repeat: no-repeat;
  221. .w_1200 {
  222. height: 86vh;
  223. padding: 10px 0;
  224. display: flex;
  225. .left {
  226. padding: 3% 0 0 2%;
  227. .txt {
  228. font-size: 30px;
  229. color: #ffffff;
  230. font-family: cursive;
  231. font-weight: bold;
  232. margin: 0 0 10px 0;
  233. font-style: italic;
  234. padding: 0 0 0 0;
  235. }
  236. .txt:nth-child(2n) {
  237. padding: 0 0 0 18%;
  238. }
  239. }
  240. .right {
  241. display: flex;
  242. align-items: flex-start;
  243. .login {
  244. width: 80%;
  245. height: 52vh;
  246. overflow: hidden;
  247. padding: 10px;
  248. background-color: #ffffff;
  249. border-radius: 5px;
  250. box-shadow: 0px 0px 10px 5px #0505054d;
  251. .login_1 {
  252. margin: 0 0 10px 0;
  253. span {
  254. position: relative;
  255. left: 5px;
  256. top: -10px;
  257. font-size: 24px;
  258. font-weight: bold;
  259. color: #666;
  260. }
  261. }
  262. .login_2 {
  263. .btn {
  264. margin: 0 0 18px 0;
  265. display: flex;
  266. justify-content: space-around;
  267. button {
  268. width: 50%;
  269. padding: 20px 0;
  270. font-size: 15px;
  271. span {
  272. padding: 0 0 0 5px;
  273. }
  274. }
  275. }
  276. .save {
  277. margin: 0 0 18px 0;
  278. button {
  279. width: 100%;
  280. }
  281. }
  282. }
  283. .login_3 {
  284. text-align: center;
  285. span {
  286. padding: 0 10px 0 0;
  287. }
  288. }
  289. }
  290. }
  291. }
  292. }
  293. .thr {
  294. padding: 10px 0;
  295. text-align: center;
  296. color: #999999;
  297. }
  298. }
  299. :deep(.el-input-group__append, .el-input-group__prepend) {
  300. padding: 0;
  301. }
  302. </style>