作者 Cool
1 个管道 的构建 通过 耗费 11 秒

update

  1 +define(['jquery', 'bootstrap', 'frontend', 'form', 'template'], function ($, undefined, Frontend, Form, Template) {
  2 + var validatoroptions = {
  3 + invalid: function (form, errors) {
  4 + $.each(errors, function (i, j) {
  5 + Layer.msg(j);
  6 + });
  7 + }
  8 + };
  9 + var Controller = {
  10 + index: function () {
  11 + Controller.api.nav();
  12 + },
  13 + register: function () {
  14 + //本地验证未通过时提示
  15 + $("#register-form").data("validator-options", validatoroptions);
  16 +
  17 + //为表单绑定事件
  18 + Form.api.bindevent($("#register-form"), function (data, ret) {
  19 + setTimeout(function () {
  20 + location.href = ret.url ? ret.url : "/";
  21 + }, 1000);
  22 + }, function (data) {
  23 + $("input[name=captcha]").next(".input-group-addon").find("img").trigger("click");
  24 + });
  25 + },
  26 + changepwd: function () {
  27 + //本地验证未通过时提示
  28 + $("#changepwd-form").data("validator-options", validatoroptions);
  29 +
  30 + //为表单绑定事件
  31 + Form.api.bindevent($("#changepwd-form"), function (data, ret) {
  32 + setTimeout(function () {
  33 + location.href = ret.url ? ret.url : "/";
  34 + }, 1000);
  35 + });
  36 + },
  37 + profile: function () {
  38 + // 给上传按钮添加上传成功事件
  39 + $("#plupload-avatar").data("upload-success", function (data) {
  40 + var url = Fast.api.cdnurl(data.url);
  41 + $(".profile-user-img").prop("src", url);
  42 + Toastr.success(__('Upload successful'));
  43 + });
  44 + Form.api.bindevent($("#profile-form"));
  45 + $(document).on("click", ".btn-change", function () {
  46 + var that = this;
  47 + var id = $(this).data("type") + "tpl";
  48 + var content = Template(id, {});
  49 + Layer.open({
  50 + type: 1,
  51 + title: "修改",
  52 + area: ["400px", "250px"],
  53 + content: content,
  54 + success: function (layero) {
  55 + var form = $("form", layero);
  56 + Form.api.bindevent(form, function (data) {
  57 + location.reload();
  58 + Layer.closeAll();
  59 + });
  60 + }
  61 + });
  62 + });
  63 + },
  64 + api: {
  65 + nav: function () {
  66 + $('#basicInforTab').find('li').click(function () {
  67 + window.location.href = $(this).data('href');
  68 + });
  69 + }
  70 + }
  71 + };
  72 + return Controller;
  73 +});