project_log.html 4.6 KB

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