VUE开发钱包助记词的逻辑

	<!-- 导航栏返回按钮 -->
	<!-- <van-nav-bar title='备份助记词' left-arrow @click-left="onClickLeft" /> -->
	<!-- 选中词 -->
	<div class="seleWords">
		<ul class="selected">
			<li :class="{'transSelect':selectab === index }" class="li" v-for="(item2 , index) in wordsArr" @click="addRemove(index,$event)">{{item2}}</li>
			<li class="li" v-for="(item1,index) in wordsNum"></li>
		</ul>
	</div>

	<!-- 助词表 -->
	<div>
		<ul class="wordsbox">
			<li ref="item" class="li" v-for="(item,index) in arr" :key="index" @click="add(index,$event)">{{item}}</li>
		</ul>
	</div>
	<button class="btn" @click="Verification">
		验证
	</button>
</div>
export default {
	data() {
		return {

			wordsArr: [],
			wordsNum: [],
			arr: ["notice", "cactus", "cushion", "panda", "stool", "loud", "wash", "finger", "actual", "surface", "job", "girl"],
			selectab: "",
			mnemonic: ["notice", "cactus", "cushion", "panda", "stool", "loud", "wash", "finger", "actual", "surface", "job",
				"girl"
			],

		};
	},
	mounted() {

		for (let i = 0; i < 12; i++) {
			this.wordsNum.push(i);
		}
	},
	methods: {
		// 添加
		add(number, e) {
			var temp = e.srcElement;
			temp.style.background = "#999";
			//定义一个变量接收数组
			let size = this.arr;
			// 空数组添加点击的这个内容
			let num = this.wordsArr.length;
			this.wordsNum.length = 0;
			if (num != 12) {
				this.wordsArr.push(size[number]);
				let choures = 12 - num;
				if (choures == 0) {
					this.wordsNum.length = 0;
				} else {
					for (let i = 1; i < choures; i++) {
						this.wordsNum.push(i);
					}
				}
			} else {
				this.wordsNum.length = 0;
			}
		},
		// 返回上一页
		onClickLeft() {
			this.$router.go(-1)
		},
		// 验证
		Verification() {
			console.log(this.wordsArr)
			console.log(this.mnemonic)
			let flag = true;
			let len = this.wordsArr.length;
			// 判断本地存储的长度跟选中添加的长度是否一致
			if (this.mnemonic.length != len) {
				flag = false;
			}
			// 判断每个数组中的单词是不是全等
			for (let i = 0; i < len; i++) {
				if (this.wordsArr[i] != this.mnemonic[i]) {
					flag = false;
				}
			}
			if (flag == true) {
				console.log("验证正确")

			} else {
				// 验证失败的步骤
				this.$dialog.alert({
					message: '请输入正确的助记词'
				}).then(() => {
					this.$router.go(0)
				});
			}
		},
		addRemove(index, e) {
			//获取点击的元素,也就是wordsArr的索引
			let words = this.wordsArr;
			//原数组
			let size = this.arr;
			//标识
			let uuid = words[index];
			size.forEach((v, i) => {
				if (uuid == v) {
					//记录arr数组需要还原的位置索引
					this.$refs.style.background ="#4D5B80"
					
				}
			});
			
			//删除点击的这个元素,也就是wordsArr中的元素,重新获取wordsArr的长度,再重新计算空格的数量。
			words.splice(index, 1);
			//console.log(words);

			let num = words.length;
			this.wordsNum.length = 0; //空格

			let choures = 12 - num;
			if (choures == 0) {
				this.wordsNum.length = 0;
			} else {
				for (let i = 0; i < choures; i++) {
					this.wordsNum.push(i);
				}
			}
		}
	},
}
.spareAux {
	text-align: center;
}

.spareAux .wordsbox {
	padding: 0 10px;
	display: flex;
	flex-wrap: wrap;
	justify-content: space-around;
}

.spareAux .wordsbox .li {
	text-align: center;
	width: 100px;
	height: 45px;
	line-height: 45px;
	border-radius: 5px;
	background: -webkit-gradient(linear, 30% 35%, 95% 100%, from(#232E6C), to(#4D5B80), color-stop(0.5, #4E5C81));
	color: #fff;
	border-radius: 5px;
	margin-bottom: 5px;
}

.spareAux .seleWords {
	margin: 5px;
	box-shadow: 0px 4px 10px #666;
	padding: 5px 0rem;
}

/* 空格填充词 */
.spareAux .selected {
	display: flex;
	flex-wrap: wrap;
	padding-left: 8px;
	width: 90%;

}

.spareAux .selected li {
	border: 1px solid #232e6c;
	width: 100px;
	display: inline-block;
	height: 45px;
	background: #FFFFFF;
	color: #232e6c;
	line-height: 45px;
	margin-right: 2px;
	border-radius: 5px;
	margin-bottom: 5px;
}

.spareAux .btn {
	width: 90%;
	margin: 0 auto;
	font-size: 28px;
	color: #fff;
	height: 80px;
	border-radius: 5px;
	background: -webkit-gradient(linear, 30% 35%, 95% 100%, from(#232E6C), to(#4D5B80), color-stop(0.5, #4E5C81));
	line-height: 80px;
	outline: none;
	border: none;
}
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
软件名称:单助记手<br>软件版本:V0.2<br>软件授权:免费<br>软件语言:简体中文<br>使用平台:XP/2003<br>建议分类:教育教学/外语学习<br>插件情况:无<br>软件简介:小巧绿色且易于沉迷的单拼写助记软件。<br>更多介绍:<br> 本软件基于一个很简单的原理:单记忆需要重复,初期重复次数要多,往后可以越来越少。程序每次从库中按一定条件选择出25个单让你记忆,然后让你根据提示进行拼写,拼写正确次数达标时即可过关,否则总出错的单会一直缠着你。<br> 你无需按照固定的时间间隔来学习,因为每学一次都会有进步,每学一次都有新体验。每次拼写完你都会获得一定经验值,随着经验值的增长,你的汇量自然得到扩大。<br> 因为它比一张软盘的容量还小,所以只要带上库文件和主程序,你就可以在任何有电脑的地方继续学习。学完一个库后,你可以到网上下载新的库继续学习;你还可以拿自己用过的库制作成更出色的库文件来共享给别人。<br> 在V0.2版中,新增的库维护器可以对属于你自己的库进行更方便的定制,新增的音标显示和单朗读功能使你即使脱离其它典软件也可以学习新单。<br> 附带库文件的内容是大学英语四级汇,更多库请到作者主页免费下载。如需特殊库也可联系作者免费定制。<br><br>注意<br>---------<br> 应用程序必须同库文件“Englishword.pls”在同一文件夹内才能运行。<br> 字体文件“Ksphonet.ttf”只有同应用程序在同一文件夹内才能保证音标正确显示。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值