This commit is contained in:
2018-03-27 18:44:23 +08:00
parent 65efb9c9fe
commit b7cf34af9b
3 changed files with 129 additions and 17 deletions
+2
View File
@@ -539,6 +539,8 @@ input::-webkit-input-placeholder{
.icon-praise-grey01{width:14px;height:14px;background:url(../images/icon-praise-grey01.png) no-repeat center center;background-size:100%;margin-right:0.3rem;vertical-align:baseline;}
.icon-praise-grey02{width:16px;height:16px;background:url(../images/icon-praise-grey02.png) no-repeat center center;background-size:100%;margin-right:0.3rem;vertical-align:text-bottom;}
.icon-praise-orange01{width:14px;height:14px;background:url(../images/icon-praise-orange.png) no-repeat center center;background-size:100%;margin-right:0.3rem;vertical-align:baseline;}
.icon-praise-orange02{width:16px;height:16px;background:url(../images/icon-praise-orange.png) no-repeat center center;background-size:100%;margin-right:0.3rem;vertical-align:text-bottom;}
.commentInput .icon-collection01{display:inline-block;vertical-align:text-bottom;margin:0;}
.commentInput .icon-collection02{display:inline-block;vertical-align:text-bottom;margin:0;}
Binary file not shown.

After

Width:  |  Height:  |  Size: 749 B

+127 -17
View File
@@ -77,7 +77,7 @@
<div class="search-input col-85">
<input type="text">
</div>
<a class="col-15">发布</a>
<a class="col-15" id="publishBtn">发布</a>
</div>
</div>
@@ -103,6 +103,7 @@ $.config = {router: false}
<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/axiosPlugin.js"></script>
<script type="text/javascript" src="../../js/shara/sharaMine.js" ></script>
<script>
@@ -112,7 +113,10 @@ var shareUrl = BASE_PATH+"/news/newDetail?newsId=";
var sharehrefTitle = "停车坐爱枫林晚,霜叶红于二月花";
var sharehrefDes = "客观里面请!";
var shareId='';
var province;
var city;
var region;
function onPlusReady() {
var self = plus.webview.currentWebview();
id = self.newsId;
@@ -141,14 +145,55 @@ function onPlusReady() {
sharehrefTitle = data.title
sharehrefDes = data.introduction
}
},
error:function(){
}
})
getPosition();
updateSerivces();
//isCollect();
}
isCollect();
function isCollect(){
axios.post("/rest/news/checkCollect",{newsId : id}).then(function (response) {
var msg = response.data.data
if(msg){
$(".collection").addClass("collection02")
$(".collection i").addClass("icon-collection02")
$(".collection").removeClass("collection01")
$(".collection i").removeClass("icon-collection01")
}
})
.catch(function (error) {
console.log(error);
});
}
// 获取当前用户位置
function getPosition(){
plus.geolocation.getCurrentPosition(function(p){
province = p.address.province;
city = p.address.city;
region = p.address.district;
}, function(e){
},
{
provider:'baidu',
enableHighAccuracy:true,
coordsType:'bd09ll'
}
);
}
//新闻评论列表
$.init()
@@ -163,7 +208,7 @@ var lastIndex = 0;
//每次加载添加多少条目
var itemsPerLoad = 10;
var url = BASE_PATH + "/rest/news/comment"
var url = "/rest/news/comment"
var curpage = 1;
var totalCount = 0;
@@ -218,14 +263,19 @@ function addItems(number, lastIndex) {
}
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 class='item-after'><span data-cid='"+vo.id+"'><i class='icon icon-praise-grey01'></i><label>"+vo.praiseCount+"</label></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>";
if(vo.commentUserProvince && vo.commentUserCity){
html = html + "<div class='item-title'><span>"+vo.commentUserProvince+vo.commentUserCity+" </span></div>";
}else{
html = html + "<div class='item-title'><span> </span></div>";
}
}
var curTime = new Date().getTime()
@@ -327,31 +377,71 @@ function getDateDiff(curTime, publishTime){
//添加评论
//点赞
$(".icon-praise-grey02").click(function(){
console.log(JSON.stringify({newsId : id}));
axios.get(BASE_PATH+"/rest/news/thumbsUp", {
data:JSON.stringify({newsId : id})
})
.then(function (response) {
/* 评论点赞 */
$("body").delegate(".commentList span", "click", function () {
$(this).find(".icon").addClass("icon-praise-orange01");
var cid = $(this).attr("data-cid")
$(this).attr("disabled","disabled");
var text = $(this).find("label").text();
axios.get("/rest/comment/thumbsUp", {
params: {
commentId:cid
}
}).then(function (response) {
var msg = response.data.data
$.toast(msg);
if(msg && msg =="点赞成功"){
$("span[data-cid='"+cid+"']").find("label").text(parseInt(text) + 1);
$.toast(msg);
}else{
msg = response.data.message
if(msg){
$.toast(msg);
}
}
})
.catch(function (error) {
console.log(error);
});
});
/*新闻点赞*/
$(".praise").one("click", function () {
$(this).find(".icon").addClass("icon-praise-orange02");
$(this).attr("disabled","disabled");
var text = $(this).find("font").text();
axios.get("/rest/news/thumbsUp", {
params: {
newsId:id
}
}).then(function (response) {
var msg = response.data.data
if(msg && msg =="点赞成功"){
$(this).find("font").text(parseInt(text) + 1);
$.toast(msg);
}else{
msg = response.data.message
if(msg){
$.toast(msg);
}
}
})
.catch(function (error) {
console.log(error);
});
});
//收藏
$(".collection").on("click", function () {
collect();
});
function collect(){
axios.post(BASE_PATH+"/rest/news/collect",
JSON.stringify({newsId : id}),{headers: {"Content-Type": "application/json"}}
)
.then(function (response) {
axios.post("/rest/news/collect",{newsId : id}).then(function (response) {
var msg = response.data.data
if(msg == "收藏成功"){
$(".collection").addClass("collection02")
@@ -382,7 +472,27 @@ $(".commentInputBox input").focus(function () {
$(".commentReleaseBox a").on("click", function () {
$(".commentReleaseBox").hide();
$(".commentInputBox").show();
var content = $(".commentReleaseBox input").val();
if(content){
addComment();
}
});
function addComment(){
var content = $(".commentReleaseBox input").val();
axios.post("/rest/comment/add",{commentObjId : id, content:content, commentUserProvince:province, commentUserCity:city}).then(function (response) {
var msg = response.data.message
if(msg){
$.toast(msg);
}else{
window.location.reload();
}
})
.catch(function (error) {
console.log(error);
});
}
</script>
</body>