data() {
return {
src:‘…/…/static/img/author.jpg’,
user:{
userName:“张三”,
userId:“123435”,
intrduction:“我爱睡觉”,
school:“”,
sex:“”,
birthday:‘’,
city:‘’
},
school:[‘清华大学’,‘北京大学’,“复旦大学”,‘南京大学’],
sex:[‘男’,‘女’]
}
},
methods: {
chooseImg(){
uni.chooseImage({
count:1,
sourceType:[‘album’],
sizeType:[‘original’,‘compressed’],
success: (res) => {
this.src=res.tempFilePaths
}
})
},
bindSchoolChange(e){
this.user.school=this.school[e.target.value]
uni.setStorage({
key:‘school’,
data:this.school[e.target.value],
})
},
bindSexChange(e){
this.user.sex=this.sex[e.target.value]
uni.setStorage({
key:‘sex’,
data:this.sex[e.target.value],
})
},
bindDateChange(e){
this.user.birthday=e.target.value
uni.setStorage({
key:‘birthday’,
data:e.target.value,
})
},
bindCityChange(e){
this.user.city=e.target.value[0]
uni.setStorage({
key:‘city’,
data:e.target.value[0]
})
}
},
onLoad() {
uni.getStorage({
key:‘userName’,
success: (res) => {
this.user.userName=res.data
}
}),
uni.getStorage({
key:‘userId’,
success: (res) => {
this.user.userId=res.data
}
}),
uni.getStorage({
key:‘intrduction’,
success: (res) => {
this.user.intrduction=res.data
}
}),
uni.getStorage({
key:‘school’,
success: (res) => {
this.user.school=res.data
}
}),
uni.getStorage({
key:‘sex’,
success: (res) => {
this.user.sex=res.data
}
}),
uni.getStorage({
key:‘birthday’,
success: (res) => {
this.user.birthday=res.data
}
}),
uni.getStorage({
key:‘city’,
success: (res) => {
this.user.city=res.data
}
})
}
}