define(["tiny"],function(a){var b={};return b.initLogin=function(b){$(".button-login").click(function(){var c=$(this);if($(this).hasClass("disabled"))return!1;var d=$.trim($('input[name="mobile"]').val());if(!d)return $.toast("请输入手机号"),!1;if(!/^1[34578][0-9]{9}/.test(d))return $.toast("手机号格式错误"),!1;var e=$.trim($('input[name="password"]').val());return e?(c.addClass("disabled"),$.post(a.getUrl("wmall/auth/login"),{mobile:d,password:e,forward:b},function(a){var b=$.parseJSON(a);b.message.errno?($.toast(b.message.message),c.removeClass("disabled")):$.toast("登陆成功",b.message.message)}),!1):($.toast("请输入密码"),!1)})},b.sendCode=function(b){$(".button-code").click(function(){if($(this).hasClass("disabled"))return!1;var c=$.trim($('input[name="mobile"]').val());if(!c)return $.toast("请输入手机号"),!1;if(!/^1[34578][0-9]{9}/.test(c))return $.toast("手机号格式错误"),!1;var d=$.trim($('input[name="captcha"]').val());if(!d)return $.toast("请输入图形验证码"),!1;var e=$(this);e.addClass("disabled");var f=60;e.html(f+"秒后重新获取");var g=setInterval(function(){f--,f<=0?(clearInterval(g),e.html("获取验证码"),e.removeClass("disabled"),f=60):e.html(f+"秒后重新获取")},1e3);return $.post(a.getUrl("system/common/code"),{mobile:c,product:b,captcha:d},function(a){"success"!=a?$.toast(a):$.toast("验证码发送成功, 请注意查收")}),!1})},b.initRegister=function(){b.sendCode("注册用户"),$(".button-register").click(function(){var b=$(this);if($(this).hasClass("disabled"))return!1;var c=$.trim($('input[name="mobile"]').val());if(!c)return $.toast("请输入手机号"),!1;var d=/^1[34578][0-9]{9}/;if(!d.test(c))return $.toast("手机号格式错误"),!1;var e=$.trim($('input[name="code"]').val());if(!e)return $.toast("请输入短信验证码"),!1;var f=$.trim($('input[name="password"]').val());if(!f)return $.toast("请输入密码"),!1;var g=f.length;if(g<8||g>20)return $.toast("请输入8-20位密码"),!1;var d=/[0-9]+[a-zA-Z]+[0-9a-zA-Z]*|[a-zA-Z]+[0-9]+[0-9a-zA-Z]*/;if(!d.test(f))return $.toast("密码必须由数字和字母组合"),!1;var h=$.trim($('input[name="repassword"]').val());return h?f!=h?($.toast("两次密码输入不一致"),!1):(b.addClass("disabled"),$.post(a.getUrl("wmall/auth/register"),{mobile:c,password:f,code:e},function(a){var c=$.parseJSON(a);c.message.errno?($.toast(c.message.message),b.removeClass("disabled")):$.toast("注册成功",c.message.message)}),!1):($.toast("请重复输入密码"),!1)})},b.initForget=function(){b.sendCode("找回密码"),$(".button-forget").click(function(){var b=$(this);if($(this).hasClass("disabled"))return!1;var c=$.trim($('input[name="mobile"]').val());if(!c)return $.toast("请输入手机号"),!1;var d=/^1[34578][0-9]{9}/;if(!d.test(c))return $.toast("手机号格式错误"),!1;var e=$.trim($('input[name="code"]').val());if(!e)return $.toast("请输入短信验证码"),!1;var f=$.trim($('input[name="password"]').val());if(!f)return $.toast("请输入密码"),!1;var g=f.length;if(g<8||g>20)return $.toast("请输入8-20位密码"),!1;var d=/[0-9]+[a-zA-Z]+[0-9a-zA-Z]*|[a-zA-Z]+[0-9]+[0-9a-zA-Z]*/;if(!d.test(f))return $.toast("密码必须由数字和字母组合"),!1;var h=$.trim($('input[name="repassword"]').val());return h?f!=h?($.toast("两次密码输入不一致"),!1):(b.addClass("disabled"),$.post(a.getUrl("wmall/auth/forget"),{mobile:c,password:f,code:e},function(a){var c=$.parseJSON(a);c.message.errno?($.toast(c.message.message),b.removeClass("disabled")):$.toast("设置新密码成功",c.message.message)}),!1):($.toast("请重复输入密码"),!1)})},b});