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. 173
      subPackages/user/profile.vue
  7. 2
      subPackages/user/register.vue

18
pages.json

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

1
pages/user/user.vue

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

1
subPackages/user/changeNickname.vue

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

7
subPackages/user/infoFilling.vue

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

5
subPackages/user/logout.vue

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

173
subPackages/user/profile.vue

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

2
subPackages/user/register.vue

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

Loading…
Cancel
Save