<template>
	<view class="container">
		<uni-list>
			<uni-list-item title="个人资料" @click="navTo('/pages/set/userinfo')"></uni-list-item>
			<uni-list-item title="收货地址" @click="navTo('/pages/set/address')"></uni-list-item>
			<uni-list-item title="交易密码" @click="navTo('/pages/money/moneyPwd')"></uni-list-item>
			<uni-list-item title="修改登录密码" @click="navTo('/pages/public/forget')"></uni-list-item>
			<uni-list-item title="隐私协议" @click="navTo('/pages/user/about')"></uni-list-item>
			<uni-list-item title="注销账户" @click="detailPhone()"></uni-list-item>
		</uni-list>
		<view class="list-cell log-out-btn" @click="toLogout"><text class="cell-tit">退出登录</text></view>
	</view>
</template>

<script>
import uniList from '@/components/uni-list/uni-list.vue';
import uniListItem from '@/components/uni-list-item/uni-list-item.vue';
import { logout } from '@/api/set.js';
import { mapMutations } from 'vuex';
export default {
	components: {
		uniList,
		uniListItem
	},
	data() {
		return {};
	},
	methods: {
		...mapMutations('user', ['logout']),
		detailPhone(){
			uni.showModal({
				title: '提示',
				content: '账号注销后无法恢复是否申请注销',
				success: res => {
					uni.showModal({
						title: '请输入注销理由',
						editable:true,
						success: res => {
							uni.showLoading({})
							setTimeout(()=>{
								uni.hideLoading()
								uni.showModal({
									title: '提示',
									content: '账号注销申请已提交，如需要取消注销请三个工作日内联系管理员，三个工作日后该账户将无法使用且无法恢复',
									showCancel:false
								});
							},1000)
						},
					});
					
					
				},
			});
		},
		navTo(url) {
			uni.navigateTo({
				url: url
			});
		},
		//退出登录
		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: $page-color-base;
}
.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 {
			color: $base-color;
			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(0.84);
	}
}
</style>
