2021-05-13 11:03:32 +08:00
|
|
|
<template>
|
|
|
|
<view class="person-msg">
|
|
|
|
<view class="head c-content" @click="changeFace">
|
|
|
|
<image :src="form.face || '/static/missing-face.png'" mode=""></image>
|
|
|
|
<view>点击修改头像</view>
|
|
|
|
</view>
|
|
|
|
<u-form :model="form" ref="uForm" class="form">
|
|
|
|
<u-form-item label="昵称" label-width="150">
|
|
|
|
<u-input v-model="form.nickName" placeholder="请输入昵称" />
|
|
|
|
</u-form-item>
|
|
|
|
<u-form-item label="性别" label-width="150">
|
|
|
|
<u-radio-group v-model="form.sex" :active-color="lightColor">
|
|
|
|
<u-radio name="1">男</u-radio>
|
|
|
|
<u-radio name="0">女</u-radio>
|
|
|
|
</u-radio-group>
|
|
|
|
</u-form-item>
|
|
|
|
|
|
|
|
<u-form-item label="生日" label-width="150" right-icon="arrow-right">
|
2023-09-13 09:36:37 +08:00
|
|
|
<div style="width: 100%;" @click="showBirthday = true">{{ birthday || '请选择出生日期' }}</div>
|
|
|
|
<u-picker v-model="showBirthday" mode="time" :confirm-color="lightColor" @confirm="selectTime"></u-picker>
|
2021-05-13 11:03:32 +08:00
|
|
|
</u-form-item>
|
|
|
|
<u-form-item label="城市" label-width="150" placeholder="请选择城市" right-icon="arrow-right">
|
2023-09-13 09:36:37 +08:00
|
|
|
<div style="width: 100%;" @click="clickRegion">{{ form.___path || '请选择城市' }}</div>
|
2021-05-13 11:03:32 +08:00
|
|
|
</u-form-item>
|
2023-09-13 15:52:08 +08:00
|
|
|
|
2021-05-13 11:03:32 +08:00
|
|
|
</u-form>
|
2023-09-13 15:52:08 +08:00
|
|
|
<div class="bottom">
|
|
|
|
<view class="submit" @click="submit">保存</view>
|
|
|
|
<view class="submit light" @click="quiteLoginOut">退出登录</view>
|
|
|
|
</div>
|
2023-01-16 16:56:45 +08:00
|
|
|
<m-city :provinceData="region" headTitle="区域选择" ref="cityPicker" @funcValue="getPickerParentValue" pickerSize="4"></m-city>
|
2021-05-13 11:03:32 +08:00
|
|
|
</view>
|
|
|
|
</template>
|
|
|
|
<script>
|
|
|
|
import { saveUserInfo } from "@/api/members.js";
|
|
|
|
import { upload } from "@/api/common.js";
|
|
|
|
import storage from "@/utils/storage.js";
|
|
|
|
import uFormItem from "@/uview-ui/components/u-form-item/u-form-item.vue";
|
2023-01-16 16:56:45 +08:00
|
|
|
import city from "@/components/m-city/m-city.vue";
|
2021-05-13 11:03:32 +08:00
|
|
|
export default {
|
2023-01-16 16:56:45 +08:00
|
|
|
components: { uFormItem, "m-city": city },
|
2021-05-13 11:03:32 +08:00
|
|
|
data() {
|
|
|
|
return {
|
2021-05-17 18:19:26 +08:00
|
|
|
lightColor: this.$lightColor, //高亮颜色
|
2021-05-13 11:03:32 +08:00
|
|
|
form: {
|
2021-05-17 18:19:26 +08:00
|
|
|
nickName: storage.getUserInfo().nickName || "",
|
|
|
|
birthday: storage.getUserInfo().birthday || "",
|
|
|
|
face: storage.getUserInfo().face || "/static/missing-face.png", //默认头像
|
|
|
|
regionId: [], //地址Id
|
|
|
|
region: storage.getUserInfo().region || [], //地址
|
2021-09-28 17:56:21 +08:00
|
|
|
sex: storage.getUserInfo().sex, //性别
|
2021-05-17 18:19:26 +08:00
|
|
|
___path: storage.getUserInfo().region,
|
2021-05-13 11:03:32 +08:00
|
|
|
},
|
2021-05-17 18:19:26 +08:00
|
|
|
birthday: storage.getUserInfo().birthday || "", //生日
|
2021-05-13 11:03:32 +08:00
|
|
|
photo: [
|
|
|
|
{ text: "立即拍照", color: this.$mainColor },
|
|
|
|
{ text: "从相册选择", color: this.$mainColor },
|
|
|
|
],
|
|
|
|
region: [
|
2021-05-17 18:19:26 +08:00
|
|
|
//请求城市默认地址
|
2021-05-13 11:03:32 +08:00
|
|
|
{
|
|
|
|
id: "",
|
|
|
|
localName: "请选择",
|
|
|
|
children: [],
|
|
|
|
},
|
|
|
|
],
|
2021-05-17 18:19:26 +08:00
|
|
|
showBirthday: false, //显示生日日期
|
2021-05-13 11:03:32 +08:00
|
|
|
};
|
|
|
|
},
|
|
|
|
methods: {
|
2022-09-23 08:44:44 +08:00
|
|
|
/**
|
2023-01-16 16:56:45 +08:00
|
|
|
* 退出登录
|
2022-09-23 08:44:44 +08:00
|
|
|
*/
|
2023-01-16 16:56:45 +08:00
|
|
|
quiteLoginOut() {
|
|
|
|
this.$options.filters.quiteLoginOut();
|
2022-09-23 08:44:44 +08:00
|
|
|
},
|
|
|
|
|
2021-05-17 18:19:26 +08:00
|
|
|
/**
|
|
|
|
* 选择地址回调
|
|
|
|
*/
|
2023-01-16 16:56:45 +08:00
|
|
|
getPickerParentValue(e) {
|
2021-05-13 11:03:32 +08:00
|
|
|
this.form.region = [];
|
|
|
|
this.form.regionId = [];
|
|
|
|
let name = "";
|
|
|
|
|
|
|
|
e.forEach((item, index) => {
|
|
|
|
if (item.id) {
|
|
|
|
this.form.region.push(item.localName);
|
|
|
|
this.form.regionId.push(item.id);
|
|
|
|
if (index == e.length - 1) {
|
|
|
|
name += item.localName;
|
|
|
|
} else {
|
|
|
|
name += item.localName + ",";
|
|
|
|
}
|
|
|
|
this.form.___path = name;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2021-05-17 18:19:26 +08:00
|
|
|
/**
|
|
|
|
* 点击选择地址
|
|
|
|
*/
|
2021-05-13 11:03:32 +08:00
|
|
|
clickRegion() {
|
|
|
|
this.$refs.cityPicker.show();
|
|
|
|
},
|
2021-05-17 18:19:26 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 提交保存
|
|
|
|
*/
|
2021-05-13 11:03:32 +08:00
|
|
|
submit() {
|
2021-06-29 16:26:32 +08:00
|
|
|
delete this.form.___path;
|
|
|
|
let params = JSON.parse(JSON.stringify(this.form));
|
|
|
|
saveUserInfo(params).then((res) => {
|
|
|
|
if (res.statusCode == 200) {
|
|
|
|
storage.setUserInfo(res.data.result);
|
|
|
|
uni.navigateBack();
|
|
|
|
}
|
|
|
|
});
|
2021-05-13 11:03:32 +08:00
|
|
|
},
|
2021-05-17 18:19:26 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 修改头像
|
|
|
|
*/
|
2021-05-13 11:03:32 +08:00
|
|
|
changeFace(index) {
|
|
|
|
uni.chooseImage({
|
|
|
|
success: (chooseImageRes) => {
|
|
|
|
const tempFilePaths = chooseImageRes.tempFilePaths;
|
|
|
|
uni.uploadFile({
|
|
|
|
url: upload,
|
|
|
|
filePath: tempFilePaths[0],
|
|
|
|
name: "file",
|
|
|
|
header: {
|
|
|
|
accessToken: storage.getAccessToken(),
|
|
|
|
},
|
|
|
|
success: (uploadFileRes) => {
|
|
|
|
let data = JSON.parse(uploadFileRes.data);
|
|
|
|
|
|
|
|
this.form.face = data.result;
|
|
|
|
},
|
|
|
|
});
|
|
|
|
},
|
|
|
|
});
|
|
|
|
},
|
2021-05-17 18:19:26 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 选择地址
|
|
|
|
*/
|
2021-05-13 11:03:32 +08:00
|
|
|
selectRegion(region) {
|
|
|
|
this.$set(
|
|
|
|
this.form,
|
|
|
|
"address",
|
|
|
|
`${region.province.label} ${region.city.label} ${region.area.label}`
|
|
|
|
);
|
|
|
|
},
|
2021-05-17 18:19:26 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 选择时间
|
|
|
|
*/
|
2021-05-13 11:03:32 +08:00
|
|
|
selectTime(time) {
|
|
|
|
this.form.birthday = `${time.year}-${time.month}-${time.day}`;
|
|
|
|
this.birthday = `${time.year} - ${time.month} - ${time.day}`;
|
|
|
|
},
|
|
|
|
},
|
2021-05-17 18:19:26 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 加载数据
|
|
|
|
*/
|
|
|
|
onLoad() {},
|
2021-05-13 11:03:32 +08:00
|
|
|
};
|
|
|
|
</script>
|
2023-09-13 15:52:08 +08:00
|
|
|
<style>
|
|
|
|
page{
|
|
|
|
background: #fff;
|
|
|
|
}
|
|
|
|
</style>
|
2021-05-13 11:03:32 +08:00
|
|
|
<style lang="scss" scoped>
|
|
|
|
.submit {
|
|
|
|
height: 90rpx;
|
|
|
|
line-height: 90rpx;
|
|
|
|
text-align: center;
|
|
|
|
margin-top: 90rpx;
|
|
|
|
|
|
|
|
width: 100%;
|
|
|
|
margin: 0 auto;
|
|
|
|
color: $main-color;
|
|
|
|
border-radius: 100px;
|
|
|
|
}
|
|
|
|
.head {
|
|
|
|
height: 260rpx;
|
|
|
|
color: $font-color-light;
|
|
|
|
font-size: $font-sm;
|
|
|
|
display: flex;
|
|
|
|
flex-direction: column;
|
|
|
|
justify-content: center;
|
|
|
|
align-items: center;
|
|
|
|
line-height: 2em;
|
|
|
|
image {
|
|
|
|
width: 144rpx;
|
|
|
|
height: 144rpx;
|
|
|
|
border-radius: 50%;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/deep/ .u-form {
|
|
|
|
background-color: #ffffff;
|
|
|
|
padding: 0;
|
|
|
|
margin-top: 30rpx;
|
|
|
|
.u-form-item {
|
|
|
|
padding: 0 20rpx;
|
|
|
|
height: 110rpx;
|
|
|
|
line-height: 110rpx;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
.form {
|
|
|
|
background-color: #ffffff;
|
|
|
|
}
|
2023-09-13 15:52:08 +08:00
|
|
|
.bottom{
|
|
|
|
position: fixed;
|
|
|
|
bottom: 40px;
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
|
|
width: 100%;
|
|
|
|
>.submit{
|
|
|
|
background: $light-color;
|
|
|
|
color: #fff;
|
|
|
|
width: 40%;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
.light{
|
|
|
|
background: rgba($color: $light-color, $alpha: 0.2) !important;
|
|
|
|
color: $light-color !important;
|
|
|
|
}
|
2021-05-13 11:03:32 +08:00
|
|
|
</style>
|