From 14e399330390ce234c6be5793a4207d75a326915 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8D=A1=E8=8B=A5?= Date: Fri, 23 Jan 2026 22:08:30 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=B0=8F=E7=A8=8B=E5=BA=8F=E4=BD=BF?= =?UTF-8?q?=E7=94=A8=E7=9C=9F=E5=AE=9E=E6=94=AF=E4=BB=98=E5=92=8C=E7=9C=9F?= =?UTF-8?q?=E5=AE=9E=E7=AB=A0=E8=8A=82=E5=86=85=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. 更新AppID为wx0976665c3a3d5a7c 2. 添加微信支付商户号配置(1318592501) 3. 阅读页改为从API读取真实章节内容 4. 移除测试支付模式,直接调用真实支付 5. API失败时显示加载提示而非假内容 --- miniprogram/app.js | 9 ++-- miniprogram/pages/read/read.js | 87 ++++++++++++--------------------- miniprogram/project.config.json | 2 +- 3 files changed, 39 insertions(+), 59 deletions(-) diff --git a/miniprogram/app.js b/miniprogram/app.js index ebd89e9..4fa6930 100644 --- a/miniprogram/app.js +++ b/miniprogram/app.js @@ -5,11 +5,14 @@ App({ globalData: { - // API基础地址 + // API基础地址 - 连接真实后端 baseUrl: 'https://soul.quwanzhi.com', - // 小程序配置 - appId: 'wxb8bbb2b10dec74aa', + // 小程序配置 - 真实AppID + appId: 'wx0976665c3a3d5a7c', + + // 微信支付配置 + mchId: '1318592501', // 商户号 // 用户信息 userInfo: null, diff --git a/miniprogram/pages/read/read.js b/miniprogram/pages/read/read.js index 5be6745..4f88850 100644 --- a/miniprogram/pages/read/read.js +++ b/miniprogram/pages/read/read.js @@ -168,10 +168,10 @@ Page({ return titles[id] || `章节 ${id}` }, - // 加载内容 + // 加载内容 - 从真实API读取章节内容 async loadContent(id) { try { - // 尝试从API获取内容 + // 从API获取真实章节内容 const res = await app.request(`/api/book/chapter/${id}`) if (res && res.content) { const lines = res.content.split('\n').filter(line => line.trim()) @@ -185,50 +185,43 @@ Page({ partTitle: res.partTitle || '', chapterTitle: res.chapterTitle || '' }) + console.log('[Read] 成功加载章节内容:', id) return } } catch (e) { - console.log('API加载失败,使用示例内容') + console.error('[Read] API加载章节失败:', e.message) } - // 使用示例内容 - const sampleContent = this.getSampleContent(id) - const lines = sampleContent.split('\n').filter(line => line.trim()) - const previewCount = Math.ceil(lines.length * 0.2) - + // API失败时显示提示,不使用假内容 this.setData({ - content: sampleContent, - previewContent: lines.slice(0, previewCount).join('\n'), - contentParagraphs: lines, - previewParagraphs: lines.slice(0, previewCount) + content: '章节内容加载中,请稍候...', + previewContent: '章节内容加载中,请稍候...', + contentParagraphs: ['章节内容加载中,请稍候...', '如果长时间无法加载,请检查网络连接后刷新页面。'], + previewParagraphs: ['章节内容加载中,请稍候...'] }) + + // 延迟重试一次 + setTimeout(async () => { + try { + const res = await app.request(`/api/book/chapter/${id}`) + if (res && res.content) { + const lines = res.content.split('\n').filter(line => line.trim()) + const previewCount = Math.ceil(lines.length * 0.2) + this.setData({ + content: res.content, + previewContent: lines.slice(0, previewCount).join('\n'), + contentParagraphs: lines, + previewParagraphs: lines.slice(0, previewCount), + partTitle: res.partTitle || '', + chapterTitle: res.chapterTitle || '' + }) + } + } catch (e) { + console.error('[Read] 重试加载失败:', e.message) + } + }, 2000) }, - // 获取示例内容 - getSampleContent(id) { - return `这是《一场SOUL的创业实验场》的章节内容。 - -在Soul派对房里,每天早上6点到9点,我都会和几百个陌生人分享真实的商业故事。 - -这不是一本教你成功的鸡汤书,而是一本记录真实创业经历的实战手册。 - -我见过太多人在创业路上摔倒,不是因为他们不够努力,而是因为他们不懂得商业的底层逻辑。 - -商业的本质是什么?是流量、是供应链、是人脉,但更重要的是——认知。 - -当你的认知提升了,你才能看到别人看不到的机会。 - -这本书会告诉你: -1. 如何找到真正赚钱的模式 -2. 如何避免常见的创业陷阱 -3. 如何构建自己的商业体系 - -希望这本书能帮助你少走弯路,在创业路上走得更稳、更远。 - -${id === 'preface' || id === 'epilogue' || id.startsWith('appendix') || id === '1.1' - ? '这是免费章节的完整内容。欢迎来到Soul创业实验场!' - : '这是付费章节的预览内容。购买后可查看完整内容。'}` - }, // 加载导航 loadNavigation(id) { @@ -431,24 +424,8 @@ ${id === 'preface' || id === 'epilogue' || id.startsWith('appendix') || id === ' throw new Error(res.error || '创建订单失败') } } catch (apiError) { - console.log('[Pay] API创建订单失败:', apiError.message) - - // 开发环境:API不可用时使用模拟支付 - const useMock = await new Promise((resolve) => { - wx.showModal({ - title: '支付服务暂不可用', - content: '是否使用测试模式完成购买?', - confirmText: '测试购买', - cancelText: '取消', - success: (res) => resolve(res.confirm) - }) - }) - - if (useMock) { - this.mockPaymentSuccess(type, sectionId) - wx.showToast({ title: '测试购买成功', icon: 'success' }) - this.initSection(this.data.sectionId) - } + console.error('[Pay] API创建订单失败:', apiError.message) + wx.showToast({ title: '支付服务暂时不可用,请稍后重试', icon: 'none', duration: 3000 }) this.setData({ isPaying: false }) return } diff --git a/miniprogram/project.config.json b/miniprogram/project.config.json index b7974b8..61dea3f 100644 --- a/miniprogram/project.config.json +++ b/miniprogram/project.config.json @@ -3,7 +3,7 @@ "miniprogramRoot": "", "projectname": "soul-startup", "description": "一场SOUL的创业实验场 - 来自Soul派对房的真实商业故事", - "appid": "wxb8bbb2b10dec74aa", + "appid": "wx0976665c3a3d5a7c", "setting": { "urlCheck": false, "es6": true,