12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- <style lang="css">
- .h1 {
- font-family: "Micrsoft YaHei";
- }
- </style>
- <template>
- <div class="main_bg">
- <div class="login-main">
- <div class="username">
- <i></i>
- <input class="form-control comminput" @keyup.enter="login()" type="text" id="accountValue"
- v-model="loginInfo.accountValue"
- placeholder="账号"/>
- </div>
- <div class="password">
- <em></em>
- <input class="form-control comminput" @keyup.enter="login()" type="password" id="password"
- v-model="loginInfo.password"
- placeholder="密码"/>
- </div>
- <input type="button" value="登 录" class="btn comminput" style="background: #3ed798;color:white;" @click="login()"/>
- <div class="errorInfo">{{errorInfo}}</div>
- </div>
- </div>
- </template>
- <script>
- export default {
- data() {
- return {
- pending: false,
- errorInfo: '',
- loginInfo: {
- rootOrgId: '',
- domain: '',
- accountType:'COMMON_LOGIN_NAME',
- accountValue: '',
- password: ''
- }
- }
- },
- methods: {
- checkAccountValue() {
- this.errorInfo = '';
- if (!this.loginInfo.accountValue) {
- this.errorInfo += '用户名不能为空!\n'
- return false;
- }
- return true;
- },
- checkPassword() {
- this.errorInfo = '';
- if (!this.loginInfo.password) {
- this.errorInfo += '密码不能为空!\n'
- return false;
- }
- return true;
- },
- login() {
- if (!this.checkAccountValue()) {
- return;
- }
- if (!this.checkPassword()) {
- return;
- }
- if (this.pending) {
- return;
- }
- this.pending = true;
- this.$http.post('/api/ecs_core/auth/login', this.loginInfo)
- .then((response) => {
- var user = response.body;
- localStorage.setItem("user_token",user.userToken);
- localStorage.setItem("rootOrgId",user.rootOrgId);
- localStorage.setItem("userName",user.displayName);
- this.$router.replace({path: '/index'})
- this.pending = false;
- }).catch((response) => {
- this.errorInfo += response.body.desc;
- this.pending = false;
- });
- }
- },
- created() {
- this.loginInfo.domain = process.env.VUE_APP_DOMAIN;
- sessionStorage.clear();
- var params = this.$route.query;
- this.loginInfo.rootOrgId = params.orgId;
- }
- }
- </script>
|