index.js
3.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
/* DaTouWang URL: www.datouwang.com */
var provinces = new Array("京","沪","浙","苏","粤","鲁","晋","冀",
"豫","川","渝","辽","吉","黑","皖","鄂",
"津","贵","云","桂","琼","青","新","藏",
"蒙","宁","甘","陕","闽","赣","湘");
var keyNums = new Array("0","1","2","3","4","5","6","7","8","9",
"Q","W","E","R","T","Y","U","I","O","P",
"A","S","D","F","G","H","J","K","L",
"关闭","Z","X","C","V","B","N","M","←");
var next=0;
function showProvince(){
$("#pro").html("");
var ss="";
for(var i=0;i<provinces.length;i++){
ss=ss+addKeyProvince(i)
}
$("#pro").html("<ul class='clearfix ul_pro'>"+ss+"<li class='li_close' onclick='closePro();'><span>关闭</span></li><li class='li_clean' onclick='cleanPro();'><span>清空</span></li></ul>");
}
function showKeybord(){
$("#pro").html("");
var sss="";
for(var i=0;i<keyNums.length;i++){
sss=sss+'<li class="ikey ikey'+i+' '+(i>9?"li_zm":"li_num")+' '+(i>28?"li_w":"")+'" ><span onclick="choosekey(this,'+i+');">'+keyNums[i]+'</span></li>'
}
$("#pro").html("<ul class='clearfix ul_keybord'>"+sss+"</ul>");
}
function addKeyProvince(provinceIds){
var addHtml = '<li>';
addHtml += '<span onclick="chooseProvince(this);">'+provinces[provinceIds]+'</span>';
addHtml += '</li>';
return addHtml;
}
function chooseProvince(obj){
$(".input_pro span").text($(obj).text());
$(".input_pro").addClass("hasPro");
$(".input_pp").find("span").text("");
$(".ppHas").removeClass("ppHas");
next=0;
showKeybord();
}
function choosekey(obj,jj){
if(jj==29){
//alert("车牌:"+$(".car_input").attr("data-pai"));
layer.closeAll();
}else if(jj==37){
if($(".ppHas").length==0){
$(".hasPro").find("span").text("");
$(".hasPro").removeClass("hasPro");
showProvince();
next=0;
}
$(".ppHas:last").find("span").text("");
$(".ppHas:last").removeClass("ppHas");
next=next-1;
if(next<1){
next=0;
}
console.log(next);
}else{
if(next>5){
return
}
console.log(next);
for(var i = 0; i<$(".input_pp").length;i++){
if(next==0 & jj<10 & $(".input_pp:eq("+next+")").hasClass("input_zim")){
layer.open({
content: '车牌第二位为字母',
skin: 'msg',
time: 1
});
return
}
$(".input_pp:eq("+next+")").find("span").text($(obj).text());
$(".input_pp:eq("+next+")").addClass("ppHas");
next=next+1;
if(next>5){
next=6;
}
getpai();
return
}
}
}
function closePro(){
layer.closeAll()
}
function cleanPro(){
$(".ul_input").find("span").text("");
$(".hasPro").removeClass("hasPro");
$(".ppHas").removeClass("ppHas");
next=0;
}
function trimStr(str){return str.replace(/(^\s*)|(\s*$)/g,"");}
function getpai(){
var pai=trimStr($(".car_input").text());
$(".car_input").attr("data-pai",pai);
}
window.onload = function() {
$(".input_pro").click(function(){
layer.open({
type: 1
,content: '<div id="pro"></div>'
,anim: 'up'
,shade :false
,style: 'position:fixed; bottom:0; left:0; width: 100%; height: auto; padding:0; border:none;'
});
showProvince();
});
$(".input_pp").click(function(){
if($(".input_pro").hasClass("hasPro")){ // 如果已选择省份
layer.open({
type: 1
,content: '<div id="pro"></div>'
,anim: 'up'
,shade :false
,style: 'position:fixed; bottom:0; left:0; width: 100%; height: auto; padding:0; border:none;'
});
showKeybord();
}else{
$(".input_pro").click()
}
})
}