mirror of
https://gitee.com/qingqing-coconut-tea/RcKtFezyRAZX
synced 2026-07-21 10:32:32 +08:00
init
This commit is contained in:
84
wechat/pages/history/history.js
Normal file
84
wechat/pages/history/history.js
Normal 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,查看完整运行演示。
|
||||
*/
|
||||
12
wechat/pages/history/history.json
Normal file
12
wechat/pages/history/history.json
Normal file
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"usingComponents": {},
|
||||
"navigationBarTitleText": "浏览历史",
|
||||
"enablePullDownRefresh": true,
|
||||
"backgroundTextStyle": "dark"
|
||||
}
|
||||
|
||||
/**
|
||||
* @联系作者:16768118056
|
||||
* @描述:(此项目非免费分享)源码百分百可用,搞定毕设不发愁,支持远程调试安装、二次开发、定制、讲解、文档类。
|
||||
* @访问:https://www.notmaker.com/detail/8326a897119d4542896c863a69d7bbe7/gtt20260415,查看完整运行演示。
|
||||
*/
|
||||
42
wechat/pages/history/history.wxml
Normal file
42
wechat/pages/history/history.wxml
Normal file
@@ -0,0 +1,42 @@
|
||||
<!-- pages/history/history.wxml -->
|
||||
<!-- 浏览历史视图 -->
|
||||
|
||||
<view class="history-container">
|
||||
<!-- 工具栏 -->
|
||||
<view class="toolbar" wx:if="{{historyList.length > 0}}">
|
||||
<text class="toolbar-btn" bindtap="onClearHistory">清空历史</text>
|
||||
</view>
|
||||
|
||||
<!-- 历史列表 -->
|
||||
<view class="history-list">
|
||||
<view class="history-item" wx:for="{{historyList}}" wx:key="id">
|
||||
<view class="item-main" bindtap="goToDetail" data-id="{{item.articleId}}">
|
||||
<image class="item-cover" wx:if="{{item.coverImage}}" src="{{item.coverImage}}" mode="aspectFill" />
|
||||
<view class="item-info">
|
||||
<text class="item-title">{{item.title}}</text>
|
||||
<view class="item-meta">
|
||||
<text class="author">{{item.authorName}}</text>
|
||||
<text class="time">{{item.browseTime}}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="loading-more" wx:if="{{loading}}">
|
||||
<text>加载中...</text>
|
||||
</view>
|
||||
<view class="no-more" wx:if="{{!hasMore && historyList.length > 0}}">
|
||||
<text>没有更多了</text>
|
||||
</view>
|
||||
<view class="empty-state" wx:if="{{!loading && historyList.length === 0}}">
|
||||
<text class="iconfont icon-history empty-icon"></text>
|
||||
<text class="empty-text">暂无浏览历史</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
/**
|
||||
* @联系作者:16768118056
|
||||
* @描述:(此项目非免费分享)源码百分百可用,搞定毕设不发愁,支持远程调试安装、二次开发、定制、讲解、文档类。
|
||||
* @访问:https://www.notmaker.com/detail/8326a897119d4542896c863a69d7bbe7/gtt20260415,查看完整运行演示。
|
||||
*/
|
||||
106
wechat/pages/history/history.wxss
Normal file
106
wechat/pages/history/history.wxss
Normal file
@@ -0,0 +1,106 @@
|
||||
/* pages/history/history.wxss */
|
||||
/* 浏览历史样式 */
|
||||
|
||||
.history-container {
|
||||
min-height: 100vh;
|
||||
background-color: #f5f5f5;
|
||||
}
|
||||
|
||||
.toolbar {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
padding: 20rpx 30rpx;
|
||||
background-color: #fff;
|
||||
}
|
||||
|
||||
.toolbar-btn {
|
||||
font-size: 26rpx;
|
||||
color: #f56c6c;
|
||||
}
|
||||
|
||||
.history-list {
|
||||
padding: 20rpx 30rpx;
|
||||
}
|
||||
|
||||
.history-item {
|
||||
background-color: #fff;
|
||||
border-radius: 16rpx;
|
||||
margin-bottom: 20rpx;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.item-main {
|
||||
display: flex;
|
||||
padding: 24rpx;
|
||||
}
|
||||
|
||||
.item-cover {
|
||||
width: 160rpx;
|
||||
height: 120rpx;
|
||||
border-radius: 12rpx;
|
||||
margin-right: 20rpx;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.item-info {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.item-title {
|
||||
font-size: 30rpx;
|
||||
font-weight: bold;
|
||||
color: #333;
|
||||
margin-bottom: 16rpx;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
display: -webkit-box;
|
||||
-webkit-line-clamp: 2;
|
||||
-webkit-box-orient: vertical;
|
||||
}
|
||||
|
||||
.item-meta {
|
||||
display: flex;
|
||||
gap: 20rpx;
|
||||
margin-top: auto;
|
||||
}
|
||||
|
||||
.author,
|
||||
.time {
|
||||
font-size: 22rpx;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.loading-more,
|
||||
.no-more {
|
||||
text-align: center;
|
||||
padding: 30rpx;
|
||||
font-size: 24rpx;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.empty-state {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
padding: 100rpx 0;
|
||||
}
|
||||
|
||||
.empty-icon {
|
||||
font-size: 100rpx;
|
||||
color: #ddd;
|
||||
margin-bottom: 20rpx;
|
||||
}
|
||||
|
||||
.empty-text {
|
||||
font-size: 28rpx;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
/**
|
||||
* @联系作者:16768118056
|
||||
* @描述:(此项目非免费分享)源码百分百可用,搞定毕设不发愁,支持远程调试安装、二次开发、定制、讲解、文档类。
|
||||
* @访问:https://www.notmaker.com/detail/8326a897119d4542896c863a69d7bbe7/gtt20260415,查看完整运行演示。
|
||||
*/
|
||||
Reference in New Issue
Block a user