Theme.js 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. $(function()
  2. {
  3. // 模板切换
  4. $('.select-theme').on('click', function()
  5. {
  6. var theme = $(this).data('theme');
  7. if(!$(this).parent().hasClass('theme-active'))
  8. {
  9. var $this = $(this);
  10. if(theme != undefined)
  11. {
  12. // ajax请求
  13. $.ajax({
  14. url:$('.data-list').data('select-url'),
  15. type:'POST',
  16. dataType:"json",
  17. timeout:10000,
  18. data:{"common_default_theme":theme},
  19. success:function(result)
  20. {
  21. if(result.code == 0)
  22. {
  23. $('.am-gallery-item').removeClass('theme-active');
  24. $this.parent().addClass('theme-active');
  25. Prompt(result.msg, 'success');
  26. } else {
  27. Prompt(result.msg);
  28. }
  29. },
  30. error:function()
  31. {
  32. Prompt('网络异常错误');
  33. }
  34. });
  35. }
  36. }
  37. });
  38. // 模板上传选择名称展示
  39. $('input[name="theme"]').on('change', function()
  40. {
  41. var fileNames = '';
  42. $.each(this.files, function()
  43. {
  44. fileNames += '<span class="am-badge">' + this.name + '</span> ';
  45. });
  46. $('#form-theme-tips').html(fileNames);
  47. });
  48. });