Files
youfang-app/fangija-zsyf/views/news/newsDetail.html
T
gaojuan 4be96e6adc Merge branch 'YOUFANGAPP1.1' of 192.168.0.27:dev0/youfang-app into YOUFANGAPP1.1
Conflicts:
	fangija-zsyf/config.js
	fangija-zsyf/manifest.json
	fangija-zsyf/views/news/newsDetail.html
2018-03-27 13:56:28 +08:00

370 lines
10 KiB
HTML

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title id="title2"></title>
<meta name="viewport" content="initial-scale=1, maximum-scale=1">
<link rel="shortcut icon" href="/favicon.ico">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<link rel="stylesheet" href="../../css/sm.css">
<link rel="stylesheet" href="../../css/main.css">
<link rel="stylesheet" href="../../css/theme-blue.css">
<link rel="stylesheet" href="../../css/mui.min.css">
</head>
<body>
<div class="page-group">
<div class="page page-current">
<header class="bar bar-nav">
<button class="button button-link button-nav pull-left" onclick="back(),plus.nativeUI.closeWaiting();">
<span class="mui-icon mui-icon mui-icon-arrowleft"></span>
</button>
<button class="button button-link button-nav pull-right open-popover" onclick="shareHref()">
<span class="icon icon-path"></span>
</button>
<h1 class="title"></h1>
</header>
<div class="content contentText infinite-scroll infinite-scroll-bottom" data-distance="40">
<div class="content-padded">
<h1 id="title"></h1>
<p><small id="source"></small><small style="float:right;" id="visit_count"><i class="icon icon-eye"></i></small><br><small id="create_time"></small></p>
<div id="content">
</div>
</div>
<div class="newCss">
<ul>
<li><span>房贷</span></li>
<li><span>广州</span></li>
<li><span>首套房</span></li>
</ul>
</div>
<div class="adBoxApp">
<img src="../../images/wx_app.png">
<p><label>有房&nbsp;&nbsp;有家&nbsp;&nbsp;有爱</label><br><small>更多房产资讯上有房APP</small></p>
</div>
<div class="list-block media-list commentList">
<ul>
</ul>
</div>
<!-- 加载提示符 -->
<div class="infinite-scroll-preloader" style="position: relative;top: -70px;">
<div class="preloader"></div>
</div>
</div>
<div class="bar commentInput">
<div class="searchbar row">
<div class="search-input col-66">
<label class="icon icon-comments" for="search"></label>
<input type="text" placeholder="我也说两句">
</div>
<span class="col-33">
<a class="praise"><i class="icon icon-praise-grey02"></i><label id="newsPraise"></label></a>
<a class="collection collection01"><i class="icon icon-collection01"></i></a>
<a class="collection collection02 dn"><i class="icon icon-collection02"></i></a>
</span>
</div>
</div>
</div>
</div>
</div>
<script type="text/javascript" src="../../js/zepto.js" charset="utf-8"></script>
<script>
/* 关闭路由,以实现不同页面之间的相互跳转(仅开发环境需要) */
Zepto = $
$.config = {router: false}
</script>
<script type="text/javascript" src="../../js/beacon_release.js"></script>
<script type="text/javascript" src="../../js/light7.js" charset="utf-8"></script>
<script type="text/javascript" src="../../js/cn.js" charset="utf-8"></script>
<script src="../../config.js"></script>
<script type="text/javascript" src="../../js/common.js" ></script>
<script type="text/javascript" src="../../js/axios.min.js"></script>
<script type="text/javascript" src="../../js/shara/sharaMine.js" ></script>
<script>
document.addEventListener('plusready', onPlusReady, false);
var id = "183627425584775168";
var shareUrl = BASE_PATH+"/news/newDetail?newsId=";
var sharehrefTitle = "停车坐爱枫林晚,霜叶红于二月花";
var sharehrefDes = "客观里面请!";
var shareId='';
function onPlusReady() {
var self = plus.webview.currentWebview();
id = self.newsId;
shareId = id
shareUrl = shareUrl+id
$.ajax({
type : 'get',
url : BASE_PATH + "/rest/news/detail",
data:{newsId:id},
dataType:'json',
async:false,
success:function(result){
if(result.code==200){
data = result.data
$("#title").text(data.title)
$("#title2").text(data.title)
$("#source").text(data.source==null?"":"来源:"+data.source)
$("#visit_count").append(data.visitCount)
var date = new Date(data.deployTime)
var dateStr = date.getFullYear() + '-' + (date.getMonth() + 1) + '-' + date.getDate()
$("#create_time").text(dateStr)
$("#content").html(data.content)
$("#newsPraise").text(data.thumbsUpCount);
//预先加载20条
sharehrefTitle = data.title
sharehrefDes = data.introduction
}
},
error:function(){
}
})
updateSerivces();
}
//新闻评论列表
$.init()
//加载flag
var loading = false;
//最多可加载的条目
var maxItems = 100;
//上次加载的序号
var lastIndex = 0;
//每次加载添加多少条目
var itemsPerLoad = 10;
var url = BASE_PATH + "/rest/news/comment"
var curpage = 1;
var totalCount = 0;
var curPageSize = 0;
function addItems(number, lastIndex) {
if(!id){
return;
}
curpage = lastIndex/itemsPerLoad + 1;
axios.get(url, {
params: {
newsId: id,
page:curpage,
pageSize:itemsPerLoad
}
})
.then(function (response) {
var results = response.data.data
if(results==null || results.length==0) {
// 加载完毕,则注销无限加载事件,以防不必要的加载
$.detachInfiniteScroll($('.infinite-scroll'));
// 删除加载提示符
$('.infinite-scroll-preloader').remove();
$('.infinite-scroll-bottom').html("");
return;
}
curPageSize = results.length;
// 生成新条目的HTML
var html = '';
for(var i in results){
var vo = results[i];
html = html+"<li>"+
"<a class='item-content'>";
if(vo.headImg!=null){
html = html + "<div class='item-media'><img src='"+vo.headImg+"'></div>";
}else{
html = html + "<div class='item-media'><img src='../../images/headPortrait.png'></div>";
}
html = html + "<div class='item-inner'>";
var name = "游客"
if(vo.wxName){
name = vo.wxName
}else if(vo.name){
name = vo.name
}
html = html + "<div class='item-title-row'>"+
"<div class='item-title'>"+name+"</div>"+
"<div class='item-after'><span><i class='icon icon-praise-grey01'></i>"+vo.praiseCount+"</span></div>"+
"</div>"+
"<div class='item-title-row'>";
var address = "";
if(vo.commentUserProvince && vo.commentUserCity && vo.commentUserProvince == vo.commentUserCity){
html = html + "<div class='item-title'><span>"+vo.commentUserCity+" </span></div>";
}else{
html = html + "<div class='item-title'><span>"+vo.commentUserProvince+vo.commentUserCity+" </span></div>";
}
var curTime = new Date().getTime()
var publishTime = vo.addTime;
var timeString = getDateDiff(curTime, publishTime)
html = html + "<div class='item-after'><span>"+timeString+"</span></div>"+
"</div>"+
"<div class='item-text'>"+vo.content+"</div>"+
"</div>"+
"</a>"+
"</li>";
}
// 添加新条目
$('.commentList ul').append(html);
if($('.commentList li').length== totalCount+1){
// 加载完毕,则注销无限加载事件,以防不必要的加载
$.detachInfiniteScroll($('.infinite-scroll'));
// 删除加载提示符
$('.infinite-scroll-preloader').hide();
}
})
.catch(function (error) {
console.log(error);
});
}
addItems(itemsPerLoad, 0);
//注册'infinite'事件处理函数
$(document).on('infinite', '.infinite-scroll-bottom',function() {
// 如果正在加载,则退出
if (loading) return;
// 设置flag
loading = true;
// 模拟1s的加载过程
setTimeout(function() {
// 重置加载flag
loading = false;
// 更新最后加载的序号
lastIndex = $('.commentList li').length;
if (curPageSize < itemsPerLoad) {
// 加载完毕,则注销无限加载事件,以防不必要的加载
$.detachInfiniteScroll($('.infinite-scroll'));
// 删除加载提示符
$('.infinite-scroll-preloader').hide();
return;
}
// 添加新条目
addItems(itemsPerLoad, $('.commentList li').length);
//容器发生改变,如果是js滚动,需要刷新滚动
// $.refreshScroller();
}, 1000);
});
var MINU_SEC = 60;
var HOUR_SEC = 3600;
var DAY_SEC = HOUR_SEC * 24;
var MONTH_SEC = DAY_SEC * 30;
var YEAR_SEC = MONTH_SEC * 12;
function getDateDiff(curTime, publishTime){
if (publishTime <= curTime) {
var diffSec = (curTime - publishTime) / 1000;
if (diffSec < DAY_SEC) {
if (diffSec >= HOUR_SEC) {
var t = diffSec / HOUR_SEC;
return parseInt(t) + "小时前";
} else if (diffSec >= MINU_SEC) {
var t = diffSec / MINU_SEC;
return parseInt(t) + "分钟前";
} else {
return "刚刚";
}
} else if (DAY_SEC > diffSec && diffSec < DAY_SEC*2) {
return "昨天";
} else {
var date = new Date(publishTime)
var dateStr = date.getFullYear() + '-' + (date.getMonth() + 1) + '-' + date.getDate()
return dateStr;
}
} else {
return "刚刚";// 输入时间大于 系统时间 返回 "刚刚"
}
}
//添加评论
//点赞
$(".icon-praise-grey02").click(function(){
axios.get(BASE_PATH+"/rest/news/thumbsUp", {
params: {
newsId : id
}
})
.then(function (response) {
var msg = response.data.data
$.toast(msg);
})
.catch(function (error) {
console.log(error);
});
});
//收藏
$(".collection01").on("click", function () {
$(".collection01").hide();
$(".collection02").show();
collect();
});
$(".collection02").on("click", function () {
$(".collection02").hide();
$(".collection01").show();
collect();
});
function collect(){
//var params = new URLSearchParams();
//params.append('newsId', id);
axios.post(BASE_PATH+"/rest/news/collect", {
params: {
newsId : id
}
})
.then(function (response) {
var msg = response.data.data
$.toast(msg);
})
.catch(function (error) {
console.log(error);
});
}
</script>
</body>
</html>