Login.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. <template>
  2. <div class="login-par">
  3. <div class="changeLanguage">
  4. <span @click="changeLanguage" :class="$i18n.locale=='zh-CN'?'choseColor':'noColor'">中文</span>
  5. /
  6. <span @click="changeLanguage" :class="$i18n.locale=='zh-CN'?'noColor':'choseColor'">Engilsh</span>
  7. </div>
  8. <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-position="left" label-width="0px" class="demo-ruleForm login-container">
  9. <div class="login-logo">
  10. <img src="../assets/image/login_logo.png" style="width:80px;height:80px;"/>
  11. </div>
  12. <h3 class="title">{{$t('base.title')}}</h3>
  13. <el-form-item class="login-input" prop="account">
  14. <el-input type="text" v-model="ruleForm.account" autocomplete="off" :placeholder="$t('base.account')" clearable prefix-icon="el-icon-user-solid"></el-input>
  15. </el-form-item>
  16. <el-form-item class="login-input" prop="password">
  17. <el-input type="password" v-model="ruleForm.password" @keyup.enter.native="handleSubmit" autocomplete="off" :placeholder="$t('base.password')" show-password prefix-icon="el-icon-lock"></el-input>
  18. </el-form-item>
  19. <el-form-item class="login-button" style="width:100%;">
  20. <el-button type="primary" style="width:100%;" @click.native.prevent="handleSubmit" :loading="logining">{{$t('base.login')}}</el-button>
  21. </el-form-item>
  22. <div style="float:right;margin-top:7px;"><a href="http://www.yunsu.cn">返回官网</a></div>
  23. </el-form>
  24. <div class="login-backImg">
  25. <img src="../assets/image/login_center.png" />
  26. </div>
  27. </div>
  28. </template>
  29. <script>
  30. export default {
  31. data() {
  32. const msg = (rule, value, callback) => {
  33. if (!value) {
  34. if(rule.field == "account") {
  35. return callback(new Error(this.$t('msg.loginAcc')));
  36. } else {
  37. return callback(new Error(this.$t('msg.loginPass')));
  38. }
  39. } else {
  40. callback();
  41. }
  42. };
  43. return {
  44. logining: false,
  45. // 登录信息
  46. ruleForm: {
  47. account: '',
  48. password: ''
  49. },
  50. rules: {
  51. account: [
  52. { required: true, validator: msg , trigger: 'blur' },
  53. ],
  54. password: [
  55. { required: true, validator: msg , trigger: 'blur' },
  56. ]
  57. }
  58. };
  59. },
  60. methods: {
  61. handleReset2() {
  62. this.$refs.ruleForm.resetFields();
  63. },
  64. changeLanguage() {
  65. this.$confirm(this.$t('msg.changeLanguage'), this.$t('el.messagebox.title'), {
  66. confirmButtonText: this.$t('el.messagebox.confirm'),
  67. cancelButtonText: this.$t('el.messagebox.cancel'),
  68. type: 'warning'
  69. }).then(() => {
  70. this.$router.go(0);
  71. if ( this.$i18n.locale === 'zh-CN' ) {
  72. this.$i18n.locale = 'en-US';
  73. localStorage.lang = 'en-US';
  74. }else {
  75. this.$i18n.locale = 'zh-CN';
  76. localStorage.lang = 'zh-CN';
  77. }
  78. }).catch(() => {});
  79. },
  80. handleSubmit() {
  81. this.$refs.ruleForm.validate((valid) => {
  82. if (valid) {
  83. var _this = this;
  84. this.logining = true;
  85. this.http.post(this.port.manage.login, this.ruleForm , res => {
  86. this.logining = false;
  87. if (res.code == "ok") {
  88. sessionStorage.setItem('user', JSON.stringify(res.data));
  89. this.$router.push({ path: '/map' });
  90. } else {
  91. this.$message({
  92. message: res.msg,
  93. type: 'error'
  94. });
  95. }
  96. }, error => {
  97. this.logining = false;
  98. this.$message({
  99. message: error,
  100. type: 'error'
  101. });
  102. })
  103. }
  104. });
  105. }
  106. }
  107. }
  108. </script>
  109. <style lang="scss" scoped>
  110. .login-par {
  111. position: relative;
  112. }
  113. .changeLanguage {
  114. position: absolute;
  115. right:30px;
  116. top:-160px;
  117. font-size: 17px;
  118. cursor: pointer;
  119. .choseColor {
  120. color: #409EFF;
  121. }
  122. .noColor {
  123. color: #cac6c6;
  124. }
  125. }
  126. .login-logo {
  127. text-align: center;
  128. margin: 0 0 20px 0;
  129. }
  130. .login-container {
  131. /*box-shadow: 0 0px 8px 0 rgba(0, 0, 0, 0.06), 0 1px 0px 0 rgba(0, 0, 0, 0.02);*/
  132. -webkit-border-radius: 5px;
  133. border-radius: 5px;
  134. -moz-border-radius: 5px;
  135. background-clip: padding-box;
  136. margin: 180px auto;
  137. // width: 350px;
  138. width: 315px;
  139. height: 365px;
  140. // padding: 35px 35px 15px 35px;
  141. padding: 25px 35px 25px 35px;
  142. background: #fff;
  143. border: 1px solid #eaeaea;
  144. box-shadow: 0 0 5px #cac6c6;
  145. border-top: 10px solid #409EFF;
  146. .title {
  147. font-size: 20px;
  148. margin: 0px auto 40px auto;
  149. text-align: center;
  150. color: #505458;
  151. }
  152. .remember {
  153. margin: 0px 0px 35px 0px;
  154. }
  155. .login-input {
  156. margin: 30px 0 0 0;
  157. }
  158. .login-button {
  159. margin: 30px 0 0 0;
  160. }
  161. .login-button .el-button {
  162. padding: 14px;
  163. }
  164. }
  165. .login-backImg {
  166. position: absolute;
  167. width: 100%;
  168. height: 350px;
  169. background-color: #409EFF;
  170. top: 110px;
  171. z-index: -1;
  172. img {
  173. width: 100%;
  174. height: 100%;
  175. }
  176. }
  177. </style>