搜索功能增强 + 设置页自动提现 + 部署规则
## 小程序 1. 搜索页面:添加热门章节推荐 2. 我的页面:点击ID可复制 3. 设置页面:添加自动提现开关 ## 后台 1. 新增热门章节API (/api/book/hot) 2. 章节保存时自动去掉Markdown标题 ## 规则 1. .cursorrules添加完整部署流程
This commit is contained in:
@@ -16,6 +16,9 @@ Page({
|
||||
wechatId: '',
|
||||
alipayAccount: '',
|
||||
|
||||
// 自动提现
|
||||
autoWithdrawEnabled: false,
|
||||
|
||||
// 绑定弹窗
|
||||
showBindModal: false,
|
||||
bindType: '', // phone | wechat | alipay
|
||||
@@ -43,16 +46,66 @@ Page({
|
||||
const phoneNumber = wx.getStorageSync('user_phone') || userInfo.phone || ''
|
||||
const wechatId = wx.getStorageSync('user_wechat') || userInfo.wechat || ''
|
||||
const alipayAccount = wx.getStorageSync('user_alipay') || userInfo.alipay || ''
|
||||
const autoWithdrawEnabled = wx.getStorageSync('auto_withdraw_enabled') || false
|
||||
|
||||
this.setData({
|
||||
isLoggedIn: true,
|
||||
userInfo,
|
||||
phoneNumber,
|
||||
wechatId,
|
||||
alipayAccount
|
||||
alipayAccount,
|
||||
autoWithdrawEnabled
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
// 切换自动提现
|
||||
async toggleAutoWithdraw(e) {
|
||||
const enabled = e.detail.value
|
||||
|
||||
// 检查是否绑定了支付方式
|
||||
if (enabled && !this.data.wechatId && !this.data.alipayAccount) {
|
||||
wx.showToast({ title: '请先绑定微信号或支付宝', icon: 'none' })
|
||||
this.setData({ autoWithdrawEnabled: false })
|
||||
return
|
||||
}
|
||||
|
||||
// 开启时需要确认
|
||||
if (enabled) {
|
||||
wx.showModal({
|
||||
title: '开启自动提现',
|
||||
content: `收益将自动打款到您的${this.data.alipayAccount ? '支付宝' : '微信'}账户,确认开启吗?`,
|
||||
success: async (res) => {
|
||||
if (res.confirm) {
|
||||
this.setData({ autoWithdrawEnabled: true })
|
||||
wx.setStorageSync('auto_withdraw_enabled', true)
|
||||
|
||||
// 同步到服务器
|
||||
try {
|
||||
await app.request('/api/user/update', {
|
||||
method: 'POST',
|
||||
data: {
|
||||
userId: app.globalData.userInfo?.id,
|
||||
autoWithdraw: true,
|
||||
withdrawAccount: this.data.alipayAccount || this.data.wechatId
|
||||
}
|
||||
})
|
||||
} catch (e) {
|
||||
console.log('同步自动提现设置失败', e)
|
||||
}
|
||||
|
||||
wx.showToast({ title: '已开启自动提现', icon: 'success' })
|
||||
} else {
|
||||
this.setData({ autoWithdrawEnabled: false })
|
||||
}
|
||||
}
|
||||
})
|
||||
} else {
|
||||
this.setData({ autoWithdrawEnabled: false })
|
||||
wx.setStorageSync('auto_withdraw_enabled', false)
|
||||
wx.showToast({ title: '已关闭自动提现', icon: 'success' })
|
||||
}
|
||||
},
|
||||
|
||||
// 绑定手机号
|
||||
bindPhone() {
|
||||
|
||||
Reference in New Issue
Block a user