<template>
	<view class="page">

		<view style="margin-bottom: 40rpx;">{{name}}</view>

		<u-parse :content="content"></u-parse>
		<button @click="show = true" class="btn">注销账号</button>
<!-- 		<view class="cancellation">
			注销后账户不可恢复，请谨慎操作
		</view> -->
		<u-modal :buttonReverse='true' :showCancelButton='true' @cancel='show = false' @confirm='logout'
			:confirmText='i18n.enter' :cancelText='i18n.Cancel' :show="show" :title="i18n.accountCancellation" :content='i18n.closeaccount'
			confirmColor='#606266' cancelColor='#2979ff'></u-modal>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				show: false,
				// title: '注销账号',
				// content: '确定要注销账号吗？',
				// confirmText: '确定',
				// cancelText: '取消'
				name:'',
				content:'',
				language :'zh-CN'
			}
		},
		onLoad() {
			uni.setNavigationBarTitle({
				title: this.i18n.accountCancellation
			})
			this.reminder()
		},
		onshow(){
			if (uni.getStorageSync('language') != '') {
				this.language = uni.getStorageSync('language')
			}
		},
		computed: {
			i18n() {
				return this.$t('index')
			}
		},
		methods: {
			//协议
			reminder(){
				uni.$u.http.get(`/api/agreement?code=cancellation_reminder`).then((res) => {
					console.log(res);
					if(this.language =='zh-CN'){
						this.name = res.name_cn
						this.content = res.content_cn
					}else if(this.language =='en-US'){
						this.name = res.name_en
						this.content = res.content_en
					}else if(this.language =='es-ES'){
						this.name = res.name_es
						this.content = res.content_es
					}else if(this.language =='it-IT'){
						this.name = res.name_ita
						this.content = res.content_ita
					}
				});
			},
			logout() {
				uni.$u.http.get(`/api/member/freeze`).then((res) => {
					// console.log(res);
					this.$u.toast('注销成功')
					this.show = false
				});
			}
		}
	}  
</script>

<style scoped lang="scss">
	.page {
		background-color: #fff;
		height: 92.5vh;
		padding: 54rpx 44rpx;
		font-size: 30rpx;
		color: rgba(34, 34, 34, .7);

		.btn {
			background-color: #f83224;
			border-radius: 44rpx;
			color: #fff;
			margin-top: 108rpx
		}

		.cancellation {
			font-size: 24rpx;
			text-align: center;
			margin-top: 32rpx;
		}
	}
</style>