Mr.Zhang
2023-10-13 07fe15e78682fb78ed84f09b9eb0913f2f96b442
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
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
<template>
  <div class="contant">
    <!-- <CommonHeader :isLogined="false" /> -->
    <div class="login-content">
      <div class="wrap">
        
        <div class="introduce">
          <h2>滨湖自行车租赁系统</h2>
        </div>
        <div class="login">
          <h1>账号登录</h1>
          <div class="info-input">
            <div class="login-title">用户名</div>
            <el-input v-model="username" placeholder="请输入用户名" maxlength="50" v-trim/>
            <div class="login-title">密码</div>
            <el-input v-model="password" placeholder="请输入密码" type="password" maxlength="30" show-password/>
            <div class="login-title">验证码</div>
            <div class="captcha-input">
              <el-input v-model="captcha.value" placeholder="图片验证码" maxlength="4" @keypress.enter.native="login"/>
              <img v-if="!captcha.loading" :src="captcha.uri" @click="refreshCaptcha">
              <span v-else><i class="el-icon-loading"></i></span>
            </div>
          </div>
          <div class="loginBtn"><el-button :loading="loading" @click="login">立即登录</el-button></div>
        </div>
      </div>
    </div>
    <div class="copyright">
      <!-- <div>技术支持:<el-button type="text" style="color: red">豆米科技</el-button></div> -->
      <div class="copyright" @click="gotoWeb">Copyright © 2022 - 2027 豆米科技. All Rights Reserved.  版权所有</div>
    </div>
  </div>
</template>
 
<script>
import { mapMutations } from 'vuex'
import CommonHeader from '@/components/common/CommonHeader'
import { getCaptcha, loginByPassword } from '@/api/system/common'
 
export default {
  name: 'Login',
  components: {
    CommonHeader
  },
  data () {
    return {
      loading: false,
      username: '',
      password: '',
      // 验证码
      captcha: {
        loading: false,
        value: '',
        uuid: '',
        uri: ''
      }
    }
  },
  methods: {
    ...mapMutations(['setUserInfo']),
    // 登录
    login () {
      if (this.loading) {
        return
      }
      if (!this.__check()) {
        return
      }
      this.loading = true
      loginByPassword({
        username: this.username.trim(),
        password: this.password,
        code: this.captcha.value.trim(),
        uuid: this.captcha.uuid
      })
        .then(() => {
          window.location.href = process.env.VUE_APP_CONTEXT_PATH
        })
        .catch(e => {
          this.refreshCaptcha()
          this.$tip.apiFailed(e)
        })
        .finally(() => {
          this.loading = false
        })
    },
    // 刷新验证码
    refreshCaptcha () {
      this.captcha.loading = true
      getCaptcha()
        .then(data => {
          this.captcha.uri = data.image
          this.captcha.uuid = data.uuid
        })
        .catch(e => {
          this.$tip.apiFailed(e)
        })
        .finally(() => {
          setTimeout(() => {
            this.captcha.loading = false
          }, 150)
        })
    },
    // 登录前验证
    __check () {
      if (this.username.trim() === '') {
        this.$tip.error('请输入用户名')
        return false
      }
      if (this.password === '') {
        this.$tip.error('请输入密码')
        return false
      }
      if (this.captcha.value.trim() === '') {
        this.$tip.error('请输入图片验证码')
        return false
      }
      return true
    },
    gotoWeb() {
      window.open('http://www.doumee.com', '_blank')
    }
  },
  created () {
    this.refreshCaptcha()
  }
}
</script>
 
