scroll.js http://www.cnblogs.com/yjzhu/archive/2012/11/22/2782418.html <script> $.door({"id" : "base", "tag" : "li", "on" : "on", "act" : "click"}); $.door({"id" : "partner", "tag" : "li", "on" : "on", "act" : "click"}); C.submit = function(formid) { if (!formid) { return ; } var data = C.getForm(formid); C.post("/commerce/save", data, function(res) { if (res.ret != 0) { return C.alert(res.msg); } C.alert(res.msg); setTimeout(function(){ window.location.href="{url|c=commerce|r}";}, 1000); return ; }) } C.addwe = function() { var data = C.getForm(‘addwes‘); C.post("/commerce/addwe", data, function(res) { if (res.ret != 0) { return C.alert(res.msg); ; } C.alert(data.msg); setTimeout(function(){ window.location.href="{url|c=commerce|r}";}, 1000); return ; }) } var M = {}; M.init = function(type){ var self = this; var option = [ {id:‘addname‘, notic:‘请输入姓名‘}, {id:‘addnick‘, notic:‘请输入称谓‘}, {id:‘addcountry‘, notic:‘请选择国籍‘}, {id:‘addbank‘, notic:‘请输入银行名称‘}, {id:‘addbanksite‘, notic:‘请输入银行地址‘}, {id:‘addbankaccount‘, notic:‘请输入银行账户‘}, {id:‘regname‘, notic:‘请输入名字‘}, {id:‘regnick‘, notic:‘请输入姓氏‘}, {id:‘addemail‘, notic:‘请输入电子邮件‘}, {id:‘addmobile‘, notic:‘请输入手机号‘}, {id:‘regemail‘, notic:‘请输入邮箱‘}, {id:‘regmobile‘, notic:‘请输入电话号码‘},] self.lien(option); $("#base li")[type].onclick(); //发送验证码时调用 $(‘#sendCodebtn‘).onclick = function(){ self.show(); }; $(‘#addcountry‘).onchange = function(){ $(‘#country‘).innerHTML = ‘<strong >‘+this.options[this.selectedIndex].text+‘</strong>(‘+ this.value +‘)‘; }; }; M.show = function(){ var msgpop = $("#msgpop"); if (msgpop) { document.body.removeChild(msgpop); } var oDiv = document.createElement("div"); oDiv.className = "pop"; oDiv.style.display = "block"; oDiv.id = "msgpop"; var html = ‘<div class="main"><div class="top"><p>身份验证</p><span onclick="$(\‘#msgpop\‘).hide()">×</span> </div>‘; html += ‘<div class="tips"><p class="care" id="doshow">‘; html += "验证码:<input type=‘text‘ name=‘imgcode‘ value=‘‘ id=‘imgcode‘/>"; html += ‘<img id="loginImage" alt="点击换一张" src="/user/code"/ onclick="this.src=\‘/user/code?n=12\‘ + Math.random();"> ‘; html +=‘<br/><span id="checkimg" style="color:red;"><span></p></div> <div class="foot"><div class="btn"><a href="javascript:;" onclick="M.check();" >确认</a></div></div></div> <div class="bg"></div>‘; oDiv.innerHTML = html; document.body.appendChild(oDiv); msgpop = oDiv; }; M.check = function () { var imgcode = $(‘#imgcode‘).value; $.post(‘/user/check?type=commerce‘, {code:imgcode}, function(data) { if (data.ret == ‘0‘) { $(‘#checkimg‘).innerHTML = data.msg; setTimeout(function(){ $(‘#msgpop‘).hide(); }, 1500); return M.sendCode();; } else { $(‘#checkimg‘).innerHTML = data.msg; setTimeout(function(){ $(‘#loginImage‘).setAttribute(‘src‘, ‘/user/code?n=12‘ + Math.random()); }, 1000); } }, ‘JSON‘); }; M.lien = function(option){ if (!option) { return; } function ln(id, notic) { $("#" + id).bind(‘blur‘, function(){ if(this.value.trim().length < 1){ this.nextElementSibling.innerHTML = notic; }else{ this.nextElementSibling.innerHTML = ‘‘; } }); } for (var n=0; n< 8; n++) { ln(option[n].id, option[n].notic); } $("#" + option[8].id).bind(‘blur‘, function(){ if(! $.string.isEmail(this.value.trim())) { this.nextElementSibling.innerHTML = option[8].notic; }else{ this.nextElementSibling.innerHTML = ‘‘; } }); $("#" + option[9].id).bind(‘blur‘, function(){ if( ! $.string.isMobileCode(this.value.trim())) { this.nextElementSibling.innerHTML = option[9].notic; }else{ this.nextElementSibling.innerHTML = ‘‘; } }); $("#" + option[10].id).bind(‘blur‘, function(){ if(! $.string.isEmail(this.value.trim())) { this.nextElementSibling.innerHTML = option[10].notic; }else{ this.nextElementSibling.innerHTML = ‘‘; } }); $("#" + option[11].id).bind(‘blur‘, function(){ if( ! $.string.isMobileCode(this.value.trim())) { this.nextElementSibling.innerHTML = option[11].notic; }else{ this.nextElementSibling.innerHTML = ‘‘; } }); }; M.flag = false; M.sendCode = function() { this.flag = true; var self = this, timeout = 60, timer, doreply = function() { var btn = $(‘#sendCodebtn‘); //获取验证码按钮的id if (timeout == 0) { timeout = 60; btn.innerHTML = ‘获取验证码‘; btn.onclick = function(){ self.sendCode(); }; return; } btn.innerHTML = timeout + ‘秒重发‘; btn.onclick = function(){}; timeout--; if (timer) { clearTimeout(timer); } timer = setTimeout(function(){ doreply(); }, 1000); } var mobileObj = $(‘#addmobile‘); var mobile = mobileObj.value.trim(); if( ! $.string.isMobileCode(mobile)) { return mobileObj.nextElementSibling.innerHTML = ‘请输入正确的手机号‘; } if (!this.flag) { return; } this.flag = false; $.post(‘/api-user/code?type=commerce&mobile=‘ + ‘86-‘+ mobile, {}, function(data) { self.flag = true; if (data.ret == ‘0‘) { return doreply(); } else { return C.alert(data.msg); } }, ‘JSON‘) }; M.init("{$type}"); </script>
时间: 2024-10-09 01:53:32