<template>
	<view>
		<view class="font">
			<!-- <uni-icons type="arrow-left" size="30" @click="back" color="#fff"></uni-icons> -->
			<uni-icons type="back" size="22" @click="back" style="font-weight: 100;padding-left: 20rpx;" color="#fff"></uni-icons>
			
			<text style="color: white;display: flex;justify-content: center;font-weight: 500; align-items: center; text-align: center; margin: 0 auto;color: white;">Delete account</text>
		</view>
		<view class="text_item">
			Once you deactivate account, your account information will no longer be accessible.
		</view>
		<view class="text_item">
			1. Your information on dopeplus.com will be permanentlydeleted.You cannot undo the action.
		</view>
		<view class="text_item">
			2.Your data on dopeplus.com will be permanentlydeleted.You won't be able to issue refunds.
		</view>
		<view class="text_item">
		3.You will lose access to member benefits. Coupons,vouchers, and rewards points will be expired.
		</view>
		<view class="address_foot">
				<button @click="deleteuserinfo()">Delete account</button>
		</view>
	</view>
</template>

<script>
	import {defaultRequest} from '../../api/index.js'
	export default {
		data(){
			return {
				delete:{
					_action:'unregistuser',
					username:'',
					password:''
				}
			}
		},
		methods:{
			getuserinfo(){
				let data={_action:'getinfo'}
				defaultRequest(data).then(res =>{
					console.log(res)
				})
			},
			deleteuserinfo(){
				
				uni.showModal({
					title: 'Confirm Delet?',
					cancelText: "cancel", // 取消按钮的文字  
					confirmText: "confirm", // 确认按钮的文字  
					showCancel: true, // 是否显示取消按钮，默认为 true
					confirmColor: '#f55850',
					cancelColor: '#39B54A',
					success: (res) => {
					if(res.confirm) {  
						console.log('comfirm') //点击确定之后执行的代码
						defaultRequest(this.delete).then(res =>{
							if(res.error == 0){
								setTimeout(() =>{
									uni.showToast({
										icon:'none',
										title:'ok to delete!',
										duration: 2000
									})
								},500)
								uni.navigateTo({
									url:'./deleteOk'
								})
							}
						})
					} else {  
						console.log('cancel')
						 //点击取消之后执行的代码
						 uni.navigateTo({
						 	url:'./deleteOk'
						 })
						}  
					} 
				})
				
				
			},
			back(){
				uni.navigateBack()
			}
		},
		onShow() {
			let user = uni.getStorageInfoSync('user_info')
			console.log(user)
			this.getuserinfo()
		}
	}
</script>

<style lang="scss" scoped>
	.padding_top{
		margin-top:80rpx;
		margin-left:20rpx;
		padding:10rpx 10rpx;
	}
	.text_item{
	 margin-top: 50rpx;
	 height: 100rpx;
	 line-height: 50rpx;
	 text-align: start;
	 margin-left: 5vw;
	 margin-right: 3vw;
	 color:#818181;
	 font-size:26rpx; 
	}
	.address_foot{
		padding: 24rpx 24rpx;
		
		// border-top: #E2E2E2 solid 1px;
		position: fixed;
		margin-top:50rpx;
		width: 80%;
		margin-left: 7%;
		// box-sizing: border-box;
		button{
			color: white;
			background-color: #000000 !important;
			font-size: 26.67rpx;
			font-weight: bold;
			margin: 0;
		}
	}
	.font{
		display: flex;
		background-color:#000000;
		color:white;
		height: 42px;
		line-height: 100rpx;
		text-align: center;
		padding-top: 20px;
		// padding-left:20rpx;
		font-size: 20px;
		font-weight: bold;
	}
</style>