<template>
	<view class="user-content">
		<!-- 头部 -->
		<view class="user-head" @click="toUserPage">
			<view class="user-photo">
				<open-data type="userAvatarUrl"></open-data>
			</view>
			<view class="user-info">
				<open-data type="userNickName"></open-data>
			</view>
			<view class="user-jifen">
				<view>乐豆：<text>345</text></view>
				<u-image mode="scaleToFill" width="35rpx" height="35rpx" src="/static/ledou.png"></u-image>
			</view>
		</view>
		<!-- 列表 -->
		<view class="user-list">
			<u-cell-group>
				<u-cell-item icon="order" icon-size="38" :icon-style="{color:'#ff5500'}" index="1" @click="toPage" title="我的订单"></u-cell-item>
				<u-cell-item icon="gift" icon-size="40" :icon-style="{color:'#00aaff'}" index="0" @click="toPage" title="投递记录"></u-cell-item>
				<u-cell-item icon="file-text" icon-size="40" :icon-style="{color:'#ffaa00'}" index="2" @click="toPage" title="服务协议"></u-cell-item>
				<u-cell-item icon="info-circle" icon-size="38" :icon-style="{color:'#55aa00'}" index="3" @click="toPage" title="关于我们"></u-cell-item>
			</u-cell-group>
		</view>
		<!-- 退出 -->
		<view class="user-btn">
			<u-button type="success" :custom-style="quitButton" @click="quitSys" shape="circle">退出登录</u-button>
		</view>
	</view>
</template>

<script>
	import {logout} from '@/api/login.js'
	export default {
		data() {
			return {
				quitButton: {
					borderRadius:'100rpx',
					fontSize:'30rpx',
					background: '#01c9b2'
				}
			};
		},
		onShow() {
		},
		onLoad() {
		},
		methods:{
			// 打开对应的页面
			toPage(index){
				let pageUrl=[
					'/pages/coupon/index/index',
					'/pages/order/order',
					'/pages/agreement/agreement?fromPage=usercenter',
					'/pages/userCenter/aboutUs'
					]
				uni.navigateTo({
					url: pageUrl[index]
				})
			},
			//  跳转
			toUserPage(){
				//  未登录跳转登录，已登录跳转用户信息页
				uni.navigateTo({
					url: '/pages/userCenter/userInfo/userInfo'
				})
			},
			// 退出登录
			quitSys(){
				let _this = this
				uni.showModal({
				  title: '提示',
				  content: '您确定要退出登录吗?',
				  success(res) {
				    if (res.confirm) {
				      logout({}).then(res => {
				       getApp().globalData.token = ''
				       _this.$u.vuex('vuex_token','')
					   // 关闭socket
					   _this.$store.commit("$closeWebsocket")
				        uni.reLaunch({
				        	url: '/pages/index/index'
				        });
				      });
				    }
				  }
				});
			},
			bindGetUserInfo(res){
				console.log(res)
			},
		}
	}
</script>

<style lang="scss">
	.user-content{
		width: 100%;
		.user-head{
			background: #01c9b2;
			display: flex;
			align-items: center;
			padding: 35rpx;
			.user-info{
				flex-grow: 1;
				padding: 0 20rpx;
				color: #FFFFFF;
			}
			.user-photo{
				width: 100rpx;
				height: 100rpx;
				border-radius: 50%;
				overflow: hidden;
				margin-right: 5rpx;
			}
			.user-jifen{
				color: #FFFFFF;
				display: flex;
				align-items: center;
				text{
					font-size: 40upx;
					font-weight: bold;
				}
				>view{
					&:first-child{
						display: flex;
						align-items: center;
					}
				}
			}
		}
		
		.user-list{
			padding:20rpx 0;
		}
		.user-btn{
			padding: 85rpx 200rpx;
		}
	}
</style>
