From 26735530b434fb53c73ef30ea948884f8a69bc07 Mon Sep 17 00:00:00 2001 From: xcbyy <2578898740@qq.com> Date: Tue, 13 Oct 2026 09:44:13 +0800 Subject: [PATCH] fix(user): remove obsolete withdrawal modal and recompile mp-weixin to dedicated withdraw page --- pwuniapp/common/api.js | 43 ++--- pwuniapp/pages/user/index.vue | 227 ++------------------------ server/tests/content-security.spec.ts | 6 +- 3 files changed, 41 insertions(+), 235 deletions(-) diff --git a/pwuniapp/common/api.js b/pwuniapp/common/api.js index 0dc1801..a383187 100644 --- a/pwuniapp/common/api.js +++ b/pwuniapp/common/api.js @@ -497,13 +497,30 @@ export async function rechargeBalance(userId = 1001, amount) { /** * 佣金提现申请 (支持微信零钱、支付宝、银行卡多渠道及账号信息) +/** + * 佣金提现申请 (支持多渠道: 微信 WECHAT / 支付宝 ALIPAY / 银行卡 BANK) + * 支持 (userId, amount, options) 与 (amount, channel, userId) 两种调用签名 */ -export async function withdrawCommission(userId = 1001, amount, options = {}) { +export async function withdrawCommission(arg1, arg2, arg3 = {}) { try { - const payload = typeof options === 'string' - ? { amount, channel: options } - : { amount, ...options }; - const res = await http.post(`/users/${userId}/withdraw`, payload); + let uid = 1001; + let amt = 0; + let opt = {}; + + if (typeof arg1 === 'number' && (typeof arg2 === 'number' || !isNaN(Number(arg2)))) { + uid = arg1; + amt = Number(arg2); + opt = typeof arg3 === 'object' ? arg3 : { channel: arg3 || 'WECHAT' }; + } else { + amt = Number(arg1) || 0; + opt = typeof arg2 === 'object' ? (arg2 || {}) : { channel: arg2 || 'WECHAT' }; + uid = Number(arg3) || 1001; + } + + const payload = typeof opt === 'string' + ? { amount: amt, channel: opt } + : { amount: amt, ...opt }; + const res = await http.post(`/users/${uid}/withdraw`, payload); return res; } catch (err) { console.warn('[API] 提现申请接口异常:', err.message); @@ -977,19 +994,3 @@ export async function getDistributionRecords(userId = 1001) { return []; } } - -/** - * 佣金提现申请 - */ -export async function withdrawCommission(amount, channel = 'WECHAT', userId = 1001) { - try { - const res = await http.post(`/users/${userId}/withdraw`, { amount, channel }); - return res; - } catch (err) { - console.warn('[API] 佣金提现申请异常:', err.message); - throw err; - } -} - - - diff --git a/pwuniapp/pages/user/index.vue b/pwuniapp/pages/user/index.vue index affc163..6037daa 100644 --- a/pwuniapp/pages/user/index.vue +++ b/pwuniapp/pages/user/index.vue @@ -38,6 +38,8 @@ + + {{ isLoggedIn ? `UID: ${user.id}` : '登录后享受完整陪伴服务' }} {{ displayPhone }} @@ -276,125 +278,6 @@ - - - - - 佣金收益提现申请 - - - - - - - - - - 微信零钱 - - - 支付宝 - - - 银行卡 - - - - - - - 提现金额 (元) - 可提现 ¥{{ user.commission || '0.00' }} - - - ¥ - - 全部 - - - - - - 资金将通过微信企业付款直达当前绑定微信号零钱钱包,预计 1-24 小时内到账。 - - - - - 支付宝账号 - - - - 收款人真实姓名 - - - - - - - 银行卡卡号 - - - - 开户银行名称 - - - - 持卡人姓名 - - - - - - - - - - - @@ -1275,21 +1158,15 @@ const handleRecharge = async () => { }); }; -const showWithdrawModal = ref(false); const showWithdrawRecordsModal = ref(false); const userWithdrawalsList = ref([]); -const withdrawForm = ref({ - channel: 'WECHAT', - amount: '', - alipayAccount: '', - bankCard: '', - bankName: '', - realName: '' + +const financeRules = computed(() => { + return platformConfigs.value.finance_rules || {}; }); const minWithdrawAmount = computed(() => { - const finRules = platformConfigs.value.finance_rules || {}; - return Number(finRules.minWithdrawAmount) || 50; + return Number(financeRules.value.minWithdrawAmount) || 50; }); const openWithdrawModal = () => { @@ -1299,6 +1176,14 @@ const openWithdrawModal = () => { }); }; +const handleWithdraw = () => { + openWithdrawModal(); +}; + +const navToWithdraw = () => { + openWithdrawModal(); +}; + const openWithdrawRecordsModal = async () => { if (!ensureLoggedIn()) return; try { @@ -1310,88 +1195,6 @@ const openWithdrawRecordsModal = async () => { showWithdrawRecordsModal.value = true; }; -const submitWithdraw = async () => { - const comm = Number(user.value.commission || 0); - const amount = Number(withdrawForm.value.amount || 0); - const minLimit = minWithdrawAmount.value; - - if (isNaN(amount) || amount <= 0) { - uni.showToast({ title: '请输入有效的提现金额', icon: 'none' }); - return; - } - if (amount < minLimit) { - uni.showToast({ title: `提现金额须满 ¥${minLimit} 起提`, icon: 'none' }); - return; - } - if (amount > comm) { - uni.showToast({ title: '提现金额超出可提余额', icon: 'none' }); - return; - } - if (amount > 20000) { - uni.showToast({ title: '单笔提现最高 ¥20000', icon: 'none' }); - return; - } - - // 渠道账号校验 - if (withdrawForm.value.channel === 'ALIPAY') { - if (!withdrawForm.value.alipayAccount.trim()) { - uni.showToast({ title: '请输入支付宝账号', icon: 'none' }); - return; - } - if (!withdrawForm.value.realName.trim()) { - uni.showToast({ title: '请输入真实姓名', icon: 'none' }); - return; - } - } else if (withdrawForm.value.channel === 'BANK') { - if (!withdrawForm.value.bankCard.trim()) { - uni.showToast({ title: '请输入银行卡号', icon: 'none' }); - return; - } - if (!withdrawForm.value.bankName.trim()) { - uni.showToast({ title: '请输入开户行全称', icon: 'none' }); - return; - } - if (!withdrawForm.value.realName.trim()) { - uni.showToast({ title: '请输入持卡人姓名', icon: 'none' }); - return; - } - } - - try { - uni.showLoading({ title: '正在提交申请...' }); - const payload = { - channel: withdrawForm.value.channel, - alipayAccount: withdrawForm.value.alipayAccount.trim(), - bankCard: withdrawForm.value.bankCard.trim(), - bankName: withdrawForm.value.bankName.trim(), - realName: withdrawForm.value.realName.trim() - }; - const result = await withdrawCommission(user.value.id || 1001, amount, payload); - uni.hideLoading(); - if (result && result.commission !== undefined) { - user.value.commission = result.commission; - } else { - user.value.commission = Math.max(0, comm - amount).toFixed(2); - } - showWithdrawModal.value = false; - uni.showToast({ - title: '提现申请已提交', - icon: 'success', - duration: 2000 - }); - } catch (err) { - uni.hideLoading(); - uni.showToast({ - title: err.message || '提现申请失败', - icon: 'none' - }); - } -}; - -const handleWithdraw = () => { - openWithdrawModal(); -}; - // 手机号脱敏展示 const displayPhone = computed(() => { const phone = user.value.phone; @@ -3682,5 +3485,7 @@ const navTo = (url) => { } } } +} + diff --git a/server/tests/content-security.spec.ts b/server/tests/content-security.spec.ts index bd9fe3d..938fdd9 100644 --- a/server/tests/content-security.spec.ts +++ b/server/tests/content-security.spec.ts @@ -628,14 +628,14 @@ describe('ContentSecurityService & Compliance Architecture (TDD 微信内容安 expect(wsContent).toContain('showWithdrawRecordsModal'); }); - it('前端用户中心 (user/index.vue) 必须支持多渠道提现与提现记录看板', () => { + it('前端用户中心 (user/index.vue) 必须支持多渠道提现路由跳转与提现记录看板', () => { const userPath = path.join(rootDir, 'pwuniapp', 'pages', 'user', 'index.vue'); const userContent = fs.readFileSync(userPath, 'utf-8'); expect(userContent).toContain('openWithdrawModal'); expect(userContent).toContain('openWithdrawRecordsModal'); - expect(userContent).toContain('showWithdrawModal'); + expect(userContent).toContain('/pages/user/withdraw'); expect(userContent).toContain('showWithdrawRecordsModal'); - expect(userContent).toContain('withdrawForm'); + expect(userContent).toContain('userWithdrawalsList'); }); it('前端动态广场与大神主页必须分别提供本人动态删除与评价回复感谢老板', () => {