project_comments.html 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. <style>
  2. #imgdel {
  3. font-size: 30px;
  4. position: absolute;
  5. top: -30px;
  6. right: -12px;
  7. display: none;
  8. color: red;
  9. }
  10. .log_content{
  11. margin: 0.3vw 1.5vw 1vw 1.5vw;
  12. }
  13. </style>
  14. <div class="log_item_top" id="comments" style="height: 80vh;overflow: auto">
  15. <div class="layui-tab-content">
  16. {volist name="$comment" id="vo"}
  17. <div class="log_top">
  18. <span>{$vo.maker}</span><span
  19. class="{if $vo.unit_type==2}log_commentary{else}log_company{/if}">{$vo.unit_name}</span><span>{$vo.create_time|date="y-m-d H:i"}</span>
  20. </div>
  21. <div class="log_content">
  22. <div>
  23. {$vo.content}
  24. </div>
  25. {if !empty($vo.thumb)}
  26. <div class="log_content_img">
  27. <span class="content_img"><img src="{$vo.thumb}" alt=""></span><span></span>
  28. </div>
  29. {/if}
  30. </div>
  31. {/volist}
  32. </div>
  33. </div>
  34. <!-- <div class="log_item_bottom">
  35. <div class="layui-form log_bottom_left">
  36. <form class="layui-form" action="">
  37. <div class="layui-form-item layui-form-text" style="float: left;width: 95%;">
  38. <label class="layui-form-label">普通文本域</label>
  39. <div class="layui-input-block" style="margin-left: 100px;">
  40. <textarea id="text" name="content" placeholder="请输入内容" class="layui-textarea"></textarea>
  41. </div>
  42. </div>
  43. <div class="layui-form-item" style="float: left;width: 4.5%;">
  44. <div class="layui-input-block">
  45. <button type="submit" class="layui-btn" lay-submit lay-filter="webform" type="button"
  46. style="width: 100%;height: 100% !important;background-color: #16baaa00 !important;margin-top: 30%;">
  47. <img src="/static/home/images/allupload.png" height="100"
  48. style="max-width: 100%;height: 100%;"/>
  49. </button>
  50. </div>
  51. </div>
  52. <div style="clear: both;"></div>
  53. <div class="layui-form-item" id="imgItem">
  54. <label class="layui-form-label">上传图片:</label>
  55. <div class="layui-input-inlines-self">
  56. <div class="layui-upload-drag-self">
  57. <div id="uploadBtn" style="position:relative;">
  58. <img src="/static/home/images/upload.png" height="100"
  59. style="max-width: 100%; width: 100%;"/>
  60. <input type="hidden" name="thumb" value="">
  61. <i class="layui-icon layui-icon-clear" id="imgdel"></i>
  62. </div>
  63. </div>
  64. </div>
  65. </div>
  66. </form>
  67. </div>
  68. </div> -->
  69. <!--zjl,懂的都懂-->
  70. <script>
  71. function comment() {
  72. console.log('我执行了')
  73. var form = layui.form,tool=layui.tool,upload = layui.upload;
  74. //头像上传
  75. var uploadInst = upload.render({
  76. elem: '#uploadBtn'
  77. , url: '/admin/api/upload'
  78. , done: function (e) {
  79. //如果上传失败
  80. if (e.code == 1) {
  81. return layer.msg('上传失败');
  82. }
  83. //上传成功
  84. $('#uploadBtn input').attr('value', e.data.filepath);
  85. $('#uploadBtn img').attr('src', e.data.filepath);
  86. $('#imgdel').show();
  87. }
  88. });
  89. $('#imgdel').click(()=>{
  90. $('#uploadBtn input').attr('value', '');
  91. $('#uploadBtn img').attr('src', '/static/home/images/upload.png');
  92. $('#imgdel').hide();
  93. return false;
  94. })
  95. $('#uploadBtn').click(()=>{
  96. console.log(1)
  97. return false;
  98. })
  99. //监听提交
  100. form.on('submit(webform)', function (data) {
  101. let callback = function (e) {
  102. layer.msg(e.msg);
  103. $("#text").val("");
  104. $('#uploadBtn input').attr('value', '');
  105. $('#imgdel').hide();
  106. $('#uploadBtn img').attr('src', '/static/home/images/upload.png');
  107. $("#comments").load(location.href+" #comments>*","type=2")
  108. }
  109. if(data.field.content === '' && data.field.thumb === ''){
  110. console.log(data.field)
  111. layer.msg("请完善内容");
  112. }else {
  113. data.field["project_id"] = project_id;
  114. tool.post("/admin/project.comment/add", data.field, callback);
  115. }
  116. return false;
  117. });
  118. }
  119. </script>