<template>
	<view class="container">
		<view class="list">
			<view class="item" @click="linkTo('/pages/login/bind',true)">
				<view class="title">修改手机号</view>
				<up-icon name="arrow-right" />
			</view>
			<view class="item" @click="linkTo('/pages/me/help_center')">
				<view class="title">帮助中心</view>
				<up-icon name="arrow-right" />
			</view>
			<view class="item" @click="linkTo('/pages/me/feedback',true)">
				<view class="title">意见反馈</view>
				<up-icon name="arrow-right" />
			</view>
			<view class="item" @click="linkTo('/pages/me/agreement')">
				<view class="title">用户协议</view>
				<up-icon name="arrow-right" />
			</view>
			<view class="item" @click="linkTo('/pages/me/privacy')">
				<view class="title">隐私协议</view>
				<up-icon name="arrow-right" />
			</view>
			<view class="item" @click="logout" v-if="token">
				<view class="title">退出登录</view>
				<up-icon name="arrow-right" />
			</view>
		</view>
		<view class="version">{{ version }}</view>
	</view>
</template>

<script setup>
import { ref } from 'vue';
import { linkTo } from '@/utils/app.js';
import { onLoad } from '@dcloudio/uni-app';

const version = ref('');
const token = ref('');

// 退出登录
function logout() {
	uni.showModal({
		title: '注意',
		content: '确定要退出登录吗？',
		success: (res) => {
			if (res.confirm) {
				uni.clearStorageSync();
				uni.reLaunch({
					url: '/pages/login/login'
				});
			}
		}
	});
}

onLoad(() => {
	token.value = uni.getStorageSync('token');
	const systemInfo = uni.getSystemInfoSync();
	//#ifdef APP-PLUS
	version.value = systemInfo.appWgtVersion;
	//#endif
	// #ifdef H5
	version.value = systemInfo.appVersion;
	// #endif
});
</script>

<style scoped lang="scss">
.container {
	font-size: 28upx;
	color: #555;
}
.list {
	padding-bottom: 120upx;
	.item {
		padding: 32upx 28upx;
		border-bottom: 1upx solid #efefef;
		display: flex;
		align-items: center;
		justify-content: space-between;
	}
}
.version {
	width: 100%;
	height: 120upx;
	display: flex;
	justify-content: center;
	position: fixed;
	bottom: 0;
	left: 0;
	color: #999;
}
</style>
