(function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS 规范 module.exports = mod; else if (typeof define == "function" && define.amd) // AMD 规范 return define(['jquery','tools'], mod); else // Plain browser env 浏览器 mod($,tools); })(function($,tools) { // var $ = require(['jquery']); // var tools = require(['tools']); // 对分页的链接添加处理 if (!tools.isEmptyValue($('.pagination').toArray())) { $('.pagination>a ').each(function(index, el) { if ($(el).attr('href') != "#") { el.href += location.search; } }); } // 验证码 $('input[name="captcha"]').one('focusin', function(e) { var img = $(this).nextAll('img.captcha'); if (tools.isEmptyValue(img)) { var imgStr = ' 3 && code.length < 8 && !_self.attr('readonly')) { // $.ajax({ // url: SITE_URL + 'service/captcha_ajax', // type: 'GET', // dataType: 'json', // data: { // code: code // } // }) // .done(function(data) { // console.log("success"); // if (data.status) { // _self.removeClass('error').addClass('success'); // _self.next('img').remove(); // _self.attr('readonly', true); // _self.nextAll(".captcha_no").remove(); // _self.nextAll(".captcha_ok").remove(); // _self.after(''); // } else { // _self.removeClass('success').addClass('error'); // _self.nextAll('.captcha_ok').remove(); // _self.nextAll('.captcha_no').remove(); // _self.next().after( // '×'); // } // }) // .fail(function() { // console.log("error"); // }) // .always(function() { // console.log("complete"); // }); // } $('input[name="captcha"]').on('keyup', function(e) { var _self = $(this); var code = _self.val(); // 长度应该 == 4 if (code.length > 3 && code.length < 8 && !_self.attr('readonly')) { $.ajax({ url: SITE_URL + 'service/captcha_ajax', type: 'GET', dataType: 'json', data: { code: code } }) .done(function(data) { console.log("success"); if (data.status) { _self.removeClass('error').addClass('success'); _self.next('img').remove(); _self.attr('readonly', true); _self.nextAll('.captcha_no').remove(); _self.after(''); } else { _self.removeClass('success').addClass('error'); _self.nextAll('.captcha_ok').remove(); _self.nextAll('.captcha_no').remove(); _self.next().after( ''); } }) .fail(function() { console.log("error"); }) .always(function() { console.log("complete"); }); } }); // 默认加载验证码 function pic(){ var imgStr = '