vue回密码_vue实现个人信息查看和密码修改功能
补水面膜vue回密码_vue实现个⼈信息查看和密码修改功能
下⾯⼀段代码给⼤家介绍vue实现个⼈信息查看和密码修改功能,具体代码如下所述:
//⽤了element组件,⾃⼰要加载和引⼊
保存
保存
//这些不要在意,这些是我们⾃定义的接⼝,⽤的时候就直接拿来了
import {fetchAll,fetchByID,fetchList,postData,putData,deleteByID,deleteAllByID,guid,bytesToSize} from "@/api/dbhelper"; //这⼀步很重要,⼀般我们直接从后台拿过来输出来会是在data⾥⾯,但是我发现却在store⾥⾯,这⾥就要⽤到vuex
六一儿童节开场白import { mapGetters } from "vuex";
export default {
data() {
/*****检验两次密码是否⼀致***/
var validatePass = (rule, value, callback) => {
if (value === "") {
callback(new Error("请输⼊密码"));
大学生学年总结} else {
if (this.ruleForm.checknewpass !== "") {
this.$refs.ruleForm.validateField("checknewpass");
}
callback();
}
};
var validatePass2 = (rule, value, callback) => {
if (value === "") {
callback(new Error("请再次输⼊密码"));
} else if (value !== wpass) {
callback(new Error("两次输⼊密码不⼀致!"));
} else {
callback();
}
};
return {
uploadParm: {}, //图⽚的上传
ruleForm: {},//修改密码的表单
activeName: "first",
loading: true,
baseUrl: v.BASE_API,
userlist: {},//⽤户信息表单
formLabelWidth: "150px",
/***校验***/
rules: {
phone: [
{
required: true,
message: "请输⼊电话号码"
},
{
pattern: /^(13[0-9]|14[5|7]|15[0|1|2|3|5|6|7|8|9]|18[0|1|2|3|5|6|7|8|9])\d{8}$/, message: "⼿机格式不对"
}
两小儿辩日文言文翻译],
email: [
{
required: true,
message: "请输⼊电⼦邮箱"
},
{
pattern: /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+((\.[a-zA-Z0-9_-]{2,3}){1,2})$/, message: "请输⼊有效的邮箱"
}
],
pass: [
{
required: true,
trigger: "blur",
message: "请输⼊密码"
}
],
newpass: [
{
validator: validatePass,
trigger: "blur"
}
],
checknewpass: [
{
validator: validatePass2,
trigger: "blur"
}
]
}
};
},
created() {
this.upload();
},
computed: {
...mapGetters(["username"])
},
methods: {
//获取个⼈⽤户的信息
getUser() {
postData("接⼝", this.username).then(response => { if (response.status === 200) {
this.userlist = response.data;
this.loading = false;
console.log(this.userlist, 9696);
} else {
this.$message({
message: "获取信息失败," + ssage,
type: "error"
});
}
});
},
//tab切换
handleClick(tab, event) {
console.log(tab, event);
},
//上传参数图⽚初始化
upload() {
var currentTimeStamp = new Date().getTime() / 1000;
if (
this.uploadParams == null ||
pire + 3 < currentTimeStamp
) {
this.$store
.dispatch("GetUploadParams")
.then(req => {
this.uploadParm = req.data;
})
.catch(err => {
this.$message({ message: ssage, type: "warning" }); });
最强地震} else {
this.uploadParm = this.uploadParams;
}
},
//上传之前
beforeupload(file) {
this.uploadParm.key = this.uploadParm.dir + guid();
// console.log(this.uploadParm)
},
//图⽚上传上传成功
handleUpSuccess(response, file, fileList) {
var newfile = {
name: file.name,
type: pe,
size: bytesToSize(file.size),
url: this.uploadParm.key
};
postData("file", newfile).then(response => {
if (response.status == 200) {
this.$message({ message: "修改成功", type: "success" }); this.userlist.style_file_id = response.data.id;
this.userlist.avatar_url = this.baseUrl + response.data.url; } else {
this.$message({ message: "修改失败", type: "error" });
}
});
console.log(this.userlist);
},
//修改密码
submitForm(ruleForm) {
var obj = {
username: this.username,
oldpwd: this.ruleForm.pass,
newpwd: wpass
};
console.log(obj);
postData("接⼝", obj).then(response => {
if (response.status == 200) {
this.$message({
message: "保存成功",
type: "success"
});
} else {
this.$message({生活需要勇气

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。