<template>
	<view >
		<RefreshView ref="mescrollRef" :pageBg="EDEDED" :hasBack="true" text="设置" :useDownScroll="false"
			:useUpScroll="false">
			<view class="menu-item"  @click="toModiUserNumber()">
				<text class="text">用户号</text>
				<text class="explain">{{page.loginName}}</text>
				<image class = "more" src="../../static/img/public/more.png" ></image>
			</view>
			<view class="line-thin"></view>
			<view class="menu-item" @click="toModiMobileInputNew()">
				<text class="text">手机号</text>
				<text class="explain">{{page.mobile}}</text>
				<image class = "more" src="../../static/img/public/more.png" ></image>
			</view>
			<view class="line-wide"></view>
			<view class="menu-item"  @click="toModiPasswordVerify()">
				<text class="text">密码设置</text>
				<image class = "more"  src="../../static/img/public/more.png"></image>
			</view>
			<view class="line-wide"></view>
			<view class="menu-item" @click="clearCache()">
				<text class="text">清除缓存</text>
				<text class="explain">{{size}}</text>
				<image class = "more" src="../../static/img/public/more.png" ></image>
			</view>
			<button class="margin-top70" @click="exitLogin()">退出登录</button>
		</RefreshView>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				page: {
					mobile: "",
					loginName: "",
				},
				size: ""
			}
		},
		onLoad() {
			try {
				const res = wx.getStorageInfoSync()
				console.log("11110",res)
				console.log(res.keys)
				console.log(res.currentSize)
				console.log(res.limitSize)
				this.size = res.currentSize + "K"
			} catch (e) {
				//Do something when catch error
			}
		},
		methods: {
			// 修改用户号
			toModiUserNumber(){
				let _this = this
				if (getApp().globalData.isLogin ) {
						uni.navigateTo({
							url: 'ModiUserNumber?loginName=' + _this.page.loginName
						})
					}
			},			
			toModiMobileInputNew(){
				let _this = this
				if (getApp().globalData.isLogin ) {
						uni.navigateTo({
							url: 'ModiMobileInputNew'
						})
					}
			},
			toModiPasswordVerify(){
				let _this = this
				if (getApp().globalData.isLogin ) {
						uni.navigateTo({
							url: 'ModiPasswordVerify?mobile=' + _this.page.mobile
						})
					}
			},
			clearCache()
			{
				// 清除缓存
				let _this = this
				uni.showModal({
					title: '提示',
					content: '是否清除全部缓存',
					success: function(res) {
						if (res.confirm) { //这里是点击了确定以后
							wx.clearStorage()
								_this.size = ""
						} else { //这里是点击了取消以后
							console.log('用户点击取消')
						}
					}
				})
			},
			exitLogin() {
				// 退出登录
				let _this = this
				uni.showModal({
					title: '提示',
					content: '是否退出登录',
					success: function(res) {
						if (res.confirm) { 
							_this.HTTP({
								url: 'aos/v1/aosUser/exitLogin',
								method: 'GET',
								data:{
									 "sysUserSid": getApp().globalData.sysUserSid,
								},
								paramsType: "FORM",
								loading: true
							}).then((res) => {
								console.log('=======', res)
							});
							// 接口退出登陆isLogin设置为0
							getApp().globalData.isLogin = false
							getApp().globalData.sysUserSid = null
							uni.setStorageSync("isLogin", false);
							uni.setStorageSync("sysUserSid", null);
							_this.Back()
						
						} else { //这里是点击了取消以后
							console.log('用户点击取消')
						}
					}
				})
			}

		},
		onShow() {
			console.log("初始化")
			let _this = this
			_this.HTTP({
				url: 'aos/v1/aosUser/getSetup/' + getApp().globalData.sysUserSid,
				method: 'GET',
				paramsType: "FORM",
				loading: true
			}).then((res) => {
				console.log('=======', res)
				_this.page = res.data
			});
		}
	}
</script>

<style lang="scss">
	@import url("../../static/master.css");
</style>