<style scoped lang="scss">
@import "@/assets/style/variables.scss";
$input-gap: 30px;
.contant {
  height: 100%;
  background-color: #F3F7FA;
  position: relative;
  .copyright {
    position: absolute;
    margin: auto;
    bottom: 10px;
    right: 0;
    left: 0;
    text-align: center;
    width: 372px;
    height: 12px;
    line-height: 12px;
    color: #828d9e;
    cursor: pointer;
  }
}
.login-content {
  height: calc(100% - 70px);
  background-image: url("../assets/images/login_bg.png");
  background-repeat: no-repeat;
  // background-size: auto 180%;
  background-clip: content-box;
  background-position: center;
  position: relative;
}
.wrap {
  display: flex;
  width: 900px;
  height: 570px;
  position: absolute;
  margin: auto;
  left: 0;
  right: 0;
  top: 0;
  bottom: 0;
  // background-image: url("../assets/images/login.jpg");
  // background-repeat: no-repeat;
  // background-size: auto 180%;
  // background-clip: content-box;
  // background-position: center;
  box-shadow: 0px 20px 60px 0px rgba(0,0,0,0.11);
  border-radius: 8px;
  // 左边介绍
  .introduce {
    // padding-left: 10%;
    width: 420px;
    height: 100%;
    box-sizing: border-box;
    background-image: url("../assets/images/login_img.jpg");
    background-repeat: no-repeat;
    background-size: 100% 100%;
    // background-clip: content-box;
    background-position: center;
    color: #fff;
    // background: rgba(0, 0, 0, 0.4);
    // display: flex;
    // flex-direction: column;
    // justify-content: center;
    h2 {
      text-align: center;
      font-size:28px;
      // font-style: italic;
      font-weight: 900;
      margin-top: 75px;
      line-height: 34px;
      text-shadow: 0px 2px 14px rgba(0,0,0,0.17);
    }
    
  }
  // 右边登录
  .login {
    height: 100%;
    width: 480px;
    // max-width: 560px;
    // min-width: 460px;
    flex-shrink: 0;
    box-sizing: border-box;
    // text-align: center;
    background: #fff;
    padding: 120px 90px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    box-sizing: border-box;
    h1 {
      font-size: 26px;
      font-weight: 600;
      color: #222222;
    }
    .info-input {
      margin-top: 46.5px;
      margin-bottom: 30px;
      ::v-deep .el-input {
        margin-top: 10px;
        margin-bottom: 18px;
        .el-input__inner {
          height: 30px;
          // background-color: #fff;
          // border: 1px solid transparent;
          &:focus {
            border: 1px solid $primary-color;
          }
        }
      }
    }
    // 验证码输入
    .captcha-input {
      display: flex;
      margin-top: 12px;
      height: 30px;
      .el-input {
        width: 100%;
        margin-top: 0;
      }
      span, img {
        width: 45%;
        height: 100%;
        flex-shrink: 0;
        margin-left: 16px;
        background-color: #f7f7f7;
      }
      span {
        display: flex;
        align-items: center;
        justify-content: center;
        background: #f7f7f7;
        border-radius: 8px;
      }
    }
    .loginBtn {
      .el-button {
        height: 35px;
        width: 100%;
        color: #fff;
        font-size: 12px;
        background: linear-gradient(130deg, $primary-title-start-color 0%, $primary-title-color 100%);
      }
    }
  }
}
.copyright {
  text-align: center;
  width: 100%;
  height: 12px;
  font-size: 12px;
  font-family: PingFangSC-Regular, PingFang SC;
  font-weight: 400;
  color: #828D9E;
  line-height: 12px;
  position: absolute;
  bottom: 20px;
}
.login-title {
  height: 14px;
  font-size: 14px;
  font-family: PingFangSC-Regular, PingFang SC;
  font-weight: 400;
  color: #222222;
  line-height: 14px;
 
}
.register {
  margin-top: 18px;
  height: 14px;
  width: 100%;
  margin: 0 auto;
  text-align: center;
  font-size: 12px;
  font-family: PingFangSC-Regular, PingFang SC;
  font-weight: 400;
  // color: #DFE2E8;
  color: #333;
  // font-weight: 600;
  line-height: 14px;
  
}
</style>