edit.html 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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-body layui-form">
  6. <div class="layui-row layui-col-space10 layui-form-item ">
  7. <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
  8. <label class="layui-form-label">轮播图片</label>
  9. <input type="hidden" name="image" id="image" value="{$data.image}">
  10. <button type="button" class="layui-btn" id="test5">
  11. 选择文件
  12. </button>
  13. <div class="layui-input-block">
  14. <blockquote class="layui-elem-quote layui-quote-nm" style="margin-top: 10px;">
  15. 预览图:
  16. <div class="layui-upload-list" >
  17. <img src="{$data.image}" id="images" style="width:100px;height:100px;">
  18. </div>
  19. </blockquote>
  20. </div>
  21. </div>
  22. <input type="hidden" name="cid" value="{$data.cid}">
  23. <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
  24. <label class="layui-form-label">url(可为空)</label>
  25. <div class="layui-input-block">
  26. <textarea name="url" placeholder="图片地址(为空请填0)" lay-verify="required" class="layui-textarea" maxlength="200">{$data.url}</textarea>
  27. </div>
  28. </div>
  29. <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
  30. <div class="layui-input-block">
  31. <button class="layui-btn" lay-submit="" lay-filter="component-form-element">保存
  32. </button>
  33. <button class="layui-btn layui-btn-primary" onclick="wk.layer_close('close')">关闭</button>
  34. </div>
  35. </div>
  36. </div>
  37. </div>
  38. </div>
  39. </div>
  40. {include file="public/footer" /}
  41. <script>
  42. layui.use(['form'], function() {
  43. var form = layui.form;
  44. form.on('submit(component-form-element)', function (data) {
  45. $('.layui-btn').addClass('layui-disabled').attr('disabled','disabled');
  46. $.ajax({
  47. url:"{:url('edit')}",
  48. type:'post',
  49. dataType:'json',
  50. data:data.field,
  51. success:function(res){
  52. if (res.code == 200) {
  53. wk.success(res.msg,'wk.layer_close()');
  54. } else {
  55. wk.error(res.msg,'$(".layui-btn").removeClass(\'layui-disabled\').removeAttr(\'disabled\')');
  56. }
  57. }
  58. })
  59. });
  60. });
  61. </script>
  62. <script>
  63. layui.use('upload', function(){
  64. var upload = layui.upload;
  65. var uploadInst = upload.render({
  66. elem: '#test5'
  67. ,url: "{:url('admin/upload/uploadLocality')}"
  68. ,accept: 'images'
  69. ,multiple:false
  70. ,done: function(res){
  71. $('#images').attr("src",res.url);
  72. $('#image').val(res.url);
  73. }
  74. ,error: function(){
  75. }
  76. });
  77. });
  78. </script>
  79. </body>
  80. </html>