123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322 |
- <template>
- <div class="login">
- <div class="position-box">
- <div class="inner-box">
- <img src="../../static/image/logo.png" class="inner-logo" />
- <div class="inner-line"></div>
- <span>重置密码</span>
- </div>
- </div>
- <div class="login-box">
- <div class="login-content">
- <div class="top-icon">
- 重置密码
- </div>
- <div v-loading="isLoading">
- <!-- 密码登录 -->
- <div class="login-password">
- <div class="pass-item">
- <img src="../../static/image/phone-icon.png" class="phone-icon" />
- <el-input placeholder="请输入手机号" v-model="mobile" class="input-phone" :maxlength="11" />
- </div>
- <div class="pass-item">
- <img src="../../static/image/code-icon.png" class="phone-icon" />
- <el-input placeholder="验证码" v-model="code" class="input-phone" :maxlength="4" />
- <div class="get-code" v-if="!showCode" @click.stop="getCode">获取短信验证码</div>
- <div class="get-code" v-else>{{ count }}秒</div>
- </div>
- <div class="pass-item">
- <img src="../../static/image/lock-icon.png" class="lock-icon" />
- <el-input placeholder="新密码" v-model="password" class="input-phone" type="password" />
- </div>
- <div class="pass-item">
- <img src="../../static/image/lock-icon.png" class="lock-icon" />
- <el-input placeholder="确认新密码" v-model="passwordAgian" class="input-phone" type="password" />
- </div>
- </div>
- </div>
- <div class="login-btn" @click.stop="commit">确认</div>
- </div>
- </div>
- </div>
- </template>
- <script>
- import {
- getPhoneCode,
- forgotPassword
- } from '../api/user.js';
- export default {
- data() {
- return {
- isLoading: false, // 请求解决展示loading
- activeIndex: 1,
- mobile: '',
- code: '',
- password: '',
- passwordAgian: '',
- showCode: false,
- count: 60,
- timer: null
- }
- },
- destroyed() {
- clearInterval( this.timer );
- this.timer = null;
- },
- methods: {
- commit() {
- if (!this.mobile.trim()) {
- return this.$message({
- message: '手机号码不能为空',
- type: 'error'
- })
- }
- if (!this.checkPhone(this.mobile)) {
- return this.$message({
- message: '请输入正确的手机号',
- type: 'error'
- })
- }
- if (!this.code.trim()) {
- return this.$message({
- message: '验证码不能为空',
- type: 'error'
- })
- }
- if (!this.password.trim()) {
- return this.$message({
- message: '密码不能为空',
- type: 'error'
- })
- }
- if (!this.passwordAgian.trim()) {
- return this.$message({
- message: '确认密码不能为空',
- type: 'error'
- })
- }
- if (this.password.trim() !== this.passwordAgian.trim()) {
- return this.$message({
- message: '两次密码不一致',
- type: 'error'
- })
- }
- let params = {
- code: this.code,
- mobile: this.mobile,
- newPassword: this.password
- }
- forgotPassword( params ).then( res => {
- if ( res.code == 200 ) {
- this.$router.go(-1);
- }else {
- return this.$message({
- message: res.msg,
- type: 'error'
- })
- }
- } )
- },
- checkPhone(phone) {
- if (!(/^1\d{10}$/.test(phone))) {
- return false;
- } else {
- return true
- }
- },
- // 获取验证码
- getCode() {
- if (!this.mobile.trim()) {
- return this.$message({
- message: '手机号码不能为空',
- type: 'error'
- })
- }
- if (!this.checkPhone(this.mobile)) {
- return this.$message({
- message: '请输入正确的手机号',
- type: 'error'
- })
- }
- let params = {
- mobile: this.mobile,
- type: 1
- };
- this.isLoading = true;
- getPhoneCode(params).then(res => {
- if (res.code == 200) {
- this.isLoading = false;
- this.showCode = true;
- this.$message({
- message: '验证码发送成功',
- type: 'success'
- })
- this.timer = setInterval(() => {
- this.count--;
- if (this.count <= 1) {
- this.showCode = false;
- clearInterval(this.timer);
- }
- }, 1000)
- } else {
- this.isLoading = false;
- return this.$message({
- message: res.msg,
- type: 'error'
- })
- }
- })
- },
- }
- }
- </script>
- <style lang="scss" scoped>
- /deep/ .el-input__inner {
- border: none !important;
- }
- .login {
- position: relative;
- width: 100%;
- height: 100%;
- .position-box {
- position: absolute;
- top: 18px;
- left: 33px;
- .inner-box {
- display: flex;
- align-items: center;
- .inner-logo {
- width: 204px;
- height: 44px;
- }
- .inner-line {
- width: 1px;
- height: 24px;
- background-color: #eee;
- margin: 0 40px;
- }
- span {
- font-size: 18px;
- font-family: PingFang SC;
- font-weight: 400;
- color: #333333;
- }
- }
- }
- .login-box {
- position: relative;
- z-index: 200;
- height: 100vh;
- display: flex;
- display: -webkit-flex;
- align-items:center;
- justify-content:center;
- .login-content {
- background-color: #fff;
- border-radius: 14px;
- width: 360px;
- box-sizing: border-box;
- align-self: center;
- padding: 30px;
- .top-icon {
- font-size: 24px;
- font-family: PingFang SC;
- font-weight: bold;
- color: #333333;
- text-align: center;
- }
- .pass-code {
- display: flex;
- padding-top: 44px;
- .item {
- font-size: 16px;
- font-family: PingFang SC;
- font-weight: 400;
- color: #565656;
- cursor: pointer;
- &:nth-child(1) {
- margin-right: 30px;
- }
- &.active {
- font-weight: bold;
- color: #111111;
- padding-bottom: 10px;
- border-bottom: 3px solid #FC7200;
- }
- }
- }
- .login-password {
- padding-top: 30px;
- .pass-item {
- display: flex;
- align-items: center;
- padding-bottom: 2px;
- border-bottom: 1px solid #eee;
- .phone-icon {
- width: 14px;
- height: 17px;
- margin-right: 16px;
- }
- .lock-icon {
- width: 16px;
- height: 18px;
- margin-right: 14px;
- }
- .input-phone {
- flex: 1;
- }
- .get-code {
- min-width: 120px;
- box-sizing: border-box;
- text-align: center;
- padding: 0 6px;
- font-size: 14px;
- font-family: PingFang SC;
- font-weight: 400;
- color: #175199;
- cursor: pointer;
- }
- }
- }
- .forgot-pass {
- text-align: right;
- font-size: 14px;
- font-family: PingFang SC;
- font-weight: 400;
- color: #8590A6;
- padding-top: 10px;
- span {
- cursor: pointer;
- }
- }
- .login-btn {
- height: 36px;
- line-height: 36px;
- text-align: center;
- background: #FC7200;
- border-radius: 3px;
- font-size: 14px;
- font-family: PingFang SC;
- font-weight: 500;
- color: #FFFFFF;
- margin-top: 40px;
- cursor: pointer;
- }
- .xie-yi {
- font-size: 12px;
- font-family: PingFang SC;
- font-weight: 400;
- color: #808080;
- text-align: center;
- margin-top: 20px;
- a {
- text-decoration: none;
- color: #175199;
- }
- }
- }
- }
- }
- </style>
|