- - + + @@ -253,4 +253,5 @@ + diff --git a/miniprogram/pages/read/read.js b/miniprogram/pages/read/read.js index 7c419fc4..d489a976 100644 --- a/miniprogram/pages/read/read.js +++ b/miniprogram/pages/read/read.js @@ -77,20 +77,29 @@ Page({ // 余额(用于余额支付) walletBalance: 0, + + // 审核模式:隐藏购买按钮 + auditMode: false, + }, + + onShow() { + this.setData({ auditMode: app.globalData.auditMode || false }) }, async onLoad(options) { wx.showShareMenu({ menus: ['shareAppMessage', 'shareTimeline'] }) - // 预加载 linkTags、linkedMiniprograms(供 onLinkTagTap 用密钥查 appId) - if (!app.globalData.linkTagsConfig || !app.globalData.linkedMiniprograms) { - app.request({ url: '/api/miniprogram/config', silent: true }).then(cfg => { - if (cfg) { - if (Array.isArray(cfg.linkTags)) app.globalData.linkTagsConfig = cfg.linkTags - if (Array.isArray(cfg.linkedMiniprograms)) app.globalData.linkedMiniprograms = cfg.linkedMiniprograms - } - }).catch(() => {}) - } + // 预加载 config:linkTags、auditMode 等(阅读页直接进入时需主动拉取最新审核状态) + app.request({ url: '/api/miniprogram/config', silent: true }).then(cfg => { + if (cfg) { + if (Array.isArray(cfg.linkTags)) app.globalData.linkTagsConfig = cfg.linkTags + if (Array.isArray(cfg.linkedMiniprograms)) app.globalData.linkedMiniprograms = cfg.linkedMiniprograms + const mp = (cfg && cfg.mpConfig) || {} + const auditMode = !!mp.auditMode + app.globalData.auditMode = auditMode + if (typeof this.setData === 'function') this.setData({ auditMode }) + } + }).catch(() => {}) // 支持 scene(扫码)、mid、id、ref、gift(代付) const sceneStr = (options && options.scene) || '' @@ -749,6 +758,33 @@ Page({ }) }, + // 右下角悬浮按钮:分享到朋友圈(复制文案 + 引导点右上角) + shareToMoments() { + const title = this.data.section?.title || this.data.chapterTitle || '好文推荐' + const raw = (this.data.content || '') + .replace(/<[^>]+>/g, '\n') + .replace(/ /g, ' ') + .replace(/</g, '<').replace(/>/g, '>').replace(/&/g, '&').replace(/"/g, '"') + .replace(/[#@]\S+/g, '') + const sentences = raw.split(/[。!?\n]+/).map(s => s.trim()).filter(s => s.length > 4) + const picked = sentences.slice(0, 5) + const copyText = picked.length > 0 ? title + '\n\n' + picked.join('\n\n') : `🔥 刚看完这篇《${title}》,推荐给你!\n\n#Soul创业派对 #真实商业故事` + wx.setClipboardData({ + data: copyText, + success: () => { + wx.showModal({ + title: '文案已复制', + content: '请点击右上角「···」菜单,选择「分享到朋友圈」即可发布', + showCancel: false, + confirmText: '知道了' + }) + }, + fail: () => { + wx.showToast({ title: '复制失败,请手动复制', icon: 'none' }) + } + }) + }, + // 分享到朋友圈:带文章标题,过长时截断 onShareTimeline() { const { section, sectionId, sectionMid, chapterTitle } = this.data diff --git a/miniprogram/pages/read/read.wxml b/miniprogram/pages/read/read.wxml index a1542697..fa7e89be 100644 --- a/miniprogram/pages/read/read.wxml +++ b/miniprogram/pages/read/read.wxml @@ -93,11 +93,14 @@ 🖼️ 生成海报 - + 🎁 代付分享 + @@ -169,8 +172,8 @@ 解锁完整内容 已阅读50%,购买后继续阅读 - - + + 购买本章 @@ -189,10 +192,11 @@ + 审核中,暂不支持购买 - 分享给好友一起学习,还能赚取佣金 - - + 分享给好友一起学习,还能赚取佣金 + + 🎁 找好友代付 @@ -306,8 +310,9 @@