project_comments.html 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  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. .wrapper{
  11. display: flex;
  12. justify-content: space-between;
  13. padding-top: 3px;
  14. }
  15. </style>
  16. <div class="log_item_top" id="comments">
  17. <div class="layui-tab-content">
  18. {volist name="$comment" id="vo"}
  19. <div class="log_top">
  20. <span>{$vo.maker}</span><span
  21. 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>
  22. </div>
  23. <div class="log_content">
  24. <div style="word-wrap:break-word;padding: 5px 10px;">
  25. {$vo.content}
  26. </div>
  27. {if !empty($vo.thumb)}
  28. <div class="log_content_img">
  29. <span class="content_img"><img src="{$vo.thumb}" alt=""></span><span></span>
  30. </div>
  31. {/if}
  32. </div>
  33. {/volist}
  34. </div>
  35. </div>
  36. <hr class="ws-space-16">
  37. <div class="log_item_bottom">
  38. <div class="layui-form log_bottom_left">
  39. <form class="layui-form" action="">
  40. <div class="layui-form-item layui-form-text" style="float: left;width: 95%;">
  41. <label class="layui-form-label">普通文本域</label>
  42. <div class="layui-input-block" style="margin-left: 100px;">
  43. <textarea id="text" name="content" placeholder="请输入内容" maxlength="3000"class="layui-textarea"></textarea>
  44. </div>
  45. <div class="wrapper">
  46. <span></span><span class="total">0/3000字</span>
  47. </div>
  48. </div>
  49. <div class="layui-form-item" style="float: left;width: 4.5%;">
  50. <div class="layui-input-block">
  51. <button type="submit" class="layui-btn" lay-submit lay-filter="webform" type="button"
  52. style="width: 100%;height: 100% !important;background-color: #16baaa00 !important;margin-top: 30%;">
  53. <img src="/static/home/images/allupload.png" height="100"
  54. style="max-width: 40px;height: 40px;"/>
  55. </button>
  56. </div>
  57. </div>
  58. <div style="clear: both;"></div>
  59. <div class="layui-form-item" id="imgItem">
  60. <label class="layui-form-label">上传图片:</label>
  61. <div class="layui-input-inlines-self">
  62. <div class="layui-upload-drag-self">
  63. <div id="uploadBtn" style="position:relative;">
  64. <img src="/static/home/images/upload.png" height="100"
  65. style="max-width: 100%; width: 100%;"/>
  66. <input type="hidden" name="thumb" value="">
  67. <i class="layui-icon layui-icon-clear" id="imgdel"></i>
  68. </div>
  69. </div>
  70. </div>
  71. </div>
  72. </form>
  73. </div>
  74. </div>
  75. <!--zjl,懂的都懂-->
  76. <script>
  77. function comment() {
  78. var form = layui.form,tool=layui.tool,upload = layui.upload;
  79. //头像上传
  80. var uploadInst = upload.render({
  81. elem: '#uploadBtn'
  82. , url: '/admin/api/upload'
  83. , done: function (e) {
  84. //如果上传失败
  85. if (e.code == 1) {
  86. return layer.msg('上传失败');
  87. }
  88. //上传成功
  89. $('#uploadBtn input').attr('value', e.data.filepath);
  90. $('#uploadBtn img').attr('src', e.data.filepath);
  91. $('#imgdel').show();
  92. }
  93. });
  94. $('#imgdel').click(()=>{
  95. $('#uploadBtn input').attr('value', '');
  96. $('#uploadBtn img').attr('src', '/static/home/images/upload.png');
  97. $('#imgdel').hide();
  98. return false;
  99. })
  100. $('#uploadBtn').click(()=>{
  101. console.log(1)
  102. return false;
  103. })
  104. //监听提交
  105. form.on('submit(webform)', function (data) {
  106. let callback = function (e) {
  107. layer.msg(e.msg);
  108. $("#text").val("");
  109. $('#uploadBtn input').attr('value', '');
  110. $('#imgdel').hide();
  111. $('#uploadBtn img').attr('src', '/static/home/images/upload.png');
  112. $("#comments").load(location.href+" #comments>*","type=2")
  113. }
  114. if(data.field.content === '' && data.field.thumb === ''){
  115. console.log(data.field)
  116. layer.msg("请完善内容");
  117. }else {
  118. data.field["project_id"] = project_id;
  119. tool.post("/admin/project.comment/add_proprietor", data.field, callback);
  120. }
  121. return false;
  122. });
  123. }
  124. </script>
  125. <script>
  126. const tx = document.querySelector('#text')
  127. const total = document.querySelector('.total')
  128. tx.addEventListener('input', function () {
  129. console.log(tx.value.length)
  130. total.innerHTML = `${tx.value.length}/3000字`
  131. })
  132. </script>