Login.vue 11 KB

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