Browse Source

用户信息修改

master
jiazhipeng 10 months ago
parent
commit
ca8057ab72
  1. 18
      pages.json
  2. 1
      pages/user/user.vue
  3. 1
      subPackages/user/changeNickname.vue
  4. 7
      subPackages/user/infoFilling.vue
  5. 5
      subPackages/user/logout.vue
  6. 159
      subPackages/user/profile.vue
  7. 2
      subPackages/user/register.vue

18
pages.json

@ -98,6 +98,24 @@
"navigationBarTitleText": "个人信息"
}
},
// {
// "path": "user/bindTel",
// "style": {
// "navigationBarTitleText": "修改手机号"
// }
// },
{
"path": "user/logout",
"style": {
"navigationBarTitleText": "注销账号"
}
},
// {
// "path": "user/changeNickname",
// "style": {
// "navigationBarTitleText": "修改姓名"
// }
// },
{
"path": "user/travelerList",
"style": {

1
pages/user/user.vue

@ -143,6 +143,7 @@
width: 106.67rpx;
height: 106.67rpx;
margin-right: 30rpx;
border-radius: 50%;
}
}

1
subPackages/user/changeNickname.vue

@ -49,6 +49,7 @@
.bg {
min-height: 100vh;
padding-top: 50rpx;
background-color: white;
}
.nickname-box {

7
subPackages/user/infoFilling.vue

@ -467,15 +467,14 @@
url: url,
filePath: tempFilePaths[0],
name: 'file',
header: {"token": '7e4bd097-8298-4cbe-8c75-535874a5c0e0'},
success: (uploadFileRes) => {
try {
let res = JSON.parse(uploadFileRes.data)
if (res.code == 1) {
if (Array.isArray(arr)) {
arr.push(res.data.fullurl)
arr.push(res.data.url)
} else {
_this.fileList.push(res.data.fullurl)
_this.fileList.push(res.data.url)
}
}
} catch(e) {}
@ -522,7 +521,7 @@
try {
let res = JSON.parse(uploadFileRes.data)
if (res.code == 1) {
_this.fileList.push(res.data.fullurl)
_this.fileList.push(res.data.url)
}
} catch(e) {}

5
subPackages/user/logout.vue

@ -32,7 +32,7 @@
},
onShow() {
this.Post({
id: 10274
id: 2
},'/api/article/getArticleById').then(res => {
if(res.code == 1) {
this.content = res.data.content
@ -77,6 +77,9 @@
</script>
<style lang="scss" scoped>
*{
box-sizing: border-box;
}
.bg {
min-height: 100vh;
background-color: #fff;

159
subPackages/user/profile.vue

@ -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>

2
subPackages/user/register.vue

@ -236,7 +236,7 @@
try {
let res = JSON.parse(uploadFileRes.data)
if (res.code == 1) {
_this.info.avatar = res.data.fullurl
_this.info.avatar = res.data.url
}
} catch(e) {}

Loading…
Cancel
Save