profile.js 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. define(['jquery', 'table', 'form', 'upload'], function($, Table, Form, Upload) {
  2. var Controller = {
  3. index: function() {
  4. Table.init = {
  5. table_elem: '#currentTable',
  6. table_render_id: 'currentTable',
  7. };
  8. Table.render({
  9. init: Table.init,
  10. toolbar: ['refresh'],
  11. url: 'general.profile/index',
  12. cols: [
  13. [
  14. { field: 'id', width: 80, title: 'ID', sort: true },
  15. { field: 'title', minWidth: 150, title: '标题' },
  16. { field: 'url', minWidth: 180, title: '操作URL' },
  17. { field: 'create_time', width: 180, title: '时间', search: 'range' },
  18. { field: 'ip', width: 120, title: 'IP' },
  19. ]
  20. ],
  21. page: {}
  22. });
  23. Table.api.bindevent();
  24. // 给上传按钮添加上传成功事件
  25. $("#faupload-avatar").data("upload-success", function (data) {
  26. var url = Backend.api.cdnurl(data.url);
  27. $(".profile-user-img").prop("src", url);
  28. Toastr.success("上传成功!");
  29. });
  30. // 给表单绑定事件
  31. Form.api.bindevent($("form#profile"), function() {
  32. $("input[name='row[password]']").val('');
  33. var url = Backend.api.cdnurl($("#c-avatar").val());
  34. top.window.$(".layui-header .layui-layout-right .userAvatar").prop("src", url);
  35. return true;
  36. });
  37. }
  38. };
  39. return Controller;
  40. });