106 lines
2.6 KiB
Vue
106 lines
2.6 KiB
Vue
<template>
|
|
<view class="my_avatar">
|
|
<view style="border-radius: 50rpx;">
|
|
<u-avatar :src="avatar" size="100rpx" shape="circle" @click="changeAvatar()"></u-avatar>
|
|
</view>
|
|
<view style="margin-top: 10rpx;margin-bottom: 4rpx;">
|
|
<u--image v-if="member=='2'" :src="normal" width="84rpx" height="30rpx">
|
|
</u--image>
|
|
<u--image v-if="member=='3'" :src="VIP" width="84rpx" height="30rpx">
|
|
</u--image>
|
|
</view>
|
|
<view style="display: flex;align-items: center;">
|
|
<text @click="changeAvatar()" style="color: #fff;font-size: 26rpx;">{{nickname}}</text>
|
|
<u--image v-if="showEdit==true" src="/static/my/wd_icon_bj.png" width="22rpx" height="22rpx"
|
|
@click="changeAvatar()">
|
|
</u--image>
|
|
</view>
|
|
<view style="margin:0 20rpx;">
|
|
<u-overlay :show="!isLoad">
|
|
<login :timoutText="timoutText" @success="reOnLoad()" @fail="failToLoad()"></login>
|
|
</u-overlay>
|
|
</view>
|
|
</view>
|
|
</template>
|
|
|
|
<script>
|
|
import login from 'pages/my/login/login'
|
|
export default {
|
|
name: "myAvatar",
|
|
props: {
|
|
center: {
|
|
type: String,
|
|
default: ''
|
|
}
|
|
},
|
|
components: {
|
|
login
|
|
},
|
|
data() {
|
|
return {
|
|
member: '',
|
|
showEdit: true,
|
|
avatar: '',
|
|
nickname: '用户',
|
|
normal: '/static/my/wo_icon_pthy.png',
|
|
VIP: '/static/my/wo_icon_vip.png',
|
|
isLoad: true,
|
|
timoutText: 1
|
|
};
|
|
},
|
|
created() {
|
|
if (this.center != false) {
|
|
this.showEdit = false
|
|
}
|
|
this.getUser()
|
|
},
|
|
options: {
|
|
styleIsolation: 'shared', // 解除样式隔离
|
|
},
|
|
methods: {
|
|
//修改头像
|
|
changeAvatar() {
|
|
uni.navigateTo({
|
|
url: '../../packageMy/changeAvatar/changeAvatar'
|
|
})
|
|
},
|
|
//获取头像昵称和普通会员和VIP会员
|
|
getUser() {
|
|
this.$apiServe.getUser().then(res => {
|
|
console.log('个人信息==', res.data);
|
|
if (res.data.msg === "登录超时,请重新登录") {
|
|
this.isLoad = false
|
|
}
|
|
var data = res.data.data
|
|
this.avatar = uni.getStorageSync('img_url') + data.avatar
|
|
this.nickname = data.nickname
|
|
this.member = data.member
|
|
uni.setStorageSync('member', data.member)
|
|
uni.setStorageSync('agreement', data.agreement)
|
|
uni.setStorageSync('com_name', data.com_name)
|
|
uni.setStorageSync('com_mobile', data.com_mobile)
|
|
}).finally(_ => {})
|
|
},
|
|
reOnLoad() {
|
|
if (!uni.getStorageSync('loginToken') || uni.getStorageSync('loginToken').length === 0) {
|
|
this.$toast.warn('登录失败请重试')
|
|
this.isLoad = false
|
|
return
|
|
}
|
|
this.isLoad = true
|
|
this.getUser()
|
|
},
|
|
failToLoad() {
|
|
uni.navigateBack({
|
|
url: '/pages/index/index'
|
|
})
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
<style>
|
|
/deep/.u-image {
|
|
margin-left: 8rpx;
|
|
}
|
|
</style>
|