project_comments.html 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  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. <div id="outerdiv"
  44. style="position:fixed;top:0;left:0;background:rgba(0,0,0,0.7);z-index:2;width:100%;height:100%;display:none;">
  45. <div id="innerdiv" style="position:absolute;" >
  46. <img id="bigimg" src=""/>
  47. </div>
  48. <!-- <hr class="ws-space-16" style="border: 1.5px solid #e2e2e2 !important;"> -->
  49. </div>
  50. <!--zjl,懂的都懂-->
  51. <script src="{__JS__}/jquery-3.4.1.min.js"></script>
  52. <script>
  53. function comment() {
  54. var form = layui.form, tool = layui.tool, upload = layui.upload;
  55. //头像上传
  56. var uploadInst = upload.render({
  57. elem: '#uploadBtn'
  58. , url: '/admin/api/upload'
  59. , done: function (e) {
  60. //如果上传失败
  61. if (e.code == 1) {
  62. return layer.msg('上传失败');
  63. }
  64. //上传成功
  65. $('#uploadBtn input').attr('value', e.data.filepath);
  66. $('#uploadBtn img').attr('src', e.data.filepath);
  67. $('#imgdel').show();
  68. }
  69. });
  70. $('#imgdel').click(() => {
  71. $('#uploadBtn input').attr('value', '');
  72. $('#uploadBtn img').attr('src', '/static/home/images/upload.png');
  73. $('#imgdel').hide();
  74. return false;
  75. })
  76. $('#uploadBtn').click(() => {
  77. console.log(1)
  78. return false;
  79. })
  80. //监听提交
  81. form.on('submit(webform)', function (data) {
  82. let callback = function (e) {
  83. layer.msg(e.msg);
  84. $("#text").val("");
  85. $('#uploadBtn input').attr('value', '');
  86. $('#imgdel').hide();
  87. $('#uploadBtn img').attr('src', '/static/home/images/upload.png');
  88. $("#comments").load(location.href + " #comments>*", "type=2");
  89. }
  90. if (data.field.content === '' && data.field.thumb === '') {
  91. console.log(data.field)
  92. layer.msg("请完善内容");
  93. } else {
  94. data.field["project_id"] = project_id;
  95. tool.post("/admin/project.comment/add", data.field, callback);
  96. }
  97. return false;
  98. });
  99. }
  100. </script>
  101. <!-- 点击放大图片 -->
  102. <script src="{__MOBILE__}/js/jquery.min.js"></script>
  103. <script>
  104. $(function () {
  105. $(".img-responsive").click(function () {
  106. // debugger
  107. var _this = $(this);
  108. imgShow("#outerdiv", "#innerdiv", "#bigimg", _this);
  109. });
  110. });
  111. function imgShow(outerdiv, innerdiv, bigimg, _this) {
  112. // debugger
  113. var src = _this.attr("src");
  114. $(bigimg).attr("src", src);
  115. $("<img/>").attr("src", src).on('load', function () {
  116. // debugger
  117. var windowW = $(window).width()
  118. var windowH = $(window).height();
  119. var realWidth = this.width;
  120. var readHeight = this.height;
  121. var imgWidth, imgHeight;
  122. var scale = 0.8;
  123. if (realWidth > windowW + scale) {
  124. imgHeight = windowH * scale;
  125. imgWidth = imgHeight / readHeight * realWidth;
  126. if (imgWidth > windowW * scale) {
  127. imgWidth = windowW * scale;
  128. }
  129. } else if (realWidth > windowW * scale) {
  130. imgWidth = windowW * scale;
  131. imgHeight = imgWidth / realWidth * readHeight;
  132. } else {
  133. imgWidth = realWidth;
  134. imgHeight = readHeight;
  135. }
  136. $(bigimg).css("width", imgWidth);
  137. var w = (windowW - imgWidth) / 2;
  138. var h = (windowH - imgHeight) / 2;
  139. $(innerdiv).css({"top": h, "left": w});
  140. $(outerdiv).fadeIn("fast");
  141. });
  142. $(outerdiv).click(function () {
  143. $(this).fadeOut("fast");
  144. });
  145. };
  146. </script>