<template>
	<view class="layout">
		<view class="item" @click="changePwd">
			<text class="item-title">设置支付密码</text>
			<view>
				<text v-if="hasPwd" class="already-set">已设置</text>
				<image class="item-right-row" src="../../static/arrow-right.png"></image>
			</view>
		</view>
		<view class="item" @click="changeAccount">
			<text class="item-title">切换账号</text>
			<image class="item-right-row" src="../../static/arrow-right.png"></image>
		</view>
		
		<view class="item1">
			<text class="item-quit" @click="quit">退出账号</text>
		</view>
		<uni-popup class="pop" ref="popup" type="center">
			<view class="dialog">
				<view class="title">是否退出登陆？</view>
				<view class="button-layout">
					<text class="cancel" @click="cancel">取消</text>
					<text class="sure" @click="sure">确认</text>
				</view>
			</view>
		</uni-popup>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				hasPwd: this.$store.state.userInfo.settingCheckCode === 1
			}
		},
		methods: {
			changePwd() {
				if (this.hasPwd) {
					this.$router.push('VertifyPhone')
					return
				}
				this.$router.push('SetPwd')
			},
			changeAccount() {
				if (this.$store.state.userInfo.allowSwitching == 0) {
					this.toast('暂无可切换账号')
				} else {
					this.$router.push('SelectAccount')
				}
				// this.$router.push('SelectAccount')
			},
			quit() {
				this.$refs.popup.open()
			},
			cancel() {
				this.$refs.popup.close()
			},
			sure() {
				this.$store.commit("refreshUserInfo", {})
				this.$net.tokenSave('')
				this.$router.pop()
			}
		}
	}
</script>

<style lang="scss" scoped>
.layout {
	width: 100%;
	height: 100%;
	background: #f5f5f5;
	padding-top: 20rpx;
	position: absolute;
	.item {
		background: #ffffff;
		height: 107rpx;
		margin-top: 2rpx;
		display: flex;
		flex-direction: row;
		justify-content: space-between;
		align-items: center;
		padding: 0 30rpx;
		.item-title {
			font-size: 30rpx;
			color: #333333;
			line-height: 85rpx;
		}
		.already-set {
			font-size: 30rpx;
			color: #333333;
			line-height: 85px;
			margin-right: 30rpx;
		}
		.item-right-row {
			width: 12rpx;
			height: 20rpx;
		}
	}
	.item1 {
		background: #ffffff;
		height: 107rpx;
		margin-top: 99rpx;
		display: flex;
		flex-direction: row;
		justify-content: space-between;
		align-items: center;
		width: 100%;
		.item-quit {
			font-size: 30rpx;
			color: #333333;
			line-height: 107rpx;
			text-align: center;
			width: 100%;
		}
	}
	.pop {
		.dialog {
			width: 640rpx;
			// height: 309rpx;
			background: #FFFFFF;
			border-radius: 16rpx;
			padding-top: 80rpx;
			padding-bottom: 40rpx;
			.title {
				font-size: 32rpx;
				color: #333333;
				line-height: 48rpx;
				text-align: center;
				margin:0 auto;
			}
			.button-layout {
				margin: 80rpx 40rpx 0 40rpx;
				display: flex;
				flex-direction: row;
				justify-content: space-between;
				.cancel {
					width: 260rpx;
					height: 80rpx;
					background: #EFEFEF;
					border-radius: 40rpx;
					font-size: 32rpx;
					color: #666666;
					line-height: 80rpx;
					text-align: center;
				}
				.sure {
					width: 260rpx;
					height: 80rpx;
					background: #FF0520;
					border-radius: 40rpx;
					font-size: 32rpx;
					color: #FFFFFF;
					line-height: 80rpx;
					text-align: center;
				}
			}
		}	
	}
}
</style>
