车辆管理系统-后台管理系统web
spring
4 天以前 9a11bff3d98aea29f37abc34a00a17f5c92ade9c
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
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
<template>
  <div class="login-container">
    <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="phone">
        <el-input
          v-model="formInline.phone"
          placeholder="请输入您的手机号"
          prefix-icon="el-icon-phone-outline"
        />
      </el-form-item>
      <el-form-item prop="password">
        <el-input
          :key="passwordType"
          v-model="formInline.password"
          :type="passwordType"
          placeholder="密码"
          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-form-item prop="domain">
        <el-input
          v-model="formInline.domain"
          placeholder="请输入网址域名"
          prefix-icon="el-icon-position"
        />
      </el-form-item>
      <el-form-item prop="code" class="captcha">
        <div class="acea-row" style="flex-wrap: nowrap;">
          <el-input
            v-model="formInline.code"
            placeholder="验证码"
            type="text"
            tabindex="1"
            autocomplete="off"
            prefix-icon="el-icon-message"
            style="width: 90%"
          />
          <el-button size="mini" :disabled=!this.canClick @click="cutDown" v-hasPermi="['admin:pass:send:code']">{{cutNUm}}</el-button>
        </div>
      </el-form-item>
      <el-button  :loading="loading" type="primary" style="width:100%;margin-bottom:20px;" @click="handleSubmit('formInline')" v-hasPermi="['admin:pass:register']">注册</el-button>
      <el-button  type="primary" style="width:100%;margin-bottom:20px;" @click="changelogo" v-hasPermi="['admin:pass:login']">立即登录</el-button>
    </el-form>
  </div>
</template>
 
<script>
import { captchaApi, registerApi } from '@/api/sms'
export default {
  name: 'Register',
  data() {
    const validatePhone = (rule, value, callback) => {
      if (!value) {
        return callback(new Error('请填写手机号'))
      } else if (!/^1[3456789]\d{9}$/.test(value)) {
        callback(new Error('手机号格式不正确!'))
      } else {
        callback()
      }
    }
    return {
      loading: false,
      passwordType: 'password',
      captchatImg: '',
      cutNUm: '获取验证码',
      canClick: true,
      formInline: {
        account: '',
        code: '',
        domain: '',
        phone: '',
        password: ''
      },
      ruleInline: {
        password: [
          { required: true, message: '请输入短信平台密码/token', trigger: 'blur' }
        ],
        domain: [
          { required: true, message: '请输入网址域名', trigger: 'blur' }
        ],
        phone: [
          { required: true, validator: validatePhone, trigger: 'blur' }
        ],
        code: [
          { required: true, message: '请输入验证码', trigger: 'blur' }
        ]
      }
    }
  },
  methods: {
    showPwd() {
      if (this.passwordType === 'password') {
        this.passwordType = ''
      } else {
        this.passwordType = 'password'
      }
      this.$nextTick(() => {
        this.$refs.password.focus()
      })
    },
    // 短信验证码
    cutDown() {
      if (this.formInline.phone) {
        if (!this.canClick) return
        this.canClick = false
        this.cutNUm = 60
        captchaApi({
          phone: this.formInline.phone,
          types: 0
        }).then(async res => {
          this.$message.success('发送成功')
        })
        const time = setInterval(() => {
          this.cutNUm--
          if (this.cutNUm === 0) {
            this.cutNUm = '获取验证码'
            this.canClick = true
            clearInterval(time)
          }
        }, 1000)
      } else {
        this.$message.warning('请填写手机号!')
      }
    },
    // 注册
    handleSubmit(name) {
      this.formInline.account = this.formInline.phone
      this.$refs[name].validate((valid) => {
        if (valid) {
          this.loading = true;
          registerApi(this.formInline).then(async res => {
            this.$message.success('注册成功')
            setTimeout(() => {
              this.changelogo()
            }, 1000)
            this.loading = false;
          }).catch(()=>{
            this.loading = false;
          })
        } else {
          return false
        }
      })
    },
    // 立即登录
    changelogo() {
      this.$emit('on-change')
    }
  }
}
</script>
<style lang="scss" scoped>
  .el-button+.el-button{
    margin-left: 0px !important;
  }
  .title{
    text-align: center;
  }
  .captcha{
    display: flex;
    align-items: flex-start;
    ::v-deep.el-form-item__content{
      width: 100%;
    }
  }
  $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>