+ + {{auditTip}} + {{auditRejectReason}} + 重新编辑并提交 + {{article.title}} {{article.authorNickname || '超级个体'}} · {{article.createdAtText}} - - - - - 复制 H5 全文链接 - 浏览器或微信内打开可阅读全文,方便分享 + + + + + + + + {{item.src ? '图片加载失败' : '配图缺失或地址无效'}} + + + diff --git a/miniprogram/pages/super-article-detail/super-article-detail.wxss b/miniprogram/pages/super-article-detail/super-article-detail.wxss index 762fdea2..bb3043dc 100644 --- a/miniprogram/pages/super-article-detail/super-article-detail.wxss +++ b/miniprogram/pages/super-article-detail/super-article-detail.wxss @@ -9,6 +9,36 @@ .article-body { padding: 8rpx 24rpx 48rpx; } +.audit-banner { + margin-bottom: 20rpx; + padding: 20rpx 22rpx; + border-radius: 16rpx; + background: rgba(251, 191, 36, 0.08); + border: 1rpx solid rgba(251, 191, 36, 0.28); +} +.audit-banner-main { + display: block; + font-size: 26rpx; + color: #fcd34d; + font-weight: 600; +} +.audit-banner-sub { + display: block; + margin-top: 12rpx; + font-size: 24rpx; + color: rgba(226, 232, 240, 0.88); + line-height: 1.45; +} +.audit-edit-btn { + margin-top: 18rpx; + display: inline-block; + padding: 14rpx 28rpx; + border-radius: 999rpx; + font-size: 24rpx; + font-weight: 600; + color: #0b1220; + background: linear-gradient(135deg, #00ced1, #20b2aa); +} .title { font-size: 36rpx; font-weight: 700; line-height: 1.4; display: block; } .meta { margin-top: 12rpx; font-size: 22rpx; color: #94a3b8; display: block; } .img-gallery { @@ -17,21 +47,34 @@ flex-direction: column; gap: 12rpx; } +.gallery-cell { + width: 100%; +} .article-gallery-img { width: 100%; display: block; - border-radius: 0; + border-radius: 12rpx; + background: rgba(15, 23, 42, 0.6); } -.h5-row { margin-top: 28rpx; padding-top: 0; border-top: none; } -.h5-btn { - display: inline-block; - padding: 12rpx 0; +.gallery-placeholder { + min-height: 220rpx; + margin-top: 0; + border-radius: 12rpx; + border: 2rpx dashed rgba(148, 163, 184, 0.35); + background: rgba(15, 23, 42, 0.55); + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; + gap: 12rpx; + padding: 24rpx; + box-sizing: border-box; +} +.gallery-ph-text { font-size: 24rpx; - font-weight: 600; - color: #22d3ee; - background: transparent; + color: #64748b; + text-align: center; } -.h5-hint { display: block; margin-top: 12rpx; font-size: 20rpx; color: #64748b; line-height: 1.5; } .content { margin-top: 24rpx; font-size: 28rpx; line-height: 1.75; color: #e2e8f0; white-space: pre-wrap; word-break: break-word; diff --git a/miniprogram/pages/super-article-editor/super-article-editor.js b/miniprogram/pages/super-article-editor/super-article-editor.js index c0f616b5..e26b9e50 100644 --- a/miniprogram/pages/super-article-editor/super-article-editor.js +++ b/miniprogram/pages/super-article-editor/super-article-editor.js @@ -27,6 +27,7 @@ Page({ aiPrompt: '', attachedFiles: [], generating: false, + editArticleId: '', }, /** 遮挡层拦截滚动穿透 */ @@ -38,7 +39,12 @@ Page({ return audit }, - onLoad() { + onLoad(options) { + const editId = options && options.id != null ? String(options.id).trim() : '' + if (editId) { + this._pendingEditId = editId + this.setData({ editArticleId: editId }) + } this.setData({ statusBarHeight: app.globalData.statusBarHeight || 44, meNickname: String(app.globalData.userInfo?.nickname || '我').trim() || '我', @@ -72,6 +78,12 @@ Page({ if (!(res?.success && res.data?.isSuperIndividual === true)) { wx.showToast({ title: '仅超级个体可发文章', icon: 'none' }) setTimeout(() => wx.navigateBack(), 400) + return + } + const pid = this._pendingEditId ? String(this._pendingEditId).trim() : '' + if (pid) { + this._pendingEditId = '' + await this.loadArticleForEdit(pid) } } catch (_) { wx.showToast({ title: '身份校验失败', icon: 'none' }) @@ -79,6 +91,40 @@ Page({ } }, + async loadArticleForEdit(id) { + const userId = app.globalData.userInfo?.id + if (!userId) return + wx.showLoading({ title: '加载中…', mask: true }) + try { + const res = await app.request({ + url: `/api/miniprogram/super/articles/${encodeURIComponent(String(id))}?viewerUserId=${encodeURIComponent(String(userId))}`, + silent: true, + }) + const article = res?.data + if (!article) throw new Error('加载失败') + if (String(article.userId) !== String(userId)) throw new Error('无权编辑') + const st = String(article.auditStatus || '').toLowerCase() + if (st !== 'pending' && st !== 'rejected') throw new Error('仅待审核或已驳回的动态可编辑') + const imgs = Array.isArray(article.images) + ? article.images.map((u) => String(u || '').trim()).filter(Boolean) + : [] + const bodyImages = imgs.map((url) => ({ id: newAttachId(), url, uploading: false })) + this.setData({ + editArticleId: String(id), + title: String(article.title || '').trim(), + content: String(article.content || ''), + bodyImages, + }) + } catch (e) { + wx.showToast({ title: (e && e.message) || '加载失败', icon: 'none' }) + setTimeout(() => wx.navigateBack(), 500) + } finally { + try { + wx.hideLoading() + } catch (_) {} + } + }, + onAiPromptInput(e) { this.setData({ aiPrompt: e.detail.value || '' }) }, @@ -455,17 +501,32 @@ Page({ const images = this.data.bodyImages .map((x) => String(x.url || '').trim()) .filter(Boolean) + const editId = String(this.data.editArticleId || '').trim() this.setData({ saving: true }) - wx.showLoading({ title: '发布中…', mask: true }) + wx.showLoading({ title: editId ? '提交中…' : '发布中…', mask: true }) try { - const res = await app.request({ - url: '/api/miniprogram/super/articles', - method: 'POST', - data: { userId, title, content, images }, - }) + let res + if (editId) { + res = await app.request({ + url: `/api/miniprogram/super/articles/${encodeURIComponent(editId)}`, + method: 'PUT', + data: { userId, title, content, images }, + }) + } else { + res = await app.request({ + url: '/api/miniprogram/super/articles', + method: 'POST', + data: { userId, title, content, images }, + }) + } if (!res?.success) throw new Error(res?.error || '发布失败') - this.setData({ title: '', content: '', bodyImages: [] }) - wx.showToast({ title: '发布成功', icon: 'success' }) + if (editId) { + wx.showToast({ title: '已提交审核', icon: 'success' }) + setTimeout(() => wx.navigateBack(), 450) + } else { + this.setData({ title: '', content: '', bodyImages: [] }) + wx.showToast({ title: '已提交审核', icon: 'success' }) + } } catch (e) { wx.showToast({ title: e.message || '发布失败', icon: 'none' }) } finally { diff --git a/miniprogram/pages/super-article-editor/super-article-editor.wxml b/miniprogram/pages/super-article-editor/super-article-editor.wxml index efad0b87..e10107f9 100644 --- a/miniprogram/pages/super-article-editor/super-article-editor.wxml +++ b/miniprogram/pages/super-article-editor/super-article-editor.wxml @@ -3,7 +3,7 @@ - 发文章 + {{editArticleId ? '编辑动态' : '发文章'}}