You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

208 lines
5.4 KiB

3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
  1. <template>
  2. <div class="site-wrapper site-page--login">
  3. <div class="site-content__wrapper">
  4. <div class="site-content">
  5. <div class="login-main">
  6. <h3 class="login-title">用户登陆</h3>
  7. <el-form :model="dataForm" :rules="dataRule" ref="dataForm" @keyup.enter.native="dataFormSubmit()" status-icon>
  8. <!-- <el-form-item>-->
  9. <!-- <el-select v-model="dataForm.site" style="width: 230px"-->
  10. <!-- placeholder="请选择工厂">-->
  11. <!-- <el-option-->
  12. <!-- v-for="(item,index) in siteList"-->
  13. <!-- :key="index"-->
  14. <!-- :label="item.siteID+' - '+item.siteName"-->
  15. <!-- :value="item.siteID"-->
  16. <!-- >-->
  17. <!-- </el-option>-->
  18. <!-- </el-select>-->
  19. <!-- </el-form-item>-->
  20. <el-form-item prop="userName">
  21. <el-input v-model="dataForm.userName" placeholder="帐号"></el-input>
  22. </el-form-item>
  23. <el-form-item prop="password">
  24. <el-input v-model="dataForm.password" type="password" placeholder="密码"></el-input>
  25. </el-form-item>
  26. <el-form-item>
  27. <el-button class="login-btn-submit" type="primary" @click="dataFormSubmit()">登录</el-button>
  28. </el-form-item>
  29. </el-form>
  30. </div>
  31. </div>
  32. </div>
  33. </div>
  34. </template>
  35. <script>
  36. import {
  37. getSiteData,
  38. } from "@/api/base/site.js"
  39. import { getUUID } from '@/utils'
  40. export default {
  41. data () {
  42. return {
  43. src: 'http://192.168.1.83/upload/ifs.png',
  44. dataForm: {
  45. userName: '',
  46. password: '',
  47. uuid: '',
  48. captcha: '',
  49. site:''
  50. },
  51. siteList:[],
  52. dataRule: {
  53. userName: [
  54. { required: true, message: '帐号不能为空', trigger: 'blur' }
  55. ],
  56. password: [
  57. { required: true, message: '密码不能为空', trigger: 'blur' }
  58. ]
  59. },
  60. captchaPath: ''
  61. }
  62. },
  63. created () {
  64. this.userName();
  65. // this.getSiteData();
  66. },
  67. methods: {
  68. // getSiteData(){
  69. // let data={};
  70. // getSiteData(data).then(({data}) => {
  71. // this.siteList = data.rows
  72. // if(this.siteList.length>0){
  73. // this.dataForm.site=this.siteList[0].siteID
  74. // }
  75. // })
  76. // },
  77. // 获取上次登陆的用户名
  78. userName(){
  79. this.dataForm.userName = localStorage.getItem('userName')
  80. },
  81. // 提交表单
  82. dataFormSubmit () {
  83. this.$refs['dataForm'].validate((valid) => {
  84. if (valid) {
  85. this.$http({
  86. url: this.$http.adornUrl('/sys/login'),
  87. method: 'post',
  88. data: this.$http.adornData({
  89. 'username': this.dataForm.userName,
  90. 'password': this.dataForm.password,
  91. 'uuid': this.dataForm.uuid,
  92. 'site': this.dataForm.site,
  93. })
  94. }).then(({data}) => {
  95. if (data && data.code === 0) {
  96. this.$cookie.set('token', data.token)
  97. this.$router.replace({ name: 'home' })
  98. this.$i18n.locale=data.language
  99. localStorage.setItem('locale', data.language)
  100. localStorage.setItem('refresh', "0")
  101. localStorage.setItem('userName', this.dataForm.userName)
  102. // localStorage.setItem('accessSite', this.dataForm.site)
  103. } else {
  104. this.$message.error(data.msg)
  105. }
  106. })
  107. }
  108. })
  109. },
  110. }
  111. }
  112. </script>
  113. <style lang="scss" scoped>
  114. .site-wrapper.site-page--login {
  115. position: absolute;
  116. top: 0;
  117. right: 0;
  118. bottom: 0;
  119. left: 0;
  120. background-color: rgba(38, 50, 56, 0);
  121. overflow: hidden;
  122. &:before {
  123. position: fixed;
  124. top: 0;
  125. left: 0;
  126. z-index: -1;
  127. width: 80%;
  128. height: 100%;
  129. content: "";
  130. background-image: url(~@/assets/img/login_bg.jpg);
  131. background-size: cover;
  132. }
  133. .site-content__wrapper {
  134. position: absolute;
  135. top: 0;
  136. right: 0;
  137. bottom: 0;
  138. left: 0;
  139. padding: 0;
  140. margin: 0;
  141. overflow-x: hidden;
  142. overflow-y: auto;
  143. background-color: transparent;
  144. }
  145. .site-content {
  146. min-height: 100%;
  147. padding: 15% 500px 30px 30px;
  148. }
  149. .brand-info {
  150. margin: 220px 100px 0 90px;
  151. color: #fff;
  152. }
  153. .brand-info__text {
  154. margin: 0 0 22px 0;
  155. font-size: 48px;
  156. font-weight: 400;
  157. text-transform : uppercase;
  158. }
  159. .brand-info__intro {
  160. margin: 10px 0;
  161. font-size: 16px;
  162. line-height: 1.58;
  163. opacity: .6;
  164. }
  165. .login-main {
  166. position: absolute;
  167. top: 0;
  168. right: 0;
  169. padding: 15% 60px 180px;
  170. width: 350px;
  171. min-height: 100%;
  172. background-color: #fff;
  173. }
  174. .login-title {
  175. font-size: 30px;
  176. }
  177. .login-captcha {
  178. overflow: hidden;
  179. > img {
  180. width: 100%;
  181. cursor: pointer;
  182. }
  183. }
  184. .login-btn-submit {
  185. width: 100%;
  186. }
  187. .login-main .el-input__inner{
  188. margin-top: 10px;
  189. height: 45px;
  190. }
  191. .el-button--medium {
  192. margin-top: 0px;
  193. padding: 5px 11px;
  194. font-size: 16px;
  195. border-radius: 4px;
  196. }
  197. .el-form-item {
  198. margin-bottom: 5px;
  199. }
  200. }
  201. </style>