<template>
	<view style="background-color: #fff;">
		<u-cell-group :border="false">
			<!-- <u-cell title="帮助和反馈" :clickable="true" @click="allClick('帮助和反馈')">
		</u-cell> -->
			<u-cell title="关于库比森轮胎" :clickable="true" @click="allClick('关于APP')">
				<view slot="right-icon">
					版本{{versionNumber}}
					<uni-icons type="right" size="18" color='#CCCCCC'></uni-icons>
				</view>
			</u-cell>
			<u-cell title="注销账号" :clickable="true" @click="allClick('注销账号')">
			</u-cell>
		</u-cell-group>
		<view style="width: 100%;position:fixed; bottom:200rpx;padding: 0;">
			<view style="width:600rpx;margin: 0 auto;">
				<debounce-button type="primary" @click="logOut" text="退出登录" bgColor="#0F974C"></debounce-button>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		deleteAccount
	} from "@/api/me/setting.js"
	export default {
		data() {
			return {
				name: '获取失败',
				versionNumber: '获取失败'
			}
		},
		created() {
			const systemInfo = uni.getSystemInfoSync();
			this.versionNumber = systemInfo.appVersion ? systemInfo.appVersion : '获取失败'
		},
		methods: {
			allClick(name) {
				if (name == '关于APP') {
					uni.navigateTo({
						url: '/pages/me/setting/aboutApp',
					});
				}
				if (name == '注销账号') {
					uni.showModal({
						title: '提示',
						content: '是否注销账号？',
						success: function(res) {
							if (res.confirm) {
								uni.showLoading({
									title: '加载中',
									mask: true
								});
								deleteAccount().then(res => {
										uni.removeStorageSync('accessToken')
										uni.removeStorageSync('userInfo')
										uni.reLaunch({
											url: '/pages/login/index'
										});
									})
									.finally(() => {
										uni.hideLoading()
									});
							}
						}
					});

				}
			},
			logOut() {
				uni.removeStorageSync('accessToken')
				uni.removeStorageSync('userInfo')
				uni.reLaunch({
					url: '/pages/login/index'
				});
			}
		}
	}
</script>

<style lang="scss" scoped>
	.head {
		padding-top: var(--status-bar-height);
	}

	.head ::v-deep.u-navbar-inner {
		z-index: -99999;
	}
</style>