<template>
	<view class="container">
		<!-- #ifdef APP -->
		<view class="top">
			<text class="iconfont icon-youjiantou zuojiantou" @click="goBack()"></text>
			<text>注销账号</text>
		</view>
		<!-- #endif -->
		
		<view class="mobileBox" >
			<text>注销手机号：</text>
			<text style="color: #20269B;">{{hideMoblie(mobile)}}</text>
		</view>
		<view class="" style="margin: 40rpx;">
			<text style="font-size: 28rpx;">注销账号后不可恢复，该账号绑定的所有权益、积分、记录等数据也将都被清空且无法恢复，包括：</text>
		</view>
		<ul class="tips">
			<li>所有积分权益不可使用；</li>
			<li>所有分享数据被清空；</li>
			<li>所有订单数据被清空；</li>
			<li>其他未列数据被清空且无法恢复</li>
		</ul>
		<view class="footer" style="">
			<view class="footer-submitbtn" style="" @click="sunmit()">
				<text>确认</text>
			</view>
			<view class="footer-cancelbtn" style="" @click="cancel()">
				<text>取消</text>
			</view>
		</view>
	</view>
</template>

<script>
	import api from "../../../api/api";
	export default {
		data() {
			return {
				mobile:'',
				userId: uni.getStorageSync('cffp_userId')
			}
		},
		onLoad() {
			let dataForm = uni.getStorageSync('userinfodataForm')
			this.mobile = dataForm.mobile
		},
		destroyed() {
			uni.hideToast();
		},
		methods: {
			hideMoblie(str){
				return str.substr(0,3) + "****" + str.substr(7)
			},
			goBack() {
				uni.navigateBack({
					delta: 1
				});
			},
			cancel(){
				uni.navigateBack({delta:1})
			},
			sunmit(){
				api.cancellation({userId: this.userId}).then(res =>{
					if(res['success']){
						uni.showToast({
							title: '操作成功',
							icon: 'none'
						});
						// 清空全部本地存储
						uni.clearStorageSync();
						uni.redirectTo({
							url:'/components/login/login?from=index'
						})
					}
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.container{
		padding: 0 20rpx;
		background-color: #f7f7f7;
	}
	.top{
		display: flex;
		height: 80rpx;
		justify-content: space-between;
		align-items: center;
		position: relative;
		width: 100%;
		// margin: 0 auto 60rpx auto;
		.zuojiantou{
			display: inline-block;
			transform: rotate(180deg);
			font-size: 30rpx;
			z-index: 1;
			position: absolute;
		}
		text:nth-child(2){
			width: 100%;
			text-align: center;
			position: absolute;
		}
	}
	.mobileBox{
		text-align: center;
		font-size: 40rpx;
		padding-top: 40rpx;
	}
	.tips{
		color: #666666;
		li{
			margin: 20rpx auto;
		}
	}
	.footer{
		display: flex;justify-content: center;position: fixed;bottom: 40rpx;width: 100vw;
		.footer-submitbtn{
			text-align: center;
			line-height: 80rpx;
			width: 300rpx;
			height: 80rpx;
			border-radius: 40rpx;
			margin: 0 40rpx;
			
			opacity: 1;
			border: 2rpx solid #20269B;
		}
		.footer-cancelbtn{
			text-align: center;
			line-height: 80rpx;
			width: 300rpx;
			height: 80rpx;
			border-radius: 40rpx;
			margin: 0 40rpx;
			color: #FFFFFF;
			background-color: #20269B;
			opacity: 1;
			border: 2rpx solid #20269B;
		}
	}

</style>
