define(['jquery', 'bootstrap', 'frontend', 'form', 'template'], function ($, undefined, Frontend, Form, Template) { var Controller = { login: function () { //本地验证未通过时提示 $("#login-form").data("validator-options", { invalid: function (form, errors) { $.each(errors, function (i, j) { Layer.alert(j); }); }, }); //为表单绑定事件 Form.api.bindevent($("#login-form"), function (data, ret) { setTimeout(function () { location.href = ret.url ? ret.url : "/"; }, 1000); }); Form.api.bindevent($("#resetpwd-form"), function (data) { Layer.closeAll(); }); $(document).on("click", ".btn-forgot", function () { var id = "resetpwdtpl"; var content = Template(id, {}); Layer.open({ type: 1, title: "修改", area: ["450px", "auto"], content: content, success: function (layero) { Form.api.bindevent($("#resetpwd-form", layero), function (data) { Layer.closeAll(); }); } }); }); }, register: function () { //本地验证未通过时提示 $("#register-form").data("validator-options", { invalid: function (form, errors) { $.each(errors, function (i, j) { Layer.alert(j); }); }, }); //为表单绑定事件 Form.api.bindevent($("#register-form"), function (data, ret) { setTimeout(function () { location.href = ret.url ? ret.url : "/"; }, 1000); }); }, changepwd: function () { //本地验证未通过时提示 $("#resetpwd-form").data("validator-options", { invalid: function (form, errors) { $.each(errors, function (i, j) { Layer.alert(j); }); }, }); //为表单绑定事件 Form.api.bindevent($("#changepwd-form"), function (data, ret) { setTimeout(function () { location.href = ret.url ? ret.url : "/"; }, 1000); }); }, profile: function () { // 给上传按钮添加上传成功事件 $("#plupload-avatar").data("upload-success", function (data) { var url = Fast.api.cdnurl(data.url); $(".profile-user-img").prop("src", url); Toastr.success("上传成功!"); }); //为表单绑定事件 Form.api.bindevent($("#profile-form"), function (data) { }); Form.api.bindevent($("#email-form"), function (data) { Layer.closeAll(); $("#basic-form #email").val($("#email").val()); }); Form.api.bindevent($("#mobile-form"), function (data) { Layer.closeAll(); $("#basic-form #mobile").val($("#mobile").val()); }); $(document).on("click", ".btn-change", function () { var id = $(this).data("type") + "tpl"; var content = Template(id, {}); Layer.open({ type: 1, title: "修改", area: ["450px", "auto"], content: content, }); }); } }; return Controller; });