优化注释

This commit is contained in:
lemon橪
2021-05-17 18:19:26 +08:00
parent 4545097a4a
commit 49eb30f265
69 changed files with 972 additions and 2622 deletions

View File

@@ -5,14 +5,10 @@
<view>点击修改头像</view>
</view>
<u-form :model="form" ref="uForm" class="form">
<!-- <u-form-item label="用户名" label-width="150"
><u-input v-model="form.username" disabled
/></u-form-item> -->
<u-form-item label="昵称" label-width="150">
<u-input v-model="form.nickName" placeholder="请输入昵称" />
</u-form-item>
<u-form-item label="性别" label-width="150">
<!-- {{typeof list[0].value}} {{form.sex + typeof form.sex}} -->
<u-radio-group v-model="form.sex" :active-color="lightColor">
<u-radio name="1"></u-radio>
<u-radio name="0"></u-radio>
@@ -20,8 +16,8 @@
</u-form-item>
<u-form-item label="生日" label-width="150" right-icon="arrow-right">
<u-input v-model="birthday" disabled placeholder="请选择出生日期" @click="showBirth = true" />
<u-picker v-model="showBirth" mode="time" :confirm-color="lightColor" @confirm="selectTime"></u-picker>
<u-input v-model="birthday" disabled placeholder="请选择出生日期" @click="showBirthday = true" />
<u-picker v-model="showBirthday" mode="time" :confirm-color="lightColor" @confirm="selectTime"></u-picker>
</u-form-item>
<u-form-item label="城市" label-width="150" placeholder="请选择城市" right-icon="arrow-right">
<u-input v-model="form.___path" disabled @click="clickRegion" />
@@ -35,7 +31,6 @@
<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";
import gkcity from "@/components/m-city/m-city.vue";
@@ -43,46 +38,36 @@ export default {
components: { uFormItem, "m-city": gkcity },
data() {
return {
lightColor: this.$lightColor,
lightColor: this.$lightColor, //高亮颜色
form: {
face: "/static/missing-face.png",
regionId: [],
region: [],
sex: "1",
___path: "",
nickName: storage.getUserInfo().nickName || "",
birthday: storage.getUserInfo().birthday || "",
face: storage.getUserInfo().face || "/static/missing-face.png", //默认头像
regionId: [], //地址Id
region: storage.getUserInfo().region || [], //地址
sex: storage.getUserInfo().sex || 1, //性别
___path: storage.getUserInfo().region,
},
birthday: "",
birthday: storage.getUserInfo().birthday || "", //生日
photo: [
{ text: "立即拍照", color: this.$mainColor },
{ text: "从相册选择", color: this.$mainColor },
],
value: "",
region: [
//请求城市默认地址
{
id: "",
localName: "请选择",
children: [],
},
],
list: [
{
sex: "男",
value: "1",
disabled: false,
},
{
sex: "女",
value: "0",
disabled: false,
},
],
showBirth: false,
showRegion: false,
showAction: false,
showBirthday: false, //显示生日日期
};
},
created() {},
methods: {
/**
* 选择地址回调
*/
getpickerParentValue(e) {
this.form.region = [];
this.form.regionId = [];
@@ -100,19 +85,24 @@ export default {
this.form.___path = name;
}
});
console.log(this.form);
},
/**
* 点击选择地址
*/
clickRegion() {
this.$refs.cityPicker.show();
},
/**
* 提交保存
*/
submit() {
if (this.form.regionId.length != 0 && this.birthday) {
delete this.form.___path;
let params = JSON.parse(JSON.stringify(this.form));
saveUserInfo(params).then((res) => {
console.log(res);
if (res.statusCode == 200) {
storage.setUserInfo(res.data.result);
uni.navigateBack();
@@ -126,6 +116,10 @@ export default {
});
}
},
/**
* 修改头像
*/
changeFace(index) {
uni.chooseImage({
success: (chooseImageRes) => {
@@ -146,34 +140,31 @@ export default {
},
});
},
/**
* 选择地址
*/
selectRegion(region) {
//选择地址
this.$set(
this.form,
"address",
`${region.province.label} ${region.city.label} ${region.area.label}`
);
},
/**
* 选择时间
*/
selectTime(time) {
// 生日
console.log(time);
this.form.birthday = `${time.year}-${time.month}-${time.day}`;
this.birthday = `${time.year} - ${time.month} - ${time.day}`;
// this.form.timestamp = `${time.year} - ${time.month} - ${time.day}`;
},
},
onLoad() {
// this.form.userName = storage.getUserInfo().username
this.form.nickName = storage.getUserInfo().nickName;
this.form.sex = storage.getUserInfo().sex || 1;
this.form.birthday = storage.getUserInfo().birthday;
this.birthday = storage.getUserInfo().birthday || "";
this.form.___path = storage.getUserInfo().region;
this.form.face = storage.getUserInfo().face || "";
this.form.regionId = storage.getUserInfo().regionId || [];
this.form.region = storage.getUserInfo().region || [];
console.log(this.form);
},
/**
* 加载数据
*/
onLoad() {},
};
</script>