车辆管理系统-后台管理系统web
liding
3 天以前 e4b773b5936ec1fa3747fd3d35b85799773d5f39
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
<template>
  <div class="login-container">
    <el-row type="flex">
      <el-col :span="24">
        <el-form ref="formInline" size="small" :model="formInline" :rules="ruleInline" class="login-form"
                 autocomplete="on" label-position="left">
          <div class="title-container">
            <h3 class="title mb15">短信账户登录</h3>
          </div>
          <el-form-item prop="account">
            <el-input
              ref="account"
              v-model="formInline.account"
              placeholder="用户名"
              prefix-icon="el-icon-user"
              name="username"
              type="text"
              tabindex="1"
              autocomplete="off"
            />
          </el-form-item>
          <el-form-item prop="password">
            <el-input
              :key="passwordType"
              ref="password"
              v-model="formInline.password"
              :type="passwordType"
              placeholder="密码"
              name="password"
              tabindex="2"
              auto-complete="off"
              prefix-icon="el-icon-lock"
            />
            <span class="show-pwd" @click="showPwd">
              <svg-icon :icon-class="passwordType === 'password' ? 'eye' : 'eye-open'"/>
            </span>
          </el-form-item>
          <el-button size="mini" :loading="loading" type="primary" style="width:100%;margin-bottom:20px;"
                     @click="handleSubmit('formInline')">登录
          </el-button>
          <div class="acea-row row-center-wrapper mb20">
            <el-button size="mini" type="text" style="margin-left: 0" @click="changePassword">忘记密码</el-button>
            <el-divider direction="vertical"></el-divider>
            <el-button size="mini" type="text" style="margin-left: 0" @click="changeReg">注册账户</el-button>
          </div>
          <el-tooltip class="item" effect="dark" content="
              一号通为我司一个第三方平台
              专门提供短信 , 物流查询,商品复制,电子面单等个性化服务
              省去了自己单独接入功能的麻烦
              初次运行代码默认是没有账号的,需要自行注册,
              登录成功后根据提示购买自己需要用到的服务即可" placement="bottom">
            <span style="margin-left: 0">平台说明</span>
          </el-tooltip>
        </el-form>
      </el-col>
    </el-row>
  </div>
</template>
 
<script>
import { configApi } from '@/api/sms'
export default {
  name: 'Login',
  data() {
    return {
      formInline: {
        account: '',
        password: ''
      },
      ruleInline: {
        account: [
          { required: true, message: '请输入用户名', trigger: 'blur' }
        ],
        password: [
          { required: true, message: '请输入密码', trigger: 'blur' }
        ]
      },
      passwordType: 'password',
      loading: false
    }
  },
  created() {
    var _this = this
    document.onkeydown = function(e) {
      const key = window.event.keyCode
      if (key === 13) {
        _this.handleSubmit('formInline')
      }
    }
  },
  methods: {
    showPwd() {
      if (this.passwordType === 'password') {
        this.passwordType = ''
      } else {
        this.passwordType = 'password'
      }
      this.$nextTick(() => {
        this.$refs.password.focus()
      })
    },
    handleSubmit(name) {
      this.$refs[name].validate((valid) => {
        if (valid) {
          this.loading = true;
          configApi(this.formInline).then(async res => {
            this.$message.success('登录成功!')
            this.$store.dispatch('user/isLogin')
            this.$emit('on-Login')
            this.loading = false;
          }).catch(()=>{
            this.loading = false;
          })
        } else {
          return false
        }
      })
    },
    // 修改密码
    changePassword() {
      this.$emit('on-change')
    },
    changeReg() {
      this.$emit('on-changes')
    }
  }
}
</script>
<style lang="scss" scoped>
  .title{
    text-align: center;
  }
  .captcha{
    display: flex;
    align-items: flex-start;
  }
  $bg: #2d3a4b;
  $dark_gray: #889aa4;
  $light_gray: #eee;
  .imgs{
    img{
      height: 36px;
    }
  }
  .login-form {
    flex: 1;
    padding: 32px 0;
    text-align: center;
    width: 384px;
    margin: 0 auto;
    overflow: hidden;
  }
  .tips {
    font-size: 14px;
    color: #fff;
    margin-bottom: 10px;
 
    span {
      &:first-of-type {
        margin-right: 16px;
      }
    }
  }
  .svg-container {
    padding: 6px 5px 6px 15px;
    color: $dark_gray;
    vertical-align: middle;
    width: 30px;
    display: inline-block;
  }
  .show-pwd {
    position: absolute;
    right: 10px;
    top: 7px;
    font-size: 16px;
    color: $dark_gray;
    cursor: pointer;
    user-select: none;
    ::v-deep.svg-icon {
      vertical-align: 0.3em;
    }
  }
  .thirdparty-button {
    position: absolute;
    right: 0;
    bottom: 6px;
  }
</style>