From 4b4622c9f74150ca60eb7c4f038e55fb98be02d7 Mon Sep 17 00:00:00 2001
From: lyfO_o <764716047@qq.com>
Date: 星期五, 06 五月 2022 16:34:32 +0800
Subject: [PATCH] 修改密码:v1

---
 src/views/login/pwdChange.vue |  174 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 174 insertions(+), 0 deletions(-)

diff --git a/src/views/login/pwdChange.vue b/src/views/login/pwdChange.vue
new file mode 100644
index 0000000..a246398
--- /dev/null
+++ b/src/views/login/pwdChange.vue
@@ -0,0 +1,174 @@
+<template>
+    <div class="register_main">
+        <div class="register_main_body">
+            <span class="register_main_body_span">密码重置</span>
+        </div>
+        <div class="register_main_form">
+            <el-form :model="pwdForm" :rules="rules" ref="ruleForm" label-width="150px">
+                <el-row>
+                    <el-col :span="20">
+                        <el-form-item label="姓名" prop="username">
+                            <el-input v-model="pwdForm.username"></el-input>
+                        </el-form-item>
+                    </el-col>
+                </el-row>
+                <el-row>
+                    <el-col :span="20">
+                        <el-form-item label="手机号(账户)" prop="phone">
+                            <el-input v-model="pwdForm.phone" ref="tel"></el-input>
+                        </el-form-item>
+                    </el-col>
+                </el-row>
+                <el-row>
+                    <el-col :span="20">
+                        <el-form-item label="密码" prop="password">
+                            <el-input v-model="pwdForm.password"></el-input>
+                        </el-form-item>
+                    </el-col>
+                </el-row>
+
+                <el-row>
+                    <el-col :span="20">
+                        <el-form-item label="确认密码" prop="repassword">
+                            <el-input v-model="pwdForm.repassword"></el-input>
+                        </el-form-item>
+                    </el-col>
+                </el-row>
+                <el-row>
+                </el-row>
+            </el-form>
+            <div  align="center" style="padding-bottom: 30px">
+                <el-button type="primary" :disabled="submitting" @click="submit()">修改密码</el-button>
+            </div>
+        </div>
+    </div>
+</template>
+
+<script>
+import {pwdChange} from "../../api/user";
+import {parseError} from "../../utils/messageDialog";
+
+export default {
+    name: "register",
+    data(){
+        return{
+            submitting: false,
+            pwdForm:{
+                username:'',
+                password:'',
+                repassword:'',
+                phone:'',
+            },
+            rules:{
+                username:[
+                    { required: true, message: '请填写姓名', trigger: 'blur' },
+                ],
+                phone:[
+                    { required: true, message: '请填写手机号', trigger: 'blur' },
+                ],
+                password:[
+                    { required: true, message: '请填写密码', trigger: 'blur' },
+                ],
+                repassword:[
+                    { required: true, message: '请填写确认密码', trigger: 'blur' },
+                ],
+
+
+            },
+        }
+    },
+    watch:{
+    },
+    created(){
+
+    },
+    methods:{
+        async submit(){
+            if (this.pwdForm.password !==  this.pwdForm.repassword) {
+                this.$message({
+                    type:'warning',
+                    message:'两次密码输入不一致'
+                })
+                return
+            }
+            if (this.pwdForm.phone.length !== 11) {
+                this.$message({
+                    type:'warning',
+                    message:'手机号长度不为11'
+                })
+                return
+            }
+            this.$refs["ruleForm"].validate((valid) =>{
+                if(valid){
+                    this.register()
+                }else{
+                    this.$message({
+                        type:'warning',
+                        message:'请填写基本信息'
+                    })
+                }
+            });
+
+        },
+
+        register(){
+            this.submitting = true
+            pwdChange(this.pwdForm)
+                .then(res=>{
+                    if (res.data.code === '200') {
+                        this.$message({
+                            type:'success',
+                            message:'修改成功'
+                        })
+                        setTimeout(()=>{
+                            this.$router.push({path:'/login'})
+                        },1000)
+                    }else{
+                        this.$message({
+                            type:'warning',
+                            message:res.data.message
+                        })
+                    }
+                })
+                .catch(err=>{
+                    console.log(err)
+                    this.$message({
+                        type:'warning',
+                        message:'请求超时'
+                    })
+                })
+                .finally(()=>{
+                    this.submitting = false
+                });
+        }
+    }
+}
+</script>
+
+<style rel="stylesheet/scss" lang="scss">
+$dark_gray:#889aa4;
+.register_main{
+    display: block;
+    width: 100%;
+    max-width: 1200px;
+    padding: 0 20px;
+    margin: 30px auto
+}
+.register_main_body{
+    font-size: 24px;
+}
+.register_main_form{
+    padding-top: 70px;
+    margin: 30px auto;
+    max-width: 800px;
+    display: block;
+    width: 100%;
+}
+.register_main_body_span{
+    padding: 6px 5px 6px 15px;
+    color: $dark_gray;
+    vertical-align: middle;
+    width: 30px;
+    display: inline-block;
+}
+</style>

--
Gitblit v1.9.2