<template>
|
<view class="box">
|
<view class="box-tx">
|
<view class="box-tx-image">
|
<image :src="form.imgFullUrl" mode="widthFix"></image>
|
</view>
|
<button open-type="chooseAvatar" @chooseavatar="getAvatar">更换头像</button>
|
</view>
|
<view class="list">
|
<view class="list-item">
|
<view class="list-item-label">昵称</view>
|
<view class="list-item-val">
|
<input type="text" v-model="form.nickname" @blur="updateUserInfo" placeholder="请输入" />
|
</view>
|
</view>
|
<view class="list-item">
|
<view class="list-item-label">真实姓名</view>
|
<view class="list-item-val">
|
<input type="text" v-model="form.name" @blur="updateUserInfo" placeholder="请输入" />
|
</view>
|
</view>
|
<view class="list-item">
|
<view class="list-item-label">绑定手机</view>
|
<view class="list-item-val" @click="show = true">
|
<text>{{form.phone1}}</text>
|
<image src="/static/icon/ar_next@2x.png" mode="widthFix"></image>
|
</view>
|
</view>
|
<view class="list-item" @click="jumpAddr">
|
<view class="list-item-label">收货地址</view>
|
<view class="list-item-val">
|
<image src="/static/icon/ar_next@2x.png" mode="widthFix"></image>
|
</view>
|
</view>
|
<view class="list-item" @click="jumpxy">
|
<view class="list-item-label">协议与说明</view>
|
<view class="list-item-val">
|
<image src="/static/icon/ar_next@2x.png" mode="widthFix"></image>
|
</view>
|
</view>
|
</view>
|
<view class="loginOut" @click="tuichu">退出登录</view>
|
<!-- 更换手机号 -->
|
<u-popup :show="show" round="15" :safeAreaInsetBottom="false" mode="center">
|
<view class="tc">
|
<view class="tc-contemt">
|
<view class="tc-contemt-title">更换绑定手机号?</view>
|
<view class="tc-contemt-nr">
|
更换后现手机号{{returnPhone(form.phone)}}将不能用于登录,180天内只可更换一次
|
</view>
|
</view>
|
<view class="tc-btn">
|
<view class="tc-btn-item" @click="show = false">我再想想</view>
|
<view class="tc-btn-item" style="color: #004096;" @click="jumpPhone">确认更换</view>
|
</view>
|
</view>
|
</u-popup>
|
</view>
|
</template>
|
|
<script>
|
import { mapState } from 'vuex'
|
import { formatPhoneStar } from '@/utils/utils.js'
|
export default {
|
computed: {
|
...mapState(['userInfo', 'token'])
|
},
|
data() {
|
return {
|
show: false,
|
form: {
|
nickname: '',
|
name: '',
|
phone: '',
|
phone1: '',
|
imgFullUrl: '',
|
imgurl: ''
|
}
|
};
|
},
|
onLoad() {
|
this.form.nickname = this.userInfo.nickname
|
this.form.name = this.userInfo.name
|
this.form.phone = this.userInfo.phone
|
this.form.phone1 = this.returnPhone(this.userInfo.phone)
|
this.form.imgFullUrl = this.userInfo.imgFullUrl
|
this.form.imgurl = this.userInfo.imgurl
|
},
|
methods: {
|
jumpxy() {
|
uni.navigateTo({
|
url: '/pages/agreement-description/agreement-description'
|
})
|
},
|
returnPhone(phone) {
|
return formatPhoneStar(phone)
|
},
|
jumpPhone() {
|
uni.navigateTo({
|
url: '/pages/change-binding/change-binding'
|
})
|
},
|
jumpAddr() {
|
uni.navigateTo({
|
url: '/pages/address/address'
|
})
|
},
|
// 上传头像
|
getAvatar(e) {
|
var that = this;
|
uni.uploadFile({
|
url: `${this.$baseUrl}public/upload`,
|
filePath: e.detail.avatarUrl,
|
name: 'file',
|
fileType: 'image',
|
header: { 'token': this.token },
|
formData: { folder: 'member' },
|
success: (uploadFileRes) => {
|
let result = JSON.parse(uploadFileRes.data)
|
that.form.imgurl = result.data.imgaddr
|
that.form.imgFullUrl = result.data.url
|
that.updateUserInfo()
|
}
|
});
|
},
|
// 更新用户信息
|
updateUserInfo() {
|
this.$u.api.updateMember(this.form)
|
.then(res => {
|
if (res.code === 200) {
|
this.setUserInfo()
|
}
|
})
|
},
|
// 缓存最新用户信息
|
async setUserInfo() {
|
let res = await this.$u.api.getUserInfo()
|
if (res.code === 200) {
|
await this.$store.commit('setUserInfo', res.data)
|
await this.$store.commit('setOpenId', res.data.openId)
|
}
|
},
|
// 退出登录
|
tuichu() {
|
this.$u.api.logOut()
|
.then(res => {
|
if (res.code === 200) {
|
this.$store.commit('clear')
|
uni.switchTab({
|
url: '/pages/index/index'
|
})
|
}
|
})
|
}
|
}
|
}
|
</script>
|
|
<style lang="scss" scoped>
|
.box {
|
width: 100%;
|
padding-top: 40rpx;
|
box-sizing: border-box;
|
.tc {
|
width: calc(100vw - 148rpx);
|
.tc-btn {
|
width: 100%;
|
height: 102rpx;
|
display: flex;
|
align-items: center;
|
justify-content: space-between;
|
border-top: 1rpx solid #EEEEEE;
|
.tc-btn-item {
|
flex: 1;
|
height: 100%;
|
display: flex;
|
align-items: center;
|
justify-content: center;
|
font-weight: 400;
|
font-size: 32rpx;
|
color: #666666;
|
border-right: 1rpx solid #EEEEEE;
|
&:last-child {
|
border: none !important;
|
}
|
}
|
}
|
.tc-contemt {
|
width: 100%;
|
padding: 40rpx 0;
|
box-sizing: border-box;
|
display: flex;
|
align-items: center;
|
justify-content: center;
|
flex-direction: column;
|
.tc-contemt-title {
|
width: 100%;
|
text-align: center;
|
font-weight: 600;
|
font-size: 32rpx;
|
color: #111111;
|
}
|
.tc-contemt-nr {
|
width: 472rpx;
|
text-align: center;
|
font-weight: 400;
|
font-size: 28rpx;
|
color: #333333;
|
margin-top: 40rpx;
|
}
|
}
|
}
|
.loginOut {
|
position: fixed;
|
left: 50%;
|
bottom: calc(40rpx + env(safe-area-inset-bottom));
|
transform: translate(-50%, 0);
|
width: 200rpx;
|
height: 72rpx;
|
line-height: 72rpx;
|
text-align: center;
|
border-radius: 36rpx;
|
font-weight: 400;
|
font-size: 28rpx;
|
color: #333333;
|
border: 1rpx solid #999999;
|
}
|
.box-tx {
|
width: 100%;
|
display: flex;
|
align-items: center;
|
flex-direction: column;
|
justify-content: center;
|
.box-tx-image {
|
width: 160rpx;
|
height: 160rpx;
|
border-radius: 50%;
|
overflow: hidden;
|
image {
|
width: 100%;
|
}
|
}
|
button {
|
width: 136rpx;
|
padding: 0;
|
height: 48rpx;
|
line-height: 48rpx;
|
text-align: center;
|
border-radius: 32rpx;
|
border: 1rpx solid #004096;
|
font-weight: 400;
|
font-size: 24rpx;
|
color: #004096;
|
margin-top: 24rpx;
|
}
|
}
|
.list {
|
width: 100%;
|
padding: 0 30rpx;
|
box-sizing: border-box;
|
display: flex;
|
flex-direction: column;
|
margin-top: 60rpx;
|
.list-item {
|
width: 100%;
|
height: 98rpx;
|
display: flex;
|
align-items: center;
|
justify-content: space-between;
|
border-bottom: 1rpx solid #E5E5E5;
|
.list-item-label {
|
flex-shrink: 0;
|
font-weight: 400;
|
font-size: 30rpx;
|
color: #111111;
|
width: 200rpx;
|
}
|
.list-item-val {
|
flex: 1;
|
display: flex;
|
align-items: center;
|
justify-content: flex-end;
|
text {
|
font-weight: 400;
|
font-size: 28rpx;
|
color: #333333;
|
}
|
input {
|
width: 100%;
|
text-align: right;
|
font-weight: 400;
|
font-size: 28rpx;
|
color: #111111;
|
}
|
image {
|
width: 40rpx;
|
height: 40rpx;
|
}
|
}
|
}
|
}
|
}
|
</style>
|