<template>
	<view class="">
		<navigation :showBack="true">
			Backup mnemonics
		</navigation>
		<view class="main">
			<view class="imgcon">
			<image src="../../../static/tongyonh/notifications_image.png" mode="aspectFill" class="img1"></image>	
			<image src="../../../static/tongyonh/Shield-protected.png" mode="aspectFill" class="img2"></image>
			</view>
		  <view class="title">
		  	 Backup Tips
		  </view>
		  <view class="bottom">
		  		<u-checkbox-group @change="checkedAll()">
		  			<u-checkbox 
		  				@change="checkboxChange(index)" 
		  				v-model="item.checked" 
		  				v-for="(item, index) in list" :key="index" 
		  				:name="item.name"
						shape=""
						size="48"
						:wrap="true"
						active-color="#5B53FF"
						:disabled="item.disabled"
		  			><text class="textname">{{item.name}}</text></u-checkbox>
		  		</u-checkbox-group>
				<button  class="custom-style" @click="test"  :class="inde?'sheng':''">Start backup</button>
		  	</view>
		</view>
	</view>
	
</template>

<script>
	import cont from "@/components/navigation/navigation.vue"
	export default {
		data() {
			return {
				list: [
					{
						name: 'Axioms are the only way to control assets.',
						checked:  false,
						disabled: false
					},
					{
						name: 'You cannot retrieve a lost mnemonic, so be sure to back it up!',
						checked:  false,
						disabled: false
					},
					{
						name: 'Do not disclose your mnemonic to anyone.',
						checked:  false,
						disabled: false
					}
				],
				inde:false,
				showI:-1
			};
		},
		methods: {
			test(){
				if(this.inde){
					console.log(this.list,777)
					for(var i=0;i<this.list.length;i++){
						this.list[i].checked=false
					}
					this.inde=false
					console.log(this.list,8888)
					uni.navigateTo({
						url:'./backUp2/index',
					})
				
				}else{
					uni.showToast({
						title: 'Please check the prompt to agree to backup',
						icon: 'none',
						duration: 1500
					}) 
				}
			},
			// 选中某个复选框时，由checkbox时触发
			checkboxChange(i) {
			      this.list[i].checked=true
			},
			// 选中任一checkbox时，由checkbox-group触发
			checkboxGroupChange(e) {
				// console.log(e);
			},
			// 全选
			checkedAll() {
				for(var i=0;i<this.list.length;i++){
					console.log(i)
				
				if(this.list[i].checked==true){
					this.inde=true;
					console.log(this.inde,'true')
				}else{
					this.inde=false
					console.log(this.inde)
				} 
				}
			}
		},
		onLoad(item){
		
			if(item!=''||item!=undefined){
				var word=this.$Token.creatingWallets();
				var word2=word.mnemonic
				// 读到钱包助记词信息,存入缓存
				uni.setStorage({
					key: 'word',
					data: word2,
					success: function() {
						console.log('success',word2)
					}
				});;
				uni.setStorageSync('createWalletName',item.name)
			}
		}
	};
</script>
<style scoped>
	.custom-style {
		line-height: 112rpx;
		text-align: center;
		 color: #fff;
		 background-color: #ABA7FD;
		 border-radius: 40rpx;
	}
	.u-default-hover{
		background-color: #5B53FF !important;
		border-radius: 40rpx !important;
		color: #fff !important;
		border: none;
	}
</style>

<style>

	@import './index.css';

</style>
