Login.vue 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413
  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 == '3') {
  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 200px;">
  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: 8px 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: 40px;
  123. font-size: 20px;
  124. }
  125. .home_header_out {
  126. // position: relative;
  127. padding-bottom: 60px;
  128. width: 100%;
  129. min-width: 1200px;
  130. background-image: url('../assets/home/bg_ty.png');
  131. background-repeat: no-repeat;
  132. background-size: contain;
  133. background-color: #FAFAFA; //估计是需要动态
  134. //获取屏幕宽度home_header_out 这个div的宽度--然后宽度*1000再除1920即为当前div的宽度
  135. .home_header_inner {
  136. min-height: 1;
  137. left: 0;
  138. right: 0;
  139. margin: auto;
  140. // height: 100px;
  141. width: 1200px;
  142. .report_top {
  143. width: 860px;
  144. margin-top: 20px;
  145. display: flex;
  146. flex-direction: row;
  147. justify-content: space-between;
  148. align-items: center;
  149. margin-left: 170px;
  150. .xlts_img {
  151. width: 200px;
  152. }
  153. .report_jt {
  154. display: flex;
  155. flex-direction: column;
  156. font-size: 40px;
  157. font-weight: 700;
  158. letter-spacing: 3px;
  159. }
  160. }
  161. }
  162. .kply {
  163. width: 100%;
  164. margin-top: 20px;
  165. // background-color: #FAFAFA;
  166. margin-bottom: 112px;
  167. .kply_inner {
  168. // padding: 20px 20px;
  169. left: 0;
  170. right: 0;
  171. margin: auto;
  172. width: 860px;
  173. min-height: 500px;
  174. background-color: #ffffff;
  175. border-radius: 40px;
  176. .user_account {
  177. font-size: 24px;
  178. // line-height: 70px;
  179. margin-bottom: 10px;
  180. letter-spacing: 5px;
  181. }
  182. .start_button_out {
  183. margin-top: 60px;
  184. margin-bottom: 40px;
  185. display: flex;
  186. flex-direction: row;
  187. justify-content: center;
  188. .start_button_self {
  189. cursor: pointer;
  190. // width: 100px;
  191. border-radius: 12px;
  192. border: 3px solid #48D68E;
  193. color: #ffffff;
  194. background-color: #000000;
  195. margin-right: 20px;
  196. padding: 5px 80px;
  197. cursor: pointer;
  198. display: flex;
  199. align-items: center;
  200. font-size: 18px;
  201. }
  202. }
  203. }
  204. .go_register {
  205. text-align: right;
  206. margin-top: 20px;
  207. span {
  208. color: #48D68E;
  209. cursor: pointer;
  210. font-size: 20px;
  211. }
  212. }
  213. }
  214. }
  215. .home_mid {
  216. // background-color: blanchedalmond;
  217. width: 1200px;
  218. left: 0;
  219. right: 0;
  220. margin: auto;
  221. margin-top: 40px;
  222. // position: relative;
  223. .kepu_title {
  224. text-align: center;
  225. font-size: 50px;
  226. color: #111111;
  227. line-height: 95px;
  228. // width: 100%;
  229. // left: 0;
  230. // right: 0;
  231. // margin: auto
  232. }
  233. .kepu_title_sub {
  234. margin-top: 30px;
  235. text-align: center;
  236. font-size: 28px;
  237. color: #48D68E;
  238. line-height: 26px;
  239. }
  240. .man1_group {
  241. margin-top: 60px;
  242. height: 100%;
  243. display: flex;
  244. .man1 {
  245. position: relative;
  246. width: 327px;
  247. // height: 100%;
  248. // height: 100%
  249. .man1_img {
  250. position: absolute;
  251. bottom: 0;
  252. /* bottom: 0px; */
  253. /* height: auto; */
  254. width: 100%;
  255. left: 100px
  256. }
  257. }
  258. .des {
  259. border: #48D68E solid 5px;
  260. border-radius: 40px;
  261. padding: 20px;
  262. letter-spacing: 6px;
  263. flex: 1;
  264. .des_inner {
  265. border: 1px dashed #48D68E;
  266. border-radius: 40px;
  267. padding-bottom: 40px;
  268. padding-top: 30px;
  269. padding-left: 100px;
  270. padding-right: 20px;
  271. letter-spacing: 6px;
  272. font-weight: normal;
  273. font-size: 24px;
  274. color: #333333;
  275. line-height: 40px;
  276. }
  277. }
  278. }
  279. .man2_group {
  280. margin-top: 60px;
  281. height: 100%;
  282. display: flex;
  283. .man2 {
  284. position: relative;
  285. width: 327px;
  286. // height: 100%;
  287. // height: 100%
  288. .man2_img {
  289. position: absolute;
  290. bottom: 0;
  291. /* bottom: 0px; */
  292. /* height: auto; */
  293. width: 100%;
  294. left: -100px
  295. }
  296. }
  297. .des2 {
  298. border: #48D68E solid 5px;
  299. border-radius: 40px;
  300. padding: 20px;
  301. letter-spacing: 6px;
  302. flex: 1;
  303. .des2_inner {
  304. border: 1px dashed #48D68E;
  305. border-radius: 40px;
  306. padding-bottom: 40px;
  307. padding-top: 30px;
  308. padding-left: 20px;
  309. padding-right: 100px;
  310. letter-spacing: 6px;
  311. font-weight: normal;
  312. font-size: 24px;
  313. color: #333333;
  314. line-height: 40px;
  315. }
  316. }
  317. }
  318. .get_more {
  319. text-align: center;
  320. img {
  321. width: 300px;
  322. margin-top: 60px;
  323. margin-bottom: 60px;
  324. }
  325. }
  326. }
  327. // .home_footer_out {
  328. // width: 100%;
  329. // background-color: #000000;
  330. // }</style>