精简「我的」页面菜单 + 数据库去重 + 内容上传接口

- 移除扫一扫/提现记录/设置独立菜单项,设置功能整合到页面内
- 新增绑定微信号、清缓存、退出登录的内联设置区
- 添加 content_upload.py:Skill 可直接调用上传内容到数据库
- 数据库已去重(196→69条)并添加唯一索引防止再次重复

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
卡若
2026-02-21 14:04:55 +08:00
parent 0e4baa4b7f
commit 934f7c7988
4 changed files with 399 additions and 23 deletions

View File

@@ -33,13 +33,10 @@ Page({
// 最近阅读
recentChapters: [],
// 菜单列表:扫一扫整合在「我的」内;提现记录与设置合并为「设置与提现」入口
menuList: [
{ id: 'scan', title: '扫一扫', icon: '📷', iconBg: 'brand' },
{ id: 'orders', title: '我的订单', icon: '📦', count: 0 },
{ id: 'referral', title: '推广中心', icon: '🎁', badge: '' },
{ id: 'about', title: '关于作者', icon: '👤', iconBg: 'brand' },
{ id: 'settings', title: '设置与提现', icon: '⚙️', iconBg: 'gray' }
{ id: 'about', title: '关于作者', icon: '👤', iconBg: 'brand' }
],
// 登录弹窗
@@ -282,32 +279,15 @@ Page({
handleMenuTap(e) {
const id = e.currentTarget.dataset.id
if (!this.data.isLoggedIn && id !== 'about' && id !== 'scan') {
if (!this.data.isLoggedIn && id !== 'about') {
this.showLogin()
return
}
// 扫一扫:在「我的」内直接调起扫码
if (id === 'scan') {
wx.scanCode({
onlyFromCamera: false,
scanType: ['qrCode', 'barCode'],
success: (res) => {
wx.showToast({ title: '已识别', icon: 'success' })
if (res.result) {
wx.setClipboardData({ data: res.result })
}
},
fail: () => {}
})
return
}
const routes = {
orders: '/pages/purchases/purchases',
referral: '/pages/referral/referral',
about: '/pages/about/about',
settings: '/pages/settings/settings'
about: '/pages/about/about'
}
if (routes[id]) {
@@ -315,6 +295,55 @@ Page({
}
},
// 绑定微信号
bindWechat() {
wx.showModal({
title: '绑定微信号',
editable: true,
placeholderText: '请输入微信号',
success: async (res) => {
if (res.confirm && res.content) {
const wechat = res.content.trim()
if (!wechat) return
try {
wx.setStorageSync('user_wechat', wechat)
const userInfo = this.data.userInfo
userInfo.wechat = wechat
this.setData({ userInfo, userWechat: wechat })
app.globalData.userInfo = userInfo
wx.setStorageSync('userInfo', userInfo)
await app.request('/api/user/update', {
method: 'POST',
data: { userId: userInfo.id, wechat }
})
wx.showToast({ title: '绑定成功', icon: 'success' })
} catch (e) {
console.log('绑定微信号失败', e)
wx.showToast({ title: '已保存到本地', icon: 'success' })
}
}
}
})
},
// 清除缓存
clearCache() {
wx.showModal({
title: '清除缓存',
content: '确定要清除本地缓存吗?不会影响账号数据',
success: (res) => {
if (res.confirm) {
const userInfo = wx.getStorageSync('userInfo')
const token = wx.getStorageSync('token')
wx.clearStorageSync()
if (userInfo) wx.setStorageSync('userInfo', userInfo)
if (token) wx.setStorageSync('token', token)
wx.showToast({ title: '缓存已清除', icon: 'success' })
}
}
})
},
// 跳转到阅读页
goToRead(e) {
const id = e.currentTarget.dataset.id