You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
canteen/components/my-userinfo/my-userinfo.vue

175 lines
3.3 KiB

<template>
<view class="my-userinfo-container">
<!--头像和昵称区域-->
<view class="top-box">
<image :src="userinfo.avatarURL" class="avatar"></image>
<button class="header" open-type="chooseAvatar" @chooseavatar="chooseAvatar"></button>
</view>
<!---->
<view class="panel-list">
<!--第一个面板-->
<view class="panel">
<view class="panel-body">
<view class="panel-item">
<text>8</text>
<text>收藏的菜品</text>
</view>
<view class="panel-item">
<text>2</text>
<text>信息</text>
</view>
<view class="panel-item">
<text>6</text>
<text>足迹</text>
</view>
</view>
</view>
<!--第二个面板-->
<view class="panel">
<view class="panel-title">
我的评价
</view>
<view class="panel-body">
</view>
</view>
<!--第三个面板-->
<view class="panel">
<view class="third-panel-list">
<text>反馈与帮助</text>
<uni-icons type="arrowright" size="15"></uni-icons>
</view>
<view class="third-panel-list" @click="logout">
<text>退出登录</text>
<uni-icons type="arrowright" size="15"></uni-icons>
</view>
</view>
</view>
</view>
</template>
<script>
import {
mapState,
mapMutations
} from 'vuex'
export default {
name: "my-userinfo",
data() {
return {
};
},
onLoad() {
this.updateUserInfo(uni.getStorageInfoSync('userinfo'))
},
computed: {
...mapState('m_user', ['userinfo'])
},
methods: {
...mapMutations('m_user', ['updatetoken', 'updateUserInfo','saveUserInfoToStorage']),
chooseAvatar(e) {
this.userinfo.avatarURL = e.detail.avatarUrl
this.saveUserInfoToStorage()
},
async logout() {
let that = this
uni.showModal({
title: '提示',
content: '确认退出登录吗?',
success: (succ) => {
if (succ.confirm) {
that.updateUserInfo({
avatarURL: '',
nickName: ''
})
that.updatetoken('')
that.savetokentostorage()
}
}
})
}
}
}
</script>
<style lang="scss">
.my-userinfo-container {
height: 100%;
background-color: #f4f4f4;
.top-box {
height: 400rpx;
background-color: #efefef;
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
.avatar {
width: 90px;
height: 90px;
border-radius: 45px;
border: 2px solid #FFF;
box-shadow: 0 1px 5px black;
}
.nikname {
font-size: 16px;
color: black;
font-weight: bold;
margin-top: 10px;
}
}
}
.panel-list {
padding: 0 10px;
position: relative;
top: -10px;
.panel {
background-color: white;
border-radius: 3px;
margin-bottom: 8px;
.panel-title {
line-height: 45px;
padding-left: 10px;
font-size: 15px;
border-bottom: 1px solid #f8f8f8;
}
.panel-body {
display: flex;
justify-content: space-around;
.panel-item {
display: flex;
flex-direction: column;
align-items: center;
justify-content: space-around;
padding: 10px 0;
font-size: 13px;
.icon {
width: 35px;
height: 35px;
}
}
}
}
}
.third-panel-list {
display: flex;
justify-content: space-between;
align-items: center;
font-size: 18px;
padding: 0 10px;
line-height: 45px;
}
</style>