Login.vue 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418
  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 class="report_top">
  78. <div class="report_jt">
  79. <span>用户登录</span>
  80. </div>
  81. <!-- <img class="xlts_img" src="../assets/report/report_top.png" /> -->
  82. </div>
  83. </div>
  84. <div class="kply">
  85. <div class="kply_inner">
  86. <div style="padding: 20px 100px;">
  87. <div style="margin-top:10px">
  88. <div class="user_account">账号:</div>
  89. <div class="input_cus"> <el-input v-model="account" style="width: 100%" placeholder="请输入账号" />
  90. </div>
  91. </div>
  92. <div style="margin-top:10px">
  93. <div class="user_account">密码:</div>
  94. <div><el-input v-model="password" type="password" style="width: 100%" placeholder="请输入密码"
  95. show-password />
  96. </div>
  97. </div>
  98. <div class="go_register">
  99. <span @click="registerFun">
  100. 没有账号,去注册
  101. </span>
  102. </div>
  103. <div class="start_button_out">
  104. <div @click="loginFun" class="start_button_self">登录</div>
  105. </div>
  106. </div>
  107. </div>
  108. </div>
  109. </div>
  110. </template>
  111. <style lang="scss" scoped>
  112. :deep(.el-input__wrapper) {
  113. align-items: center;
  114. border-radius: 60px !important;
  115. border: 2px solid #B2F2D2 !important;
  116. padding-left: 20px;
  117. }
  118. :deep(.el-input__wrapper .is-fous) {
  119. box-shadow: none
  120. }
  121. :deep(.el-input__inner) {
  122. height: 36px;
  123. font-size: 16px;
  124. }
  125. .home_header_out {
  126. scroll-snap-align: start;
  127. // position: relative;
  128. padding-bottom: 60px;
  129. width: 100%;
  130. min-width: 1200px;
  131. // background-image: url('../assets/home/bg_ty.png');
  132. background-repeat: no-repeat;
  133. background-size: 100% auto;
  134. // background-size: auto 100%;
  135. // background-color: #B3F1DA; //估计是需要动态
  136. flex: 1;
  137. //获取屏幕宽度home_header_out 这个div的宽度--然后宽度*1000再除1920即为当前div的宽度
  138. .home_header_inner {
  139. min-height: 1;
  140. left: 0;
  141. right: 0;
  142. margin: auto;
  143. // height: 100px;
  144. width: 100%;
  145. .report_top {
  146. width: 650px;
  147. margin-left: 285px;
  148. margin-top: 20px;
  149. display: flex;
  150. flex-direction: row;
  151. justify-content: space-between;
  152. align-items: center;
  153. // margin-left: 170px;
  154. .xlts_img {
  155. width: 200px;
  156. }
  157. .report_jt {
  158. display: flex;
  159. flex-direction: column;
  160. font-size: 20px;
  161. font-weight: 700;
  162. letter-spacing: 3px;
  163. margin: auto;
  164. }
  165. }
  166. }
  167. .kply {
  168. width: 100%;
  169. margin-top: 20px;
  170. // background-color: #FAFAFA;
  171. // margin-bottom: 112px;
  172. .kply_inner {
  173. left: 0;
  174. right: 0;
  175. margin: auto;
  176. width: 650px;
  177. min-height: 360px;
  178. background-color: #ffffff;
  179. border-radius: 5px;
  180. box-shadow: 0px 4px 32px 0px rgba(0, 0, 0, 0.17);
  181. .user_account {
  182. font-size: 18px;
  183. // line-height: 70px;
  184. margin-bottom: 10px;
  185. letter-spacing: 5px;
  186. }
  187. .start_button_out {
  188. margin-top: 40px;
  189. margin-bottom: 20px;
  190. display: flex;
  191. flex-direction: row;
  192. justify-content: center;
  193. .start_button_self {
  194. cursor: pointer;
  195. // width: 100px;
  196. border-radius: 5px;
  197. border: 1px solid #48D68E;
  198. color: #ffffff;
  199. background-color: #3B3B3B;
  200. margin-right: 20px;
  201. padding: 5px 50px;
  202. cursor: pointer;
  203. display: flex;
  204. align-items: center;
  205. font-size: 16px;
  206. }
  207. }
  208. }
  209. .go_register {
  210. text-align: right;
  211. margin-top: 20px;
  212. span {
  213. color: #48D68E;
  214. cursor: pointer;
  215. font-size: 16px;
  216. }
  217. }
  218. }
  219. }
  220. .home_mid {
  221. // background-color: blanchedalmond;
  222. width: 1200px;
  223. left: 0;
  224. right: 0;
  225. margin: auto;
  226. margin-top: 40px;
  227. // position: relative;
  228. .kepu_title {
  229. text-align: center;
  230. font-size: 50px;
  231. color: #111111;
  232. line-height: 95px;
  233. // width: 100%;
  234. // left: 0;
  235. // right: 0;
  236. // margin: auto
  237. }
  238. .kepu_title_sub {
  239. margin-top: 30px;
  240. text-align: center;
  241. font-size: 28px;
  242. color: #48D68E;
  243. line-height: 26px;
  244. }
  245. .man1_group {
  246. margin-top: 60px;
  247. height: 100%;
  248. display: flex;
  249. .man1 {
  250. position: relative;
  251. width: 327px;
  252. // height: 100%;
  253. // height: 100%
  254. .man1_img {
  255. position: absolute;
  256. bottom: 0;
  257. /* bottom: 0px; */
  258. /* height: auto; */
  259. width: 100%;
  260. left: 100px
  261. }
  262. }
  263. .des {
  264. border: #48D68E solid 5px;
  265. border-radius: 40px;
  266. padding: 20px;
  267. letter-spacing: 6px;
  268. flex: 1;
  269. .des_inner {
  270. border: 1px dashed #48D68E;
  271. border-radius: 40px;
  272. padding-bottom: 40px;
  273. padding-top: 30px;
  274. padding-left: 100px;
  275. padding-right: 20px;
  276. letter-spacing: 6px;
  277. font-weight: normal;
  278. font-size: 24px;
  279. color: #333333;
  280. line-height: 40px;
  281. }
  282. }
  283. }
  284. .man2_group {
  285. margin-top: 60px;
  286. height: 100%;
  287. display: flex;
  288. .man2 {
  289. position: relative;
  290. width: 327px;
  291. // height: 100%;
  292. // height: 100%
  293. .man2_img {
  294. position: absolute;
  295. bottom: 0;
  296. /* bottom: 0px; */
  297. /* height: auto; */
  298. width: 100%;
  299. left: -100px
  300. }
  301. }
  302. .des2 {
  303. border: #48D68E solid 5px;
  304. border-radius: 40px;
  305. padding: 20px;
  306. letter-spacing: 6px;
  307. flex: 1;
  308. .des2_inner {
  309. border: 1px dashed #48D68E;
  310. border-radius: 40px;
  311. padding-bottom: 40px;
  312. padding-top: 30px;
  313. padding-left: 20px;
  314. padding-right: 100px;
  315. letter-spacing: 6px;
  316. font-weight: normal;
  317. font-size: 24px;
  318. color: #333333;
  319. line-height: 40px;
  320. }
  321. }
  322. }
  323. .get_more {
  324. text-align: center;
  325. img {
  326. width: 300px;
  327. margin-top: 60px;
  328. margin-bottom: 60px;
  329. }
  330. }
  331. }
  332. // .home_footer_out {
  333. // width: 100%;
  334. // background-color: #000000;
  335. // }</style>