Mui手势密码



	
		
		index页面
		
		
		
		

		
		
		
		
	
	
		

设置手势密码

(function($, doc) {
	mui.init({
		keyEventBind: {
			backbutton: false
		}
	});
	var view = null,
		holder = doc.querySelector('#holder'),
		lockTit = doc.querySelector('#lockTit'),
		alert = doc.querySelector('#alert'),
		modify = doc.querySelector('#modify'),
		forget = doc.querySelector('#forget'),
		pass = [],
		flag = false,
		user = null,
		serPass = '';
	$.plusReady(function() {
		view = plus.webview.currentWebview(); //当前webview
		mainIf();
	})
	document.addEventListener("resume", function() {
		mainIf();
	})
	function mainIf() {
		holderDoc('设置', '0');
	}
	//设置密码手势监听
	function holderDoc(lockTit, status) {
		if(lockTit.indexOf('设置') > -1) {
			holder.addEventListener('done', function(event) {
				var rs = event.detail;
				if(rs.points.length < 4) {
					alert.style.color = '#f50';
					alert.innerText = '请至少设置4个密码连接点';
					pass = [];
					rs.sender.clear();
					return;
				}
				pass.push(rs.points.join(''));
				if(pass.length >= 2) {
					if(pass[0] == pass[1]) {
						var a = 1;
						console.log(pass[0])
						App.setHandPassword(pass[0],function(res){
							console.log('手势密码----',JSON.stringify(res))
							var result = JSON.parse(res.result);
							if(res.stateCode == 'SUCCESS'){
								alert.style.color = '#f50';
								alert.innerText = '图案设定完成';
								var my = plus.webview.getWebviewById('pages/my.html');
								plus.webview.create('pages/my.html');
								closeOthPage();
								mui.fire(my,'back');
							}else{
								mui.alert(res.message,'提示','确定',function (e) {
								},'div')
							}
						})
					} else {
						alert.style.color = '#f50';
						alert.innerText = '两次图案绘制不一致';
					}
					rs.sender.clear();
					pass = [];
				} else {
					alert.style.color = '#f50';
					alert.innerText = '请再次绘制图案密码';
					rs.sender.clear();
				}
			});
		} 
	}
	
}(mui, document));




你可能感兴趣的:(H5)