123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225 |
- var page =1; //页数
- var maxPage =1; //最大页数
- var loadingFlag = false;
- var id = '';//帖子id
- var view_num = '';//帖子浏览数
- var comment_con = '';//评论内容
- var title = '';//标题
- var qs = parseQueryString(window.location.href);
- $().ready(function() {
-
- if(qs.id){
- id = qs.id ;
- }
- if(qs.view_num){
- view_num = qs.view_num ;
- }
- if(qs.title) {
- title = qs.title;
- }
- document.title = title;
-
- // login(); //登录获取权限
-
- getBurstDetailsData(id,view_num); //获取下款爆料详情数据
-
- //点击触发弹窗
- $('.comment_input .in_input').click(function(){
- $('.shareMask').css("display",'block');
- isScrollFalse(); //触发弹窗的时候禁止页面滚动
- })
- //点击关闭弹窗
- $('.comment_back').click(function(){
- $('.shareMask').css("display",'none');
- comment_con = $('.comment_c').val('');
- isScrollTure(); //关闭弹框时开启页面滚动
- })
-
-
- makeExpandingArea(textarea); //textarea高度跟随文字高度而变化
-
- //点击发布
- $('.publish').click(function(){
- comment_con = $('.comment_c').val();
- if(comment_con == ''){
- showMsg('说点啥吧~')
- return;
- }
- releaseComment(id,comment_con)
- })
- })
- //获取地址栏参数
- function parseQueryString(url) {
- var urlObj = {};
- var reg = /([^?=&]+)=([^?=&]+)/g;
- url.replace(reg, ($0, $1, $2) => {
- urlObj[$1] = decodeURIComponent($2);
- })
- return urlObj;
- }
- //登录获取权限
- function login(){
- $.ajax({
- type: "post",
- url: "/user/user/login",
- data:{
- phone : '13612345678',
- password : '123456'
- },
- success:function(res){
- // console.log(res)
- },
- error:function(err){
- console.log(err)
- }
- })
- }
- //获取下款爆料详情数据
- function getBurstDetailsData(id,view_num){
- $.ajax({
- type: "post",
- url: "/user/huaJiangHu/postDetail",
- data:{
- id : id,
- view_num : view_num
- },
- // headers:{
- // Cookie:'aaaaaaaaaaaaaaa'
- // },
- success:function(res){
- if(res.rst){
- var data = res.rst;
- //帖子详情
- if(res.errno == 0){
- var detail = data.detail ;
- }else if(res.errno == 60001){
- var detail = data;
- }
- var detailsTopHtml ='';
- var touxiang = '' ;
- if(detail.user_img != ''){ touxiang = '<img src='+ detail.user_img +' class="touxiangimg"/>' ; }
- if(detail.user_img == ''){ touxiang = '<img src="imgs/moren.png" class="touxiangimg"/>' ; }
- 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>'
-
- //是否是马甲发布的帖子
- var vestConHtml = '';
- if(detail.is_vest == 1){
- 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>'
- }else if(detail.is_vest == 0){
- vestConHtml = '';
- }
- //评论内容
- if(res.errno == 0){
- var comment = data.comment;
- var comment_touxiang = '';
- var commentListHtml = '' ;
- comment.forEach(function(item,index){
- if(item.user_img != ''){ item_touxiang = '<img src='+ item.user_img +' class="tou_img"/>' ; }
- if(item.user_img == '' || item.user_img == null){ item_touxiang = '<img src="imgs/moren.png" class="tou_img"/>' ; }
- 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>'
- })
- }else if(res.errno == "60001"){
- $('.all').hide()
- }
-
- }
- $('.details_top').html(detailsTopHtml); //帖子详情
- $('.details_bottom').html(vestConHtml); //是否是马甲发布的帖子
- $('.comment_listCon').html(commentListHtml); //评论内容
- },
- error:function(err){
- console.log(err)
- }
- })
- }
- function bodyScroll(event){
- event.preventDefault();
- }
- //触发弹窗的时候禁止页面滚动
- function isScrollFalse(){
- document.body.addEventListener('touchmove',bodyScroll,false);
- $('body').css({'position':'fixed',"width":"100%"});
- }
- //关闭弹窗的时候开启页面滚动
- function isScrollTure(){
- document.body.removeEventListener('touchmove',bodyScroll,false);
- $("body").css({"position":"initial","height":"auto"});
- }
- //textarea高度跟随文字高度而变化
- function makeExpandingArea(el) {
- var setStyle = function(el) {
- el.style.height = 'auto';
- el.style.height = el.scrollHeight + 'px';
- // console.log(el.scrollHeight);
- }
- var delayedResize = function(el) {
- window.setTimeout(function() {
- setStyle(el)
- },
- 0);
- }
- if (el.addEventListener) {
- el.addEventListener('input',function() {
- setStyle(el)
- },false);
- setStyle(el)
- } else if (el.attachEvent) {
- el.attachEvent('onpropertychange',function() {
- setStyle(el)
- });
- setStyle(el)
- }
- if (window.VBArray && window.addEventListener) { //IE9
- el.attachEvent("onkeydown",function() {
- var key = window.event.keyCode;
- if (key == 8 || key == 46) delayedResize(el);
- });
- el.attachEvent("oncut",function() {
- delayedResize(el);
- }); //处理粘贴
- }
- }
- //发布评论
- function releaseComment(id,comment_con){
- $.ajax({
- type: "post",
- url: "/user/huaJiangHu/addComment",
- data:{
- id : id,
- comment : comment_con
- },
- success:function(res){
- if(res.errno == "0" && res.rst){
- showMsg('评论成功已提交后台审核')
- $('.shareMask').css('display','none')//弹框关闭
- $('.comment_c').val(''); //评论框的值清空
- isScrollTure(); //关闭弹框时开启页面滚动
- }else{
- showMsg('评论失败')
- }
- },
- error:function(err){
- console.log(err)
- }
- })
- }
- //提示信息
- function showMsg(msg) {
- var msg = msg;
- var msgBox = $('.alert-info');
- msgBox.children('p').text(msg);
- msgBox.show();
- setTimeout(function() {
- msgBox.hide();
- }, 2000);
- }
|