<template>
	<view class="zhuxiao">
		<view class="title">注销后，你账号将：</view>
		<view class="content" v-html="content">
			
		</view>
		<view class="fd">
			<view class="xieyi" @click="toToggle()">
				<image v-if="isCheck ==false" src="@/static/icon-select.png"></image>
				<image v-else src="@/static/icon-select-on.png"></image>我已认真阅读且同意注销账号需要注意的内容
			</view>
			<view class="btns">
				<view class="cancle" @click="toCancle">取消</view>
				<view class="sure" @click="toClick">确定</view>
			</view>
		</view>
		
	</view>
</template>

<script>
	export default {
		data() {
			return {
				isCheck: false,
				content: ""
			};
		},
		onLoad() {
			this.getInfo()
		},
		methods: {
			toToggle() {
				this.isCheck = !this.isCheck
			},
			toClick() {
				const that = this;
				if(this.isCheck == false){
					uni.showToast({
						icon: "none",
						position: "bottom",
						title: "请选择注销内容协议"
					})
					return ;
				}
				uni.showModal({
					title: "温馨提示",
					content: "是否要注销当前账号?",
					async success( res) {
						if(res.confirm){
							const res = await that.$api.cancelAccount({userId: uni.getStorageSync("userInfo").id});
							console.log(res)
							if(res.code == 200){
								uni.showToast({
									title: "注销成功",
								})
								uni.clearStorageSync();
								uni.closeSocket();
								setTimeout(()=>{
									uni.reLaunch({
										url: "/pages/login/index"
									})
								},2000)
							}else{
								uni.showToast({
									icon: "none",
									position: "bottom",
									title: res.msg
								})
							}
						}
					}
				})
				
			},
			toCancle() {
				uni.navigateBack({
					delta: 1
				})
			},
			async getInfo() {
				const { code,data } = await this.$api.getConfigData({dictType: 'CONFIG_CANCEL_ACCOUNT'});
				if(code == 200){
					this.content = data.content.replace(/style=""/g, '')
								.replace(/<img " src=/g, '<img src=')
								.replace(/<img src=/g, '<img style="width: 100%; height:100%; display:block" src=');
				
				}
			},
		}
	}
</script>

<style scoped lang="scss">
.zhuxiao{
	min-height: 100vh;
	background-color: #fff;
	padding: 30rpx 30rpx 400rpx;
	overflow: hidden;
	box-sizing: border-box;
	.title{
		font-weight: 500;
		font-size: 36rpx;
		color: #222222;
		line-height: 40rpx;
		margin-top: 20rpx;
	}
	.content{
		font-weight: 500;
		font-size: 26rpx;
		color: #666666;
		line-height: 40rpx;
		text-align: left;
		margin-top: 40rpx;
	}
	.fd{
		width: 100%;
		font-weight: 500;
		font-size: 24rpx;
		color: #222222;
		position: fixed;
		left: 0;
		bottom: 100rpx;
		z-index: 22;
		padding: 0 30rpx;
		box-sizing: border-box;
		.xieyi{
			display: flex;
			align-items: center;
			justify-content: flex-start;
			image{
				width: 35rpx;
				height: 35rpx;
				margin-right: 10rpx;
			}
		}
		.btns{
			display: flex;
			align-items: center;
			justify-content: space-between;
			margin-top: 50rpx;
			text-align: center;
			.cancle{
				width: 300rpx;
				height: 90rpx;
				line-height: 90rpx;
				background: #EDEDED;
				border-radius: 90rpx;
				font-weight: 500;
				font-size: 30rpx;
				color: #222222;
			}
			.sure{
				width: 300rpx;
				height: 90rpx;
				line-height: 90rpx;
				background: linear-gradient(0deg, #000000, #3D3B38);
				border-radius: 90rpx;
				font-weight: 500;
				font-size: 30rpx;
				color: #fff;
			}
		}
	}
}
</style>
