功能:完善评论测试与优惠券最优选择
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
const request = require('../utils/request')
|
||||
|
||||
module.exports = {
|
||||
listComments(params) {
|
||||
return request({
|
||||
url: '/comment/list',
|
||||
params
|
||||
})
|
||||
},
|
||||
|
||||
deleteComment(id) {
|
||||
return request({
|
||||
url: `/comment/delete/${id}`,
|
||||
method: 'DELETE'
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -10,6 +10,7 @@
|
||||
"pages/user-form/index",
|
||||
"pages/products/index",
|
||||
"pages/product-form/index",
|
||||
"pages/comments/index",
|
||||
"pages/coupons/index",
|
||||
"pages/coupon-form/index",
|
||||
"pages/coupon-distribute/index",
|
||||
@@ -38,25 +39,25 @@
|
||||
"list": [
|
||||
{
|
||||
"pagePath": "pages/workbench/index",
|
||||
"text": "工作台",
|
||||
"text": "Workbench",
|
||||
"iconPath": "assets/tabbar/workbench.png",
|
||||
"selectedIconPath": "assets/tabbar/workbench-active.png"
|
||||
},
|
||||
{
|
||||
"pagePath": "pages/orders/index",
|
||||
"text": "订单",
|
||||
"text": "Orders",
|
||||
"iconPath": "assets/tabbar/orders.png",
|
||||
"selectedIconPath": "assets/tabbar/orders-active.png"
|
||||
},
|
||||
{
|
||||
"pagePath": "pages/manage/index",
|
||||
"text": "经营",
|
||||
"text": "Manage",
|
||||
"iconPath": "assets/tabbar/manage.png",
|
||||
"selectedIconPath": "assets/tabbar/manage-active.png"
|
||||
},
|
||||
{
|
||||
"pagePath": "pages/profile/index",
|
||||
"text": "我的",
|
||||
"text": "Profile",
|
||||
"iconPath": "assets/tabbar/profile.png",
|
||||
"selectedIconPath": "assets/tabbar/profile-active.png"
|
||||
}
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
const commentApi = require('../../api/comment')
|
||||
|
||||
Page({
|
||||
data: {
|
||||
loading: false,
|
||||
keyword: '',
|
||||
comments: []
|
||||
},
|
||||
|
||||
onShow() {
|
||||
this.loadComments()
|
||||
},
|
||||
|
||||
async onPullDownRefresh() {
|
||||
await this.loadComments()
|
||||
wx.stopPullDownRefresh()
|
||||
},
|
||||
|
||||
handleKeywordInput(event) {
|
||||
this.setData({
|
||||
keyword: event.detail.value
|
||||
})
|
||||
},
|
||||
|
||||
async loadComments() {
|
||||
this.setData({ loading: true })
|
||||
try {
|
||||
const comments = await commentApi.listComments({
|
||||
keyword: this.data.keyword || undefined
|
||||
})
|
||||
this.setData({
|
||||
comments: Array.isArray(comments) ? comments : []
|
||||
})
|
||||
} catch (error) {
|
||||
wx.showToast({
|
||||
title: error.message || '评论加载失败',
|
||||
icon: 'none'
|
||||
})
|
||||
} finally {
|
||||
this.setData({ loading: false })
|
||||
}
|
||||
},
|
||||
|
||||
handleSearch() {
|
||||
this.loadComments()
|
||||
},
|
||||
|
||||
handleDelete(event) {
|
||||
const id = event.currentTarget.dataset.id
|
||||
if (!id) {
|
||||
return
|
||||
}
|
||||
wx.showModal({
|
||||
title: '删除评论',
|
||||
content: '确认删除这条评论?',
|
||||
confirmText: '删除',
|
||||
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,94 @@
|
||||
.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;
|
||||
}
|
||||
@@ -23,6 +23,14 @@ const MANAGE_MODULES = [
|
||||
permissionCodes: ['coupon:view'],
|
||||
requiresShopContext: true
|
||||
},
|
||||
{
|
||||
key: 'comments',
|
||||
title: '评论管理',
|
||||
description: '查看作品评论与回复,删除不合规内容',
|
||||
path: '/pages/comments/index',
|
||||
permissionCodes: ['comment:view'],
|
||||
requiresShopContext: true
|
||||
},
|
||||
{
|
||||
key: 'tags',
|
||||
title: '标签管理',
|
||||
|
||||
Reference in New Issue
Block a user