mirror of
https://github.com/rumosky/mp-Blog.git
synced 2026-10-29 12:59:58 +08:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2584ad4e3a | ||
|
|
8abcad84c8 | ||
|
|
725d4d26bf | ||
|
|
742bdc5c0d |
Binary file not shown.
|
After Width: | Height: | Size: 8.5 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 8.7 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 11 KiB |
@@ -11,6 +11,7 @@ Page({
|
||||
archivesCount: 0,
|
||||
archivesList: [],
|
||||
showArticleList: false,
|
||||
imgURL: "",
|
||||
emptyContentText: "暂无内容",
|
||||
currentYear: app.globalData.currentYear,
|
||||
lastRequestTime: 0, // 最后一次发起请求的时间
|
||||
@@ -85,6 +86,7 @@ Page({
|
||||
this.setData({
|
||||
showArticleList: false,
|
||||
emptyContentText: "暂无内容",
|
||||
imgURL: "/assets/img/custom-empty-image.png",
|
||||
});
|
||||
}
|
||||
return;
|
||||
@@ -127,6 +129,7 @@ Page({
|
||||
that.setData({
|
||||
showArticleList: false,
|
||||
emptyContentText: "内容获取失败",
|
||||
imgURL: "/assets/img/empty-image-error.png",
|
||||
});
|
||||
}
|
||||
wx.hideLoading();
|
||||
|
||||
@@ -43,7 +43,11 @@
|
||||
</view>
|
||||
<view wx:else="{{ showArticleList }}">
|
||||
<van-col span="24">
|
||||
<van-empty description="{{ emptyContentText }}" />
|
||||
<van-empty
|
||||
class="custom-image"
|
||||
image="{{ imgURL }}"
|
||||
description="{{ emptyContentText }}"
|
||||
/>
|
||||
</van-col>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
@@ -10,6 +10,8 @@ Page({
|
||||
pageSize: 5,
|
||||
hasMore: true,
|
||||
commentsDetail: [],
|
||||
imgURL: "",
|
||||
imgURL: "",
|
||||
emptyContentText: "暂无评论",
|
||||
},
|
||||
// 监听页面滚动事件
|
||||
@@ -72,7 +74,6 @@ Page({
|
||||
if (res.statusCode === 200) {
|
||||
const data = res.data.data.dataSet;
|
||||
const flattenedComments = that.flattenComments(data, 0);
|
||||
// that.formatComments(data);
|
||||
// 将时间戳转换为时间
|
||||
data.forEach((comment) => {
|
||||
comment.created = that.formatTimestamp(comment.created);
|
||||
@@ -80,9 +81,7 @@ Page({
|
||||
childComment.created = that.formatTimestamp(childComment.created);
|
||||
});
|
||||
});
|
||||
// console.log(data, "datadata");
|
||||
that.setData({
|
||||
// commentsDetail: that.data.commentsDetail.concat(data),
|
||||
commentsDetail: that.data.commentsDetail.concat(flattenedComments),
|
||||
});
|
||||
// 判断是否还有下一页评论
|
||||
@@ -101,6 +100,8 @@ Page({
|
||||
that.setData({
|
||||
showComments: false,
|
||||
emptyContentText: "评论获取失败",
|
||||
imgURL: "/assets/img/empty-image-error.png",
|
||||
imgURL: "/assets/img/empty-image-error.png",
|
||||
});
|
||||
}
|
||||
wx.hideLoading();
|
||||
@@ -130,17 +131,17 @@ Page({
|
||||
success: function (res) {
|
||||
if (res.statusCode === 200) {
|
||||
const data = res.data.data;
|
||||
that.setData({
|
||||
articleDetail: data,
|
||||
});
|
||||
// console.log(data, "articleDetail");
|
||||
// console.log(data, "articleDetail");
|
||||
// 计算总页数
|
||||
const commentsNum = data.commentsNum;
|
||||
const pageSize = that.data.pageSize;
|
||||
const totalPages = Math.ceil(commentsNum / pageSize);
|
||||
that.setData({
|
||||
articleDetail: data,
|
||||
articleDetail: data,
|
||||
totalPages: totalPages,
|
||||
});
|
||||
|
||||
if (data.commentsNum != 0) {
|
||||
that.loadArticleComments(that.data.articleDetail.cid);
|
||||
that.setData({
|
||||
@@ -150,6 +151,8 @@ Page({
|
||||
that.setData({
|
||||
showComments: false,
|
||||
emptyContentText: "暂无评论",
|
||||
imgURL: "/assets/img/custom-empty-image.png",
|
||||
imgURL: "/assets/img/custom-empty-image.png",
|
||||
});
|
||||
}
|
||||
} else {
|
||||
@@ -158,9 +161,37 @@ Page({
|
||||
title: "获取文章内容失败!",
|
||||
icon: "none",
|
||||
});
|
||||
const defaultData = {
|
||||
title: "Oops,您访问的页面找不到了",
|
||||
commentsNum: 0,
|
||||
text: '<img src="https://cdn.rumosky.com/assets/mpblog/404.svg" alt="404" title="404">',
|
||||
categories: [
|
||||
{
|
||||
name: "未知",
|
||||
},
|
||||
],
|
||||
date: {
|
||||
year: "2018",
|
||||
month: "04",
|
||||
day: "01",
|
||||
},
|
||||
fields: {
|
||||
Hot: {
|
||||
value: "99",
|
||||
},
|
||||
views: {
|
||||
value: "8888",
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
that.setData({
|
||||
articleDetail: defaultData,
|
||||
articleDetail: defaultData,
|
||||
showComments: false,
|
||||
emptyContentText: "评论获取失败",
|
||||
imgURL: "/assets/img/empty-image-error.png",
|
||||
imgURL: "/assets/img/empty-image-error.png",
|
||||
});
|
||||
}
|
||||
wx.hideLoading();
|
||||
@@ -172,6 +203,36 @@ Page({
|
||||
title: "获取文章内容失败!",
|
||||
icon: "none",
|
||||
});
|
||||
const defaultData = {
|
||||
title: "Oops,您访问的页面找不到了",
|
||||
commentsNum: 0,
|
||||
text: '<img src="https://cdn.rumosky.com/assets/mpblog/404.svg" alt="404" title="404">',
|
||||
categories: [
|
||||
{
|
||||
name: "未知",
|
||||
},
|
||||
],
|
||||
date: {
|
||||
year: "2018",
|
||||
month: "04",
|
||||
day: "01",
|
||||
},
|
||||
fields: {
|
||||
Hot: {
|
||||
value: "99",
|
||||
},
|
||||
views: {
|
||||
value: "8888",
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
that.setData({
|
||||
articleDetail: defaultData,
|
||||
showComments: false,
|
||||
emptyContentText: "评论获取失败",
|
||||
imgURL: "/assets/img/empty-image-error.png",
|
||||
});
|
||||
},
|
||||
});
|
||||
},
|
||||
@@ -221,6 +282,7 @@ Page({
|
||||
},
|
||||
|
||||
onLoad(options) {
|
||||
// const cid = 1;
|
||||
const cid = options.cid;
|
||||
this.loadArticleDetail(cid);
|
||||
},
|
||||
|
||||
@@ -49,7 +49,11 @@
|
||||
</view>
|
||||
</view>
|
||||
<view class="comments-empty" wx:else="{{ showComments }}">
|
||||
<van-empty description="{{ emptyContentText }}" />
|
||||
<van-empty
|
||||
class="custom-image"
|
||||
image="{{ imgURL }}"
|
||||
description="{{ emptyContentText }}"
|
||||
/>
|
||||
</view>
|
||||
</view>
|
||||
</van-col>
|
||||
|
||||
@@ -10,6 +10,7 @@ Page({
|
||||
articleList: [],
|
||||
categoryList: [],
|
||||
showArticleList: false,
|
||||
imgURL: "",
|
||||
emptyContentText: "暂无内容",
|
||||
currentTabCount: null,
|
||||
currentYear: app.globalData.currentYear,
|
||||
@@ -83,6 +84,7 @@ Page({
|
||||
that.setData({
|
||||
showArticleList: false,
|
||||
emptyContentText: "暂无内容",
|
||||
imgURL: "/assets/img/custom-empty-image.png",
|
||||
});
|
||||
}
|
||||
} else {
|
||||
@@ -94,6 +96,7 @@ Page({
|
||||
that.setData({
|
||||
showArticleList: false,
|
||||
emptyContentText: "内容获取失败",
|
||||
imgURL: "/assets/img/empty-image-error.png",
|
||||
});
|
||||
}
|
||||
wx.hideLoading();
|
||||
|
||||
@@ -64,7 +64,11 @@
|
||||
|
||||
<view wx:else="{{ showArticleList }}">
|
||||
<van-col span="24">
|
||||
<van-empty description="{{ emptyContentText }}" />
|
||||
<van-empty
|
||||
class="custom-image"
|
||||
image="{{ imgURL }}"
|
||||
description="{{ emptyContentText }}"
|
||||
/>
|
||||
</van-col>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
@@ -7,6 +7,7 @@ Page({
|
||||
pageSize: 10,
|
||||
articleList: [],
|
||||
showArticleList: false,
|
||||
imgURL: "",
|
||||
emptyContentText: "暂无内容",
|
||||
hasMore: true,
|
||||
currentYear: app.globalData.currentYear,
|
||||
@@ -88,6 +89,7 @@ Page({
|
||||
that.setData({
|
||||
showArticleList: false,
|
||||
emptyContentText: "暂无内容",
|
||||
imgURL: "/assets/img/custom-empty-image.png",
|
||||
});
|
||||
}
|
||||
} else {
|
||||
@@ -99,6 +101,7 @@ Page({
|
||||
that.setData({
|
||||
showArticleList: false,
|
||||
emptyContentText: "内容获取失败",
|
||||
imgURL: "/assets/img/empty-image-error.png",
|
||||
});
|
||||
}
|
||||
wx.hideLoading();
|
||||
|
||||
@@ -69,7 +69,11 @@
|
||||
</view>
|
||||
<view wx:else="{{ showArticleList }}">
|
||||
<van-col span="24">
|
||||
<van-empty description="{{ emptyContentText }}" />
|
||||
<van-empty
|
||||
class="custom-image"
|
||||
image="{{ imgURL }}"
|
||||
description="{{ emptyContentText }}"
|
||||
/>
|
||||
</van-col>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
@@ -8,6 +8,7 @@ Page({
|
||||
articleList: [],
|
||||
hasMore: true,
|
||||
count: 0,
|
||||
imgURL: "",
|
||||
emptyContentText: "暂无内容",
|
||||
showSearchResults: false,
|
||||
currentYear: app.globalData.currentYear,
|
||||
@@ -90,6 +91,7 @@ Page({
|
||||
that.setData({
|
||||
showSearchResults: false,
|
||||
emptyContentText: "暂无内容",
|
||||
imgURL: "/assets/img/empty-image-search.png",
|
||||
});
|
||||
}
|
||||
} else {
|
||||
@@ -101,6 +103,7 @@ Page({
|
||||
that.setData({
|
||||
showSearchResults: false,
|
||||
emptyContentText: "内容获取失败",
|
||||
imgURL: "/assets/img/empty-image-error.png",
|
||||
});
|
||||
}
|
||||
wx.hideLoading();
|
||||
|
||||
@@ -65,7 +65,11 @@
|
||||
</view>
|
||||
<view wx:else="{{ showSearchResults }}">
|
||||
<van-col span="24">
|
||||
<van-empty description="{{ emptyContentText }}" />
|
||||
<van-empty
|
||||
class="custom-image"
|
||||
image="{{ imgURL }}"
|
||||
description="{{ emptyContentText }}"
|
||||
/>
|
||||
</van-col>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
Reference in New Issue
Block a user