<template>
	<view class="content">
		<view class="head">
			<icon class="t-icon t-icon-nvtouxiang"></icon>
			<text>栗子</text>
		</view>
		<view class="list">
			<view class="item" @tap="navTo('/pageTwo/me/mymenu?pageName=我的菜谱')">
				<text>我的菜谱</text>
				<icon class="iconfont icon-arrow-right"></icon>
			</view>
			<view class="item" @tap="navTo('/pageTwo/me/mymenu?pageName=我的收藏')">
				<text>我的收藏</text>
				<icon class="iconfont icon-arrow-right"></icon>
			</view>
			<view class="item" @tap="navTo('/pageTwo/me/userEdit')">
				<text>个人资料</text>
				<icon class="iconfont icon-arrow-right"></icon>
			</view>
			<view class="item" @tap="navTo('/pageTwo/me/record')">
				<text>饮食记录</text>
				<icon class="iconfont icon-arrow-right"></icon>
			</view>
			<view class="item" @tap="navTo('/pageTwo/me/feedBack')">
				<text>联系客服</text>
				<icon class="iconfont icon-arrow-right"></icon>
			</view>
		</view>

		<view class="btn " v-if="!token" @click="handleOutLogin">退出登录</view>

	</view>
</template>

<script>
	export default {
		data() {
			return {
				token: null
			}
		},
		onLoad() {
			let that = this
			that.token = uni.getStorageSync('token')
		},
		methods: {
			handleOutLogin() {
				let that = this
				uni.showModal({
					title: '友情提示',
					content: '是否退出登录？',
					success: function(res) {
						if (res.confirm) {
							that.$model.getoutlogin({
								sessionid: uni.getStorageSync('sessionid')
							}).then((res) => {
								that.$tools.msg(res.message)
								if (res.code != 0) return
								uni.setStorageSync('sessionid', null)
								uni.setStorageSync('token', null)
								that.$store.commit("changeLogout", false);
								that.handleLogin()
							})
						} else if (res.cancel) {
							that.$tools.msg("您已取消操作！");
						}
					},
				})
			},
			navTo(url) {
				// if (!uni.getStorageSync('token')) {
				// 	this.$tools.msg("登录后查看等多！")
				// 	return
				// }
				uni.navigateTo({
					url
				})
			},
		}
	}
</script>

<style scoped lang="scss">
	.content {
		padding: 0 15px;
		min-height: 100vh;
	}

	.head {
		width: 100%;
		height: 6rem;
		background: #fff;
		display: flex;
		align-items: center;
		border-radius: 10px;
		font-size: 16px;
		font-weight: bold;

		icon {
			width: 50px;
			height: 50px;
			margin: 0 15px;
		}
	}

	.list {
		width: 100%;
		background: #fff;
		margin: 15px;
		border-radius: 10px;
		line-height: 50px;

		.item {
			display: flex;
			justify-content: space-between;
			margin: 0 15px;
			border-bottom: 1px solid #f7f7f7;
		}
	}

	.btn {
		width: 100%;
		color: #fff;
	}
</style>
