<template>
|
<!-- 我的信息 -->
|
<view class="font-14">
|
<view class="center">
|
<image class="header-img"
|
:src="formData.photo?formData.photo:'../../static/images/default-avatar.png'"
|
@click="showUploadImage"></image>
|
</view>
|
<view class="mt-20 content">
|
<view class="input-group-row">
|
<text class="label">姓名<text class="require">*</text></text>
|
<input type="text" v-model="formData.name" maxlength="20" placeholder="姓名" placeholder-class='placeholder'/>
|
</view>
|
<view class="input-group-row">
|
<text class="label">英文名</text>
|
<input type="text" v-model="formData.engName" maxlength="100" placeholder="英文名" placeholder-class='placeholder'/>
|
</view>
|
<view class="input-group-row">
|
<text class="label">手机号码<text class="require">*</text></text>
|
<input type="text" v-model="formData.telphone" maxlength="20" placeholder="手机号码" placeholder-class='placeholder'/>
|
</view>
|
<view class="input-group-row">
|
<text class="label">性别<text class="require">*</text></text>
|
<view class="right-text">
|
<radio-group name="sex" @change="sexChange">
|
<label><radio value="男" color="#518EFF" class="radio" :checked="formData.sex==='男'"/>男</label>
|
<label><radio value="女" color="#518EFF" class="radio" :checked="formData.sex==='女'"/>女</label>
|
</radio-group>
|
</view>
|
</view>
|
<view class="input-group-row">
|
<text class="label">生日</text>
|
<view class="right-text">
|
<picker mode="date" @change="dateChange" :end="endDate">
|
<text :class="formData.birthday?'':'gray'">{{formData.birthday?formData.birthday:'请选择生日'}}</text>
|
</picker>
|
</view>
|
</view>
|
<view class="input-group-row">
|
<text class="label">Eamil</text>
|
<input type="text" v-model="formData.email" maxlength="20" placeholder="请输入Eamil" placeholder-class='placeholder'/>
|
</view>
|
<view class="input-group-row">
|
<text class="label">服务签名</text>
|
<input type="text" v-model="formData.serviceSign" maxlength="100" placeholder="请输入服务签名" placeholder-class='placeholder'/>
|
</view>
|
<view class="input-group-row">
|
<text class="label">住址</text>
|
<input type="text" v-model="formData.address" maxlength="100" placeholder="请输入住址" placeholder-class='placeholder'/>
|
</view>
|
</view>
|
<button class="blue-btn sticky-footer" :disabled="isDisabled" @click="submit">保存</button>
|
</view>
|
</template>
|
|
<script>
|
import imageUploadUtils from '../../common/jssdk/uploadImg.js'
|
export default{
|
data(){
|
return{
|
isDisabled: false,
|
formData: {
|
sex: '女',
|
photo: ''
|
}
|
}
|
},
|
onLoad() {
|
this.loadUserInfo()
|
},
|
computed: {
|
endDate() {
|
return this.getDate('end');
|
}
|
},
|
methods:{
|
loadUserInfo(){
|
this.$httpUtils.request('/api/user/findUserInfo').then((res) => {
|
if(res.status == 200){
|
this.formData = res.mapInfo.detail
|
}
|
})
|
},
|
valid(){
|
const {name, telphone, sex} = this.formData;
|
if(!name){
|
this.$toast.info('请输入姓名');
|
return false;
|
}
|
if(!this.$utils.checkPhone(telphone)){
|
this.$toast.info('请填写正确的手机号码');
|
return false;
|
}
|
if(!sex){
|
this.$toast.info('请选择性别');
|
return false;
|
}
|
},
|
submit(){
|
if(this.valid() === false){
|
return;
|
}
|
let roleInfo = this.$httpUtils.getRoleInfo();
|
let token = this.$httpUtils.getToken();
|
let userFunction = this.$httpUtils.getUserFunction();
|
this.isDisabled = true;
|
this.$httpUtils.request('/api/user/modifyUserInfo', this.formData, 'POST').then((res) => {
|
if(res.status == 200){
|
if(roleInfo){
|
roleInfo.name = this.formData.name;
|
roleInfo.photo = this.formData.photo;
|
uni.setStorage({
|
key: 'userInfo',
|
data: JSON.stringify({
|
token: token,
|
roleInfo: roleInfo,
|
userFunction: userFunction
|
}),
|
success: () => {
|
uni.navigateBack()
|
}
|
});
|
}
|
|
}
|
this.isDisabled = false;
|
this.$toast.info(res.info)
|
}).catch((err) => {
|
this.isDisabled = false;
|
})
|
},
|
sexChange(e){
|
this.formData.sex = e.detail.value;
|
},
|
dateChange(e){
|
this.formData.birthday = e.detail.value;
|
},
|
showUploadImage(){
|
imageUploadUtils.show((res) => {
|
this.formData.photo = res;
|
})
|
},
|
getDate(type) {
|
const date = new Date();
|
let year = date.getFullYear();
|
let month = date.getMonth() + 1;
|
let day = date.getDate();
|
|
if (type === 'start') {
|
year = year - 70;
|
}
|
month = month > 9 ? month : '0' + month;;
|
day = day > 9 ? day : '0' + day;
|
return `${year}-${month}-${day}`;
|
},
|
}
|
}
|
</script>
|
|
<style>
|
.header-img{
|
width: 70px;
|
height: 70px;
|
margin-top: 10px;
|
border-radius: 50%;
|
}
|
.content{
|
padding: 0 10px;
|
}
|
.content-row{
|
border-bottom: 1px solid #EDEAF4;
|
padding-bottom: 5px;
|
}
|
</style>
|