commit | author | age
|
19351a
|
1 |
//检查结果 |
B |
2 |
var _CHECK_RESULT = { |
|
3 |
// 邮箱检查结果是否可以注册 |
|
4 |
email: false, |
|
5 |
// 手机检查结果是否可以注册 |
|
6 |
mobile_phone: false |
|
7 |
}; |
|
8 |
|
|
9 |
/* $Id : user.js 4865 2007-01-31 14:04:10Z paulgao $ */ |
|
10 |
/* 代码增加2014-12-23 by _star */ |
|
11 |
function check_username(val) { |
|
12 |
if (val == '') { |
|
13 |
document.getElementById('username_message').innerHTML = '用户名不能为空!'; |
|
14 |
} else if (val.match(/[\u4e00-\u9fa5]/)) { |
|
15 |
document.getElementById('username_message').innerHTML = '用户名不能有中文!'; |
|
16 |
/* 代码增加 By Start */ |
|
17 |
} else if (!val.match(/^[a-zA-Z0-9_]{1,}$/)) { |
|
18 |
document.getElementById('username_message').innerHTML = '用户名只能由字母数字下划线组成!'; |
|
19 |
/* 代码增加 By End */ |
|
20 |
} else { |
|
21 |
Ajax.call('user.php?act=check_username', 'username=' + val, checkusername_callback, 'GET', 'TEXT', true, true); |
|
22 |
} |
|
23 |
} |
|
24 |
|
|
25 |
function checkusername_callback(result) { |
|
26 |
if (result == 0) { |
|
27 |
document.getElementById('username_message').innerHTML = '可以修改'; |
|
28 |
} else { |
|
29 |
document.getElementById('username_message').innerHTML = '用户名已存在,请重新输入!'; |
|
30 |
} |
|
31 |
} |
|
32 |
|
|
33 |
function identity() { |
|
34 |
var frm = document.forms['formIdentity']; |
|
35 |
var real_name = frm.elements['real_name'].value; |
|
36 |
var card = frm.elements['card'].value; |
|
37 |
var country = frm.elements['country'].value; |
|
38 |
var province = frm.elements['province'].value; |
|
39 |
var city = frm.elements['city'].value; |
|
40 |
var district = frm.elements['district'].value; |
|
41 |
var address = frm.elements['address'].value; |
|
42 |
if (real_name.length == 0) { |
|
43 |
$('form[name=formIdentity]').find('.people-name-notice').html('真实姓名不能为空').parents('.required-notice').css('visibility','visible'); |
|
44 |
//alert('真实姓名不能为空'); |
|
45 |
return false; |
|
46 |
}else{ |
|
47 |
$('form[name=formIdentity]').find('.people-name-notice').html('').parents('.required-notice').css('visibility','hidden'); |
|
48 |
} |
|
49 |
if (card.length == 0) { |
|
50 |
$('form[name=formIdentity]').find('.people-num-notice').html('身份证号不能为空').parents('.required-notice').css('visibility','visible'); |
|
51 |
//alert('身份证号不能为空!'); |
|
52 |
return false; |
|
53 |
}else { |
|
54 |
var reg = /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/; |
|
55 |
if (reg.test(card) === false) { |
|
56 |
$('form[name=formIdentity]').find('.people-num-notice').html('身份证输入不合法').parents('.required-notice').css('visibility','visible'); |
|
57 |
//alert("身份证输入不合法"); |
|
58 |
return false; |
|
59 |
}else{ |
|
60 |
$('form[name=formIdentity]').find('.people-num-notice').html('').parents('.required-notice').css('visibility','hidden'); |
|
61 |
} |
|
62 |
} |
|
63 |
|
|
64 |
if (country == 0 || province == 0 || city == 0 || district == 0) { |
|
65 |
$('form[name=formIdentity]').find('.address-notice').html('现居地请选择完整').parents('.required-notice').css('visibility','visible'); |
|
66 |
//alert('现居地请选择完整!'); |
|
67 |
return false; |
|
68 |
}else{ |
|
69 |
$('form[name=formIdentity]').find('.address-notice').html('').parents('.required-notice').css('visibility','hidden'); |
|
70 |
} |
|
71 |
if (address.length == 0) { |
|
72 |
$('form[name=formIdentity]').find('.address-detail-notice').html('详细地址不能为空').parents('.required-notice').css('visibility','visible'); |
|
73 |
//alert('详细地址不能为空!'); |
|
74 |
return false; |
|
75 |
}else{ |
|
76 |
$('form[name=formIdentity]').find('.address-detail-notice').html('').parents('.required-notice').css('visibility','hidden'); |
|
77 |
} |
|
78 |
return true; |
|
79 |
} |
|
80 |
/* 代码增加2014-12-23 by _end */ |
|
81 |
/******************************************************************************* |
|
82 |
* 修改会员信息 |
|
83 |
*/ |
|
84 |
function userEdit() { |
|
85 |
var frm = document.forms['formEdit']; |
|
86 |
var email = frm.elements['email'].value; |
|
87 |
var msg = ''; |
|
88 |
var reg = null; |
|
89 |
var passwd_answer = frm.elements['passwd_answer'] ? Utils.trim(frm.elements['passwd_answer'].value) : ''; |
|
90 |
var sel_question = frm.elements['sel_question'] ? Utils.trim(frm.elements['sel_question'].value) : ''; |
|
91 |
/* 代码增加2014-12-23 by _star */ |
|
92 |
var username = frm.elements['username'].value; |
|
93 |
if (username.length == 0) { |
|
94 |
msg += '用户名不能为空' + '\n'; |
|
95 |
} else if (username.match(/[\u4e00-\u9fa5]/)) { |
|
96 |
msg += username_chana + '\n'; |
|
97 |
} else if (!username.match(/^[a-zA-Z0-9_]{1,}$/)) { |
|
98 |
msg += '用户名只能由字母数字下划线组成' + '\n'; |
|
99 |
} |
|
100 |
/* 代码增加2014-12-23 by _end */ |
|
101 |
if (email.length == 0) { |
|
102 |
msg += email_empty + '\n'; |
|
103 |
} else { |
|
104 |
if (!(Utils.isEmail(email))) { |
|
105 |
msg += email_error + '\n'; |
|
106 |
} |
|
107 |
} |
|
108 |
|
|
109 |
if (passwd_answer.length > 0 && sel_question == 0 || document.getElementById('passwd_quesetion') && passwd_answer.length == 0) { |
|
110 |
msg += no_select_question + '\n'; |
|
111 |
} |
|
112 |
|
|
113 |
for (var i = 7; i < frm.elements.length - 2; i++) // 从第七项开始循环检查是否为必填项 |
|
114 |
{ |
|
115 |
var needinput = document.getElementById(frm.elements[i].name + 'i') ? document.getElementById(frm.elements[i].name + 'i') : ''; |
|
116 |
|
|
117 |
if (needinput != '' && frm.elements[i].value.length == 0) { |
|
118 |
msg += '- ' + needinput.innerHTML + msg_blank + '\n'; |
|
119 |
} |
|
120 |
} |
|
121 |
|
|
122 |
if (msg.length > 0) { |
|
123 |
alert(msg); |
|
124 |
return false; |
|
125 |
} else { |
|
126 |
return true; |
|
127 |
} |
|
128 |
} |
|
129 |
|
|
130 |
/* 会员修改密码 */ |
|
131 |
function editPassword() { |
|
132 |
var frm = document.forms['formPassword']; |
|
133 |
var old_password = frm.elements['old_password'].value; |
|
134 |
var new_password = frm.elements['new_password'].value; |
|
135 |
var confirm_password = frm.elements['comfirm_password'].value; |
|
136 |
|
|
137 |
var msg = ''; |
|
138 |
var reg = null; |
|
139 |
|
|
140 |
if (old_password.length == 0) { |
|
141 |
msg += old_password_empty + '\n'; |
|
142 |
} |
|
143 |
|
|
144 |
if (new_password.length == 0) { |
|
145 |
msg += new_password_empty + '\n'; |
|
146 |
} |
|
147 |
|
|
148 |
if (confirm_password.length == 0) { |
|
149 |
msg += confirm_password_empty + '\n'; |
|
150 |
} |
|
151 |
|
|
152 |
if (new_password.length > 0 && confirm_password.length > 0) { |
|
153 |
if (new_password != confirm_password) { |
|
154 |
msg += both_password_error + '\n'; |
|
155 |
} |
|
156 |
} |
|
157 |
|
|
158 |
if (msg.length > 0) { |
|
159 |
alert(msg); |
|
160 |
return false; |
|
161 |
} else { |
|
162 |
return true; |
|
163 |
} |
|
164 |
} |
|
165 |
|
|
166 |
/******************************************************************************* |
|
167 |
* 对会员的留言输入作处理 |
|
168 |
*/ |
|
169 |
function submitMsg() { |
|
170 |
var frm = document.forms['formMsg']; |
|
171 |
var msg_title = frm.elements['msg_title'].value; |
|
172 |
var msg_content = frm.elements['msg_content'].value; |
|
173 |
var msg = ''; |
|
174 |
|
|
175 |
if (msg_title.length == 0) { |
|
176 |
$('form[name=formMsg]').find('.message-title-notice').html(msg_title_empty).parents('.required-notice').css('visibility','visible'); |
|
177 |
msg += msg_title_empty + '\n'; |
|
178 |
}else if(msg_title.length > 200) { |
|
179 |
$('form[name=formMsg]').find('.message-title-notice').html(msg_title_limit).parents('.required-notice').css('visibility','visible'); |
|
180 |
msg += msg_title_limit + '\n'; |
|
181 |
}else{ |
|
182 |
$('form[name=formMsg]').find('.message-title-notice').html('').parents('.required-notice').css('visibility','hidden'); |
|
183 |
} |
|
184 |
if (msg_content.length == 0) { |
|
185 |
$('form[name=formMsg]').find('.message-content-notice').html(msg_content_empty).parents('.required-notice').css('visibility','visible'); |
|
186 |
msg += msg_content_empty + '\n' |
|
187 |
}else{ |
|
188 |
$('form[name=formMsg]').find('.message-content-notice').html('').parents('.required-notice').css('visibility','hidden'); |
|
189 |
} |
|
190 |
|
|
191 |
if (msg.length > 0) { |
|
192 |
//alert(msg); |
|
193 |
return false; |
|
194 |
} else { |
|
195 |
return true; |
|
196 |
} |
|
197 |
} |
|
198 |
|
|
199 |
/******************************************************************************* |
|
200 |
* 会员找回密码时,对输入作处理 |
|
201 |
*/ |
|
202 |
function submitPwdInfo() { |
|
203 |
var frm = document.forms['getPassword']; |
|
204 |
var user_name = frm.elements['user_name'].value; |
|
205 |
var email = frm.elements['email'].value; |
|
206 |
|
|
207 |
var errorMsg = ''; |
|
208 |
if (user_name.length == 0) { |
|
209 |
errorMsg += user_name_empty + '\n'; |
|
210 |
} |
|
211 |
|
|
212 |
if (email.length == 0) { |
|
213 |
errorMsg += email_address_empty + '\n'; |
|
214 |
} else { |
|
215 |
if (!(Utils.isEmail(email))) { |
|
216 |
errorMsg += email_address_error + '\n'; |
|
217 |
} |
|
218 |
} |
|
219 |
|
|
220 |
if (errorMsg.length > 0) { |
|
221 |
alert(errorMsg); |
|
222 |
return false; |
|
223 |
} |
|
224 |
|
|
225 |
return true; |
|
226 |
} |
|
227 |
|
|
228 |
/******************************************************************************* |
|
229 |
* 会员找回密码时,对输入作处理 |
|
230 |
*/ |
|
231 |
function submitPwd() { |
|
232 |
var frm = document.forms['getPassword2']; |
|
233 |
var password = frm.elements['new_password'].value; |
|
234 |
var confirm_password = frm.elements['confirm_password'].value; |
|
235 |
|
|
236 |
var errorMsg = ''; |
|
237 |
if (password.length == 0) { |
|
238 |
errorMsg += new_password_empty + '\n'; |
|
239 |
} |
|
240 |
|
|
241 |
if (confirm_password.length == 0) { |
|
242 |
errorMsg += confirm_password_empty + '\n'; |
|
243 |
} |
|
244 |
|
|
245 |
if (confirm_password != password) { |
|
246 |
errorMsg += both_password_error + '\n'; |
|
247 |
} |
|
248 |
|
|
249 |
if (errorMsg.length > 0) { |
|
250 |
alert(errorMsg); |
|
251 |
return false; |
|
252 |
} else { |
|
253 |
return true; |
|
254 |
} |
|
255 |
} |
|
256 |
|
|
257 |
/******************************************************************************* |
|
258 |
* 处理会员提交的缺货登记 |
|
259 |
*/ |
|
260 |
function addBooking() { |
|
261 |
var frm = document.forms['formBooking']; |
|
262 |
var goods_id = frm.elements['id'].value; |
|
263 |
var rec_id = frm.elements['rec_id'].value; |
|
264 |
var number = frm.elements['number'].value; |
|
265 |
var desc = frm.elements['desc'].value; |
|
266 |
var linkman = frm.elements['linkman'].value; |
|
267 |
var email = frm.elements['email'].value; |
|
268 |
var tel = frm.elements['tel'].value; |
|
269 |
var msg = ""; |
|
270 |
|
|
271 |
if (number.length == 0) { |
|
272 |
msg += booking_amount_empty + '\n'; |
|
273 |
} else { |
|
274 |
var reg = /^[0-9]+/; |
|
275 |
if (!reg.test(number)) { |
|
276 |
msg += booking_amount_error + '\n'; |
|
277 |
} |
|
278 |
} |
|
279 |
|
|
280 |
if (desc.length == 0) { |
|
281 |
msg += describe_empty + '\n'; |
|
282 |
} |
|
283 |
|
|
284 |
if (linkman.length == 0) { |
|
285 |
msg += contact_username_empty + '\n'; |
|
286 |
} |
|
287 |
|
|
288 |
if (email.length == 0) { |
|
289 |
msg += email_empty + '\n'; |
|
290 |
} else { |
|
291 |
if (!(Utils.isEmail(email))) { |
|
292 |
msg += email_error + '\n'; |
|
293 |
} |
|
294 |
} |
|
295 |
|
|
296 |
if (tel.length == 0) { |
|
297 |
msg += contact_phone_empty + '\n'; |
|
298 |
} |
|
299 |
|
|
300 |
if (msg.length > 0) { |
|
301 |
alert(msg); |
|
302 |
return false; |
|
303 |
} |
|
304 |
|
|
305 |
return true; |
|
306 |
} |
|
307 |
|
|
308 |
/******************************************************************************* |
|
309 |
* 会员登录 |
|
310 |
*/ |
|
311 |
function user_login(back_history){ |
|
312 |
|
|
313 |
var logform = $('form[name="formLogin"]'); |
|
314 |
var username = logform.find('#username'); |
|
315 |
var password = logform.find('#password'); |
|
316 |
var captcha = logform.find('#authcode'); |
|
317 |
var error = logform.find('.msg-wrap'); |
|
318 |
var back_act = logform.find("input[name='back_act']").val(); |
|
319 |
|
|
320 |
if(username.val()==''){ |
|
321 |
error.css({'visibility':'visible'}); |
|
322 |
error.find('.msg-error-text').html('请输入账户名'); |
|
323 |
username.parents('.item').addClass('item-error'); |
|
324 |
return false; |
|
325 |
} |
|
326 |
|
|
327 |
if(password.val()==''){ |
|
328 |
error.css({'visibility':'visible'}); |
|
329 |
password.parents('.item').addClass('item-error'); |
|
330 |
error.find('.msg-error-text').html('请输入密码'); |
|
331 |
return false; |
|
332 |
} |
|
333 |
|
|
334 |
if(captcha.val()==''){ |
|
335 |
error.css({'visibility':'visible'}); |
|
336 |
captcha.parents('.item-detail').addClass('item-error'); |
|
337 |
error.find('.msg-error-text').html('请输入验证码'); |
|
338 |
return false; |
|
339 |
} |
|
340 |
|
|
341 |
if(back_history){ |
|
342 |
Ajax.call( 'user.php?act=act_login', 'username=' + username.val()+'&password='+password.val()+'&captcha='+captcha.val()+'&back_act='+back_act, return_login_back , 'POST', 'JSON'); |
|
343 |
}else{ |
|
344 |
Ajax.call( 'user.php?act=act_login', 'username=' + username.val()+'&password='+password.val()+'&captcha='+captcha.val()+'&back_act='+back_act, return_login , 'POST', 'JSON'); |
|
345 |
} |
|
346 |
return false; |
|
347 |
} |
|
348 |
function return_login(result){ |
|
349 |
if(result.error>0){ |
|
350 |
$('form[name="formLogin"]').find('.msg-error-text').html(result.message); |
|
351 |
$('#o-authcode').find('img').attr('src','captcha.php?is_login=1&'+Math.random()); |
|
352 |
if(result.message != '对不起,您输入的验证码不正确。'){ |
|
353 |
$('#authcode').parents('.item-detail').removeClass('item-error'); |
|
354 |
$('form[name="formLogin"]').find('.msg-wrap').css('visibility','visible'); |
|
355 |
} |
|
356 |
if(result.message == '对不起,您输入的验证码不正确。'){ |
|
357 |
$('#authcode').parents('.item-detail').addClass('item-error'); |
|
358 |
$('form[name="formLogin"]').find('.msg-wrap').css('visibility','visible'); |
|
359 |
} |
|
360 |
if(result.message == '用户名或密码错误'){ |
|
361 |
$('#password,#username').parents('.item').addClass('item-error'); |
|
362 |
$('form[name="formLogin"]').find('.msg-wrap').css('visibility','visible'); |
|
363 |
} |
|
364 |
if(result.message != '用户名或密码错误'){ |
|
365 |
$('#password,#username').parents('.item').removeClass('item-error'); |
|
366 |
$('form[name="formLogin"]').find('.msg-wrap').css('visibility','visible'); |
|
367 |
} |
|
368 |
}else{ |
|
369 |
$('.pop-login,.pop-mask').hide(); |
|
370 |
$('form[name="formLogin"]').find('.msg-error-text').css('visibility','visible'); |
|
371 |
top.location.reload(); |
|
372 |
} |
|
373 |
} |
|
374 |
function return_login_back(result){ |
|
375 |
if(result.error>0){ |
|
376 |
$('form[name="formLogin"]').find('.msg-error-text').html(result.message); |
|
377 |
$('#o-authcode').find('img').attr('src','captcha.php?is_login=1&'+Math.random()); |
|
378 |
if(result.message != '对不起,您输入的验证码不正确。'){ |
|
379 |
$('#authcode').parents('.item-detail').removeClass('item-error'); |
|
380 |
$('form[name="formLogin"]').find('.msg-wrap').css('visibility','visible'); |
|
381 |
} |
|
382 |
if(result.message == '对不起,您输入的验证码不正确。'){ |
|
383 |
$('#authcode').parents('.item-detail').addClass('item-error'); |
|
384 |
$('form[name="formLogin"]').find('.msg-wrap').css('visibility','visible'); |
|
385 |
} |
|
386 |
if(result.message == '用户名或密码错误'){ |
|
387 |
$('#password,#username').parents('.item').addClass('item-error'); |
|
388 |
$('form[name="formLogin"]').find('.msg-wrap').css('visibility','visible'); |
|
389 |
} |
|
390 |
if(result.message != '用户名或密码错误'){ |
|
391 |
$('#password,#username').parents('.item').removeClass('item-error'); |
|
392 |
$('form[name="formLogin"]').find('.msg-wrap').css('visibility','visible'); |
|
393 |
} |
|
394 |
}else{ |
|
395 |
$('form[name="formLogin"]').find('.msg-error-text').css('visibility','visible'); |
|
396 |
window.location.href = result.url; |
|
397 |
} |
|
398 |
} |
|
399 |
function userLogin() { |
|
400 |
var frm = document.forms['formLogin']; |
|
401 |
var username = frm.elements['username'].value; |
|
402 |
var password = frm.elements['password'].value; |
|
403 |
var msg = ''; |
|
404 |
|
|
405 |
if (username.length == 0) { |
|
406 |
msg += username_empty + '\n'; |
|
407 |
} |
|
408 |
|
|
409 |
if (password.length == 0) { |
|
410 |
msg += password_empty + '\n'; |
|
411 |
} |
|
412 |
|
|
413 |
if (msg.length > 0) { |
|
414 |
alert(msg); |
|
415 |
return false; |
|
416 |
} else { |
|
417 |
return true; |
|
418 |
} |
|
419 |
} |
|
420 |
|
|
421 |
function chkstr(str) { |
|
422 |
for (var i = 0; i < str.length; i++) { |
|
423 |
if (str.charCodeAt(i) < 127 && !str.substr(i, 1).match(/^\w+$/ig)) { |
|
424 |
return false; |
|
425 |
} |
|
426 |
} |
|
427 |
return true; |
|
428 |
} |
|
429 |
|
|
430 |
function check_password(password) { |
|
431 |
conform_password = document.getElementById('conform_password').value; |
|
432 |
if (password.length < 6) { |
|
433 |
document.getElementById('password_notice').innerHTML = password_shorter; |
|
434 |
$("#pwd_notice").show(); |
|
435 |
$("#pwd_intensity").hide(); |
|
436 |
} else if (conform_password.length > 0) { |
|
437 |
if (password != conform_password) { |
|
438 |
document.getElementById('password_notice').innerHTML = confirm_password_invalid; |
|
439 |
document.getElementById('password_notice').style.color = "#E31939"; |
|
440 |
$("#pwd_notice").show(); |
|
441 |
$("#pwd_intensity").hide(); |
|
442 |
} else { |
|
443 |
document.getElementById('password_notice').innerHTML = msg_can_rg; |
|
444 |
document.getElementById('password_notice').style.color = "#093"; |
|
445 |
document.getElementById('conform_password_notice').innerHTML = msg_can_rg; |
|
446 |
document.getElementById('conform_password_notice').style.color = "#093"; |
|
447 |
$("#pwd_notice").hide(); |
|
448 |
$("#pwd_intensity").show(); |
|
449 |
} |
|
450 |
} else { |
|
451 |
document.getElementById('password_notice').innerHTML = msg_can_rg; |
|
452 |
document.getElementById('password_notice').style.color = "#093"; |
|
453 |
$("#pwd_notice").hide(); |
|
454 |
$("#pwd_intensity").show(); |
|
455 |
} |
|
456 |
} |
|
457 |
|
|
458 |
function check_conform_password(conform_password) { |
|
459 |
var password = document.getElementById('password').value; |
|
460 |
|
|
461 |
if (conform_password.length < 6) { |
|
462 |
document.getElementById('conform_password_notice').innerHTML = password_shorter; |
|
463 |
document.getElementById('conform_password_notice').style.color = "#E31939"; |
|
464 |
return false; |
|
465 |
} |
|
466 |
if (conform_password != password) { |
|
467 |
document.getElementById('conform_password_notice').innerHTML = confirm_password_invalid; |
|
468 |
document.getElementById('conform_password_notice').style.color = "#E31939"; |
|
469 |
} else { |
|
470 |
document.getElementById('conform_password_notice').innerHTML = msg_can_rg; |
|
471 |
document.getElementById('conform_password_notice').style.color = "#093"; |
|
472 |
} |
|
473 |
} |
|
474 |
|
|
475 |
function is_registered(username) { |
|
476 |
var submit_disabled = false; |
|
477 |
var unlen = username.replace(/[^\x00-\xff]/g, "**").length; |
|
478 |
if (username.match(/[\u4e00-\u9fa5]/)) { |
|
479 |
document.getElementById('username_notice').innerHTML = msg_un_chine; |
|
480 |
document.getElementById('username_notice').style.color = "#E31939"; |
|
481 |
var submit_disabled = true; |
|
482 |
} |
|
483 |
if (username == '') { |
|
484 |
document.getElementById('username_notice').innerHTML = msg_un_blank; |
|
485 |
document.getElementById('username_notice').style.color = "#E31939"; |
|
486 |
var submit_disabled = true; |
|
487 |
} |
|
488 |
|
|
489 |
if (!chkstr(username)) { |
|
490 |
document.getElementById('username_notice').innerHTML = msg_un_format; |
|
491 |
document.getElementById('username_notice').style.color = "#E31939"; |
|
492 |
var submit_disabled = true; |
|
493 |
} |
|
494 |
if (unlen < 3) { |
|
495 |
document.getElementById('username_notice').innerHTML = username_shorter; |
|
496 |
document.getElementById('username_notice').style.color = "#E31939"; |
|
497 |
var submit_disabled = true; |
|
498 |
} |
|
499 |
if (unlen > 14) { |
|
500 |
document.getElementById('username_notice').innerHTML = msg_un_length; |
|
501 |
document.getElementById('username_notice').style.color = "#E31939"; |
|
502 |
var submit_disabled = true; |
|
503 |
} |
|
504 |
|
|
505 |
if (submit_disabled) { |
|
506 |
document.forms['formUser'].elements['Submit'].disabled = 'disabled'; |
|
507 |
return false; |
|
508 |
} |
|
509 |
|
|
510 |
Ajax.call('user.php?act=is_registered', 'username=' + username, registed_callback, 'GET', 'TEXT', true, true); |
|
511 |
} |
|
512 |
|
|
513 |
function registed_callback(result) { |
|
514 |
if (result == "true") { |
|
515 |
document.getElementById('username_notice').innerHTML = msg_can_rg; |
|
516 |
document.getElementById('username_notice').style.color = "#093"; |
|
517 |
document.forms['formUser'].elements['Submit'].disabled = ''; |
|
518 |
} else { |
|
519 |
document.getElementById('username_notice').innerHTML = msg_un_registered; |
|
520 |
document.getElementById('username_notice').style.color = "#E31939"; |
|
521 |
document.forms['formUser'].elements['Submit'].disabled = 'disabled'; |
|
522 |
} |
|
523 |
} |
|
524 |
|
|
525 |
/** |
|
526 |
* 验证邮箱,第一步合法性验证, 第二步是否存在验证 |
|
527 |
* |
|
528 |
* @param email |
|
529 |
* 验证邮箱:支持邮箱和邮箱对象 |
|
530 |
* @param callback |
|
531 |
* 回调函数:true-可以注册 false-不可以注册 |
|
532 |
*/ |
|
533 |
function checkEmail(email, callback) { |
|
534 |
var submit_disabled = false; |
|
535 |
|
|
536 |
var emailObj = null; |
|
537 |
|
|
538 |
if (typeof (email) == 'object') { |
|
539 |
emailObj = $(email); |
|
540 |
email = emailObj.val(); |
|
541 |
} |
|
542 |
|
|
543 |
if (email == '') { |
|
544 |
document.getElementById('email_notice').innerHTML = msg_email_blank; |
|
545 |
document.getElementById('email_notice').style.color = '#E31939'; |
|
546 |
submit_disabled = true; |
|
547 |
|
|
548 |
if (emailObj != null) { |
|
549 |
emailObj.focus(); |
|
550 |
} |
|
551 |
|
|
552 |
} else if (!Utils.isEmail(email)) { |
|
553 |
document.getElementById('email_notice').innerHTML = msg_email_format; |
|
554 |
document.getElementById('email_notice').style.color = '#E31939'; |
|
555 |
submit_disabled = true; |
|
556 |
|
|
557 |
if (emailObj != null) { |
|
558 |
emailObj.focus(); |
|
559 |
} |
|
560 |
|
|
561 |
} |
|
562 |
|
|
563 |
if (submit_disabled) { |
|
564 |
document.forms['formUser'].elements['Submit'].disabled = 'disabled'; |
|
565 |
return false; |
|
566 |
} |
|
567 |
|
|
568 |
// Ajax.call('user.php?act=check_email', 'email=' + email, |
|
569 |
// check_email_callback, 'GET', 'TEXT', true, true); |
|
570 |
if (emailObj == null) { |
|
571 |
checkEmailExist(email, callback); |
|
572 |
} else { |
|
573 |
checkEmailExist(emailObj, callback); |
|
574 |
} |
|
575 |
} |
|
576 |
|
|
577 |
/** |
|
578 |
* 检查邮箱是否已经绑定过用户 |
|
579 |
* |
|
580 |
* @param email |
|
581 |
* 验证邮件:支持邮箱和邮箱对象 |
|
582 |
* @param callback |
|
583 |
* 回调函数:true-可以注册 false-不可以注册 |
|
584 |
*/ |
|
585 |
function checkEmailExist(email, callback) { |
|
586 |
|
|
587 |
var emailObj = null; |
|
588 |
|
|
589 |
if (typeof (email) == 'object') { |
|
590 |
emailObj = $(email); |
|
591 |
email = emailObj.val(); |
|
592 |
} |
|
593 |
|
|
594 |
// Ajax.call('user.php?act=check_email', 'email=' + email, |
|
595 |
// check_email_callback, 'GET', 'TEXT', true, true); |
|
596 |
$.post('user.php?act=check_email', { |
|
597 |
email: email |
|
598 |
}, function(result) { |
|
599 |
if (result == 'ok') { |
|
600 |
document.getElementById('email_notice').innerHTML = msg_can_rg; |
|
601 |
document.getElementById('email_notice').style.color = '#093'; |
|
602 |
document.forms['formUser'].elements['Submit'].disabled = ''; |
|
603 |
|
|
604 |
if ($.isFunction(callback)) { |
|
605 |
callback(true); |
|
606 |
} |
|
607 |
} else { |
|
608 |
document.getElementById('email_notice').innerHTML = msg_email_registered; |
|
609 |
document.getElementById('email_notice').style.color = '#E31939'; |
|
610 |
document.forms['formUser'].elements['Submit'].disabled = 'disabled'; |
|
611 |
|
|
612 |
if (emailObj != null) { |
|
613 |
emailObj.focus(); |
|
614 |
} |
|
615 |
|
|
616 |
if ($.isFunction(callback)) { |
|
617 |
callback(false); |
|
618 |
} |
|
619 |
|
|
620 |
} |
|
621 |
}, 'text'); |
|
622 |
} |
|
623 |
|
|
624 |
function checkMobilePhone(mobile, callback) { |
|
625 |
var submit_disabled = false; |
|
626 |
|
|
627 |
var mobileObj = null; |
|
628 |
|
|
629 |
if (typeof (mobile) == 'object') { |
|
630 |
mobileObj = $(mobile); |
|
631 |
mobile = mobileObj.val(); |
|
632 |
} |
|
633 |
|
|
634 |
if (mobile == '') { |
|
635 |
document.getElementById('mobile_phone_notice').innerHTML = msg_mobile_phone_blank; |
|
636 |
document.getElementById('mobile_phone_notice').style.color = '#E31939'; |
|
637 |
submit_disabled = true; |
|
638 |
|
|
639 |
if (mobileObj != null) { |
|
640 |
mobileObj.focus(); |
|
641 |
} |
|
642 |
|
|
643 |
} else if (!Utils.isMobile(mobile)) { |
|
644 |
document.getElementById('mobile_phone_notice').innerHTML = msg_mobile_phone_format; |
|
645 |
document.getElementById('mobile_phone_notice').style.color = '#E31939'; |
|
646 |
submit_disabled = true; |
|
647 |
|
|
648 |
if (mobileObj != null) { |
|
649 |
mobileObj.focus(); |
|
650 |
} |
|
651 |
} |
|
652 |
|
|
653 |
if (submit_disabled) { |
|
654 |
document.forms['formUser'].elements['Submit'].disabled = 'disabled'; |
|
655 |
return false; |
|
656 |
} |
|
657 |
// Ajax.call('user.php?act=check_mobile_phone', 'mobile_phone=' + mobileObj, |
|
658 |
// check_mobile_phone_callback, 'GET', 'TEXT', true, true); |
|
659 |
|
|
660 |
if (mobileObj == null) { |
|
661 |
checkMobilePhoneExist(mobile, callback); |
|
662 |
} else { |
|
663 |
checkMobilePhoneExist(mobileObj, callback); |
|
664 |
} |
|
665 |
} |
|
666 |
|
|
667 |
/** |
|
668 |
* 检查手机号是否已经存在 |
|
669 |
* |
|
670 |
* @param mobile |
|
671 |
* @param callback |
|
672 |
*/ |
|
673 |
var cur_mobile_phone = null; |
|
674 |
function checkMobilePhoneExist(mobile, callback) { |
|
675 |
var mobileObj = null; |
|
676 |
|
|
677 |
if (typeof (mobile) == 'object') { |
|
678 |
mobileObj = $(mobile); |
|
679 |
mobile = mobileObj.val(); |
|
680 |
} |
|
681 |
|
|
682 |
if (mobile == cur_mobile_phone && !$.isFunction(callback)) { |
|
683 |
if (mobileObj != null) { |
|
684 |
mobileObj.focus(); |
|
685 |
} |
|
686 |
return; |
|
687 |
} |
|
688 |
|
|
689 |
$.post('user.php?act=check_mobile_phone', { |
|
690 |
mobile_phone: mobile |
|
691 |
}, function(result) { |
|
692 |
|
|
693 |
if (result == 'ok') { |
|
694 |
document.getElementById('mobile_phone_notice').innerHTML = msg_can_rg; |
|
695 |
document.getElementById('mobile_phone_notice').style.color = '#093'; |
|
696 |
document.forms['formUser'].elements['Submit'].disabled = ''; |
|
697 |
|
|
698 |
if ($.isFunction(callback)) { |
|
699 |
callback(true); |
|
700 |
} |
|
701 |
} else { |
|
702 |
document.getElementById('mobile_phone_notice').innerHTML = msg_mobile_phone_registered; |
|
703 |
document.getElementById('mobile_phone_notice').style.color = '#E31939'; |
|
704 |
document.forms['formUser'].elements['Submit'].disabled = 'disabled'; |
|
705 |
|
|
706 |
if (mobileObj != null) { |
|
707 |
mobileObj.focus(); |
|
708 |
} |
|
709 |
|
|
710 |
if ($.isFunction(callback)) { |
|
711 |
callback(false); |
|
712 |
} |
|
713 |
} |
|
714 |
|
|
715 |
cur_mobile_phone = mobile; |
|
716 |
|
|
717 |
}, 'text'); |
|
718 |
} |
|
719 |
|
|
720 |
/******************************************************************************* |
|
721 |
* 处理注册用户 |
|
722 |
*/ |
|
723 |
function register1() { |
|
724 |
var frm = document.forms['formUser']; |
|
725 |
var username = Utils.trim(frm.elements['username'].value); |
|
726 |
var email = frm.elements['email'].value; |
|
727 |
var password = Utils.trim(frm.elements['password'].value); |
|
728 |
var confirm_password = Utils.trim(frm.elements['confirm_password'].value); |
|
729 |
var checked_agreement = frm.elements['agreement'].checked; |
|
730 |
var msn = frm.elements['extend_field1'] ? Utils.trim(frm.elements['extend_field1'].value) : ''; |
|
731 |
var qq = frm.elements['extend_field2'] ? Utils.trim(frm.elements['extend_field2'].value) : ''; |
|
732 |
var home_phone = frm.elements['extend_field4'] ? Utils.trim(frm.elements['extend_field4'].value) : ''; |
|
733 |
var office_phone = frm.elements['extend_field3'] ? Utils.trim(frm.elements['extend_field3'].value) : ''; |
|
734 |
var mobile_phone = frm.elements['extend_field5'] ? Utils.trim(frm.elements['extend_field5'].value) : ''; |
|
735 |
var passwd_answer = frm.elements['passwd_answer'] ? Utils.trim(frm.elements['passwd_answer'].value) : ''; |
|
736 |
var sel_question = frm.elements['sel_question'] ? Utils.trim(frm.elements['sel_question'].value) : ''; |
|
737 |
|
|
738 |
var msg = ""; |
|
739 |
// 检查输入 |
|
740 |
var msg = ''; |
|
741 |
if (username.length == 0) { |
|
742 |
msg += username_empty + '\n'; |
|
743 |
} else if (username.match(/^\s*$|^c:\\con\\con$|[%,\'\*\"\s\t\<\>\&\\]/)) { |
|
744 |
msg += username_invalid + '\n'; |
|
745 |
} else if (username.length < 3) { |
|
746 |
// msg += username_shorter + '\n'; |
|
747 |
} |
|
748 |
|
|
749 |
if (username.match(/[\u4e00-\u9fa5]/)) { |
|
750 |
msg += username_chana + '\n'; |
|
751 |
} |
|
752 |
|
|
753 |
if (email.length == 0) { |
|
754 |
msg += email_empty + '\n'; |
|
755 |
} else { |
|
756 |
if (!(Utils.isEmail(email))) { |
|
757 |
msg += email_invalid + '\n'; |
|
758 |
} |
|
759 |
} |
|
760 |
if (password.length == 0) { |
|
761 |
msg += password_empty + '\n'; |
|
762 |
} else if (password.length < 6) { |
|
763 |
msg += password_shorter + '\n'; |
|
764 |
} |
|
765 |
if (/ /.test(password) == true) { |
|
766 |
msg += passwd_balnk + '\n'; |
|
767 |
} |
|
768 |
if (confirm_password != password) { |
|
769 |
msg += confirm_password_invalid + '\n'; |
|
770 |
} |
|
771 |
if (checked_agreement != true) { |
|
772 |
msg += agreement + '\n'; |
|
773 |
} |
|
774 |
|
|
775 |
if (msn.length > 0 && (!Utils.isEmail(msn))) { |
|
776 |
msg += msn_invalid + '\n'; |
|
777 |
} |
|
778 |
|
|
779 |
if (qq.length > 0 && (!Utils.isNumber(qq))) { |
|
780 |
msg += qq_invalid + '\n'; |
|
781 |
} |
|
782 |
|
|
783 |
if (office_phone.length > 0) { |
|
784 |
var reg = /^[\d|\-|\s]+$/; |
|
785 |
if (!reg.test(office_phone)) { |
|
786 |
msg += office_phone_invalid + '\n'; |
|
787 |
} |
|
788 |
} |
|
789 |
if (home_phone.length > 0) { |
|
790 |
var reg = /^[\d|\-|\s]+$/; |
|
791 |
|
|
792 |
if (!reg.test(home_phone)) { |
|
793 |
msg += home_phone_invalid + '\n'; |
|
794 |
} |
|
795 |
} |
|
796 |
if (mobile_phone.length > 0) { |
|
797 |
var reg = /^[\d|\-|\s]+$/; |
|
798 |
if (!reg.test(mobile_phone)) { |
|
799 |
msg += mobile_phone_invalid + '\n'; |
|
800 |
} |
|
801 |
} |
|
802 |
if (passwd_answer.length > 0 && sel_question == 0 || document.getElementById('passwd_quesetion') && passwd_answer.length == 0) { |
|
803 |
msg += no_select_question + '\n'; |
|
804 |
} |
|
805 |
|
|
806 |
for (var i = 4; i < frm.elements.length - 4; i++) // 从第五项开始循环检查是否为必填项 |
|
807 |
{ |
|
808 |
var needinput = document.getElementById(frm.elements[i].name + 'i') ? document.getElementById(frm.elements[i].name + 'i') : ''; |
|
809 |
|
|
810 |
if (needinput != '' && frm.elements[i].value.length == 0) { |
|
811 |
msg += '- ' + needinput.innerHTML + msg_blank + '\n'; |
|
812 |
} |
|
813 |
} |
|
814 |
|
|
815 |
if (msg.length > 0) { |
|
816 |
alert(msg); |
|
817 |
return false; |
|
818 |
} else { |
|
819 |
return true; |
|
820 |
} |
|
821 |
} |
|
822 |
|
|
823 |
/** |
|
824 |
* 用户注册 |
|
825 |
* |
|
826 |
* @param register_type |
|
827 |
* 注册类型:email、mobile |
|
828 |
*/ |
|
829 |
function register(register_type) { |
|
830 |
if (register_type == "email") { |
|
831 |
return reg_by_email(); |
|
832 |
} else { |
|
833 |
return reg_by_mobile(); |
|
834 |
} |
|
835 |
} |
|
836 |
|
|
837 |
/** |
|
838 |
* 通过邮箱注册 |
|
839 |
* |
|
840 |
* @returns {Boolean} |
|
841 |
*/ |
|
842 |
function reg_by_email() { |
|
843 |
var frm = document.forms['formUser']; |
|
844 |
// 邮箱注册时不支持用户名注册 |
|
845 |
// var username = Utils.trim(frm.elements['username'].value); |
|
846 |
var email = frm.elements['email'].value; |
|
847 |
var password = Utils.trim(frm.elements['password'].value); |
|
848 |
var confirm_password = Utils.trim(frm.elements['confirm_password'].value); |
|
849 |
var checked_agreement = frm.elements['agreement'].checked; |
|
850 |
var msn = frm.elements['extend_field1'] ? Utils.trim(frm.elements['extend_field1'].value) : ''; |
|
851 |
var qq = frm.elements['extend_field2'] ? Utils.trim(frm.elements['extend_field2'].value) : ''; |
|
852 |
var home_phone = frm.elements['extend_field4'] ? Utils.trim(frm.elements['extend_field4'].value) : ''; |
|
853 |
var office_phone = frm.elements['extend_field3'] ? Utils.trim(frm.elements['extend_field3'].value) : ''; |
|
854 |
// 邮箱注册不能绑定手机,许多注册成功后再绑定 |
|
855 |
// var mobile_phone = frm.elements['extend_field5'] ? |
|
856 |
// Utils.trim(frm.elements['extend_field5'].value) : ''; |
|
857 |
var passwd_answer = frm.elements['passwd_answer'] ? Utils.trim(frm.elements['passwd_answer'].value) : ''; |
|
858 |
var sel_question = frm.elements['sel_question'] ? Utils.trim(frm.elements['sel_question'].value) : ''; |
|
859 |
// 邮箱验证码 |
|
860 |
var email_code = frm.elements['email_code'] ? Utils.trim(frm.elements['email_code'].value) : ''; |
|
861 |
// 验证码 |
|
862 |
var captcha = frm.elements['captcha'] ? Utils.trim(frm.elements['captcha'].value) : ''; |
|
863 |
|
|
864 |
var msg = ""; |
|
865 |
// 检查输入 |
|
866 |
var msg = ''; |
|
867 |
|
|
868 |
if (email.length == 0) { |
|
869 |
msg += email_empty + '\n'; |
|
870 |
} else { |
|
871 |
if (!(Utils.isEmail(email))) { |
|
872 |
msg += email_invalid + '\n'; |
|
873 |
} |
|
874 |
} |
|
875 |
if (password.length == 0) { |
|
876 |
msg += password_empty + '\n'; |
|
877 |
} else if (password.length < 6) { |
|
878 |
msg += password_shorter + '\n'; |
|
879 |
} |
|
880 |
if (/ /.test(password) == true) { |
|
881 |
msg += passwd_balnk + '\n'; |
|
882 |
} |
|
883 |
if (confirm_password != password) { |
|
884 |
msg += confirm_password_invalid + '\n'; |
|
885 |
} |
|
886 |
if (checked_agreement != true) { |
|
887 |
msg += agreement + '\n'; |
|
888 |
} |
|
889 |
|
|
890 |
if (msn.length > 0 && (!Utils.isEmail(msn))) { |
|
891 |
msg += msn_invalid + '\n'; |
|
892 |
} |
|
893 |
|
|
894 |
if (qq.length > 0 && (!Utils.isNumber(qq))) { |
|
895 |
msg += qq_invalid + '\n'; |
|
896 |
} |
|
897 |
|
|
898 |
if (office_phone.length > 0) { |
|
899 |
var reg = /^[\d|\-|\s]+$/; |
|
900 |
if (!reg.test(office_phone)) { |
|
901 |
msg += office_phone_invalid + '\n'; |
|
902 |
} |
|
903 |
} |
|
904 |
if (home_phone.length > 0) { |
|
905 |
var reg = /^[\d|\-|\s]+$/; |
|
906 |
|
|
907 |
if (!reg.test(home_phone)) { |
|
908 |
msg += msg_email_code_blank + '\n'; |
|
909 |
} |
|
910 |
} |
|
911 |
|
|
912 |
if ($("#email_code").size() > 0 && email_code.length == 0) { |
|
913 |
msg += msg_email_code_blank + '\n'; |
|
914 |
} |
|
915 |
|
|
916 |
if ($("#captcha").size() > 0 && captcha.length == 0) { |
|
917 |
msg += msg_captcha_blank + '\n'; |
|
918 |
} |
|
919 |
|
|
920 |
// if (mobile_phone.length > 0) { |
|
921 |
// var reg = /^[\d|\-|\s]+$/; |
|
922 |
// if (!reg.test(mobile_phone)) { |
|
923 |
// msg += mobile_phone_invalid + '\n'; |
|
924 |
// } |
|
925 |
// } |
|
926 |
if (passwd_answer.length > 0 && sel_question == 0 || document.getElementById('passwd_quesetion') && passwd_answer.length == 0) { |
|
927 |
msg += no_select_question + '\n'; |
|
928 |
} |
|
929 |
|
|
930 |
for (var i = 4; i < frm.elements.length - 4; i++) // 从第五项开始循环检查是否为必填项 |
|
931 |
{ |
|
932 |
var needinput = document.getElementById(frm.elements[i].name + 'i') ? document.getElementById(frm.elements[i].name + 'i') : ''; |
|
933 |
|
|
934 |
if (needinput != '' && frm.elements[i].value.length == 0) { |
|
935 |
msg += '- ' + needinput.innerHTML + msg_blank + '\n'; |
|
936 |
} |
|
937 |
} |
|
938 |
|
|
939 |
if (msg.length > 0) { |
|
940 |
alert(msg); |
|
941 |
return false; |
|
942 |
} else { |
|
943 |
return true; |
|
944 |
} |
|
945 |
} |
|
946 |
|
|
947 |
function reg_by_mobile() { |
|
948 |
var frm = document.forms['formUser']; |
|
949 |
// 手机时不支持用户名注册 |
|
950 |
// var username = Utils.trim(frm.elements['username'].value); |
|
951 |
var mobile_phone = frm.elements['mobile_phone'].value; |
|
952 |
var password = Utils.trim(frm.elements['password'].value); |
|
953 |
var confirm_password = Utils.trim(frm.elements['confirm_password'].value); |
|
954 |
var checked_agreement = frm.elements['agreement'].checked; |
|
955 |
var msn = frm.elements['extend_field1'] ? Utils.trim(frm.elements['extend_field1'].value) : ''; |
|
956 |
var qq = frm.elements['extend_field2'] ? Utils.trim(frm.elements['extend_field2'].value) : ''; |
|
957 |
var home_phone = frm.elements['extend_field4'] ? Utils.trim(frm.elements['extend_field4'].value) : ''; |
|
958 |
var office_phone = frm.elements['extend_field3'] ? Utils.trim(frm.elements['extend_field3'].value) : ''; |
|
959 |
// 邮箱注册不能绑定手机,许多注册成功后再绑定 |
|
960 |
// var mobile_phone = frm.elements['extend_field5'] ? |
|
961 |
// Utils.trim(frm.elements['extend_field5'].value) : ''; |
|
962 |
var passwd_answer = frm.elements['passwd_answer'] ? Utils.trim(frm.elements['passwd_answer'].value) : ''; |
|
963 |
var sel_question = frm.elements['sel_question'] ? Utils.trim(frm.elements['sel_question'].value) : ''; |
|
964 |
// 手机验证码 |
|
965 |
var mobile_code = frm.elements['mobile_code'] ? Utils.trim(frm.elements['mobile_code'].value) : ''; |
|
966 |
// 验证码 |
|
967 |
var captcha = frm.elements['captcha'] ? Utils.trim(frm.elements['captcha'].value) : ''; |
|
968 |
|
|
969 |
var msg = ""; |
|
970 |
// 检查输入 |
|
971 |
var msg = ''; |
|
972 |
|
|
973 |
if (mobile_phone.length == 0) { |
|
974 |
msg += msg_mobile_phone_blank + '\n'; |
|
975 |
} else { |
|
976 |
if (!(Utils.isMobile(mobile_phone))) { |
|
977 |
msg += mobile_phone_invalid + '\n'; |
|
978 |
} |
|
979 |
} |
|
980 |
if (password.length == 0) { |
|
981 |
msg += password_empty + '\n'; |
|
982 |
} else if (password.length < 6) { |
|
983 |
msg += password_shorter + '\n'; |
|
984 |
} |
|
985 |
if (/ /.test(password) == true) { |
|
986 |
msg += passwd_balnk + '\n'; |
|
987 |
} |
|
988 |
if (confirm_password != password) { |
|
989 |
msg += confirm_password_invalid + '\n'; |
|
990 |
} |
|
991 |
if (checked_agreement != true) { |
|
992 |
msg += agreement + '\n'; |
|
993 |
} |
|
994 |
|
|
995 |
if (msn.length > 0 && (!Utils.isEmail(msn))) { |
|
996 |
msg += msn_invalid + '\n'; |
|
997 |
} |
|
998 |
|
|
999 |
if (qq.length > 0 && (!Utils.isNumber(qq))) { |
|
1000 |
msg += qq_invalid + '\n'; |
|
1001 |
} |
|
1002 |
|
|
1003 |
if (office_phone.length > 0) { |
|
1004 |
var reg = /^[\d|\-|\s]+$/; |
|
1005 |
if (!reg.test(office_phone)) { |
|
1006 |
msg += office_phone_invalid + '\n'; |
|
1007 |
} |
|
1008 |
} |
|
1009 |
if (home_phone.length > 0) { |
|
1010 |
var reg = /^[\d|\-|\s]+$/; |
|
1011 |
|
|
1012 |
if (!reg.test(home_phone)) { |
|
1013 |
msg += home_phone_invalid + '\n'; |
|
1014 |
} |
|
1015 |
} |
|
1016 |
|
|
1017 |
if ($("#mobile_code").size() > 0 && mobile_code.length == 0) { |
|
1018 |
msg += msg_mobile_phone_code_blank + '\n'; |
|
1019 |
} |
|
1020 |
|
|
1021 |
if ($("#captcha").size() > 0 && captcha.length == 0) { |
|
1022 |
msg += msg_captcha_blank + '\n'; |
|
1023 |
} |
|
1024 |
|
|
1025 |
// if (mobile_phone.length > 0) { |
|
1026 |
// var reg = /^[\d|\-|\s]+$/; |
|
1027 |
// if (!reg.test(mobile_phone)) { |
|
1028 |
// msg += mobile_phone_invalid + '\n'; |
|
1029 |
// } |
|
1030 |
// } |
|
1031 |
if (passwd_answer.length > 0 && sel_question == 0 || document.getElementById('passwd_quesetion') && passwd_answer.length == 0) { |
|
1032 |
msg += no_select_question + '\n'; |
|
1033 |
} |
|
1034 |
|
|
1035 |
for (var i = 4; i < frm.elements.length - 4; i++) // 从第五项开始循环检查是否为必填项 |
|
1036 |
{ |
|
1037 |
var needinput = document.getElementById(frm.elements[i].name + 'i') ? document.getElementById(frm.elements[i].name + 'i') : ''; |
|
1038 |
|
|
1039 |
if (needinput != '' && frm.elements[i].value.length == 0) { |
|
1040 |
msg += '- ' + needinput.innerHTML + msg_blank + '\n'; |
|
1041 |
} |
|
1042 |
} |
|
1043 |
|
|
1044 |
if (msg.length > 0) { |
|
1045 |
alert(msg); |
|
1046 |
return false; |
|
1047 |
} else { |
|
1048 |
return true; |
|
1049 |
} |
|
1050 |
} |
|
1051 |
|
|
1052 |
/** |
|
1053 |
* 发送邮箱验证码 |
|
1054 |
* |
|
1055 |
* @param emailObj |
|
1056 |
* 邮箱对象 |
|
1057 |
* @param emailCodeObj |
|
1058 |
* 邮箱验证码对象 |
|
1059 |
* @param sendButton |
|
1060 |
* 点击发送邮箱验证码的按钮对象,用于显示倒计时信息 |
|
1061 |
*/ |
|
1062 |
function sendEmailCode(emailObj, emailCodeObj, sendButton) { |
|
1063 |
checkEmail(emailObj, function(result) { |
|
1064 |
if (result) { |
|
1065 |
// 发送邮件 |
|
1066 |
// &XDEBUG_SESSION_START=ECLIPSE_DBGP |
|
1067 |
var url = 'user.php?act=send_email_code&XDEBUG_SESSION_START=ECLIPSE_DBGP'; |
|
1068 |
$.post(url, { |
|
1069 |
email: emailObj.val() |
|
1070 |
}, function(result) { |
|
1071 |
if (result == 'ok') { |
|
1072 |
// 倒计时 |
|
1073 |
countdown(sendButton); |
|
1074 |
} else { |
|
1075 |
alert(result); |
|
1076 |
} |
|
1077 |
}, 'text'); |
|
1078 |
} |
|
1079 |
}); |
|
1080 |
} |
|
1081 |
|
|
1082 |
/** |
|
1083 |
* 发送邮箱验证码 |
|
1084 |
* |
|
1085 |
* @param mobileObj |
|
1086 |
* 手机号对象 |
|
1087 |
* @param mobileCodeObj |
|
1088 |
* 短信验证码对象 |
|
1089 |
* @param sendButton |
|
1090 |
* 点击发送短信证码的按钮对象,用于显示倒计时信息 |
|
1091 |
*/ |
|
1092 |
function sendMobileCode(mobileObj, mobileCodeObj, sendButton) { |
|
1093 |
alert(2); |
|
1094 |
checkMobilePhone(mobileObj, function(result) { |
|
1095 |
if (result) { |
|
1096 |
// 发送邮件 |
|
1097 |
var url = 'user.php?act=send_mobile_code&XDEBUG_SESSION_START=ECLIPSE_DBGP'; |
|
1098 |
$.post(url, { |
|
1099 |
mobile_phone: mobileObj.val() |
|
1100 |
}, function(result) { |
|
1101 |
if (result == 'ok') { |
|
1102 |
// 倒计时 |
|
1103 |
countdown(sendButton); |
|
1104 |
} else { |
|
1105 |
alert(result); |
|
1106 |
} |
|
1107 |
}, 'text'); |
|
1108 |
} |
|
1109 |
}); |
|
1110 |
} |
|
1111 |
|
|
1112 |
/******************************************************************************* |
|
1113 |
* 用户中心订单保存地址信息 |
|
1114 |
*/ |
|
1115 |
function saveOrderAddress(id) { |
|
1116 |
var frm = document.forms['formAddress']; |
|
1117 |
var consignee = frm.elements['consignee'].value; |
|
1118 |
var email = frm.elements['email'].value; |
|
1119 |
var address = frm.elements['address'].value; |
|
1120 |
var zipcode = frm.elements['zipcode'].value; |
|
1121 |
var tel = frm.elements['tel'].value; |
|
1122 |
var mobile = frm.elements['mobile'].value; |
|
1123 |
var sign_building = frm.elements['sign_building'].value; |
|
1124 |
var best_time = frm.elements['best_time'].value; |
|
1125 |
|
|
1126 |
if (id == 0) { |
|
1127 |
alert(current_ss_not_unshipped); |
|
1128 |
return false; |
|
1129 |
} |
|
1130 |
var msg = ''; |
|
1131 |
if (address.length == 0) { |
|
1132 |
msg += address_name_not_null + "\n"; |
|
1133 |
} |
|
1134 |
if (consignee.length == 0) { |
|
1135 |
msg += consignee_not_null + "\n"; |
|
1136 |
} |
|
1137 |
|
|
1138 |
if (msg.length > 0) { |
|
1139 |
alert(msg); |
|
1140 |
return false; |
|
1141 |
} else { |
|
1142 |
return true; |
|
1143 |
} |
|
1144 |
} |
|
1145 |
|
|
1146 |
/******************************************************************************* |
|
1147 |
* 会员余额申请 |
|
1148 |
*/ |
|
1149 |
function submitSurplus() { |
|
1150 |
var frm = document.forms['formSurplus']; |
|
1151 |
var surplus_type = frm.elements['surplus_type'].value; |
|
1152 |
var surplus_amount = frm.elements['amount'].value; |
|
1153 |
var process_notic = frm.elements['user_note'].value; |
|
1154 |
var payment_id = 0; |
|
1155 |
var msg = ''; |
|
1156 |
|
|
1157 |
if (surplus_amount.length == 0) { |
|
1158 |
msg += surplus_amount_empty + "\n"; |
|
1159 |
} else { |
|
1160 |
var reg = /^[\.0-9]+/; |
|
1161 |
if (!reg.test(surplus_amount)) { |
|
1162 |
msg += surplus_amount_error + '\n'; |
|
1163 |
} |
|
1164 |
} |
|
1165 |
|
|
1166 |
if (process_notic.length == 0) { |
|
1167 |
msg += process_desc + "\n"; |
|
1168 |
} |
|
1169 |
|
|
1170 |
if (msg.length > 0) { |
|
1171 |
alert(msg); |
|
1172 |
return false; |
|
1173 |
} |
|
1174 |
|
|
1175 |
if (surplus_type == 0) { |
|
1176 |
for (var i = 0; i < frm.elements.length; i++) { |
|
1177 |
if (frm.elements[i].name == "payment_id" && frm.elements[i].checked) { |
|
1178 |
payment_id = frm.elements[i].value; |
|
1179 |
break; |
|
1180 |
} |
|
1181 |
} |
|
1182 |
|
|
1183 |
if (payment_id == 0) { |
|
1184 |
alert(payment_empty); |
|
1185 |
return false; |
|
1186 |
} |
|
1187 |
} |
|
1188 |
|
|
1189 |
return true; |
|
1190 |
} |
|
1191 |
|
|
1192 |
/******************************************************************************* |
|
1193 |
* 处理用户添加一个红包 |
|
1194 |
*/ |
|
1195 |
function addBonus() { |
|
1196 |
var frm = document.forms['addBouns']; |
|
1197 |
var bonus_sn = frm.elements['bonus_sn'].value; |
|
1198 |
|
|
1199 |
if (bonus_sn.length == 0) { |
|
1200 |
alert(bonus_sn_empty); |
|
1201 |
return false; |
|
1202 |
} else { |
|
1203 |
var reg = /^[0-9]{10}$/; |
|
1204 |
if (!reg.test(bonus_sn)) { |
|
1205 |
alert(bonus_sn_error); |
|
1206 |
return false; |
|
1207 |
} |
|
1208 |
} |
|
1209 |
|
|
1210 |
return true; |
|
1211 |
} |
|
1212 |
|
|
1213 |
/******************************************************************************* |
|
1214 |
* 合并订单检查 |
|
1215 |
*/ |
|
1216 |
function mergeOrder() { |
|
1217 |
if (!confirm(confirm_merge)) { |
|
1218 |
return false; |
|
1219 |
} |
|
1220 |
|
|
1221 |
var frm = document.forms['formOrder']; |
|
1222 |
var from_order = frm.elements['from_order'].value; |
|
1223 |
var to_order = frm.elements['to_order'].value; |
|
1224 |
var msg = ''; |
|
1225 |
|
|
1226 |
if (from_order == 0) { |
|
1227 |
msg += from_order_empty + '\n'; |
|
1228 |
} |
|
1229 |
if (to_order == 0) { |
|
1230 |
msg += to_order_empty + '\n'; |
|
1231 |
} else if (to_order == from_order) { |
|
1232 |
msg += order_same + '\n'; |
|
1233 |
} |
|
1234 |
if (msg.length > 0) { |
|
1235 |
alert(msg); |
|
1236 |
return false; |
|
1237 |
} else { |
|
1238 |
return true; |
|
1239 |
} |
|
1240 |
} |
|
1241 |
|
|
1242 |
/******************************************************************************* |
|
1243 |
* 订单中的商品返回购物车 |
|
1244 |
* |
|
1245 |
* @param int |
|
1246 |
* orderId 订单号 |
|
1247 |
*/ |
|
1248 |
function returnToCart(orderId) { |
|
1249 |
Ajax.call('user.php?act=return_to_cart', 'order_id=' + orderId, returnToCartResponse, 'POST', 'JSON'); |
|
1250 |
} |
|
1251 |
|
|
1252 |
function returnToCartResponse(result) { |
|
1253 |
// alert(result.message); |
|
1254 |
if (result.error > 0) { |
|
1255 |
// 如果需要缺货登记,跳转 |
|
1256 |
|
|
1257 |
if (result.error == 1) { |
|
1258 |
alert(result.message); |
|
1259 |
location.href = 'user.php'; |
|
1260 |
} else if (result.error == 2) { |
|
1261 |
|
|
1262 |
// if (confirm(result.message)) { |
|
1263 |
// location.href = 'user.php?act=add_booking&id=' + result.goods_id |
|
1264 |
// + '&spec=' + result.product_spec; |
|
1265 |
// document.getElementById('tell_me_form').style.display = 'block'; |
|
1266 |
// } |
|
1267 |
// document.getElementById('tell_me_form').style.display = 'block'; |
|
1268 |
|
|
1269 |
if (document.getElementById('g_id')) { |
|
1270 |
document.getElementById('g_id').value = result.goods_id; |
|
1271 |
} |
|
1272 |
if (document.getElementById('rgoods_name')) { |
|
1273 |
document.getElementById('rgoods_name').innerHTML = result.goods_name; |
|
1274 |
} |
|
1275 |
document.getElementById('tell_me_form').style.display = document.getElementById('tell_me_form').style.display == 'none' ? 'block' : 'none'; |
|
1276 |
// document.getElementById('bg').style.display='none'; |
|
1277 |
|
|
1278 |
} |
|
1279 |
// 没选规格,弹出属性选择框 |
|
1280 |
else if (result.error == 6) { |
|
1281 |
openSpeDiv(result.message, result.goods_id, result.parent); |
|
1282 |
} else if (result.error == 999) { |
|
1283 |
if (confirm(result.message)) { |
|
1284 |
location.href = 'user.php'; |
|
1285 |
} |
|
1286 |
} else if (result.error == 888) { |
|
1287 |
alert(result.message); |
|
1288 |
} else if (result.error == 777) { |
|
1289 |
// 预售活动提示 |
|
1290 |
// 预售跳转到商品详情页 |
|
1291 |
if (confirm(result.message)) { |
|
1292 |
window.location.href = result.uri; |
|
1293 |
} |
|
1294 |
} else { |
|
1295 |
alert(result.message); |
|
1296 |
} |
|
1297 |
} else { |
|
1298 |
var cartInfo = $('.ECS_CARTINFO'); |
|
1299 |
if (cartInfo) { |
|
1300 |
cartInfo.html(result.content); |
|
1301 |
} |
|
1302 |
} |
|
1303 |
} |
|
1304 |
|
|
1305 |
/******************************************************************************* |
|
1306 |
* 检测密码强度 |
|
1307 |
* |
|
1308 |
* @param string |
|
1309 |
* pwd 密码 |
|
1310 |
*/ |
|
1311 |
function checkIntensity(pwd) { |
|
1312 |
|
|
1313 |
$("#pwd_notice").hide(); |
|
1314 |
$("#pwd_intensity").show(); |
|
1315 |
|
|
1316 |
var Mcolor = "#FFF", Lcolor = "#FFF", Hcolor = "#FFF"; |
|
1317 |
var m = 0; |
|
1318 |
|
|
1319 |
var Modes = 0; |
|
1320 |
for (var i = 0; i < pwd.length; i++) { |
|
1321 |
var charType = 0; |
|
1322 |
var t = pwd.charCodeAt(i); |
|
1323 |
if (t >= 48 && t <= 57) { |
|
1324 |
charType = 1; |
|
1325 |
} else if (t >= 65 && t <= 90) { |
|
1326 |
charType = 2; |
|
1327 |
} else if (t >= 97 && t <= 122) |
|
1328 |
charType = 4; |
|
1329 |
else |
|
1330 |
charType = 4; |
|
1331 |
Modes |= charType; |
|
1332 |
} |
|
1333 |
|
|
1334 |
for (i = 0; i < 4; i++) { |
|
1335 |
if (Modes & 1) |
|
1336 |
m++; |
|
1337 |
Modes >>>= 1; |
|
1338 |
} |
|
1339 |
|
|
1340 |
if (pwd.length <= 4) { |
|
1341 |
m = 1; |
|
1342 |
} |
|
1343 |
|
|
1344 |
switch (m) { |
|
1345 |
case 1: |
|
1346 |
Lcolor = "2px solid red"; |
|
1347 |
Mcolor = Hcolor = "2px solid #DADADA"; |
|
1348 |
break; |
|
1349 |
case 2: |
|
1350 |
Mcolor = "2px solid #f90"; |
|
1351 |
Lcolor = Hcolor = "2px solid #DADADA"; |
|
1352 |
break; |
|
1353 |
case 3: |
|
1354 |
Hcolor = "2px solid #3c0"; |
|
1355 |
Lcolor = Mcolor = "2px solid #DADADA"; |
|
1356 |
break; |
|
1357 |
case 4: |
|
1358 |
Hcolor = "2px solid #3c0"; |
|
1359 |
Lcolor = Mcolor = "2px solid #DADADA"; |
|
1360 |
break; |
|
1361 |
default: |
|
1362 |
Hcolor = Mcolor = Lcolor = ""; |
|
1363 |
break; |
|
1364 |
} |
|
1365 |
if (document.getElementById("pwd_lower")) { |
|
1366 |
document.getElementById("pwd_lower").style.borderBottom = Lcolor; |
|
1367 |
document.getElementById("pwd_middle").style.borderBottom = Mcolor; |
|
1368 |
document.getElementById("pwd_high").style.borderBottom = Hcolor; |
|
1369 |
} |
|
1370 |
|
|
1371 |
} |
|
1372 |
|
|
1373 |
function changeType(obj) { |
|
1374 |
if (obj.getAttribute("min") && document.getElementById("ECS_AMOUNT")) { |
|
1375 |
document.getElementById("ECS_AMOUNT").disabled = false; |
|
1376 |
document.getElementById("ECS_AMOUNT").value = obj.getAttribute("min"); |
|
1377 |
if (document.getElementById("ECS_NOTICE") && obj.getAttribute("to") && obj.getAttribute('fee')) { |
|
1378 |
var fee = parseInt(obj.getAttribute("fee")); |
|
1379 |
var to = parseInt(obj.getAttribute("to")); |
|
1380 |
if (fee < 0) { |
|
1381 |
to = to + fee * 2; |
|
1382 |
} |
|
1383 |
document.getElementById("ECS_NOTICE").innerHTML = notice_result + to; |
|
1384 |
} |
|
1385 |
} |
|
1386 |
} |
|
1387 |
|
|
1388 |
function calResult() { |
|
1389 |
var amount = document.getElementById("ECS_AMOUNT").value; |
|
1390 |
var notice = document.getElementById("ECS_NOTICE"); |
|
1391 |
|
|
1392 |
reg = /^\d+$/; |
|
1393 |
if (!reg.test(amount)) { |
|
1394 |
notice.innerHTML = notice_not_int; |
|
1395 |
return; |
|
1396 |
} |
|
1397 |
amount = parseInt(amount); |
|
1398 |
var frm = document.forms['transform']; |
|
1399 |
for (var i = 0; i < frm.elements['type'].length; i++) { |
|
1400 |
if (frm.elements['type'][i].checked) { |
|
1401 |
var min = parseInt(frm.elements['type'][i].getAttribute("min")); |
|
1402 |
var to = parseInt(frm.elements['type'][i].getAttribute("to")); |
|
1403 |
var fee = parseInt(frm.elements['type'][i].getAttribute("fee")); |
|
1404 |
var result = 0; |
|
1405 |
if (amount < min) { |
|
1406 |
notice.innerHTML = notice_overflow + min; |
|
1407 |
return; |
|
1408 |
} |
|
1409 |
|
|
1410 |
if (fee > 0) { |
|
1411 |
result = (amount - fee) * to / (min - fee); |
|
1412 |
} else { |
|
1413 |
// result = (amount + fee* min /(to+fee)) * (to + fee) / min ; |
|
1414 |
result = amount * (to + fee) / min + fee; |
|
1415 |
} |
|
1416 |
|
|
1417 |
notice.innerHTML = notice_result + parseInt(result + 0.5); |
|
1418 |
} |
|
1419 |
} |
|
1420 |
} |
|
1421 |
/* 代码增加2014-12-23 by _star */ |
|
1422 |
function choose_type(val) { |
|
1423 |
if (val == 0) { |
|
1424 |
document.getElementById('f_mobile').style.display = 'none'; |
|
1425 |
document.getElementById('f_code').style.display = 'none'; |
|
1426 |
document.getElementById('f_email').style.display = 'none'; |
|
1427 |
} |
|
1428 |
if (val == 1) { |
|
1429 |
document.getElementById('f_mobile').style.display = 'block'; |
|
1430 |
document.getElementById('f_code').style.display = 'block'; |
|
1431 |
document.getElementById('f_email').style.display = 'none'; |
|
1432 |
} |
|
1433 |
if (val == 2) { |
|
1434 |
document.getElementById('f_mobile').style.display = 'none'; |
|
1435 |
document.getElementById('f_code').style.display = 'none'; |
|
1436 |
document.getElementById('f_email').style.display = 'block'; |
|
1437 |
} |
|
1438 |
} |
|
1439 |
|
|
1440 |
function forget_pass() { |
|
1441 |
var frm = document.forms['fpForm']; |
|
1442 |
var user_name = frm.elements['u_name'].value; |
|
1443 |
var find_type = frm.elements['find_type'].value; |
|
1444 |
var mobile = frm.elements['mobile'].value; |
|
1445 |
var code = frm.elements['code'].value; |
|
1446 |
var email = frm.elements['email'].value; |
|
1447 |
if (user_name.length == 0) { |
|
1448 |
alert('用户名不能为空!'); |
|
1449 |
return false; |
|
1450 |
} |
|
1451 |
if (find_type == 0) { |
|
1452 |
alert('请选择找回方式!'); |
|
1453 |
return false; |
|
1454 |
} |
|
1455 |
if (find_type == 1) { |
|
1456 |
if (mobile.length == 0) { |
|
1457 |
alert('手机号不能为空!'); |
|
1458 |
return false; |
|
1459 |
} else { |
|
1460 |
if (mobile.length != 11) { |
|
1461 |
alert('手机号不是11位!'); |
|
1462 |
return false; |
|
1463 |
} else { |
|
1464 |
if (code.length == 0) { |
|
1465 |
alert('验证码不能为空!'); |
|
1466 |
return false; |
|
1467 |
} |
|
1468 |
} |
|
1469 |
} |
|
1470 |
} |
|
1471 |
|
|
1472 |
if (find_type == 2) { |
|
1473 |
if (email.length == 0) { |
|
1474 |
alert('邮箱不能为空!'); |
|
1475 |
return false; |
|
1476 |
} else { |
|
1477 |
if (!(Utils.isEmail(email))) { |
|
1478 |
alert('邮箱格式不正确!'); |
|
1479 |
return false; |
|
1480 |
} |
|
1481 |
} |
|
1482 |
} |
|
1483 |
return true; |
|
1484 |
} |
|
1485 |
|
|
1486 |
var wait = 60; |
|
1487 |
function countdown(obj, msg) { |
|
1488 |
obj = $(obj); |
|
1489 |
|
|
1490 |
if (wait == 0) { |
|
1491 |
obj.removeAttr("disabled"); |
|
1492 |
obj.val(msg); |
|
1493 |
wait = 60; |
|
1494 |
} else { |
|
1495 |
if (msg == undefined || msg == null) { |
|
1496 |
msg = obj.val(); |
|
1497 |
} |
|
1498 |
obj.attr("disabled", "disabled"); |
|
1499 |
obj.val(wait + "秒后重新获取"); |
|
1500 |
wait--; |
|
1501 |
setTimeout(function() { |
|
1502 |
countdown(obj, msg) |
|
1503 |
}, 1000) |
|
1504 |
} |
|
1505 |
} |
|
1506 |
/* 代码增加2014-12-23 by _end */ |