196 lines
4.9 KiB
Vue
196 lines
4.9 KiB
Vue
<template>
|
||
<view>
|
||
<headers :showBack="true">
|
||
<view class="headerName">
|
||
修改个人信息
|
||
</view>
|
||
</headers>
|
||
<view class="userLogin">
|
||
<u-form style="width: 100%;" :rules="rules" :error-type="['message']" :model="formData" ref="uForm">
|
||
<u-form-item prop="account" class="uni-form-item disabled" :border-bottom="false">
|
||
<view>当前账号:</view>
|
||
<input class="uni-input" name="userInfo" readonly :disabled="true" v-model="userInfo.account"
|
||
placeholder="请输入您的账号" />
|
||
</u-form-item>
|
||
<u-form-item prop="realName" class="uni-form-item" :border-bottom="false">
|
||
<view>姓名:</view>
|
||
<input class="uni-input" name="realName" v-model="formData.realName" placeholder="请输入" />
|
||
<!-- <u-icon :name="showPassword ? 'eye-off' : 'eye-fill'" @click="showPassword = !showPassword"></u-icon> -->
|
||
</u-form-item>
|
||
<u-form-item prop="userTel" class="uni-form-item" :border-bottom="false">
|
||
<view>电话号码:</view>
|
||
<input class="uni-input" name="userTel" v-model="formData.userTel" placeholder="请输入" />
|
||
<!-- <u-icon :name="showPassword ? 'eye-off' : 'eye-fill'" @click="showPassword = !showPassword"></u-icon> -->
|
||
</u-form-item>
|
||
<u-form-item prop="sex" class="uni-form-item" :border-bottom="false">
|
||
<view>性别:</view>
|
||
<u-radio-group v-model="formData.sex" style="margin-left: 15rpx;">
|
||
<u-radio :name="1">
|
||
男
|
||
</u-radio>
|
||
<u-radio :name="2">
|
||
女
|
||
</u-radio>
|
||
</u-radio-group>
|
||
</u-form-item>
|
||
<u-form-item prop="personMail" class="uni-form-item" :border-bottom="false">
|
||
<view>电子邮箱:</view>
|
||
<input class="uni-input" name="personMail" v-model="formData.personMail" placeholder="请输入电子邮箱" />
|
||
</u-form-item>
|
||
<!-- <u-form-item prop="email" class="uni-form-item" :border-bottom="false">
|
||
<image class="icon" mode="widthFix" src="@/static/login/email.png"></image>
|
||
<input class="uni-input" type="email" name="email" v-model="formData.email" placeholder="请输入您的电子邮箱" />
|
||
</u-form-item> -->
|
||
<view class="uni-form-item submit">
|
||
<button type="primary" class="btn" @click="formSubmit">完成</button>
|
||
</view>
|
||
</u-form>
|
||
</view>
|
||
</view>
|
||
</template>
|
||
|
||
<script>
|
||
import headers from '../../../components/headers/headers.vue';
|
||
import {
|
||
exitApp
|
||
} from "@/utils/tool.js"
|
||
|
||
export default {
|
||
components: {
|
||
headers
|
||
},
|
||
data() {
|
||
return {
|
||
showPassword: true,
|
||
userInfo: {},
|
||
formData: {
|
||
realName: "",
|
||
personMail: "",
|
||
userTel: "",
|
||
sex: 1
|
||
},
|
||
rules: {
|
||
realName: [{
|
||
required: true,
|
||
message: '请输入',
|
||
trigger: ['change', 'blur'],
|
||
}],
|
||
userTel: [{
|
||
required: true,
|
||
message: "请输入正确的手机号码",
|
||
trigger: ['change', 'blur'],
|
||
pattern: /^1(3|4|5|6|7|8|9)\d{9}$/,
|
||
}, ],
|
||
personMail: [{
|
||
required: false,
|
||
message: '请输入邮箱',
|
||
trigger: ['change', 'blur'],
|
||
},
|
||
{
|
||
type: "email",
|
||
required: false,
|
||
message: '邮箱格式错误',
|
||
trigger: ['change', 'blur'],
|
||
}
|
||
],
|
||
}
|
||
};
|
||
},
|
||
onLoad() {
|
||
this.userInfo = JSON.parse(uni.getStorageSync('userInfo'));
|
||
this.getInfoFn();
|
||
},
|
||
onReady() {
|
||
this.$refs.uForm.setRules(this.rules);
|
||
},
|
||
methods: {
|
||
// 获取个人信息
|
||
getInfoFn() {
|
||
let that = this;
|
||
this.sendRequest({
|
||
url: "xmgl/systemUser/queryById",
|
||
data: {
|
||
id: this.userInfo.userId
|
||
},
|
||
method: "POST",
|
||
success(res) {
|
||
console.log(res)
|
||
that.formData = {...res.result}
|
||
}
|
||
})
|
||
},
|
||
formSubmit() {
|
||
// 表单验证 -> 下一步
|
||
let that = this;
|
||
this.$refs.uForm.validate(valid => {
|
||
if (valid) {
|
||
// 修改个人信息
|
||
that.sendRequest({
|
||
url: "xmgl/systemUser/edit",
|
||
data: {
|
||
...that.formData
|
||
},
|
||
method: "POST",
|
||
success(res) {
|
||
uni.showToast({
|
||
title: "修改成功",
|
||
})
|
||
setTimeout(function() {
|
||
uni.navigateBack({
|
||
delta: 1
|
||
})
|
||
}, 1000)
|
||
let originUserInfo = JSON.parse(uni.getStorageSync("userInfo"))
|
||
uni.setStorageSync("userInfo",JSON.stringify({...originUserInfo,...that.formData}))
|
||
}
|
||
})
|
||
}
|
||
});
|
||
},
|
||
}
|
||
}
|
||
</script>
|
||
|
||
<style lang="scss" scoped>
|
||
.userLogin {
|
||
padding: 30rpx;
|
||
.uni-form-item.disabled {
|
||
color: #707070;
|
||
}
|
||
.uni-form-item {
|
||
display: flex;
|
||
padding: 20rpx 10rpx;
|
||
width: 100%;
|
||
color: #171717;
|
||
// border-bottom: 1rpx solid #ddd;
|
||
|
||
&.submit {
|
||
border: none;
|
||
margin-top: 80rpx;
|
||
padding-left: 48rpx;
|
||
padding-right: 48rpx;
|
||
.btn {
|
||
padding: 20rpx 28rpx;
|
||
background-color: #2D8EF3;
|
||
}
|
||
|
||
}
|
||
|
||
.icon {
|
||
width: 40rpx;
|
||
height: auto;
|
||
margin: auto 0;
|
||
}
|
||
|
||
.uni-input {
|
||
width: 70%;
|
||
padding: 15rpx;
|
||
}
|
||
|
||
.btn {
|
||
width: 100%;
|
||
font-size: 32rpx;
|
||
}
|
||
}
|
||
}
|
||
</style> |