edit_comments.html 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  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. /* 点击图片放大 */
  16. .img-responsive{
  17. /* width: 150px; */
  18. height: 150px;
  19. /* padding: 10px; */
  20. }
  21. </style>
  22. <div class="log_item_top" id="comments">
  23. <div class="layui-tab-content">
  24. {volist name="$comment" id="vo"}
  25. <div class="log_top">
  26. <span>{$vo.maker}</span><span
  27. 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>
  28. </div>
  29. <div class="log_content">
  30. <div style="word-wrap:break-word;padding: 5px 10px;width: fit-content;">
  31. {$vo.content}
  32. </div>
  33. {if !empty($vo.thumb)}
  34. <div class="log_content_img" style="width: fit-content;">
  35. <img src="{$vo.thumb}" alt="" class="img-responsive">
  36. <span></span>
  37. </div>
  38. {/if}
  39. </div>
  40. {/volist}
  41. </div>
  42. </div>
  43. <!-- <hr class="ws-space-16" style="border: 1.5px solid #e2e2e2 !important;"> -->
  44. <div class="log_item_bottom" style="border-top: 2px solid #e2e2e2;">
  45. <div class="layui-form log_bottom_left">
  46. <form class="layui-form" action="">
  47. <div class="layui-form-item layui-form-text" style="float: left;width: 95%;">
  48. <label class="layui-form-label">普通文本域</label>
  49. <div class="layui-input-block" style="margin-left: 100px;">
  50. <textarea id="text" name="content" placeholder="请输入内容" maxlength="3000"class="layui-textarea"></textarea>
  51. </div>
  52. <div class="wrapper">
  53. <span></span><span class="total">0/3000字</span>
  54. </div>
  55. </div>
  56. <div class="layui-form-item" style="float: left;width: 4.5%;">
  57. <div class="layui-input-block">
  58. <button type="submit" class="layui-btn" lay-submit lay-filter="webform" type="button"
  59. style="width: 100%;height: 100% !important;background-color: #16baaa00 !important;margin-top: 30%;">
  60. <img src="/static/home/images/allupload.png" height="100"
  61. style="max-width: 40px;height: 40px;"/>
  62. </button>
  63. </div>
  64. </div>
  65. <div style="clear: both;"></div>
  66. <div class="layui-form-item" id="imgItem">
  67. <label class="layui-form-label">上传图片:</label>
  68. <div>
  69. <div class="layui-upload-drag-self">
  70. <div id="uploadBtn2" style="position:relative;">
  71. <img src="/static/home/images/upload.png" height="100"
  72. style="max-width: 100%; width: 100%;"/>
  73. <input type="hidden" name="thumb" value="">
  74. <i class="layui-icon layui-icon-clear" id="imgdel"></i>
  75. </div>
  76. </div>
  77. </div>
  78. <!--//TODO 重载的时候加上comment_type,0:全部,1:财政局to公司,2财政局to业主,3公司to业主-->
  79. <!-- <label class="layui-form-label">通信对象:</label>-->
  80. <!-- <div>-->
  81. <!-- <div class="layui-upload-drag-self">-->
  82. <!-- <div id="uploadBtn3" style="position:relative;">-->
  83. <!-- <select lay-filter="uploadBtn3" name="type">-->
  84. <!-- <option value="0">全部</option>-->
  85. <!-- <option value="1">财政局to公司</option>-->
  86. <!-- <option value="2">财政局to业主</option>-->
  87. <!--<option value="3">公司to业主</option>-->
  88. <!-- </select>-->
  89. <!-- </div>-->
  90. <!-- </div>-->
  91. <!--</div>-->
  92. </div>
  93. </form>
  94. </div>
  95. <div id="outerdiv" style="position:fixed;top:0;left:0;background:rgba(0,0,0,0.7);z-index:2;width:100%;height:100%;display:none;">
  96. <div id="innerdiv" style="position:absolute;">
  97. <img id="bigimg" style="" src="" />
  98. </div>
  99. </div>
  100. </div>
  101. <!--zjl,懂的都懂-->
  102. <script>
  103. function comment() {
  104. console.log(location.href)
  105. var form = layui.form,tool=layui.tool,upload = layui.upload;
  106. //头像上传
  107. var uploadInst = upload.render({
  108. elem: '#uploadBtn2'
  109. , url: '/admin/api/upload'
  110. , done: function (e) {
  111. //如果上传失败
  112. if (e.code == 1) {
  113. return layer.msg('上传失败');
  114. }
  115. //上传成功
  116. $('#uploadBtn2 input').attr('value', e.data.filepath);
  117. $('#uploadBtn2 img').attr('src', e.data.filepath);
  118. $('#imgdel').show();
  119. }
  120. });
  121. $('#imgdel').click(()=>{
  122. $('#uploadBtn2 input').attr('value', '');
  123. $('#uploadBtn2 img').attr('src', '/static/home/images/upload.png');
  124. $('#imgdel').hide();
  125. return false;
  126. })
  127. form.on('select(uploadBtn3)', function (data) {
  128. console.log(data)
  129. $("#comments").load(location.href + " #comments>*", "type=2&comment_type=" + data.value)
  130. return false;
  131. });
  132. let a = 1;
  133. //监听提交
  134. form.on('submit(webform)', function (data) {
  135. if (a) {
  136. console.log(data)
  137. let callback = function (e) {
  138. a = 1
  139. layer.msg(e.msg);
  140. $("#text").val("");
  141. $('#uploadBtn2 input').attr('value', '');
  142. $('#imgdel').hide();
  143. $('#uploadBtn2 img').attr('src', '/static/home/images/upload.png');
  144. //TODO 重载的时候加上comment_type,0:全部,1:财政局to公司,2财政局to业主,3公司to业主
  145. $("#comments").load(location.href + " #comments>*", "type=2&comment_type=" + data.field.type)
  146. }
  147. if (data.field.content === '' && data.field.thumb === '') {
  148. console.log(data.field)
  149. layer.msg("请完善内容");
  150. } else {
  151. data.field["project_id"] = project_id;
  152. tool.post("/admin/project.comment/add", data.field, callback);
  153. }
  154. }
  155. a = 0
  156. return false;
  157. });
  158. }
  159. </script>
  160. <script>
  161. const tx = document.querySelector('#text')
  162. const total = document.querySelector('.total')
  163. tx.addEventListener('input', function () {
  164. total.innerHTML = `${tx.value.length}/3000字`
  165. })
  166. </script>
  167. <!-- 点击放大图片 -->
  168. <script src="{__MOBILE__}/js/jquery.min.js"></script>
  169. <script>
  170. $(function() {
  171. $(".img-responsive").click(function (){
  172. // debugger
  173. var _this=$(this);
  174. imgShow("#outerdiv","#innerdiv","#bigimg",_this);
  175. });
  176. });
  177. function imgShow(outerdiv,innerdiv,bigimg,_this){
  178. // debugger
  179. var src=_this.attr("src");
  180. $(bigimg).attr("src",src);
  181. $("<img/>").attr("src",src).on('load',function () {
  182. // debugger
  183. var windowW=$(window).width()
  184. var windowH=$(window).height();
  185. var realWidth=this.width;
  186. var readHeight=this.height;
  187. var imgWidth,imgHeight;
  188. var scale=0.8;
  189. if(realWidth>windowW+scale){
  190. imgHeight=windowH*scale;
  191. imgWidth=imgHeight/readHeight*realWidth;
  192. if(imgWidth>windowW*scale){
  193. imgWidth=windowW*scale;
  194. }
  195. }else if(realWidth>windowW*scale){
  196. imgWidth=windowW*scale;
  197. imgHeight=imgWidth/realWidth*readHeight;
  198. }else {
  199. imgWidth=realWidth;
  200. imgHeight=readHeight;
  201. }
  202. $(bigimg).css("width",imgWidth);
  203. var w=(windowW-imgWidth)/2;
  204. var h=(windowH-imgHeight)/2;
  205. $(innerdiv).css({"top":h,"left":w});
  206. $(outerdiv).fadeIn("fast");
  207. });
  208. $(outerdiv).click(function (){
  209. $(this).fadeOut("fast");
  210. });
  211. };
  212. </script>