| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187 |
- <template>
- <div class="login-par">
- <div class="changeLanguage">
- <span @click="changeLanguage" :class="$i18n.locale=='zh-CN'?'choseColor':'noColor'">中文</span>
- /
- <span @click="changeLanguage" :class="$i18n.locale=='zh-CN'?'noColor':'choseColor'">Engilsh</span>
- </div>
- <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-position="left" label-width="0px" class="demo-ruleForm login-container">
- <div class="login-logo">
- <img src="../assets/image/login_logo.png" style="width:80px;height:80px;"/>
- </div>
- <h3 class="title">{{$t('base.title')}}</h3>
- <el-form-item class="login-input" prop="account">
- <el-input type="text" v-model="ruleForm.account" autocomplete="off" :placeholder="$t('base.account')" clearable prefix-icon="el-icon-user-solid"></el-input>
- </el-form-item>
- <el-form-item class="login-input" prop="password">
- <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>
- </el-form-item>
- <el-form-item class="login-button" style="width:100%;">
- <el-button type="primary" style="width:100%;" @click.native.prevent="handleSubmit" :loading="logining">{{$t('base.login')}}</el-button>
- </el-form-item>
- <div style="float:right;margin-top:7px;"><a href="http://www.yunsu.cn">返回官网</a></div>
- </el-form>
-
- <div class="login-backImg">
- <img src="../assets/image/login_center.png" />
- </div>
-
- </div>
- </template>
- <script>
- export default {
- data() {
- const msg = (rule, value, callback) => {
- if (!value) {
- if(rule.field == "account") {
- return callback(new Error(this.$t('msg.loginAcc')));
- } else {
- return callback(new Error(this.$t('msg.loginPass')));
- }
- } else {
- callback();
- }
- };
- return {
- logining: false,
- // 登录信息
- ruleForm: {
- account: '',
- password: ''
- },
- rules: {
- account: [
- { required: true, validator: msg , trigger: 'blur' },
- ],
- password: [
- { required: true, validator: msg , trigger: 'blur' },
- ]
- }
- };
- },
- methods: {
- handleReset2() {
- this.$refs.ruleForm.resetFields();
- },
- changeLanguage() {
- this.$confirm(this.$t('msg.changeLanguage'), this.$t('el.messagebox.title'), {
- confirmButtonText: this.$t('el.messagebox.confirm'),
- cancelButtonText: this.$t('el.messagebox.cancel'),
- type: 'warning'
- }).then(() => {
- this.$router.go(0);
- if ( this.$i18n.locale === 'zh-CN' ) {
- this.$i18n.locale = 'en-US';
- localStorage.lang = 'en-US';
- }else {
- this.$i18n.locale = 'zh-CN';
- localStorage.lang = 'zh-CN';
- }
- }).catch(() => {});
- },
- handleSubmit() {
- this.$refs.ruleForm.validate((valid) => {
- if (valid) {
- var _this = this;
- this.logining = true;
- this.http.post(this.port.manage.login, this.ruleForm , res => {
- this.logining = false;
- if (res.code == "ok") {
- sessionStorage.setItem('user', JSON.stringify(res.data));
- this.$router.push({ path: '/map' });
- } else {
- this.$message({
- message: res.msg,
- type: 'error'
- });
- }
- }, error => {
- this.logining = false;
- this.$message({
- message: error,
- type: 'error'
- });
- })
- }
- });
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- .login-par {
- position: relative;
- }
- .changeLanguage {
- position: absolute;
- right:30px;
- top:-160px;
- font-size: 17px;
- cursor: pointer;
- .choseColor {
- color: #409EFF;
- }
- .noColor {
- color: #cac6c6;
- }
- }
- .login-logo {
- text-align: center;
- margin: 0 0 20px 0;
- }
- .login-container {
- /*box-shadow: 0 0px 8px 0 rgba(0, 0, 0, 0.06), 0 1px 0px 0 rgba(0, 0, 0, 0.02);*/
- -webkit-border-radius: 5px;
- border-radius: 5px;
- -moz-border-radius: 5px;
- background-clip: padding-box;
- margin: 180px auto;
- // width: 350px;
- width: 315px;
- height: 365px;
- // padding: 35px 35px 15px 35px;
- padding: 25px 35px 25px 35px;
- background: #fff;
- border: 1px solid #eaeaea;
- box-shadow: 0 0 5px #cac6c6;
- border-top: 10px solid #409EFF;
- .title {
- font-size: 20px;
- margin: 0px auto 40px auto;
- text-align: center;
- color: #505458;
- }
- .remember {
- margin: 0px 0px 35px 0px;
- }
- .login-input {
- margin: 30px 0 0 0;
- }
- .login-button {
- margin: 30px 0 0 0;
- }
- .login-button .el-button {
- padding: 14px;
- }
- }
- .login-backImg {
- position: absolute;
- width: 100%;
- height: 350px;
- background-color: #409EFF;
- top: 110px;
- z-index: -1;
- img {
- width: 100%;
- height: 100%;
- }
- }
- </style>
|