Login.vue 12 KB

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