edit.html 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  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="课程标题" value="{$data.pruduct_name}">
  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" value="{$data.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="{$data.product_parameter}" 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">富文本1</label>-->
  31. <!-- <div class="layui-input-block">-->
  32. <!-- <textarea id="demo" style="display: none;">{$data.product_fuwenben}</textarea>-->
  33. <!-- </div>-->
  34. <!--</div>-->
  35. <!--<div class="layui-form-item layui-col-md-offset1 layui-col-md8">-->
  36. <!-- <label class="layui-form-label">产品优势</label>-->
  37. <!-- <div class="layui-input-block">-->
  38. <!-- <textarea id="demo2" style="display: none;">{$data.product_youshi}</textarea>-->
  39. <!-- </div>-->
  40. <!--</div>-->
  41. <!--<div class="layui-form-item layui-col-md-offset1 layui-col-md8">-->
  42. <!-- <label class="layui-form-label">产品实拍</label>-->
  43. <!-- <div class="layui-input-block">-->
  44. <!-- <textarea id="demo3" style="display: none;">{$data.product_shipai}</textarea>-->
  45. <!-- </div>-->
  46. <!--</div>-->
  47. <input type="hidden" name="oid" value="{$data.oid}">
  48. <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
  49. <div class="layui-input-block">
  50. <button class="layui-btn" lay-submit="" lay-filter="component-form-element">保存
  51. </button>
  52. <button class="layui-btn layui-btn-primary" onclick="history.back()">关闭</button>
  53. </div>
  54. </div>
  55. </div>
  56. </div>
  57. </div>
  58. </div>
  59. {include file="public/footer" /}
  60. <script>
  61. layui.use(['form','upload','element','layedit'], function() {
  62. var form = layui.form
  63. , upload = layui.upload
  64. , element = layui.element
  65. //富文本
  66. var layedit = layui.layedit;
  67. layedit.set({
  68. uploadImage: {
  69. url: '/admin/Aipimagesearch/Upload',
  70. type: 'post'
  71. }
  72. });
  73. var index =layedit.build('demo'); //建立编辑器
  74. var index2 =layedit.build('demo2'); //建立编辑器
  75. var index3 =layedit.build('demo3'); //建立编辑器
  76. form.on('submit(component-form-element)', function (data) {
  77. $('.layui-btn').addClass('layui-disabled').attr('disabled','disabled');
  78. var layeditcontent=layedit.getContent(index);
  79. var layeditcontent2=layedit.getContent(index2);
  80. var layeditcontent3=layedit.getContent(index3);
  81. //alert(layeditcontent);
  82. data.field.product_fuwenben=layeditcontent;
  83. data.field.product_youshi=layeditcontent2;
  84. data.field.product_shipai=layeditcontent3
  85. // console.log(data.field);
  86. $.ajax({
  87. url:"{:url('edit')}",
  88. type:'post',
  89. dataType:'json',
  90. data:data.field,
  91. success:function(res){
  92. if (res.code == 200) {
  93. layer.msg(res.msg,{icon:1,time:1500,shade:0.1},function(index){
  94. wk.layer_close();
  95. setTimeout(function () {
  96. location.reload();
  97. },1000);
  98. })
  99. } else {
  100. $(".layui-btn").removeClass('layui-disabled').removeAttr('disabled');
  101. wk.error(res.msg);
  102. return false;
  103. }
  104. }
  105. })
  106. });
  107. });
  108. </script>
  109. <script>
  110. layui.use('upload', function(){
  111. var upload = layui.upload;
  112. var uploadInst = upload.render({
  113. elem: '#test1'
  114. ,url: "{:url('admin/upload/uploadLocality')}"
  115. ,accept: 'images'
  116. ,multiple:false
  117. ,done: function(res){
  118. $('#lay-img-list1').attr("src",res.url);
  119. $('#product_image').val(res.url);
  120. }
  121. ,error: function(){
  122. }
  123. });
  124. });
  125. </script>
  126. <script>
  127. layui.use('upload', function(){
  128. var upload = layui.upload;
  129. var uploadInst = upload.render({
  130. elem: '#test2'
  131. ,url: "{:url('admin/upload/uploadLocality')}"
  132. ,accept: 'images'
  133. ,multiple:false
  134. ,done: function(res){
  135. $('#lay-img-list2').attr("src",res.url);
  136. $('#product_parameter').val(res.url);
  137. }
  138. ,error: function(){
  139. }
  140. });
  141. });
  142. </script>
  143. </body>
  144. </html>