Няма описание

burst_details.js 6.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  1. var page =1; //页数
  2. var maxPage =1; //最大页数
  3. var loadingFlag = false;
  4. var id = '';//帖子id
  5. var view_num = '';//帖子浏览数
  6. var comment_con = '';//评论内容
  7. var title = '';//标题
  8. var qs = parseQueryString(window.location.href);
  9. $().ready(function() {
  10. if(qs.id){
  11. id = qs.id ;
  12. }
  13. if(qs.view_num){
  14. view_num = qs.view_num ;
  15. }
  16. if(qs.title) {
  17. title = qs.title;
  18. }
  19. document.title = title;
  20. // login(); //登录获取权限
  21. getBurstDetailsData(id,view_num); //获取下款爆料详情数据
  22. //点击触发弹窗
  23. $('.comment_input .in_input').click(function(){
  24. $('.shareMask').css("display",'block');
  25. isScrollFalse(); //触发弹窗的时候禁止页面滚动
  26. })
  27. //点击关闭弹窗
  28. $('.comment_back').click(function(){
  29. $('.shareMask').css("display",'none');
  30. comment_con = $('.comment_c').val('');
  31. isScrollTure(); //关闭弹框时开启页面滚动
  32. })
  33. makeExpandingArea(textarea); //textarea高度跟随文字高度而变化
  34. //点击发布
  35. $('.publish').click(function(){
  36. comment_con = $('.comment_c').val();
  37. if(comment_con == ''){
  38. showMsg('说点啥吧~')
  39. return;
  40. }
  41. releaseComment(id,comment_con)
  42. })
  43. })
  44. //获取地址栏参数
  45. function parseQueryString(url) {
  46. var urlObj = {};
  47. var reg = /([^?=&]+)=([^?=&]+)/g;
  48. url.replace(reg, ($0, $1, $2) => {
  49. urlObj[$1] = decodeURIComponent($2);
  50. })
  51. return urlObj;
  52. }
  53. //登录获取权限
  54. function login(){
  55. $.ajax({
  56. type: "post",
  57. url: "/user/user/login",
  58. data:{
  59. phone : '13612345678',
  60. password : '123456'
  61. },
  62. success:function(res){
  63. // console.log(res)
  64. },
  65. error:function(err){
  66. console.log(err)
  67. }
  68. })
  69. }
  70. //获取下款爆料详情数据
  71. function getBurstDetailsData(id,view_num){
  72. $.ajax({
  73. type: "post",
  74. url: "/user/huaJiangHu/postDetail",
  75. data:{
  76. id : id,
  77. view_num : view_num
  78. },
  79. // headers:{
  80. // Cookie:'aaaaaaaaaaaaaaa'
  81. // },
  82. success:function(res){
  83. if(res.rst){
  84. var data = res.rst;
  85. //帖子详情
  86. if(res.errno == 0){
  87. var detail = data.detail ;
  88. }else if(res.errno == 60001){
  89. var detail = data;
  90. }
  91. var detailsTopHtml ='';
  92. var touxiang = '' ;
  93. if(detail.user_img != ''){ touxiang = '<img src='+ detail.user_img +' class="touxiangimg"/>' ; }
  94. if(detail.user_img == ''){ touxiang = '<img src="imgs/moren.png" class="touxiangimg"/>' ; }
  95. detailsTopHtml += '<p class="details_title">'+ detail.title +'</p> <div class="details_userinfo"><div class="left">'+ touxiang +'<span class="tel">'+ detail.user_phone +'</span><span class="time">'+ detail.create_time +'</span></div><div class="right"> <img src="imgs/look.png" class="look"/><span>'+ detail.view_num +'</span></div></div><div class="details_content">'+ detail.content +'</div>'
  96. //是否是马甲发布的帖子
  97. var vestConHtml = '';
  98. if(detail.is_vest == 1){
  99. vestConHtml +='<p class="details_class">产品:'+ detail.product +'</p><p class="details_class">入口:'+ detail.entrance +'</p><p class="details_class">申请时间:'+ detail.apply_time +'</p><p class="details_class">下款时间:'+ detail.exhausting_time +' </p><p class="details_class">到账金额:'+ detail.arrival_amount +'元</p><p class="details_class">借款期限:'+ detail.deadline +'</p><p class="details_tip_one">**以上信息来源于用户成功下款后分享**</p><p class="details_tip_two">本帖为作者发布,不代表平台立场,转帖需标明出处。</p><div class="form"><span class="form_left">发布于:</span><span class="form_right">下款爆料</span></div>'
  100. }else if(detail.is_vest == 0){
  101. vestConHtml = '';
  102. }
  103. //评论内容
  104. if(res.errno == 0){
  105. var comment = data.comment;
  106. var comment_touxiang = '';
  107. var commentListHtml = '' ;
  108. comment.forEach(function(item,index){
  109. if(item.user_img != ''){ item_touxiang = '<img src='+ item.user_img +' class="tou_img"/>' ; }
  110. if(item.user_img == '' || item.user_img == null){ item_touxiang = '<img src="imgs/moren.png" class="tou_img"/>' ; }
  111. commentListHtml += '<div class="comment_list">'+ item_touxiang +'<div class="comment_content"><div class="top"><span class="tel">'+ item.user_phone +'</span></div><p class="comment_message">'+ item.comment +'</p><div class="reply"><div class="comment_time">'+ item.create_time +'</div></div></div></div>'
  112. })
  113. }else if(res.errno == "60001"){
  114. $('.all').hide()
  115. }
  116. }
  117. $('.details_top').html(detailsTopHtml); //帖子详情
  118. $('.details_bottom').html(vestConHtml); //是否是马甲发布的帖子
  119. $('.comment_listCon').html(commentListHtml); //评论内容
  120. },
  121. error:function(err){
  122. console.log(err)
  123. }
  124. })
  125. }
  126. function bodyScroll(event){
  127. event.preventDefault();
  128. }
  129. //触发弹窗的时候禁止页面滚动
  130. function isScrollFalse(){
  131. document.body.addEventListener('touchmove',bodyScroll,false);
  132. $('body').css({'position':'fixed',"width":"100%"});
  133. }
  134. //关闭弹窗的时候开启页面滚动
  135. function isScrollTure(){
  136. document.body.removeEventListener('touchmove',bodyScroll,false);
  137. $("body").css({"position":"initial","height":"auto"});
  138. }
  139. //textarea高度跟随文字高度而变化
  140. function makeExpandingArea(el) {
  141. var setStyle = function(el) {
  142. el.style.height = 'auto';
  143. el.style.height = el.scrollHeight + 'px';
  144. // console.log(el.scrollHeight);
  145. }
  146. var delayedResize = function(el) {
  147. window.setTimeout(function() {
  148. setStyle(el)
  149. },
  150. 0);
  151. }
  152. if (el.addEventListener) {
  153. el.addEventListener('input',function() {
  154. setStyle(el)
  155. },false);
  156. setStyle(el)
  157. } else if (el.attachEvent) {
  158. el.attachEvent('onpropertychange',function() {
  159. setStyle(el)
  160. });
  161. setStyle(el)
  162. }
  163. if (window.VBArray && window.addEventListener) { //IE9
  164. el.attachEvent("onkeydown",function() {
  165. var key = window.event.keyCode;
  166. if (key == 8 || key == 46) delayedResize(el);
  167. });
  168. el.attachEvent("oncut",function() {
  169. delayedResize(el);
  170. }); //处理粘贴
  171. }
  172. }
  173. //发布评论
  174. function releaseComment(id,comment_con){
  175. $.ajax({
  176. type: "post",
  177. url: "/user/huaJiangHu/addComment",
  178. data:{
  179. id : id,
  180. comment : comment_con
  181. },
  182. success:function(res){
  183. if(res.errno == "0" && res.rst){
  184. showMsg('评论成功已提交后台审核')
  185. $('.shareMask').css('display','none')//弹框关闭
  186. $('.comment_c').val(''); //评论框的值清空
  187. isScrollTure(); //关闭弹框时开启页面滚动
  188. }else{
  189. showMsg('评论失败')
  190. }
  191. },
  192. error:function(err){
  193. console.log(err)
  194. }
  195. })
  196. }
  197. //提示信息
  198. function showMsg(msg) {
  199. var msg = msg;
  200. var msgBox = $('.alert-info');
  201. msgBox.children('p').text(msg);
  202. msgBox.show();
  203. setTimeout(function() {
  204. msgBox.hide();
  205. }, 2000);
  206. }