login.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  1. <template>
  2. <div class="login">
  3. <div class="loginMai">
  4. <div class="loginPir">
  5. <div class="loginPir-t">
  6. <!-- <img src="../../assets/img/logo1.png" alt="" srcset=""> -->
  7. </div>
  8. <div class="loginPir-c">
  9. <div class="loginPir-cLR">
  10. <div class="loginPir-c-L">
  11. <h1>冷链验证报告线上</h1>
  12. <div class="loginPir-c-L">
  13. 验证模板管理、校准证书管理
  14. </div>
  15. </div>
  16. <div class="loginPir-c-R">
  17. <div class="loginPir-c-R1">
  18. 账号登录/Login
  19. </div>
  20. <div class="loginPir-c-R2">
  21. <div style="margin-bottom: 15px;">
  22. <el-input v-model="Info.bzd_username" placeholder="请输入内容"></el-input>
  23. </div>
  24. <div style="margin-bottom: 15px;">
  25. <el-input placeholder="请输入密码" v-model="Info.bzd_password" show-password></el-input>
  26. </div>
  27. <div style="margin-bottom: 15px;">
  28. <el-select v-model="Info.value" placeholder="请选择" style="width: 100%;">
  29. <el-option v-for="item in options" :key="item.value" :label="item.label"
  30. :value="item.value">
  31. </el-option>
  32. </el-select>
  33. </div>
  34. <div style="margin-top: 40px;">
  35. <el-button type="primary" style="width: 100%;" @click="login">登录</el-button>
  36. </div>
  37. </div>
  38. </div>
  39. </div>
  40. </div>
  41. <div class="loginPir-b"></div>
  42. </div>
  43. </div>
  44. </div>
  45. </template>
  46. <script>
  47. import {
  48. UserLogin,AdminLogin
  49. } from '@/api/login.js'
  50. export default {
  51. data(){
  52. return{
  53. Info: {
  54. bzd_username: '',
  55. bzd_password: '',
  56. value:'2'
  57. },
  58. options: [{
  59. value: '1',
  60. label: '管理员登录'
  61. }, {
  62. value: '2',
  63. label: '用户登录'
  64. }],
  65. }
  66. },
  67. methods:{
  68. login(){
  69. if(this.Info.bzd_username===''){
  70. this.$message.error('请输入登录账号')
  71. return
  72. }else if(this.Info.bzd_username===''){
  73. this.$message.error('请输入登录密码')
  74. return
  75. }else{
  76. if(this.Info.value==1){
  77. this.GetadminLgApi()
  78. }else{
  79. this.GetuserLgApi()
  80. }
  81. }
  82. },
  83. GetuserLgApi(){//用户登录
  84. var obj = {
  85. bzd_username : this.Info.bzd_username,
  86. bzd_password : this.$md5(this.Info.bzd_password)
  87. }
  88. UserLogin(obj).then(res=>{
  89. if(res.data.Code==200){
  90. this.$store.commit('setuserInfo', {
  91. username: this.Info.bzd_username,
  92. password: this.Info.bzd_password,
  93. value:this.Info.value,
  94. token: res.data.Data
  95. })
  96. this.$router.replace('/home')
  97. }
  98. })
  99. },
  100. GetadminLgApi(){//管理员登录
  101. var obj = {
  102. bzd_username : this.Info.bzd_username,
  103. bzd_password : this.$md5(this.Info.bzd_password)
  104. }
  105. AdminLogin(obj).then(res=>{
  106. if(res.data.Code==200){
  107. this.$store.commit('setuserInfo', {
  108. username: this.Info.bzd_username,
  109. password: this.Info.bzd_password,
  110. value:this.Info.value,
  111. token: res.data.Data
  112. })
  113. this.$router.replace('/home')
  114. }
  115. })
  116. }
  117. }
  118. }
  119. </script>
  120. <style lang="scss">
  121. .login {
  122. user-select: none;
  123. background: #fff;
  124. .loginMai {
  125. height: 100vh;
  126. width: 100%;
  127. display: flex;
  128. align-items: center;
  129. .loginPir {
  130. width: 100%;
  131. display: flex;
  132. flex-direction: column;
  133. .loginPir-t {
  134. height: 80px;
  135. margin: 0 auto;
  136. }
  137. .loginPir-c {
  138. flex: 1;
  139. height: 500px;
  140. background-image: url('../../assets/img/BJ.jfif');
  141. background-size:cover;
  142. background-repeat: no-repeat;
  143. @media screen and (max-width: 1200px) {
  144. .loginPir-cLR {
  145. height: 100%;
  146. margin: 0 auto;
  147. display: flex;
  148. align-items: center;
  149. justify-content: center;
  150. .loginPir-c-L {
  151. display: none;
  152. color: #fff;
  153. h1{
  154. letter-spacing: 5px;
  155. }
  156. }
  157. .loginPir-c-R {
  158. background: #fff;
  159. border-radius: 4px;
  160. padding: 40px 30px;
  161. width: 300px;
  162. .loginPir-c-R1 {
  163. padding-bottom: 30px;
  164. letter-spacing: 2px;
  165. color: #606266;
  166. }
  167. }
  168. }
  169. }
  170. @media screen and (min-width: 1200px) {
  171. .loginPir-cLR {
  172. max-width: 1200px;
  173. height: 100%;
  174. margin: 0 auto;
  175. display: flex;
  176. align-items: center;
  177. justify-content: space-between;
  178. .loginPir-c-L {
  179. color: #fff;
  180. h1{
  181. letter-spacing: 5px;
  182. }
  183. }
  184. .loginPir-c-R {
  185. background: #fff;
  186. border-radius: 4px;
  187. padding: 40px 30px;
  188. width: 300px;
  189. .loginPir-c-R1 {
  190. padding-bottom: 30px;
  191. letter-spacing: 2px;
  192. color: #606266;
  193. }
  194. }
  195. }
  196. }
  197. }
  198. .loginPir-b {
  199. height: 80px;
  200. }
  201. }
  202. }
  203. }
  204. </style>