<template>
	<view class="container">
		<uni-list>
		    <uni-list-item title="个人资料" clickable showArrow  @click="navTo('/pages/user/set/userinfo')" ></uni-list-item>
			<uni-list-item title="修改密码" clickable showArrow  @click="navTo('/pages/user/set/password')" ></uni-list-item>
			<uni-list-item title="交易密码" clickable showArrow  @click="navTo('/pages/user/set/transaction')" ></uni-list-item>
		</uni-list>
		<view class="list-cell log-out-btn" @click="toLogout">
			<text class="cell-tit">退出登录</text>
		</view>
	</view>
</template>

<script>
	import { logout } from '@/api/set.js';
	import {  
	    mapMutations  
	} from 'vuex';
	export default {
		data() {
			return {
				
			};
		},
		methods:{
			...mapMutations('user',['logout']),
			navTo(url){
				uni.navigateTo({
					url:url,
					fail(red) {
						console.log(red);
					}
				})
			},
			//退出登录
			toLogout(){
				let obj = this;
				uni.showModal({
				    content: '确定要退出登录么',
				    success: (e)=>{
				    	if(e.confirm){
							logout({}).then((e) => {
								uni.navigateBack();
							}).catch((e) => {
								console.log(e);
							})
				    		obj.logout();
				    	}
				    }
				});
			},
			//switch切换触发方法
			switchChange(e){
				console.log(e);
				let statusTip = e.value ? '打开': '关闭';
				this.$api.msg(`${statusTip}消息推送`);
			},

		}
	}
</script>

<style lang='scss'>
	page{
		background: #f3f3f3;
	}
	.list-cell{
		display:flex;
		align-items:baseline;
		padding: 20rpx $page-row-spacing;
		line-height:60rpx;
		position:relative;
		background: #fff;
		justify-content: center;
		&.log-out-btn{
			margin-top: 40rpx;
			.cell-tit{
				text-align: center;
				margin-right: 0;
			}
		}
		.cell-tit{
			flex: 1;
			font-size: $font-base + 2rpx;
			color: $font-color-dark;
			margin-right:10rpx;
		}
		.cell-tip{
			font-size: $font-base;
			color: $font-color-light;
		}
		switch{
			transform: translateX(16rpx) scale(.84);
		}
	}
</style>
