This commit is contained in:
mzltMpfqGS
2026-04-15 19:45:16 +08:00
commit e4a087e67e
301 changed files with 35048 additions and 0 deletions

View File

@@ -0,0 +1,84 @@
// pages/history/history.js
// 浏览历史逻辑处理
const app = getApp()
const api = require('../../services/api')
Page({
data: {
historyList: [],
page: 1,
pageSize: 10,
hasMore: true,
loading: false
},
onLoad() {
this.loadHistoryList()
},
onPullDownRefresh() {
this.setData({ page: 1, historyList: [], hasMore: true })
this.loadHistoryList()
wx.stopPullDownRefresh()
},
onReachBottom() {
if (this.data.hasMore && !this.data.loading) {
this.setData({ page: this.data.page + 1 })
this.loadHistoryList()
}
},
loadHistoryList() {
if (this.data.loading || !this.data.hasMore) return
this.setData({ loading: true })
api.getBrowseHistory({
page: this.data.page,
pageSize: this.data.pageSize
}).then(res => {
this.setData({ loading: false })
if (res.code === 200) {
const list = res.data.list || []
this.setData({
historyList: this.data.page === 1 ? list : this.data.historyList.concat(list),
hasMore: list.length >= this.data.pageSize
})
}
}).catch(() => {
this.setData({ loading: false })
})
},
goToDetail(e) {
const articleId = e.currentTarget.dataset.id
wx.navigateTo({
url: `/pages/article-detail/article-detail?id=${articleId}`
})
},
onClearHistory() {
wx.showModal({
title: '提示',
content: '确定要清空浏览历史吗?',
success: res => {
if (res.confirm) {
api.clearBrowseHistory().then(result => {
if (result.code === 200) {
wx.showToast({ title: '已清空', icon: 'success' })
this.setData({ historyList: [], hasMore: false })
}
})
}
}
})
}
})
/**
* @联系作者:16768118056
* @描述:(此项目非免费分享)源码百分百可用,搞定毕设不发愁,支持远程调试安装、二次开发、定制、讲解、文档类。
* @访问:https://www.notmaker.com/detail/8326a897119d4542896c863a69d7bbe7/gtt20260415,查看完整运行演示。
*/