<template>
	<uv-toast ref="toast"></uv-toast>
	<view class="">
		<navbar :title="$t('my_center')" size="48" :backtext="$t('back')"  color="#fff" :backShow="false"></navbar>
	</view>
	<view class="app_content">
		<uv-cell-group :title="$t('policy')">
			<uv-cell :title="$t('privacy_policy')" :isLink="true" @click="showPrivacyPolicy"></uv-cell>
		</uv-cell-group>
		<br />
		<uv-cell-group title="">
			<uv-cell :title="$t('quit')" :isLink="true" @click="quit"></uv-cell>
		</uv-cell-group>
		<br />
	<!-- 	<uv-cell-group title="">
			<uv-cell :title="$t('cancel_account')" :isLink="true" @click="cancel_account"></uv-cell>
		</uv-cell-group> -->
		<uv-cell-group title="">
			<uv-cell>
				<template v-slot:title>
					<text class="cancel_account" @click="cancel_account">{{$t('cancel_account')}}</text>
				</template>
			</uv-cell>
		</uv-cell-group>
	</view>
	<uv-modal ref="cancel_account_modal" :content="$t('is_cancel_account')"
	:confirmText="$t('confirm1')" :cancelText="$t('cancel1')" showCancelButton="true"  align="center"
	@confirm="do_cancel_account" @cancel="do_cancel_account_cancel"></uv-modal>
</template>

<script>
	import {cancelaccount} from "@/common/api/user.js"
	export default {
		data() {
			return {
				userinfo:{},
			}
		},
		methods: {
			init_reload(){
				this.userinfo = uni.getStorageSync("userinfo")
			},
			quit(){
				uni.removeStorage({
					key: 'userinfo',
				});
				uni.redirectTo({
					url: '/pages/login/login'
				});
			},
			showPrivacyPolicy(){
				let weburl = 'https://app.chienxutech.com:30443/Uploads/ssjprivate_en.html';
				uni.navigateTo({
					url: '/pages/webview/webview?weburl='+weburl+'&title='+this.$t('privacy_policy')
				});	
			},
			cancel_account(){
				this.$refs.cancel_account_modal.open();
			},
			do_cancel_account(){
				let uid = this.userinfo.id
				let data={uid:uid}
				cancelaccount(data)
			},
			do_cancel_account_cancel(){
				this.$refs.cancel_account_modal.close();
			}
		},
		mounted(){
			uni.setNavigationBarTitle({
				title: this.$t('my_center')
			});
		},
		onShow(option){
			this.init_reload()
		},
	}
</script>

<style scoped>
	.app_content{
		padding: 0 1em;
	}
</style>
<style lang="scss" scoped>
	.cancel_account{
		color: $uni-color-error;
	}
</style>
