add.html 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. {include file="public/header" /}
  2. <body class="gray-bg">
  3. <div class="layui-fluid layui-col-md12">
  4. <div class="layui-card">
  5. <div class="layui-card-header">添加图库</div>
  6. <div class="layui-card-body layui-form">
  7. <div class="layui-row layui-col-space10 layui-form-item ">
  8. <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
  9. <label class="layui-form-label">图库名</label>
  10. <div class="layui-input-block">
  11. <input type="text" class="layui-input " name="pruduct_name" lay-verify="required" placeholder="课程标题">
  12. </div>
  13. </div>
  14. <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
  15. <label class="layui-form-label">参数图</label>
  16. <input type="hidden" name="product_parameter" id="product_parameter">
  17. <button type="button" class="layui-btn" id="test2">
  18. 选择文件
  19. </button>
  20. <div class="layui-input-block">
  21. <blockquote class="layui-elem-quote layui-quote-nm" style="margin-top: 10px;">
  22. 预览图:
  23. <div class="layui-upload-list" >
  24. <img src="" id="lay-img-list2" style="width:100px;height:100px;">
  25. </div>
  26. </blockquote>
  27. </div>
  28. </div>
  29. <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
  30. <label class="layui-form-label">产品图片</label>
  31. <input type="hidden" name="product_image" id="product_image">
  32. <button type="button" class="layui-btn" id="test1">
  33. 选择文件
  34. </button>
  35. <div class="layui-input-block">
  36. <blockquote class="layui-elem-quote layui-quote-nm" style="margin-top: 10px;">
  37. 预览图:
  38. <div class="layui-upload-list" >
  39. <img src="" id="lay-img-list1" style="width:100px;height:100px;">
  40. </div>
  41. </blockquote>
  42. </div>
  43. </div>
  44. <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
  45. <label class="layui-form-label">富文本1 (图片规则 宽小于375,高小于500)</label>
  46. <div class="layui-input-block">
  47. <textarea id="demo" style="display: none;"></textarea>
  48. </div>
  49. </div>
  50. <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
  51. <label class="layui-form-label">产品优势 (图片规则 宽小于375,高小于500)</label>
  52. <div class="layui-input-block">
  53. <textarea id="demo2" style="display: none;"></textarea>
  54. </div>
  55. </div>
  56. <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
  57. <label class="layui-form-label">产品实拍 (图片规则 宽小于375,高小于500)</label>
  58. <div class="layui-input-block">
  59. <textarea id="demo3" style="display: none;"></textarea>
  60. </div>
  61. </div>
  62. <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
  63. <div class="layui-input-block">
  64. <button class="layui-btn" lay-submit="" lay-filter="component-form-element">保存
  65. </button>
  66. <button class="layui-btn layui-btn-primary" onclick="history.back()">关闭</button>
  67. </div>
  68. </div>
  69. </div>
  70. </div>
  71. </div>
  72. </div>
  73. {include file="public/footer" /}
  74. <script>
  75. layui.use(['form','upload','element','layedit'], function() {
  76. var form = layui.form
  77. , upload = layui.upload
  78. , element = layui.element
  79. //富文本
  80. var layedit = layui.layedit;
  81. layedit.set({
  82. uploadImage: {
  83. url: '/admin/Aipimagesearch/Upload',
  84. type: 'post'
  85. }
  86. });
  87. var index =layedit.build('demo'); //建立编辑器
  88. var index2 =layedit.build('demo2'); //建立编辑器
  89. var index3 =layedit.build('demo3'); //建立编辑器
  90. form.on('submit(component-form-element)', function (data) {
  91. $('.layui-btn').addClass('layui-disabled').attr('disabled','disabled');
  92. var layeditcontent=layedit.getContent(index);
  93. var layeditcontent2=layedit.getContent(index2);
  94. var layeditcontent3=layedit.getContent(index3);
  95. //alert(layeditcontent);
  96. data.field.product_fuwenben=layeditcontent;
  97. data.field.product_youshi=layeditcontent2;
  98. data.field.product_shipai=layeditcontent3
  99. // console.log(data.field);
  100. $.ajax({
  101. url:"{:url('add')}",
  102. type:'post',
  103. dataType:'json',
  104. data:data.field,
  105. success:function(res){
  106. if (res.code == 200) {
  107. layer.msg(res.msg,{icon:1,time:1500,shade:0.1},function(index){
  108. wk.layer_close();
  109. setTimeout(function () {
  110. location.reload();
  111. },1000);
  112. })
  113. } else {
  114. $(".layui-btn").removeClass('layui-disabled').removeAttr('disabled');
  115. wk.error(res.msg);
  116. return false;
  117. }
  118. }
  119. })
  120. });
  121. });
  122. </script>
  123. <script>
  124. layui.use('upload', function(){
  125. var upload = layui.upload;
  126. var uploadInst = upload.render({
  127. elem: '#test1'
  128. ,url: "{:url('admin/upload/uploadLocality')}"
  129. ,accept: 'images'
  130. ,multiple:false
  131. ,done: function(res){
  132. $('#lay-img-list1').attr("src",res.url);
  133. $('#product_image').val(res.url);
  134. }
  135. ,error: function(){
  136. }
  137. });
  138. });
  139. </script>
  140. <script>
  141. layui.use('upload', function(){
  142. var upload = layui.upload;
  143. var uploadInst = upload.render({
  144. elem: '#test2'
  145. ,url: "{:url('admin/upload/uploadLocality')}"
  146. ,accept: 'images'
  147. ,multiple:false
  148. ,done: function(res){
  149. $('#lay-img-list2').attr("src",res.url);
  150. $('#product_parameter').val(res.url);
  151. }
  152. ,error: function(){
  153. }
  154. });
  155. });
  156. </script>
  157. </body>
  158. </html>