提交 6505fc0e 编写于 作者: ijianbo's avatar ijianbo

修复评论偶尔无法提交的问题

上级 3efc8b91
......@@ -128,7 +128,7 @@ Page({
var postLikeRequest = wxRequest.postRequest(url, data);
postLikeRequest
.then(response => {
if (response.data.status == '201') {
if (response.data.status == '200') {
var _likeList = []
var _like = { "avatarurl": app.globalData.userInfo.avatarUrl, "openid": app.globalData.openid }
......@@ -184,7 +184,7 @@ Page({
var postIsLikeRequest = wxRequest.postRequest(url, data);
postIsLikeRequest
.then(response => {
if (response.data.status == '201') {
if (response.data.status == '200') {
self.setData({
likeImag: "like-on.png"
});
......@@ -251,6 +251,22 @@ Page({
});
// 调用API从本地缓存中获取阅读记录并记录
var logs = wx.getStorageSync('readLogs') || [];
// 过滤重复值
if (logs.length > 0) {
logs = logs.filter(function (log) {
return log[0] !== id;
});
}
// 如果超过指定数量
if (logs.length > 19) {
logs.pop();//去除最后一个
}
logs.unshift([id, response.data.title.rendered]);
wx.setStorageSync('readLogs', logs);
//end
})
.then(response => {
wx.setNavigationBarTitle({
......@@ -548,11 +564,11 @@ Page({
parent: parent,
openid: openid
};
var url = Api.postComment();
var url = Api.postWeixinComment();
var postCommentRequest = wxRequest.postRequest(url, data);
postCommentRequest
.then(res => {
if (res.statusCode == 201 || res.statusCode == 200) {
if (res.statusCode == 200 ) {
self.setData({
content: '',
parent: "0",
......@@ -562,6 +578,7 @@ Page({
ChildrenCommentsList: []
});
// console.log(res.data.code);
self.fetchCommentData(self.data, '1');
}
else {
......@@ -583,7 +600,7 @@ Page({
});
}
else {
console.log(res)
console.log(res.data.code)
self.setData({
'dialog.hidden': false,
'dialog.title': '提示',
......
......@@ -57,7 +57,6 @@ Page({
})
},
onShareAppMessage: function () {
var title = "分享“"+ config.getWebsiteName +"”的热点文章。";
var path ="pages/hot/hot";
return {
......@@ -73,8 +72,7 @@ Page({
},
reload:function(e)
{
var self = this;
var self = this;
self.fetchPostsData(self.data);
},
......@@ -119,17 +117,12 @@ Page({
mask:true
});
var getTopHotPostsRequest = wxRequest.getRequest(Api.getTopHotPosts(tab));
getTopHotPostsRequest.then(response =>{
if (response.statusCode === 201) {
if (response.statusCode === 200) {
self.setData({
showallDisplay: "block",
postsList: self.data.postsList.concat(response.data.map(function (item) {
var strdate = item.post_date
if (item.post_thumbnail_image == null || item.post_thumbnail_image == '') {
item.post_thumbnail_image = '../../images/watch-life-logo-128.jpg';
}
......@@ -139,7 +132,6 @@ Page({
});
} else if (response.statusCode === 404) {
wx.showModal({
title: '加载失败',
......
......@@ -7,7 +7,7 @@
"minified": true
},
"compileType": "weapp",
"libVersion": "1.5.4",
"libVersion": "1.6.0",
"appid": "wx39075d0bde24f9f7",
"projectname": "%22%E5%AE%88%E6%9C%9B%E8%BD%A9%22%E7%BD%91%E7%AB%99%E5%B0%8F%E7%A8%8B%E5%BA%8F",
"miniprogramRoot": "./",
......
......@@ -40,7 +40,7 @@ module.exports = {
var postOpenidRequest = wxRequest.postRequest(url, data);
//获取openid
postOpenidRequest.then(response => {
if (response.data.status == '201') {
if (response.data.status == '200') {
//console.log(response.data.openid)
console.log("openid 获取成功");
app.globalData.openid = response.data.openid;
......@@ -55,6 +55,8 @@ module.exports = {
// .then(response => {
// self.getIslike();
// })
}).catch(function (error) {
console.log('error: ' + error.errMsg);
})
}
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册