|
|
@ -1,34 +1,47 @@ |
|
|
|
<template> |
|
|
|
<view v-if="info"> |
|
|
|
<view v-if="info" class="bg"> |
|
|
|
<view class="user-other-info"> |
|
|
|
<div class="info-avatar-top"> |
|
|
|
<span>头像</span> |
|
|
|
<view @click="uploadImg()"> |
|
|
|
<view @click="uploadImg()" class="edit"> |
|
|
|
<image :src="showImg(info.avatar)" mode="aspectFill" |
|
|
|
style="width: 80rpx;height: 80rpx;border-radius: 50%;"></image> |
|
|
|
</view> |
|
|
|
</div> |
|
|
|
<navigator url="/subPackages/user/changeNickname" tag="view" class="userinfo-item"> |
|
|
|
<span>姓名</span> |
|
|
|
<view>{{nickname}}</view> |
|
|
|
</navigator> |
|
|
|
<view class="userinfo-item" @click="showSexSelect = true"> |
|
|
|
<view class="userinfo-item"> |
|
|
|
<span>昵称</span> |
|
|
|
<view> |
|
|
|
<input type="text" v-model="nickname" placeholder="请填写"/> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
<view class="userinfo-item edit" @click="showSexSelect = true"> |
|
|
|
<span>性别</span> |
|
|
|
<view @click="$refs.popup.open()">{{gender == 1 ? '男' : (gender == 2 ? '女' : '保密')}}</view> |
|
|
|
</view> |
|
|
|
<view class="userinfo-item"> |
|
|
|
<span>邮箱</span> |
|
|
|
<view> |
|
|
|
<input type="text" v-model="email" placeholder="请填写"/> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
<view class="userinfo-item"> |
|
|
|
<span>手机号</span> |
|
|
|
<view>{{info.mobile}}</view> |
|
|
|
</view> |
|
|
|
<view class="userinfo-item"> |
|
|
|
<view class="userinfo-item edit"> |
|
|
|
<span>生日</span> |
|
|
|
<view> |
|
|
|
<picker mode="date" :value="date" :start="startDate" :end="endDate" @change="bindDateChange"> |
|
|
|
<view class="uni-input">{{birthday}}</view> |
|
|
|
<text class="uni-input">{{birthday}}</text> |
|
|
|
</picker> |
|
|
|
</view> |
|
|
|
<navigator url="/subPackages/user/logout" tag="view" class="userinfo-item"> |
|
|
|
|
|
|
|
</view> |
|
|
|
<navigator url="/subPackages/user/logout" tag="view" class="userinfo-item edit"> |
|
|
|
<span>注销账号</span> |
|
|
|
<view> |
|
|
|
<i>注销后账号无法恢复,请谨慎操作</i> |
|
|
|
</view> |
|
|
|
</navigator> |
|
|
|
<view class="btn-tao" @click="submit">保存</view> |
|
|
|
</view> |
|
|
@ -99,7 +112,7 @@ |
|
|
|
let today = new Date(); |
|
|
|
today = today.getFullYear() + "/" + (today.getMonth() + 1) + "/" + today.getDate(); |
|
|
|
this.today = today; |
|
|
|
this.Post({}, "/api/user/userInfo").then(res => { |
|
|
|
this.Post({}, "/api/user/getUserDetails").then(res => { |
|
|
|
if (!res.data.birthday) { |
|
|
|
let date = new Date(); |
|
|
|
res.data.birthday = date.getFullYear() + "/" + (date.getMonth() + 1) + "/" + date |
|
|
@ -116,64 +129,47 @@ |
|
|
|
}) |
|
|
|
}, |
|
|
|
uploadImg() { |
|
|
|
let _this = this |
|
|
|
let url = this.NEWAPIURL |
|
|
|
// #ifdef H5 |
|
|
|
url = '/api' |
|
|
|
// #endif |
|
|
|
url+='/api/Common/upload' |
|
|
|
uni.chooseImage({ |
|
|
|
success: (chooseImageRes) => { |
|
|
|
const tempFilePaths = chooseImageRes.tempFilePaths; |
|
|
|
// // #ifdef MP-WEIXIN |
|
|
|
// uni.getFileSystemManager().readFile({ |
|
|
|
// filePath: tempFilePaths[0], |
|
|
|
// encoding: 'base64', |
|
|
|
// success: res => { |
|
|
|
// this.Post({ |
|
|
|
// method: 'POST', |
|
|
|
// base64: 'data:image/png;base64,' + res.data |
|
|
|
// }, '/api/common/base64').then(res => { |
|
|
|
// if (res.data) { |
|
|
|
// this.Post({ |
|
|
|
// avatar: res.data |
|
|
|
// }, '/api/user/profile').then(res => { |
|
|
|
// uni.showModal({ |
|
|
|
// title: '提示', |
|
|
|
// content: res.msg, |
|
|
|
// showCancel: false, |
|
|
|
// success: res => { |
|
|
|
// if (res.confirm) { |
|
|
|
// this.getList() |
|
|
|
// } |
|
|
|
// } |
|
|
|
// }) |
|
|
|
// }) |
|
|
|
// } |
|
|
|
// }) |
|
|
|
// } |
|
|
|
// }) |
|
|
|
// // #endif |
|
|
|
|
|
|
|
pathToBase64(tempFilePaths[0]).then(base64 => { |
|
|
|
this.Post({ |
|
|
|
method: 'POST', |
|
|
|
base64: base64 |
|
|
|
}, '/api/common/base64').then(res => { |
|
|
|
if (res.data) { |
|
|
|
this.Post({ |
|
|
|
avatar: res.data |
|
|
|
}, '/api/user/profile').then(res => { |
|
|
|
uni.showModal({ |
|
|
|
title: '提示', |
|
|
|
content: res.msg, |
|
|
|
showCancel: false, |
|
|
|
success: res => { |
|
|
|
if (res.confirm) { |
|
|
|
this.getList() |
|
|
|
} |
|
|
|
count:1, |
|
|
|
success: (res) => { |
|
|
|
const tempFilePaths = res.tempFilePaths; |
|
|
|
const uploadTask = uni.uploadFile({ |
|
|
|
url: url, |
|
|
|
filePath: tempFilePaths[0], |
|
|
|
name: 'file', |
|
|
|
success: (uploadFileRes) => { |
|
|
|
try { |
|
|
|
let res = JSON.parse(uploadFileRes.data) |
|
|
|
if (res.code == 1) { |
|
|
|
_this.info.avatar = res.data.url |
|
|
|
} |
|
|
|
}) |
|
|
|
} catch(e) {} |
|
|
|
|
|
|
|
|
|
|
|
}, |
|
|
|
fail:()=> { |
|
|
|
uni.showToast({ |
|
|
|
title:'上传失败', |
|
|
|
icon:'none' |
|
|
|
}) |
|
|
|
} |
|
|
|
}) |
|
|
|
}); |
|
|
|
|
|
|
|
}, |
|
|
|
fail:()=> { |
|
|
|
uni.showToast({ |
|
|
|
title:'上传失败', |
|
|
|
icon:'none' |
|
|
|
}) |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
}, |
|
|
|
//生日 |
|
|
|
bindDateChange: function(e) { |
|
|
@ -199,21 +195,43 @@ |
|
|
|
this.$refs.popup.close() |
|
|
|
}, |
|
|
|
submit() { |
|
|
|
try { |
|
|
|
this.nickname = this.nickname.trim() |
|
|
|
this.email = this.email.trim() |
|
|
|
} catch(e) {} |
|
|
|
|
|
|
|
if (!this.nickname) { |
|
|
|
uni.showToast({ |
|
|
|
title:"请输入昵称", |
|
|
|
icon:"none" |
|
|
|
}) |
|
|
|
} |
|
|
|
if (this.email && !this.IsMail(this.email)) { |
|
|
|
uni.showToast({ |
|
|
|
title:"请输入正确的邮箱", |
|
|
|
icon:"none" |
|
|
|
}) |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
uni.showModal({ |
|
|
|
title: '提示', |
|
|
|
content: '确认修改您的信息?', |
|
|
|
success: res => { |
|
|
|
if (res.confirm) { |
|
|
|
this.Post({ |
|
|
|
method: 'POST', |
|
|
|
nickname: this.nickname, |
|
|
|
gender: this.gender, |
|
|
|
birthday: this.birthday |
|
|
|
birthday: this.birthday, |
|
|
|
avatar: this.info.avatar, |
|
|
|
email: this.email |
|
|
|
}, '/api/user/profile').then(res => { |
|
|
|
console.log(res) |
|
|
|
if (res.code == 1) { |
|
|
|
uni.showModal({ |
|
|
|
title: '提示', |
|
|
|
content: res.msg, |
|
|
|
content: res.msg || '修改成功', |
|
|
|
showCancel: false, |
|
|
|
success: res => { |
|
|
|
if (res.confirm) { |
|
|
@ -233,6 +251,11 @@ |
|
|
|
</script> |
|
|
|
|
|
|
|
<style scoped lang="scss"> |
|
|
|
.bg { |
|
|
|
min-height: calc(100vh - 44px); |
|
|
|
background-color: #FFFFFF; |
|
|
|
position: relative; |
|
|
|
} |
|
|
|
view { |
|
|
|
box-sizing: content-box; |
|
|
|
} |
|
|
@ -286,7 +309,7 @@ |
|
|
|
} |
|
|
|
|
|
|
|
.user-other-info { |
|
|
|
margin: 30rpx; |
|
|
|
margin:0 30rpx; |
|
|
|
} |
|
|
|
|
|
|
|
.userinfo-item { |
|
|
@ -321,7 +344,7 @@ |
|
|
|
} |
|
|
|
|
|
|
|
.userinfo-item { |
|
|
|
& view::after { |
|
|
|
&.edit view::after { |
|
|
|
content: ""; |
|
|
|
width: 20rpx; |
|
|
|
height: 20rpx; |
|
|
@ -404,4 +427,8 @@ |
|
|
|
border-top: 13rpx solid #F2F2F2; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
input{ |
|
|
|
text-align: right; |
|
|
|
} |
|
|
|
</style> |
|
|
|