重构项目文件夹目录
This commit is contained in:
@@ -0,0 +1,143 @@
|
||||
/**
|
||||
* Purpose: commentApi supports index.js by holding or executing the comment api page or API role.
|
||||
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
const commentApi = require('../../api/comment')
|
||||
|
||||
Page({
|
||||
/**
|
||||
* Purpose: data supports index.js by holding or executing the data page or API role.
|
||||
* Usage: import, call, read, or update this page-data from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
data: {
|
||||
/**
|
||||
* Purpose: loading supports index.js by holding or executing the loading page or API role.
|
||||
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
loading: false,
|
||||
/**
|
||||
* Purpose: keyword supports index.js by holding or executing the keyword page or API role.
|
||||
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
keyword: '',
|
||||
/**
|
||||
* Purpose: comments supports index.js by holding or executing the comments page or API role.
|
||||
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
comments: []
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: onShow supports index.js by holding or executing the on show page or API role.
|
||||
* Usage: import, call, read, or update this method from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
onShow() {
|
||||
this.loadComments()
|
||||
},
|
||||
|
||||
async onPullDownRefresh() {
|
||||
await this.loadComments()
|
||||
wx.stopPullDownRefresh()
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleKeywordInput supports index.js by holding or executing the handle keyword input page or API role.
|
||||
* Usage: import, call, read, or update this method from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
handleKeywordInput(event) {
|
||||
this.setData({
|
||||
/**
|
||||
* Purpose: keyword supports index.js by holding or executing the keyword page or API role.
|
||||
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
keyword: event.detail.value
|
||||
})
|
||||
},
|
||||
|
||||
async loadComments() {
|
||||
this.setData({ loading: true })
|
||||
try {
|
||||
const comments = await commentApi.listComments({
|
||||
/**
|
||||
* Purpose: keyword supports index.js by holding or executing the keyword page or API role.
|
||||
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
keyword: this.data.keyword || undefined
|
||||
})
|
||||
this.setData({
|
||||
/**
|
||||
* Purpose: comments supports index.js by holding or executing the comments page or API role.
|
||||
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
comments: Array.isArray(comments) ? comments : []
|
||||
})
|
||||
} catch (error) {
|
||||
wx.showToast({
|
||||
/**
|
||||
* Purpose: title supports index.js by holding or executing the title page or API role.
|
||||
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
title: error.message || '评论加载失败',
|
||||
/**
|
||||
* Purpose: icon supports index.js by holding or executing the icon page or API role.
|
||||
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
icon: 'none'
|
||||
})
|
||||
} finally {
|
||||
this.setData({ loading: false })
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleSearch supports index.js by holding or executing the handle search page or API role.
|
||||
* Usage: import, call, read, or update this method from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
handleSearch() {
|
||||
this.loadComments()
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleDelete supports index.js by holding or executing the handle delete page or API role.
|
||||
* Usage: import, call, read, or update this method from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
handleDelete(event) {
|
||||
const id = event.currentTarget.dataset.id
|
||||
if (!id) {
|
||||
return
|
||||
}
|
||||
wx.showModal({
|
||||
/**
|
||||
* Purpose: title supports index.js by holding or executing the title page or API role.
|
||||
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
title: '删除评论',
|
||||
/**
|
||||
* Purpose: content supports index.js by holding or executing the content page or API role.
|
||||
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
content: '确认删除这条评论?',
|
||||
/**
|
||||
* Purpose: confirmText supports index.js by holding or executing the confirm text page or API role.
|
||||
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
confirmText: '删除',
|
||||
/**
|
||||
* Purpose: success supports index.js by holding or executing the success page or API role.
|
||||
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
success: async res => {
|
||||
if (!res.confirm) {
|
||||
return
|
||||
}
|
||||
try {
|
||||
await commentApi.deleteComment(id)
|
||||
wx.showToast({ title: '评论已删除', icon: 'none' })
|
||||
this.loadComments()
|
||||
} catch (error) {
|
||||
wx.showToast({ title: error.message || '删除失败', icon: 'none' })
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
@@ -0,0 +1,21 @@
|
||||
<navigation-bar title="评论管理" showBack="{{true}}" background="#081518" color="#ffffff"></navigation-bar>
|
||||
|
||||
<view class="page">
|
||||
<view class="search-row">
|
||||
<input class="search-input" placeholder="搜索评论内容" value="{{keyword}}" bindinput="handleKeywordInput" confirm-type="search" bindconfirm="handleSearch" />
|
||||
<view class="search-btn" bindtap="handleSearch">搜索</view>
|
||||
</view>
|
||||
|
||||
<view wx:if="{{!comments.length && !loading}}" class="empty">暂无评论</view>
|
||||
|
||||
<view wx:for="{{comments}}" wx:key="id" class="comment-card">
|
||||
<view class="comment-head">
|
||||
<text class="comment-user">{{item.userNickname || '用户'}}</text>
|
||||
<text class="comment-time">{{item.createTime}}</text>
|
||||
</view>
|
||||
<view class="comment-content">{{item.commentContent}}</view>
|
||||
<view wx:if="{{item.parentCommentContent}}" class="reply-content">回复:{{item.parentCommentContent}}</view>
|
||||
<view class="comment-meta">{{item.productTitle || '作品'}} · {{item.shopName || '门店'}}</view>
|
||||
<view class="delete-btn" data-id="{{item.id}}" bindtap="handleDelete">删除</view>
|
||||
</view>
|
||||
</view>
|
||||
@@ -0,0 +1,95 @@
|
||||
@import "../../app.wxss";
|
||||
.page {
|
||||
min-height: 100vh;
|
||||
padding: 28rpx 24rpx 60rpx;
|
||||
background: #0c181b;
|
||||
}
|
||||
|
||||
.search-row {
|
||||
display: flex;
|
||||
gap: 16rpx;
|
||||
margin-bottom: 24rpx;
|
||||
}
|
||||
|
||||
.search-input {
|
||||
flex: 1;
|
||||
height: 76rpx;
|
||||
padding: 0 24rpx;
|
||||
border-radius: 18rpx;
|
||||
background: #132529;
|
||||
color: #ffffff;
|
||||
font-size: 26rpx;
|
||||
}
|
||||
|
||||
.search-btn {
|
||||
width: 128rpx;
|
||||
height: 76rpx;
|
||||
line-height: 76rpx;
|
||||
text-align: center;
|
||||
border-radius: 18rpx;
|
||||
background: #f07e57;
|
||||
color: #ffffff;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.empty {
|
||||
padding: 80rpx 0;
|
||||
text-align: center;
|
||||
color: #7e8f8c;
|
||||
}
|
||||
|
||||
.comment-card {
|
||||
margin-bottom: 18rpx;
|
||||
padding: 24rpx;
|
||||
border-radius: 20rpx;
|
||||
background: #132529;
|
||||
color: #dce7e4;
|
||||
}
|
||||
|
||||
.comment-head {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
gap: 16rpx;
|
||||
}
|
||||
|
||||
.comment-user {
|
||||
font-size: 28rpx;
|
||||
font-weight: 700;
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
.comment-time,
|
||||
.comment-meta {
|
||||
font-size: 22rpx;
|
||||
color: #7e8f8c;
|
||||
}
|
||||
|
||||
.comment-content {
|
||||
margin-top: 16rpx;
|
||||
font-size: 26rpx;
|
||||
line-height: 1.8;
|
||||
}
|
||||
|
||||
.reply-content {
|
||||
margin-top: 12rpx;
|
||||
padding: 16rpx;
|
||||
border-radius: 16rpx;
|
||||
background: #0c181b;
|
||||
color: #a9bbb6;
|
||||
font-size: 24rpx;
|
||||
}
|
||||
|
||||
.comment-meta {
|
||||
margin-top: 14rpx;
|
||||
}
|
||||
|
||||
.delete-btn {
|
||||
margin-top: 18rpx;
|
||||
width: 120rpx;
|
||||
height: 56rpx;
|
||||
line-height: 56rpx;
|
||||
text-align: center;
|
||||
border-radius: 999rpx;
|
||||
color: #ffffff;
|
||||
background: #d95f5f;
|
||||
}
|
||||
Reference in New Issue
Block a user