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,106 @@
// pages/my-article/my-article.js
// 我的文章逻辑处理
const app = getApp()
const api = require('../../services/api')
Page({
data: {
articleList: [],
page: 1,
pageSize: 10,
hasMore: true,
loading: false,
status: 'all'
},
onLoad(options) {
if (options.status) {
this.setData({ status: options.status })
}
this.checkLogin()
},
onShow() {
this.checkLogin()
},
onPullDownRefresh() {
this.setData({ page: 1, articleList: [], hasMore: true })
this.loadArticleList()
wx.stopPullDownRefresh()
},
onReachBottom() {
if (this.data.hasMore && !this.data.loading) {
this.setData({ page: this.data.page + 1 })
this.loadArticleList()
}
},
checkLogin() {
const userInfo = wx.getStorageSync('userInfo')
if (!userInfo) {
wx.redirectTo({ url: '/pages/login/login' })
return
}
this.loadArticleList()
},
loadArticleList() {
if (this.data.loading || !this.data.hasMore) return
this.setData({ loading: true })
api.getMyArticleList({
page: this.data.page,
pageSize: this.data.pageSize,
status: this.data.status !== 'all' ? this.data.status : null
}).then(res => {
this.setData({ loading: false })
if (res.code === 200) {
const list = res.data.list || []
this.setData({
articleList: this.data.page === 1 ? list : this.data.articleList.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}`
})
},
onDelete(e) {
const articleId = e.currentTarget.dataset.id
wx.showModal({
title: '提示',
content: '确定要删除这篇文章吗?',
success: res => {
if (res.confirm) {
api.deleteArticle({ id: articleId }).then(result => {
if (result.code === 200) {
wx.showToast({ title: '删除成功', icon: 'success' })
this.setData({ page: 1, articleList: [], hasMore: true })
this.loadArticleList()
} else {
wx.showToast({ title: result.message || '删除失败', icon: 'none' })
}
})
}
}
})
}
})
/**
* @联系作者:16768118056
* @描述:(此项目非免费分享)源码百分百可用,搞定毕设不发愁,支持远程调试安装、二次开发、定制、讲解、文档类。
* @访问:https://www.notmaker.com/detail/8326a897119d4542896c863a69d7bbe7/gtt20260415,查看完整运行演示。
*/

View File

@@ -0,0 +1,12 @@
{
"usingComponents": {},
"navigationBarTitleText": "我的文章",
"enablePullDownRefresh": true,
"backgroundTextStyle": "dark"
}
/**
* @联系作者:16768118056
* @描述:(此项目非免费分享)源码百分百可用,搞定毕设不发愁,支持远程调试安装、二次开发、定制、讲解、文档类。
* @访问:https://www.notmaker.com/detail/8326a897119d4542896c863a69d7bbe7/gtt20260415,查看完整运行演示。
*/

View File

@@ -0,0 +1,41 @@
<!-- pages/my-article/my-article.wxml -->
<!-- 我的文章视图 -->
<view class="my-article-container">
<!-- 文章列表 -->
<view class="article-list">
<view class="article-item" wx:for="{{articleList}}" wx:key="id">
<view class="article-main" bindtap="goToDetail" data-id="{{item.id}}">
<image class="article-cover" wx:if="{{item.coverImage}}" src="{{item.coverImage}}" mode="aspectFill" />
<view class="article-info">
<text class="article-title">{{item.title}}</text>
<view class="article-meta">
<text class="status {{item.status}}">{{item.statusText}}</text>
<text class="time">{{item.createTime}}</text>
</view>
</view>
</view>
<view class="article-actions">
<view class="action-btn" bindtap="goToDetail" data-id="{{item.id}}">编辑</view>
<view class="action-btn delete" bindtap="onDelete" data-id="{{item.id}}">删除</view>
</view>
</view>
</view>
<view class="loading-more" wx:if="{{loading}}">
<text>加载中...</text>
</view>
<view class="no-more" wx:if="{{!hasMore && articleList.length > 0}}">
<text>没有更多了</text>
</view>
<view class="empty-state" wx:if="{{!loading && articleList.length === 0}}">
<text class="iconfont icon-article empty-icon"></text>
<text class="empty-text">暂无文章</text>
</view>
</view>
/**
* @联系作者:16768118056
* @描述:(此项目非免费分享)源码百分百可用,搞定毕设不发愁,支持远程调试安装、二次开发、定制、讲解、文档类。
* @访问:https://www.notmaker.com/detail/8326a897119d4542896c863a69d7bbe7/gtt20260415,查看完整运行演示。
*/

View File

@@ -0,0 +1,129 @@
/* pages/my-article/my-article.wxss */
/* 我的文章样式 */
.my-article-container {
min-height: 100vh;
background-color: #f5f5f5;
padding: 20rpx 30rpx;
}
.article-item {
background-color: #fff;
border-radius: 16rpx;
margin-bottom: 20rpx;
overflow: hidden;
}
.article-main {
display: flex;
padding: 24rpx;
}
.article-cover {
width: 160rpx;
height: 120rpx;
border-radius: 12rpx;
margin-right: 20rpx;
flex-shrink: 0;
}
.article-info {
flex: 1;
display: flex;
flex-direction: column;
min-width: 0;
}
.article-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;
}
.article-meta {
display: flex;
gap: 20rpx;
margin-top: auto;
}
.status {
font-size: 22rpx;
padding: 4rpx 12rpx;
border-radius: 8rpx;
}
.status.published {
color: #67c23a;
background-color: rgba(103, 194, 58, 0.1);
}
.status.draft {
color: #e6a23c;
background-color: rgba(230, 162, 60, 0.1);
}
.status.deleted {
color: #f56c6c;
background-color: rgba(245, 108, 108, 0.1);
}
.time {
font-size: 22rpx;
color: #999;
}
.article-actions {
display: flex;
border-top: 1rpx solid #f0f0f0;
}
.action-btn {
flex: 1;
text-align: center;
padding: 24rpx;
font-size: 28rpx;
color: #667eea;
}
.action-btn.delete {
color: #f56c6c;
border-left: 1rpx solid #f0f0f0;
}
.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,查看完整运行演示。
*/