script.blade.php 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <script>
  2. $('#base-form').ajaxForm({
  3. success: function (result) {
  4. if(!result.status){
  5. swal({
  6. title: result.message,
  7. text: "",
  8. type: "error"
  9. })
  10. } else {
  11. swal({
  12. title: "保存成功!",
  13. text: "",
  14. type: "success"
  15. }, function () {
  16. location = '{{route('admin.course.teacher.index')}}';
  17. });
  18. }
  19. }
  20. });
  21. $(function () {
  22. var uploader = WebUploader.create({
  23. // 选完文件后,是否自动上传。
  24. auto: true,
  25. swf: '{{url(env("APP_URL").'/assets/backend/libs/webuploader-0.1.5/Uploader.swf')}}',
  26. server: '{{route('ibrand.file.upload',['_token'=>csrf_token()])}}',
  27. pick: '#filePicker',
  28. fileVal: 'upload_file',
  29. accept: {
  30. title: 'Images',
  31. extensions: 'gif,jpg,jpeg,bmp,png',
  32. mimeTypes: 'image/*'
  33. }
  34. });
  35. // 文件上传成功,给item添加成功class, 用样式标记上传成功。
  36. uploader.on('uploadSuccess', function (file, response) {
  37. $('#userAvatar img').attr("src", response.data.url);
  38. $('#userAvatar input').val('/storage/' + response.data.path);
  39. });
  40. });
  41. $(function () {
  42. var datas = [];
  43. $.ajax({
  44. type: "GET",
  45. url: '{{route('admin.course.teacher.getsimilartags')}}',
  46. success: function (data) {
  47. if (data) {
  48. console.log(data);
  49. datas = data;
  50. $("#inputDiscountTags").tagator({
  51. autocomplete: datas
  52. });
  53. }
  54. }
  55. });
  56. });
  57. function delColumn(_self) {
  58. $(_self).parent().parent().remove();
  59. }
  60. $(function () {
  61. var type_html = $('#type-template').html();
  62. $('#add-type').click(function () {
  63. var num = $('.typeList').length;
  64. $('#typeBody').append(type_html.replace(/{NUM}/g, num));
  65. });
  66. var content_html = $('#content-template').html();
  67. $('#add-content').click(function () {
  68. var num = $('.contentList').length;
  69. $('#contentBody').append(content_html.replace(/{NUM}/g, num));
  70. });
  71. })
  72. </script>