4 Commits
Author SHA1 Message Date
rumosky 2584ad4e3a v1.2.1 2023-11-28 14:38:34 +08:00
rumosky 8abcad84c8 Merge branch 'master' of gitee.com:rumosky/mp-Blog 2023-11-28 14:35:50 +08:00
rumosky 725d4d26bf v1.2.1 2023-11-28 14:31:51 +08:00
rumosky 742bdc5c0d v1.2.1 2023-11-28 14:20:53 +08:00
13 changed files with 106 additions and 12 deletions
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

+3
View File
@@ -11,6 +11,7 @@ Page({
archivesCount: 0, archivesCount: 0,
archivesList: [], archivesList: [],
showArticleList: false, showArticleList: false,
imgURL: "",
emptyContentText: "暂无内容", emptyContentText: "暂无内容",
currentYear: app.globalData.currentYear, currentYear: app.globalData.currentYear,
lastRequestTime: 0, // 最后一次发起请求的时间 lastRequestTime: 0, // 最后一次发起请求的时间
@@ -85,6 +86,7 @@ Page({
this.setData({ this.setData({
showArticleList: false, showArticleList: false,
emptyContentText: "暂无内容", emptyContentText: "暂无内容",
imgURL: "/assets/img/custom-empty-image.png",
}); });
} }
return; return;
@@ -127,6 +129,7 @@ Page({
that.setData({ that.setData({
showArticleList: false, showArticleList: false,
emptyContentText: "内容获取失败", emptyContentText: "内容获取失败",
imgURL: "/assets/img/empty-image-error.png",
}); });
} }
wx.hideLoading(); wx.hideLoading();
+5 -1
View File
@@ -43,7 +43,11 @@
</view> </view>
<view wx:else="{{ showArticleList }}"> <view wx:else="{{ showArticleList }}">
<van-col span="24"> <van-col span="24">
<van-empty description="{{ emptyContentText }}" /> <van-empty
class="custom-image"
image="{{ imgURL }}"
description="{{ emptyContentText }}"
/>
</van-col> </van-col>
</view> </view>
</view> </view>
+69 -7
View File
@@ -10,6 +10,8 @@ Page({
pageSize: 5, pageSize: 5,
hasMore: true, hasMore: true,
commentsDetail: [], commentsDetail: [],
imgURL: "",
imgURL: "",
emptyContentText: "暂无评论", emptyContentText: "暂无评论",
}, },
// 监听页面滚动事件 // 监听页面滚动事件
@@ -72,7 +74,6 @@ Page({
if (res.statusCode === 200) { if (res.statusCode === 200) {
const data = res.data.data.dataSet; const data = res.data.data.dataSet;
const flattenedComments = that.flattenComments(data, 0); const flattenedComments = that.flattenComments(data, 0);
// that.formatComments(data);
// 将时间戳转换为时间 // 将时间戳转换为时间
data.forEach((comment) => { data.forEach((comment) => {
comment.created = that.formatTimestamp(comment.created); comment.created = that.formatTimestamp(comment.created);
@@ -80,9 +81,7 @@ Page({
childComment.created = that.formatTimestamp(childComment.created); childComment.created = that.formatTimestamp(childComment.created);
}); });
}); });
// console.log(data, "datadata");
that.setData({ that.setData({
// commentsDetail: that.data.commentsDetail.concat(data),
commentsDetail: that.data.commentsDetail.concat(flattenedComments), commentsDetail: that.data.commentsDetail.concat(flattenedComments),
}); });
// 判断是否还有下一页评论 // 判断是否还有下一页评论
@@ -101,6 +100,8 @@ Page({
that.setData({ that.setData({
showComments: false, showComments: false,
emptyContentText: "评论获取失败", emptyContentText: "评论获取失败",
imgURL: "/assets/img/empty-image-error.png",
imgURL: "/assets/img/empty-image-error.png",
}); });
} }
wx.hideLoading(); wx.hideLoading();
@@ -130,17 +131,17 @@ Page({
success: function (res) { success: function (res) {
if (res.statusCode === 200) { if (res.statusCode === 200) {
const data = res.data.data; const data = res.data.data;
that.setData({ // console.log(data, "articleDetail");
articleDetail: data, // console.log(data, "articleDetail");
});
// 计算总页数 // 计算总页数
const commentsNum = data.commentsNum; const commentsNum = data.commentsNum;
const pageSize = that.data.pageSize; const pageSize = that.data.pageSize;
const totalPages = Math.ceil(commentsNum / pageSize); const totalPages = Math.ceil(commentsNum / pageSize);
that.setData({ that.setData({
articleDetail: data,
articleDetail: data,
totalPages: totalPages, totalPages: totalPages,
}); });
if (data.commentsNum != 0) { if (data.commentsNum != 0) {
that.loadArticleComments(that.data.articleDetail.cid); that.loadArticleComments(that.data.articleDetail.cid);
that.setData({ that.setData({
@@ -150,6 +151,8 @@ Page({
that.setData({ that.setData({
showComments: false, showComments: false,
emptyContentText: "暂无评论", emptyContentText: "暂无评论",
imgURL: "/assets/img/custom-empty-image.png",
imgURL: "/assets/img/custom-empty-image.png",
}); });
} }
} else { } else {
@@ -158,9 +161,37 @@ Page({
title: "获取文章内容失败!", title: "获取文章内容失败!",
icon: "none", 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({ that.setData({
articleDetail: defaultData,
articleDetail: defaultData,
showComments: false, showComments: false,
emptyContentText: "评论获取失败", emptyContentText: "评论获取失败",
imgURL: "/assets/img/empty-image-error.png",
imgURL: "/assets/img/empty-image-error.png",
}); });
} }
wx.hideLoading(); wx.hideLoading();
@@ -172,6 +203,36 @@ Page({
title: "获取文章内容失败!", title: "获取文章内容失败!",
icon: "none", 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) { onLoad(options) {
// const cid = 1;
const cid = options.cid; const cid = options.cid;
this.loadArticleDetail(cid); this.loadArticleDetail(cid);
}, },
+5 -1
View File
@@ -49,7 +49,11 @@
</view> </view>
</view> </view>
<view class="comments-empty" wx:else="{{ showComments }}"> <view class="comments-empty" wx:else="{{ showComments }}">
<van-empty description="{{ emptyContentText }}" /> <van-empty
class="custom-image"
image="{{ imgURL }}"
description="{{ emptyContentText }}"
/>
</view> </view>
</view> </view>
</van-col> </van-col>
+3
View File
@@ -10,6 +10,7 @@ Page({
articleList: [], articleList: [],
categoryList: [], categoryList: [],
showArticleList: false, showArticleList: false,
imgURL: "",
emptyContentText: "暂无内容", emptyContentText: "暂无内容",
currentTabCount: null, currentTabCount: null,
currentYear: app.globalData.currentYear, currentYear: app.globalData.currentYear,
@@ -83,6 +84,7 @@ Page({
that.setData({ that.setData({
showArticleList: false, showArticleList: false,
emptyContentText: "暂无内容", emptyContentText: "暂无内容",
imgURL: "/assets/img/custom-empty-image.png",
}); });
} }
} else { } else {
@@ -94,6 +96,7 @@ Page({
that.setData({ that.setData({
showArticleList: false, showArticleList: false,
emptyContentText: "内容获取失败", emptyContentText: "内容获取失败",
imgURL: "/assets/img/empty-image-error.png",
}); });
} }
wx.hideLoading(); wx.hideLoading();
+5 -1
View File
@@ -64,7 +64,11 @@
<view wx:else="{{ showArticleList }}"> <view wx:else="{{ showArticleList }}">
<van-col span="24"> <van-col span="24">
<van-empty description="{{ emptyContentText }}" /> <van-empty
class="custom-image"
image="{{ imgURL }}"
description="{{ emptyContentText }}"
/>
</van-col> </van-col>
</view> </view>
</view> </view>
+3
View File
@@ -7,6 +7,7 @@ Page({
pageSize: 10, pageSize: 10,
articleList: [], articleList: [],
showArticleList: false, showArticleList: false,
imgURL: "",
emptyContentText: "暂无内容", emptyContentText: "暂无内容",
hasMore: true, hasMore: true,
currentYear: app.globalData.currentYear, currentYear: app.globalData.currentYear,
@@ -88,6 +89,7 @@ Page({
that.setData({ that.setData({
showArticleList: false, showArticleList: false,
emptyContentText: "暂无内容", emptyContentText: "暂无内容",
imgURL: "/assets/img/custom-empty-image.png",
}); });
} }
} else { } else {
@@ -99,6 +101,7 @@ Page({
that.setData({ that.setData({
showArticleList: false, showArticleList: false,
emptyContentText: "内容获取失败", emptyContentText: "内容获取失败",
imgURL: "/assets/img/empty-image-error.png",
}); });
} }
wx.hideLoading(); wx.hideLoading();
+5 -1
View File
@@ -69,7 +69,11 @@
</view> </view>
<view wx:else="{{ showArticleList }}"> <view wx:else="{{ showArticleList }}">
<van-col span="24"> <van-col span="24">
<van-empty description="{{ emptyContentText }}" /> <van-empty
class="custom-image"
image="{{ imgURL }}"
description="{{ emptyContentText }}"
/>
</van-col> </van-col>
</view> </view>
</view> </view>
+3
View File
@@ -8,6 +8,7 @@ Page({
articleList: [], articleList: [],
hasMore: true, hasMore: true,
count: 0, count: 0,
imgURL: "",
emptyContentText: "暂无内容", emptyContentText: "暂无内容",
showSearchResults: false, showSearchResults: false,
currentYear: app.globalData.currentYear, currentYear: app.globalData.currentYear,
@@ -90,6 +91,7 @@ Page({
that.setData({ that.setData({
showSearchResults: false, showSearchResults: false,
emptyContentText: "暂无内容", emptyContentText: "暂无内容",
imgURL: "/assets/img/empty-image-search.png",
}); });
} }
} else { } else {
@@ -101,6 +103,7 @@ Page({
that.setData({ that.setData({
showSearchResults: false, showSearchResults: false,
emptyContentText: "内容获取失败", emptyContentText: "内容获取失败",
imgURL: "/assets/img/empty-image-error.png",
}); });
} }
wx.hideLoading(); wx.hideLoading();
+5 -1
View File
@@ -65,7 +65,11 @@
</view> </view>
<view wx:else="{{ showSearchResults }}"> <view wx:else="{{ showSearchResults }}">
<van-col span="24"> <van-col span="24">
<van-empty description="{{ emptyContentText }}" /> <van-empty
class="custom-image"
image="{{ imgURL }}"
description="{{ emptyContentText }}"
/>
</van-col> </van-col>
</view> </view>
</view> </view>