feat: 完善后台管理+搜索功能+分销系统

主要更新:
- 后台菜单精简(9项→6项)
- 新增搜索功能(敏感信息过滤)
- 分销绑定和提现系统完善
- 数据库初始化API(自动修复表结构)
- 用户管理:显示绑定关系详情
- 小程序:上下章导航优化、匹配页面重构
- 修复hydration和数据类型问题
This commit is contained in:
卡若
2026-01-25 19:37:59 +08:00
parent 65d2831a45
commit 4dd2f9f4a7
49 changed files with 5921 additions and 636 deletions

View File

@@ -0,0 +1,87 @@
/**
* Soul创业派对 - 章节搜索页
* 搜索章节标题和内容
*/
const app = getApp()
Page({
data: {
statusBarHeight: 44,
keyword: '',
results: [],
loading: false,
searched: false,
total: 0,
// 热门搜索
hotKeywords: ['私域', '电商', '流量', '赚钱', '创业', 'Soul', '抖音']
},
onLoad() {
this.setData({
statusBarHeight: app.globalData.statusBarHeight || 44
})
},
// 输入关键词
onInput(e) {
this.setData({ keyword: e.detail.value })
},
// 清空搜索
clearSearch() {
this.setData({
keyword: '',
results: [],
searched: false,
total: 0
})
},
// 点击热门关键词
onHotKeyword(e) {
const keyword = e.currentTarget.dataset.keyword
this.setData({ keyword })
this.doSearch()
},
// 执行搜索
async doSearch() {
const { keyword } = this.data
if (!keyword || keyword.trim().length < 1) {
wx.showToast({ title: '请输入搜索关键词', icon: 'none' })
return
}
this.setData({ loading: true, searched: true })
try {
const res = await app.request(`/api/book/search?q=${encodeURIComponent(keyword.trim())}`)
if (res && res.success) {
this.setData({
results: res.results || [],
total: res.total || 0
})
} else {
this.setData({ results: [], total: 0 })
}
} catch (e) {
console.error('搜索失败:', e)
wx.showToast({ title: '搜索失败', icon: 'none' })
this.setData({ results: [], total: 0 })
} finally {
this.setData({ loading: false })
}
},
// 跳转阅读
goToRead(e) {
const id = e.currentTarget.dataset.id
wx.navigateTo({ url: `/pages/read/read?id=${id}` })
},
// 返回上一页
goBack() {
wx.navigateBack()
}
})

View File

@@ -0,0 +1,5 @@
{
"usingComponents": {},
"navigationStyle": "custom",
"navigationBarTitleText": "搜索"
}

View File

@@ -0,0 +1,92 @@
<!--pages/search/search.wxml-->
<!--章节搜索页-->
<view class="page">
<!-- 自定义导航栏 -->
<view class="nav-bar" style="padding-top: {{statusBarHeight}}px;">
<view class="nav-content">
<view class="back-btn" bindtap="goBack">
<text class="back-icon">←</text>
</view>
<view class="search-input-wrap">
<view class="search-icon-small">🔍</view>
<input
class="search-input"
placeholder="搜索章节标题或内容..."
value="{{keyword}}"
bindinput="onInput"
bindconfirm="doSearch"
confirm-type="search"
focus="{{true}}"
/>
<view class="clear-btn" wx:if="{{keyword}}" bindtap="clearSearch">×</view>
</view>
<view class="search-btn" bindtap="doSearch">搜索</view>
</view>
</view>
<!-- 主内容区 -->
<view class="main-content" style="padding-top: {{statusBarHeight + 56}}px;">
<!-- 热门搜索(未搜索时显示) -->
<view class="hot-section" wx:if="{{!searched}}">
<text class="section-title">热门搜索</text>
<view class="hot-tags">
<view
class="hot-tag"
wx:for="{{hotKeywords}}"
wx:key="*this"
bindtap="onHotKeyword"
data-keyword="{{item}}"
>{{item}}</view>
</view>
</view>
<!-- 搜索结果 -->
<view class="results-section" wx:if="{{searched}}">
<!-- 加载中 -->
<view class="loading-wrap" wx:if="{{loading}}">
<view class="loading-spinner"></view>
<text class="loading-text">搜索中...</text>
</view>
<!-- 结果列表 -->
<block wx:elif="{{results.length > 0}}">
<view class="results-header">
<text class="results-count">找到 {{total}} 个结果</text>
</view>
<view class="results-list">
<view
class="result-item"
wx:for="{{results}}"
wx:key="id"
bindtap="goToRead"
data-id="{{item.id}}"
>
<view class="result-header">
<text class="result-chapter">{{item.chapterLabel}}</text>
<view class="result-tags">
<text class="tag tag-match" wx:if="{{item.matchType === 'title'}}">标题匹配</text>
<text class="tag tag-match" wx:elif="{{item.matchType === 'content'}}">内容匹配</text>
<text class="tag tag-free" wx:if="{{item.isFree}}">免费</text>
</view>
</view>
<text class="result-title">{{item.title}}</text>
<text class="result-part">{{item.part}}</text>
<view class="result-content" wx:if="{{item.matchedContent}}">
<text class="content-preview">{{item.matchedContent}}</text>
</view>
<view class="result-arrow">→</view>
</view>
</view>
</block>
<!-- 无结果 -->
<view class="empty-wrap" wx:elif="{{!loading}}">
<text class="empty-icon">🔍</text>
<text class="empty-text">未找到相关章节</text>
<text class="empty-hint">换个关键词试试</text>
</view>
</view>
</view>
</view>

