<template>
	<view>
		<view class="setting-content">
			<uni-list>
				<uni-list-item title="关于我们" clickable @click="toAboutOur" showArrow></uni-list-item>
				<uni-list-item title="清除缓存" clickable @click="cleanStorage" ></uni-list-item>
			</uni-list>

			<view class="uni-padding-wrap uni-common-mt">
				<button type="warn" @click="loginOutAlert">退出登录</button>
			</view>

		</view>

	</view>
</template>

<script>
	
	export default {
		data() {
			return {
				
			}
		},
		methods: {
			toAboutOur() {
				uni.navigateTo({
					url: '../aboutOur/aboutOur'
				
				});			
			},
			cleanStorage() {
				uni.clearStorageSync();
				uni.showToast({
					title: "清理缓存成功",
					mask: false,
					duration:2000
				})
			},
			loginOutAlert(){
				let that = this;
				uni.showModal({
					title:'提示',
					content:'是否确定退出登录？',
					success: (res) => {
						if(res.confirm){
							that.loginOut();
						}else if(res.cancel){
							console.log('用户点击取消')
						}
					}
				})
				
			},
			loginOut(){
				let that = this;
				that.$myRequest({
					url: that.$common.userLoginout,
					method: 'POST',
					data: that.$common.requestSign()
				}).then(res => {
						// 获取真实数据之前，务必判断状态是否为200
						console.log('退出：' + JSON.stringify(res));
						if (res.code == 0) {
							
							uni.clearStorageSync();						
							uni.reLaunch({
								url: "../index/index"
							})
							uni.hideLoading();
							
						} else {
							
							uni.clearStorageSync();						
							uni.reLaunch({
								url: "../index/index"
							})						
							uni.hideLoading();
							
						}
					
				})
			}
		}
	}
</script>

<style lang="scss">
	.setting-content {
		background-color: #f6f6f6;
		height: 100vh;
	}
</style>
