<template>
    <view class="my">
        <view class="my_content">
            <view class="news">
                <view class="private">
                    <view class="avatar"><image src="@/static/image/ic_me.png"></image></view>
                    <view class="info">
                        <text>{{info.username}}</text>
                        <!-- <text>156*****7654</text> -->
                    </view>
                </view>
                <view class="right" @click="logOut"><pv-image imgSrc="/playVideo/video/ic_more_white.png" width="32" height="32"></pv-image></view>
            </view>
            <view class="menu">
                <view class="menu_item" @click="toHistory">
                    <view class="name">
                        <pv-image imgSrc="/playVideo/video/ic-jilu.png" width="48" height="48"></pv-image>
                        <text>观看历史</text>
                    </view>
                    <pv-image imgSrc="/playVideo/video/ic_more_black.png" width="24" height="24"></pv-image>
                </view>
                <!-- <view class="menu_item">
                    <view class="name">
                        <pv-image imgSrc="/playVideo/video/ic-kefu.png" width="48" height="48"></pv-image>
                        <text>联系客服</text>
                    </view>
                    <pv-image imgSrc="/playVideo/video/ic_more_black.png" width="24" height="24"></pv-image>
                </view> -->
            </view>
        </view>
        
        <u-popup :show="show" @close="close" safeAreaInsetBottom :round="8">
            <view class="safe-area-inset-bottom">
                <view class="login-out" @click="outLogin">退出登录</view>
            </view>
		</u-popup>
    </view>
</template>

<script>
import { getUserInfo } from '@/apis/my'
import { logout } from '@/apis/login'
export default {
    data(){
        return{
            show:false,
            info:{},
        }
    },
    mounted() {
        this.getInfo()
    },
    methods:{
        toHistory(){
            uni.navigateTo({
                url:'/pages/history/index'
            })
        },
        async getInfo(){
            const res = await getUserInfo()
            this.info = res
            console.log(res,'res');
        },
        async outLogin(){
            const res = await logout()
            uni.removeStorageSync('Authorization')
            uni.removeStorageSync('username')
            uni.redirectTo({
                url: '/pages/login/index'
            })
        },
        logOut(){
			this.show = true
        },
        close() {
            this.show = false
            // console.log('close');
        }
        
    }
}
</script>

<style lang="scss" scoped>
    .my{
        height: 100%;
        background: linear-gradient( 172deg, #216CFF 0%, #C7F0FF 36%, #E1FAFF 100%);
        .my_content{
            height: 100%;
            display: flex;
            flex-direction: column;
        }
        .news{
            padding: 32rpx 32rpx 48rpx;
            display: flex;
            justify-content: space-between;
            align-items: center;
            .private{
                display: flex;
                
                .avatar{
                    width: 104rpx;
                    height: 104rpx;
                    background: #21FFFA;
                    margin-right: 24rpx;
                    border-radius:50% ;
                    image{
                        width: 100%;
                        height: 100%;
                        border-radius: 50%;
                    }
                }
                .info{
                    color: #fff;
                    display: flex;
                    flex-direction: column;
                    justify-content: space-around;
                }
            }
            .right{
                flex: 1;
                display: flex;
                justify-content: flex-end;
                .more{
                
                    margin-top: 26rpx;
                }
            }
        }
        .menu{
            padding: 24rpx 32rpx;
            flex: 1;
            background: #fff;
            border-radius: 24rpx 24rpx 0 0;
            .menu_item{
                padding: 32rpx 28rpx 32rpx 24rpx;
                display: flex;
                justify-content: space-between;
                align-items: center;
                border-bottom: 2rpx solid #F0F2F4;
                .name{
                    display: flex;
                    align-items: center;
                    text{
                        margin-left: 20rpx;
                        font-size: 28rpx;
                    }
                }
            }
            .menu_item:nth-last-child(1){
                border: none;
            }
        }
        .login-out{
			text-align: center;
			margin: 40rpx 0;
		}
    }
</style>