Login.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516
  1. <script setup lang="ts">
  2. import { md5 } from 'js-md5'
  3. import CpmdHeader from '@/components/CpmdHeader.vue';
  4. import CpmdFooter from '@/components/CpmdFooter.vue'
  5. import { ElMessage } from 'element-plus';
  6. import { onMounted, onUnmounted, reactive, ref } from 'vue'
  7. import { useRoute, useRouter } from 'vue-router'
  8. import { loginTestApi, userLoginApi } from '@/api/login';
  9. import { userInfoStore } from '@/stores'
  10. const userInfo = userInfoStore()
  11. //定义账号
  12. const account = ref<string>('')
  13. //定义密码
  14. const password = ref<string>('')
  15. //此处应该是唯一的报告ID
  16. const id = ref<string>('')
  17. //持久化设置 菜单状态
  18. //刚进入页面就将高度设置为页面需要的
  19. onMounted(async () => {
  20. //调用查看是否是演示版的接口
  21. const res: any = await loginTestApi()
  22. if (res.code == 200) {
  23. if (res.msg == 'test') {
  24. isTest.value = true
  25. } else {
  26. isTest.value = false
  27. }
  28. } else {
  29. ElMessage({ message: `${res.msg}`, type: 'error' })
  30. }
  31. })
  32. //跳转到注册页面的方法
  33. const router = useRouter()
  34. const registerFun = () => {
  35. router.push({ name: 'register' })
  36. }
  37. const isTest = ref<boolean>(false)
  38. //轮旋切换页面的方法
  39. //退出页面销毁 方法
  40. onUnmounted(async () => {
  41. })
  42. const loginTest = async () => {
  43. let params = {
  44. userNo: '20250126386',
  45. password: md5('123456')
  46. }
  47. const res: any = await userLoginApi(params)
  48. if (res.code == 200) {
  49. if (res.data.type == '1' || res.data.type == '2') {
  50. userInfo.saveToken(res.data.token)
  51. userInfo.saveUserInfo(res.data.user)
  52. ElMessage({ message: `${res.msg}`, type: 'success' })
  53. //跳转到首页
  54. router.push({ name: 'homeView' })
  55. } else {
  56. ElMessage({ message: `请使用普通账户登录`, type: 'error' })
  57. }
  58. //登录成功后将信息存入缓存
  59. } else {
  60. ElMessage({ message: `${res.msg}`, type: 'error' })
  61. }
  62. //登录成功后将信息存入缓存
  63. }
  64. //登录方法
  65. const loginFun = async () => {
  66. //先判断是否是字段都填写了
  67. if (account.value == '') {
  68. ElMessage({
  69. message: '工号不能为空',
  70. type: 'warning'
  71. })
  72. return
  73. }
  74. if (password.value == '') {
  75. ElMessage({
  76. message: '密码不能为空',
  77. type: 'warning'
  78. })
  79. return
  80. } else if (password.value.length < 6) {
  81. ElMessage({
  82. message: '密码最少6位',
  83. type: 'warning'
  84. })
  85. return
  86. }
  87. let params = {
  88. userNo: account.value,
  89. password: md5(password.value)
  90. }
  91. const res: any = await userLoginApi(params)
  92. if (res.code == 200) {
  93. if (res.data.type == '1' || res.data.type == '2') {
  94. userInfo.saveToken(res.data.token)
  95. userInfo.saveUserInfo(res.data.user)
  96. ElMessage({ message: `${res.msg}`, type: 'success' })
  97. //跳转到首页
  98. router.push({ name: 'homeView' })
  99. } else {
  100. ElMessage({ message: `请使用普通账户登录`, type: 'error' })
  101. }
  102. //登录成功后将信息存入缓存
  103. } else {
  104. ElMessage({ message: `${res.msg}`, type: 'error' })
  105. }
  106. }
  107. </script>
  108. <template>
  109. <div class="home_header_out">
  110. <div class=" home_header_inner">
  111. <CpmdHeader />
  112. </div>
  113. <div class="leave_message">
  114. <!-- <img class="img" src="../assets/zs/community.png" alt=""> -->
  115. <div class="font_blue"> 用户登录 </div>
  116. <img width="80px" style="position: absolute;left: 100px;bottom: 0;z-index: 11;"
  117. src="../assets/scale/guo.png" alt="">
  118. </div>
  119. <div class="kply">
  120. <div class="kply_inner">
  121. <div class="login_top">
  122. <span class="des">用户登录</span>
  123. </div>
  124. <div style="padding: 20px 50px;">
  125. <div style="margin-top:10px">
  126. <div class="user_account">账号:</div>
  127. <div class="input_cus"> <el-input v-model="account" style="width: 100%" placeholder="请输入工号" />
  128. </div>
  129. </div>
  130. <div style="margin-top:10px">
  131. <div class="user_account">密码:</div>
  132. <div><el-input v-model="password" type="password" style="width: 100%" placeholder="请输入密码"
  133. show-password />
  134. </div>
  135. </div>
  136. <div class="go_register">
  137. <span @click="registerFun">
  138. 没有账号,去注册
  139. </span>
  140. </div>
  141. <div class="start_button_out">
  142. <div @click="loginFun" class="start_button_self">登录</div>
  143. </div>
  144. <div v-show="isTest">
  145. <el-divider>
  146. 演示账号一键登录
  147. </el-divider>
  148. </div>
  149. <div style="text-align: center;" v-show="isTest">
  150. <el-button size="small" @click="loginTest">演示账号一键登录</el-button>
  151. </div>
  152. </div>
  153. </div>
  154. </div>
  155. </div>
  156. <div class="home_footer_out">
  157. <CpmdFooter />
  158. </div>
  159. </template>
  160. <style lang="scss" scoped>
  161. .home_footer_out {
  162. width: 100%;
  163. background-color: #1F2761;
  164. }
  165. :deep(.el-input__wrapper) {
  166. align-items: center;
  167. border-radius: 0px !important;
  168. border: 1px solid #4D6AD5 !important;
  169. padding-left: 20px;
  170. box-shadow: none
  171. }
  172. :deep(.el-input__wrapper.is-focus) {
  173. box-shadow: none
  174. }
  175. :deep(.el-input__inner) {
  176. height: 36px;
  177. font-size: 16px;
  178. }
  179. .home_header_out {
  180. // scroll-snap-align: start;
  181. // position: relative;
  182. padding-bottom: 60px;
  183. width: 100%;
  184. min-width: 1200px;
  185. // background-image: url('../assets/home/bg_ty.png');
  186. background-repeat: no-repeat;
  187. background-size: 100% auto;
  188. // background-size: auto 100%;
  189. // background-color: #B3F1DA; //估计是需要动态
  190. flex: 1;
  191. //获取屏幕宽度home_header_out 这个div的宽度--然后宽度*1000再除1920即为当前div的宽度
  192. .home_header_inner {
  193. min-height: 1;
  194. left: 0;
  195. right: 0;
  196. margin: auto;
  197. // height: 100px;
  198. width: 100%;
  199. .report_top {
  200. width: 650px;
  201. margin-left: 285px;
  202. margin-top: 20px;
  203. display: flex;
  204. flex-direction: row;
  205. justify-content: space-between;
  206. align-items: center;
  207. // margin-left: 170px;
  208. .xlts_img {
  209. width: 200px;
  210. }
  211. .report_jt {
  212. display: flex;
  213. flex-direction: column;
  214. font-size: 20px;
  215. font-weight: 700;
  216. letter-spacing: 3px;
  217. margin: auto;
  218. }
  219. }
  220. }
  221. .leave_message {
  222. left: 0;
  223. right: 0;
  224. margin: auto;
  225. width: 650px;
  226. margin-bottom: 20px;
  227. margin-top: 20px;
  228. position: relative;
  229. .font_blue {
  230. position: relative;
  231. color: #D31E1B;
  232. font-weight: 700;
  233. font-size: 22px;
  234. font-family: 'Rammetto One-Regular';
  235. padding-top: 30px;
  236. z-index: 10;
  237. background: url(../assets/zs/login_text1.png) no-repeat;
  238. background-size: auto 50px;
  239. }
  240. }
  241. .kply {
  242. width: 100%;
  243. margin-top: 20px;
  244. // background-color: #FAFAFA;
  245. // margin-bottom: 112px;
  246. .kply_inner {
  247. left: 0;
  248. right: 0;
  249. margin: auto;
  250. width: 650px;
  251. min-height: 360px;
  252. background-color: #ffffff;
  253. border-radius: 5px;
  254. box-shadow: 0px 4px 32px 0px rgba(0, 0, 0, 0.17);
  255. .login_top {
  256. background-color: #4D6AD5;
  257. line-height: 50px;
  258. .des {
  259. color: #ffffff;
  260. font-weight: 700;
  261. margin-left: 50px;
  262. // background-image: url('../assets/zs/login_line.png');
  263. background-repeat: no-repeat;
  264. background-size: contain;
  265. padding-bottom: 6px;
  266. background-position: bottom;
  267. }
  268. }
  269. .user_account {
  270. font-size: 18px;
  271. // line-height: 70px;
  272. margin-bottom: 10px;
  273. letter-spacing: 5px;
  274. }
  275. .start_button_out {
  276. margin-top: 40px;
  277. margin-bottom: 20px;
  278. display: flex;
  279. flex-direction: row;
  280. justify-content: center;
  281. .start_button_self {
  282. cursor: pointer;
  283. // width: 100px;
  284. border-radius: 4px;
  285. border: 1px solid #4D6AD5;
  286. color: #ffffff;
  287. background-color: #4D6AD5;
  288. margin-right: 20px;
  289. padding: 5px 50px;
  290. cursor: pointer;
  291. display: flex;
  292. align-items: center;
  293. font-size: 16px;
  294. }
  295. }
  296. }
  297. .go_register {
  298. text-align: right;
  299. margin-top: 20px;
  300. span {
  301. font-weight: 700;
  302. color: #4D6AD5;
  303. cursor: pointer;
  304. font-size: 16px;
  305. }
  306. }
  307. }
  308. }
  309. .home_mid {
  310. // background-color: blanchedalmond;
  311. width: 1200px;
  312. left: 0;
  313. right: 0;
  314. margin: auto;
  315. margin-top: 40px;
  316. // position: relative;
  317. .kepu_title {
  318. text-align: center;
  319. font-size: 50px;
  320. color: #111111;
  321. line-height: 95px;
  322. // width: 100%;
  323. // left: 0;
  324. // right: 0;
  325. // margin: auto
  326. }
  327. .kepu_title_sub {
  328. margin-top: 30px;
  329. text-align: center;
  330. font-size: 28px;
  331. color: #48D68E;
  332. line-height: 26px;
  333. }
  334. .man1_group {
  335. margin-top: 60px;
  336. height: 100%;
  337. display: flex;
  338. .man1 {
  339. position: relative;
  340. width: 327px;
  341. // height: 100%;
  342. // height: 100%
  343. .man1_img {
  344. position: absolute;
  345. bottom: 0;
  346. /* bottom: 0px; */
  347. /* height: auto; */
  348. width: 100%;
  349. left: 100px
  350. }
  351. }
  352. .des {
  353. border: #48D68E solid 5px;
  354. border-radius: 40px;
  355. padding: 20px;
  356. letter-spacing: 6px;
  357. flex: 1;
  358. .des_inner {
  359. border: 1px dashed #48D68E;
  360. border-radius: 40px;
  361. padding-bottom: 40px;
  362. padding-top: 30px;
  363. padding-left: 100px;
  364. padding-right: 20px;
  365. letter-spacing: 6px;
  366. font-weight: normal;
  367. font-size: 24px;
  368. color: #333333;
  369. line-height: 40px;
  370. }
  371. }
  372. }
  373. .man2_group {
  374. margin-top: 60px;
  375. height: 100%;
  376. display: flex;
  377. .man2 {
  378. position: relative;
  379. width: 327px;
  380. // height: 100%;
  381. // height: 100%
  382. .man2_img {
  383. position: absolute;
  384. bottom: 0;
  385. /* bottom: 0px; */
  386. /* height: auto; */
  387. width: 100%;
  388. left: -100px
  389. }
  390. }
  391. .des2 {
  392. border: #48D68E solid 5px;
  393. border-radius: 40px;
  394. padding: 20px;
  395. letter-spacing: 6px;
  396. flex: 1;
  397. .des2_inner {
  398. border: 1px dashed #48D68E;
  399. border-radius: 40px;
  400. padding-bottom: 40px;
  401. padding-top: 30px;
  402. padding-left: 20px;
  403. padding-right: 100px;
  404. letter-spacing: 6px;
  405. font-weight: normal;
  406. font-size: 24px;
  407. color: #333333;
  408. line-height: 40px;
  409. }
  410. }
  411. }
  412. .get_more {
  413. text-align: center;
  414. img {
  415. width: 300px;
  416. margin-top: 60px;
  417. margin-bottom: 60px;
  418. }
  419. }
  420. }
  421. // .home_footer_out {
  422. // width: 100%;
  423. // background-color: #000000;
  424. // }</style>