profile.js 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'upload'], function ($, undefined, Backend, Table, Form, Upload) {
  2. var Controller = {
  3. index: function () {
  4. // 初始化表格参数配置
  5. Table.api.init({
  6. search: true,
  7. advancedSearch: true,
  8. pagination: true,
  9. extend: {
  10. "index_url": "general/profile/index",
  11. "add_url": "",
  12. "edit_url": "",
  13. "del_url": "",
  14. "multi_url": "",
  15. }
  16. });
  17. var table = $("#table");
  18. // 初始化表格
  19. table.bootstrapTable({
  20. url: $.fn.bootstrapTable.defaults.extend.index_url,
  21. columns: [
  22. [
  23. {field: 'id', title: 'ID'},
  24. {field: 'title', title: __('Title')},
  25. {field: 'url', title: __('Url'), align: 'left', formatter: Table.api.formatter.url},
  26. {field: 'ip', title: __('ip'), formatter:Table.api.formatter.search},
  27. {field: 'createtime', title: __('Createtime'), formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange', sortable: true},
  28. ]
  29. ],
  30. commonSearch: false
  31. });
  32. // 为表格绑定事件
  33. Table.api.bindevent(table);//当内容渲染完成后
  34. // 给上传按钮添加上传成功事件
  35. $("#faupload-avatar").data("upload-success", function (data) {
  36. var url = Backend.api.cdnurl(data.url);
  37. $(".profile-user-img").prop("src", url);
  38. Toastr.success("上传成功!");
  39. });
  40. // 给表单绑定事件
  41. Form.api.bindevent($("#update-form"), function () {
  42. $("input[name='row[password]']").val('');
  43. var url = Backend.api.cdnurl($("#c-avatar").val());
  44. top.window.$(".user-panel .image img,.user-menu > a > img,.user-header > img").prop("src", url);
  45. return true;
  46. });
  47. },
  48. };
  49. return Controller;
  50. });