social_media_update.blade.php 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. @extends('admin/layout')
  2. @section('header')
  3. <link href="{{asset('css/plugins/chosen/chosen.css')}}" rel="stylesheet">
  4. <link href="{{asset('css/plugins/switchery/switchery.css')}}" rel="stylesheet">
  5. <link rel="stylesheet"
  6. href="https://cdn.jsdelivr.net/npm/bootstrap-select@1.13.9/dist/css/bootstrap-select.min.css">
  7. @endsection
  8. @section('content')
  9. <body class="gray-bg">
  10. <div class="wrapper wrapper-content animated fadeInRight">
  11. <div class="row">
  12. <div class="col-sm-12">
  13. <div class="ibox float-e-margins">
  14. <div class="ibox-content">
  15. <form method="get" class="form-horizontal" id="form">
  16. <div class="form-group">
  17. <label class="col-sm-2 control-label" for="nickname"><span
  18. class="red">* </span>标题:</label>
  19. <div class="col-sm-6">
  20. <input type="text" class="form-control" id="title" name="title" autocomplete="off"
  21. value="{{$info->title??''}}">
  22. </div>
  23. </div>
  24. <div class="form-group">
  25. <label class="col-sm-2 control-label" for="username_new"><span class="red">* </span>
  26. 内容:</label>
  27. <div class="col-sm-6">
  28. <input type="text" class="form-control" id="content" name="content"
  29. value="{{$info->content??''}}" autocomplete="off">
  30. </div>
  31. </div>
  32. <div class="form-group">
  33. <label class="col-sm-2 control-label">图片:</label>
  34. <div class="col-sm-4">
  35. <button type="button" class="btn btn-primary" name="file_upload">文件上传
  36. </button>
  37. <input type="file" value="" style="display: none" name="uploadFile"
  38. data-for="logo_img">
  39. <img id="image" width="200px" src="{{$info->image??''}}">
  40. </div>
  41. </div>
  42. <div class="form-group">
  43. <label class="col-sm-2 control-label" for="translate_content">详情:</label>
  44. <div class="col-sm-8">
  45. <script id="translate_content" name="details"
  46. type="text/plain">{!! $info->details??''!!}</script>
  47. </div>
  48. </div>
  49. <div class="form-group">
  50. <div class="col-sm-4 col-sm-offset-2">
  51. <button class="btn btn-primary" type="button" data-id="{{$info->id??0}}"
  52. id="save">
  53. 保存
  54. </button>
  55. <button class="btn btn-white" type="button" id="cancel">取消</button>
  56. </div>
  57. </div>
  58. </form>
  59. </div>
  60. </div>
  61. </div>
  62. </div>
  63. </div>
  64. </body>
  65. @endsection
  66. @section('footer')
  67. @include('vendor.ueditor.assets')
  68. <script src="{{asset('js/plugins/switchery/switchery.js')}}"></script>
  69. <script src="https://cdn.jsdelivr.net/npm/bootstrap-select@1.13.9/dist/js/bootstrap-select.min.js"></script>
  70. <script>
  71. var ue = UE.getEditor('content');
  72. ue.ready(function () {
  73. ue.setHeight(300);
  74. });
  75. var ueTranslate = UE.getEditor('translate_content');
  76. ueTranslate.ready(function () {
  77. ueTranslate.setHeight(300);
  78. });
  79. $(document).on('click', '[name=file_upload]', function () {
  80. $(this).next().trigger('click');
  81. });
  82. $(document).on('change', '[name=uploadFile]', function () {
  83. if (!$(this)[0].files[0]) {
  84. return;
  85. }
  86. var formData = new FormData();
  87. formData.append('file', $(this)[0].files[0]);
  88. var ln;
  89. $.ajax({
  90. url: '/admin/tool/upload',
  91. type: 'POST',
  92. cache: false,
  93. data: formData,
  94. processData: false,
  95. contentType: false,
  96. beforeSend: function () {
  97. ln = layer.load();
  98. },
  99. complete: function () {
  100. layer.close(ln);
  101. },
  102. success: function (result) {
  103. var data = result.data;
  104. $('#image').attr('src', data.file_url);
  105. },
  106. error: function (XMLHttpRequest) {
  107. if (XMLHttpRequest.status === 500) {
  108. layer.alert("异步请求失败", {icon: 5});
  109. return;
  110. }
  111. layer.alert(JSON.parse(XMLHttpRequest.responseText).message, {icon: 0});
  112. }
  113. });
  114. });
  115. $(document).on('click', '#cancel', function () {
  116. tips.closeParentLayer();
  117. });
  118. $(document).on('click', '#save', function () {
  119. var data = tips.getFormValues('#form');
  120. data.image = $("#image").attr('src');
  121. var id = $(this).data('id');
  122. var url = '/admin/classroom/social-media-update/' + id;
  123. var type = 'get';
  124. var ajaxConfig = {
  125. url: url,
  126. type: type,
  127. data: data,
  128. success: function (result) {
  129. layer.msg(result.message, {icon: 6, time: 1500}, function () {
  130. tips.closeParentLayer();
  131. window.parent.tips.tableRefresh('#table');
  132. });
  133. }
  134. };
  135. tips.ajax(ajaxConfig);
  136. });
  137. </script>
  138. @endsection