View File

@@ -0,0 +1,264 @@
/* 章节搜索页样式 */
.page {
min-height: 100vh;
background: linear-gradient(180deg, #0a0a0a 0%, #111111 100%);
}
/* 导航栏 */
.nav-bar {
position: fixed;
top: 0;
left: 0;
right: 0;
z-index: 100;
background: rgba(10, 10, 10, 0.95);
backdrop-filter: blur(20px);
-webkit-backdrop-filter: blur(20px);
}
.nav-content {
display: flex;
align-items: center;
padding: 8rpx 24rpx;
height: 88rpx;
}
.back-btn {
width: 60rpx;
height: 60rpx;
display: flex;
align-items: center;
justify-content: center;
}
.back-icon {
font-size: 40rpx;
color: #00CED1;
}
.search-input-wrap {
flex: 1;
display: flex;
align-items: center;
background: rgba(255,255,255,0.08);
border-radius: 40rpx;
padding: 0 24rpx;
height: 64rpx;
margin: 0 16rpx;
}
.search-icon-small {
font-size: 28rpx;
margin-right: 12rpx;
}
.search-input {
flex: 1;
font-size: 28rpx;
color: #fff;
}
.search-input::placeholder {
color: rgba(255,255,255,0.4);
}
.clear-btn {
width: 40rpx;
height: 40rpx;
display: flex;
align-items: center;
justify-content: center;
font-size: 32rpx;
color: rgba(255,255,255,0.5);
}
.search-btn {
font-size: 28rpx;
color: #00CED1;
padding: 0 16rpx;
}
/* 主内容 */
.main-content {
padding: 24rpx;
}
/* 热门搜索 */
.hot-section {
padding: 24rpx 0;
}
.section-title {
font-size: 28rpx;
color: rgba(255,255,255,0.6);
margin-bottom: 24rpx;
display: block;
}
.hot-tags {
display: flex;
flex-wrap: wrap;
gap: 20rpx;
}
.hot-tag {
background: rgba(0, 206, 209, 0.15);
color: #00CED1;
padding: 16rpx 32rpx;
border-radius: 32rpx;
font-size: 28rpx;
border: 1rpx solid rgba(0, 206, 209, 0.3);
}
/* 搜索结果 */
.results-section {
padding: 16rpx 0;
}
.results-header {
margin-bottom: 24rpx;
}
.results-count {
font-size: 26rpx;
color: rgba(255,255,255,0.5);
}
.results-list {
display: flex;
flex-direction: column;
gap: 24rpx;
}
.result-item {
background: rgba(255,255,255,0.05);
border-radius: 24rpx;
padding: 28rpx;
position: relative;
border: 1rpx solid rgba(255,255,255,0.08);
}
.result-header {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 16rpx;
}
.result-chapter {
font-size: 24rpx;
color: #00CED1;
font-weight: 500;
}
.result-tags {
display: flex;
gap: 12rpx;
}
.tag {
font-size: 20rpx;
padding: 6rpx 16rpx;
border-radius: 20rpx;
}
.tag-match {
background: rgba(147, 112, 219, 0.2);
color: #9370DB;
}
.tag-free {
background: rgba(76, 175, 80, 0.2);
color: #4CAF50;
}
.result-title {
font-size: 30rpx;
color: #fff;
font-weight: 500;
line-height: 1.5;
display: block;
margin-bottom: 8rpx;
}
.result-part {
font-size: 24rpx;
color: rgba(255,255,255,0.5);
display: block;
}
.result-content {
margin-top: 16rpx;
padding-top: 16rpx;
border-top: 1rpx solid rgba(255,255,255,0.1);
}
.content-preview {
font-size: 24rpx;
color: rgba(255,255,255,0.6);
line-height: 1.6;
display: -webkit-box;
-webkit-line-clamp: 3;
-webkit-box-orient: vertical;
overflow: hidden;
}
.result-arrow {
position: absolute;
right: 28rpx;
top: 50%;
transform: translateY(-50%);
font-size: 32rpx;
color: rgba(255,255,255,0.3);
}
/* 加载状态 */
.loading-wrap {
display: flex;
flex-direction: column;
align-items: center;
padding: 100rpx 0;
}
.loading-spinner {
width: 60rpx;
height: 60rpx;
border: 4rpx solid rgba(0, 206, 209, 0.3);
border-top-color: #00CED1;
border-radius: 50%;
animation: spin 1s linear infinite;
}
@keyframes spin {
to { transform: rotate(360deg); }
}
.loading-text {
margin-top: 24rpx;
font-size: 28rpx;
color: rgba(255,255,255,0.5);
}
/* 空状态 */
.empty-wrap {
display: flex;
flex-direction: column;
align-items: center;
padding: 100rpx 0;
}
.empty-icon {
font-size: 80rpx;
margin-bottom: 24rpx;
}
.empty-text {
font-size: 32rpx;
color: rgba(255,255,255,0.6);
margin-bottom: 12rpx;
}
.empty-hint {
font-size: 26rpx;
color: rgba(255,255,255,0.4);
}