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,101 @@
// pages/my-comment/my-comment.js
// 我的评论逻辑处理
const app = getApp()
const api = require('../../services/api')
Page({
data: {
commentList: [],
page: 1,
pageSize: 10,
hasMore: true,
loading: false
},
onLoad() {
this.checkLogin()
},
onShow() {
this.checkLogin()
},
onPullDownRefresh() {
this.setData({ page: 1, commentList: [], hasMore: true })
this.loadCommentList()
wx.stopPullDownRefresh()
},
onReachBottom() {
if (this.data.hasMore && !this.data.loading) {
this.setData({ page: this.data.page + 1 })
this.loadCommentList()
}
},
checkLogin() {
const userInfo = wx.getStorageSync('userInfo')
if (!userInfo) {
wx.redirectTo({ url: '/pages/login/login' })
return
}
this.loadCommentList()
},
loadCommentList() {
if (this.data.loading || !this.data.hasMore) return
this.setData({ loading: true })
api.getMyCommentList({
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({
commentList: this.data.page === 1 ? list : this.data.commentList.concat(list),
hasMore: list.length >= this.data.pageSize
})
}
}).catch(() => {
this.setData({ loading: false })
})
},
goToArticle(e) {
const articleId = e.currentTarget.dataset.articleId
wx.navigateTo({
url: `/pages/article-detail/article-detail?id=${articleId}`
})
},
onDelete(e) {
const commentId = e.currentTarget.dataset.id
wx.showModal({
title: '提示',
content: '确定要删除这条评论吗?',
success: res => {
if (res.confirm) {
api.deleteComment({ id: commentId }).then(result => {
if (result.code === 200) {
wx.showToast({ title: '删除成功', icon: 'success' })
this.setData({ page: 1, commentList: [], hasMore: true })
this.loadCommentList()
} 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,37 @@
<!-- pages/my-comment/my-comment.wxml -->
<!-- 我的评论视图 -->
<view class="my-comment-container">
<view class="comment-list">
<view class="comment-item" wx:for="{{commentList}}" wx:key="id">
<view class="comment-main" bindtap="goToArticle" data-article-id="{{item.articleId}}">
<view class="article-title">评论文章:{{item.articleTitle}}</view>
<view class="comment-content">{{item.content}}</view>
<view class="comment-meta">
<text class="time">{{item.createTime}}</text>
<text class="likes">{{item.likeCount}}赞</text>
</view>
</view>
<view class="comment-actions">
<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 && commentList.length > 0}}">
<text>没有更多了</text>
</view>
<view class="empty-state" wx:if="{{!loading && commentList.length === 0}}">
<text class="iconfont icon-comment empty-icon"></text>
<text class="empty-text">暂无评论</text>
</view>
</view>
/**
* @联系作者:16768118056
* @描述:(此项目非免费分享)源码百分百可用,搞定毕设不发愁,支持远程调试安装、二次开发、定制、讲解、文档类。
* @访问:https://www.notmaker.com/detail/8326a897119d4542896c863a69d7bbe7/gtt20260415,查看完整运行演示。
*/

View File

@@ -0,0 +1,95 @@
/* pages/my-comment/my-comment.wxss */
/* 我的评论样式 */
.my-comment-container {
min-height: 100vh;
background-color: #f5f5f5;
padding: 20rpx 30rpx;
}
.comment-item {
background-color: #fff;
border-radius: 16rpx;
margin-bottom: 20rpx;
overflow: hidden;
}
.comment-main {
padding: 24rpx;
}
.article-title {
font-size: 24rpx;
color: #667eea;
margin-bottom: 16rpx;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.comment-content {
font-size: 28rpx;
color: #333;
line-height: 1.6;
margin-bottom: 16rpx;
}
.comment-meta {
display: flex;
gap: 20rpx;
}
.time {
font-size: 22rpx;
color: #999;
}
.likes {
font-size: 22rpx;
color: #999;
}
.comment-actions {
display: flex;
border-top: 1rpx solid #f0f0f0;
}
.action-btn {
flex: 1;
text-align: center;
padding: 24rpx;
font-size: 28rpx;
color: #f56c6c;
}
.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,查看完整运行演示。
*/