From ae9ed6c2b988928175d02caebb83ad61b866ceb2 Mon Sep 17 00:00:00 2001
From: Zhou Weidong <502333560@qq.com>
Date: Fri, 13 Nov 2026 13:43:16 +0800
Subject: [PATCH] =?UTF-8?q?feat(commerce):=20=E5=AE=8C=E6=88=90=E5=A5=96?=
=?UTF-8?q?=E5=8A=B1=E4=BB=BB=E5=8A=A1=E7=AE=A1=E7=90=86=E9=A1=B5=E9=9D=A2?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
public/indonesia/app.js | 2 +
public/indonesia/data.js | 2 +
public/indonesia/index.html | 78 +-
public/indonesia/styles.css | 4 +
src/api/admin/reward.ts | 43 +
src/styles/business/index.css | 1 +
src/styles/business/reward.css | 205 +++++
.../commerce/RewardTaskManagementView.vue | 777 +++++-------------
.../components/RewardActivityEditorDrawer.vue | 119 +++
.../components/RewardActivityPane.vue | 90 ++
.../commerce/components/RewardGrantPane.vue | 69 ++
.../commerce/components/RewardRulePane.vue | 33 +
.../components/RewardTaskEditorDrawer.vue | 168 ++++
.../commerce/components/RewardTaskPane.vue | 132 +++
.../composables/useRewardManagement.js | 457 ++++++++++
15 files changed, 1542 insertions(+), 638 deletions(-)
create mode 100644 public/indonesia/app.js
create mode 100644 public/indonesia/data.js
create mode 100644 public/indonesia/styles.css
create mode 100644 src/styles/business/reward.css
create mode 100644 src/views/commerce/components/RewardActivityEditorDrawer.vue
create mode 100644 src/views/commerce/components/RewardActivityPane.vue
create mode 100644 src/views/commerce/components/RewardGrantPane.vue
create mode 100644 src/views/commerce/components/RewardRulePane.vue
create mode 100644 src/views/commerce/components/RewardTaskEditorDrawer.vue
create mode 100644 src/views/commerce/components/RewardTaskPane.vue
create mode 100644 src/views/commerce/composables/useRewardManagement.js
diff --git a/public/indonesia/app.js b/public/indonesia/app.js
new file mode 100644
index 0000000..1b1c701
--- /dev/null
+++ b/public/indonesia/app.js
@@ -0,0 +1,2 @@
+// Author: fruit.com.cn
+(function(){'use strict';const d=window.YMB_DATA,s={genre:'Semua',query:''},grid=document.querySelector('#video-grid'),toast=document.querySelector('#toast');const notify=(m)=>{toast.textContent=m;toast.classList.add('show');setTimeout(()=>toast.classList.remove('show'),1600)};const render=()=>{document.querySelector('#genre-nav').innerHTML=d.genres.slice(1).map((g)=>`${g}`).join('');document.querySelector('#filter-chips').innerHTML=d.genres.map((g)=>``).join('');const rows=d.videos.filter((v)=>(s.genre==='Semua'||v[2]===s.genre)&&(!s.query||v.join(' ').toLowerCase().includes(s.query)));grid.innerHTML=rows.map((v,i)=>`
${v[4]} `).join('')||'
Belum ada drama yang cocok.
';document.querySelector('#shorts-row').innerHTML=d.shorts.map((v)=>`
${v[0]}`).join('');document.querySelector('#channel-grid').innerHTML=d.channels.map((v)=>`${v[2]}`).join('')};document.addEventListener('click',(e)=>{const g=e.target.closest('[data-genre]');if(g){e.preventDefault();s.genre=g.dataset.genre;render()}const p=e.target.closest('[data-play]');if(p)notify(`Memutar: ${p.dataset.play}`);const f=e.target.closest('[data-follow]');if(f){f.textContent=f.textContent==='Ikuti'?'Mengikuti':'Ikuti';notify(f.textContent==='Mengikuti'?'Channel ditambahkan':'Channel dihapus')}if(e.target.closest('#menu-toggle'))document.querySelector('#sidebar').classList.toggle('open')});document.querySelector('#search-form').addEventListener('submit',(e)=>{e.preventDefault();s.query=document.querySelector('#global-search').value.trim().toLowerCase();render()});document.querySelector('#global-search').addEventListener('focus',()=>document.querySelector('#search-form').classList.add('open'));render()}());
diff --git a/public/indonesia/data.js b/public/indonesia/data.js
new file mode 100644
index 0000000..55c13bd
--- /dev/null
+++ b/public/indonesia/data.js
@@ -0,0 +1,2 @@
+// Author: fruit.com.cn
+window.YMB_DATA={genres:['Semua','Romansa','Balas dendam','Keluarga','Rahasia','Kisah kedua'],videos:[['Pernikahan yang Tak Terduga','YMB Originals','Romansa','wedding.jpg','12:48'],['Rahasia di Balik Senyuman','Cerita Senja','Rahasia','secret.jpg','09:32'],['Pewaris yang Kembali','Drama Pilihan','Keluarga','heir.jpg','15:20'],['Kesempatan Kedua untuk Kita','YMB Originals','Kisah kedua','second-chance.jpg','11:04'],['Cinta Setelah Balas Dendam','Cerita Senja','Balas dendam','revenge.jpg','13:40'],['Sahabat yang Selalu Ada','Drama Pilihan','Keluarga','friends.jpg','08:16'],['Kota Kecil, Rahasia Besar','YMB Originals','Rahasia','hero.jpg','10:12'],['Satu Janji Terakhir','Drama Pilihan','Romansa','romance.jpg','07:55']],shorts:[['Dia kembali setelah 5 tahun','second-chance.jpg'],['Ketika rahasia terbongkar','secret.jpg'],['Satu pesan yang mengubah semuanya','romance.jpg'],['Jangan percaya senyumnya','revenge.jpg'],['Pewaris tanpa nama','heir.jpg'],['Hari pernikahan itu','wedding.jpg']],channels:[['YMB Originals','2,4 jt pengikut','Y','#ca4d43'],['Cerita Senja','986 rb pengikut','C','#5c4aa1'],['Drama Pilihan','742 rb pengikut','D','#2e7d71'],['Kisah Hari Ini','428 rb pengikut','K','#a06a39']]};
diff --git a/public/indonesia/index.html b/public/indonesia/index.html
index 6855f8a..8697208 100644
--- a/public/indonesia/index.html
+++ b/public/indonesia/index.html
@@ -1,72 +1,38 @@
-
-
-
- FruitShorts · Drama pendek pilihanmu
+
+
+ YMB · Cerita pendek, emosi besar
-
-
-
-
-
-
-
- Langsung ke konten
-
-
-
+
+
+ YMB ORIGINALCerita pendek,
emosi besar.
Temukan drama yang bikin kamu terus menonton. Episode baru setiap hari.
+
+
+ CHANNEL UNTUKMU
Ikuti cerita favoritmu
Kelola →
+
-
-
-
+
+
+
diff --git a/public/indonesia/styles.css b/public/indonesia/styles.css
new file mode 100644
index 0000000..25dde05
--- /dev/null
+++ b/public/indonesia/styles.css
@@ -0,0 +1,4 @@
+/* Author: fruit.com.cn */
+:root{--bg:#0f0f0f;--surface:#181818;--line:#303030;--text:#f1f1f1;--muted:#aaa;--accent:#ff4b3e;--sidebar:230px}*{box-sizing:border-box}body{margin:0;background:var(--bg);color:var(--text);font:14px Arial,sans-serif}a{color:inherit;text-decoration:none}button,input{font:inherit}.topbar{height:64px;position:sticky;top:0;z-index:3;display:flex;align-items:center;gap:24px;padding:0 28px;background:#0f0f0ff2;border-bottom:1px solid #222}.brand{display:flex;align-items:center;gap:8px;font-size:26px;font-weight:700;min-width:150px}.brand-symbol{display:grid;place-items:center;width:28px;height:28px;border-radius:8px;background:var(--accent);font-size:12px}.search-form{display:flex;max-width:620px;flex:1;margin:auto}.search-form input{width:100%;height:40px;padding:0 16px;border:1px solid #3b3b3b;border-radius:22px 0 0 22px;background:#121212;color:#fff}.search-form button{width:54px;border:1px solid #3b3b3b;border-left:0;border-radius:0 22px 22px 0;background:#282828;color:#fff;font-size:24px}.top-actions{display:flex;align-items:center;gap:10px}.icon-button{border:0;background:transparent;color:#fff;font-size:22px;cursor:pointer}.profile-chip{border:0;border-radius:50%;width:32px;height:32px;background:#d45a68;color:#fff}.sidebar{position:fixed;top:64px;bottom:0;width:var(--sidebar);padding:20px 12px;background:var(--bg);border-right:1px solid #222}.main-nav,.genre-nav{display:grid;gap:4px}.nav-item,.genre-nav a{display:flex;gap:18px;align-items:center;padding:11px 14px;border-radius:10px;color:#ccc}.nav-item:hover,.nav-item.active,.genre-nav a:hover{background:#272727;color:#fff}.nav-item span{width:18px;text-align:center;font-size:20px}.nav-item b{font-weight:400}.nav-rule{height:1px;background:var(--line);margin:18px 10px}.nav-label{padding:0 14px;color:#888;font-size:11px;text-transform:uppercase;letter-spacing:.1em}.sidebar-footer{position:absolute;bottom:24px;padding:0 14px;color:#666;font-size:11px;line-height:1.8}.content{max-width:1500px;padding:28px 34px 80px calc(var(--sidebar) + 34px);margin:auto}.hero-card{position:relative;min-height:350px;overflow:hidden;border-radius:18px;background:#27191a;margin-bottom:44px}.hero-copy{position:relative;z-index:1;width:52%;padding:54px}.eyebrow{color:#ff786f;font-size:11px;font-weight:700;letter-spacing:.16em}.hero-copy h1{margin:12px 0;font-size:56px;line-height:.98}.hero-copy h1 em{color:#ff786f;font-style:normal}.hero-copy p{max-width:390px;color:#ccc;line-height:1.7}.hero-art{position:absolute;inset:0 0 0 40%}.hero-art img{width:100%;height:100%;object-fit:cover}.hero-gradient{position:absolute;inset:0;background:linear-gradient(90deg,#27191a,rgba(39,25,26,.75) 26%,transparent 80%)}.hero-actions{display:flex;gap:10px}.primary-button,.ghost-button,.chip{border:0;border-radius:22px;padding:11px 17px;cursor:pointer;font-weight:600}.primary-button{background:#fff;color:#111}.ghost-button,.chip{background:#2b2b2b;color:#fff}.section-block{margin-bottom:46px}.section-heading{display:flex;justify-content:space-between;align-items:end;margin-bottom:17px}.section-heading h2{margin:7px 0 0;font-size:24px}.see-all{color:#ff8a82;font-size:13px}.chip-row{display:flex;gap:8px;overflow:auto;margin-bottom:18px}.chip.active,.chip:hover{background:#fff;color:#111}.video-grid{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:24px 16px}.thumb{position:relative;aspect-ratio:16/9;overflow:hidden;border-radius:10px;background:#222}.thumb img,.short-card img{width:100%;height:100%;object-fit:cover}.duration{position:absolute;right:7px;bottom:7px;padding:3px 6px;background:#000c;border-radius:4px;font-size:11px}.video-meta{display:flex;gap:9px;padding-top:9px}.channel-avatar{display:grid;place-items:center;flex:none;width:32px;height:32px;border-radius:50%;background:#734c67;font-weight:700}.video-title{margin:0;line-height:1.4;font-weight:600}.video-sub{margin:4px 0 0;color:#999;font-size:11px;line-height:1.45}.shorts-row{display:grid;grid-template-columns:repeat(6,1fr);gap:14px}.short-card{position:relative;aspect-ratio:9/14;overflow:hidden;border-radius:11px}.short-card:after{content:'';position:absolute;inset:45% 0 0;background:linear-gradient(transparent,#000c)}.short-title{position:absolute;z-index:1;bottom:10px;left:9px;right:9px;font-size:12px;font-weight:600}.channel-grid{display:grid;grid-template-columns:repeat(4,1fr);gap:12px}.channel-card{display:flex;align-items:center;gap:10px;padding:14px;border:1px solid var(--line);border-radius:11px}.channel-card p{margin:0 0 4px;font-weight:600}.channel-card span{color:#888;font-size:11px}.follow-button{margin-left:auto;border:0;border-radius:18px;padding:8px 11px;background:#fff;color:#111}.bottom-nav,.mobile-only{display:none}.toast{position:fixed;left:50%;bottom:24px;transform:translate(-50%,20px);opacity:0;background:#fff;color:#111;padding:11px 16px;border-radius:7px;transition:.2s}.toast.show{opacity:1;transform:translate(-50%,0)}
+@media(max-width:1100px){.video-grid{grid-template-columns:repeat(3,1fr)}.shorts-row{grid-template-columns:repeat(5,1fr)}.channel-grid{grid-template-columns:repeat(2,1fr)}}
+@media(max-width:760px){.topbar{height:58px;padding:0 14px;gap:12px}.mobile-only{display:block}.desktop-only,.sidebar{display:none}.brand{min-width:auto;font-size:23px}.search-form{position:absolute;top:65px;left:14px;right:14px;display:none}.search-form.open{display:flex}.content{padding:20px 14px 90px}.hero-card{min-height:420px;margin:0 -14px 36px;border-radius:0;display:flex;align-items:flex-end}.hero-copy{width:100%;padding:24px}.hero-copy h1{font-size:42px}.hero-art{inset:0}.hero-gradient{background:linear-gradient(0deg,#27191a,rgba(39,25,26,.45) 55%,transparent)}.section-heading h2{font-size:21px}.video-grid{grid-template-columns:repeat(2,1fr);gap:22px 12px}.shorts-row{display:flex;overflow:auto;margin-right:-14px}.short-card{flex:0 0 130px}.channel-grid{grid-template-columns:1fr}.bottom-nav{position:fixed;display:flex;justify-content:space-around;align-items:center;left:0;right:0;bottom:0;height:66px;z-index:3;background:#151515;border-top:1px solid #292929}.bottom-nav a{display:grid;place-items:center;gap:4px;color:#aaa;font-size:10px}.bottom-nav span{font-size:20px}.bottom-nav .active{color:#fff}.bottom-nav .active span{color:var(--accent)}}
diff --git a/src/api/admin/reward.ts b/src/api/admin/reward.ts
index 75effc7..19938a9 100644
--- a/src/api/admin/reward.ts
+++ b/src/api/admin/reward.ts
@@ -47,6 +47,37 @@ export interface RewardTaskPageParams {
export type RewardTaskSaveData = Omit
+export interface RewardActivityItem {
+ id: string
+ code: string
+ coverUrl: string
+ actionType: string
+ actionUrl: string
+ titleId: string
+ titleEn: string
+ titleZh: string
+ summaryId: string
+ summaryEn: string
+ summaryZh: string
+ ctaId: string
+ ctaEn: string
+ ctaZh: string
+ sort: number
+ status: number
+ statusText: string
+ startAt?: string
+ endAt?: string
+}
+
+export interface RewardActivityPageParams {
+ pageIndex?: number
+ pageSize?: number
+ keyword?: string
+ status?: number
+}
+
+export type RewardActivitySaveData = Omit
+
export interface RewardRuleDay {
dayIndex: number
rewardCoin: number
@@ -80,6 +111,18 @@ export const updateRewardTaskApi = (id: string, data: RewardTaskSaveData) =>
export const updateRewardTaskStatusApi = (id: string, status: number) =>
request.put({ url: `/admin/rewards/tasks/${id}/status`, params: { status } })
+export const pageRewardActivitiesApi = (params: RewardActivityPageParams) =>
+ request.get>({ url: '/admin/rewards/activities/page', params })
+
+export const createRewardActivityApi = (data: RewardActivitySaveData) =>
+ request.post({ url: '/admin/rewards/activities', data })
+
+export const updateRewardActivityApi = (id: string, data: RewardActivitySaveData) =>
+ request.put({ url: `/admin/rewards/activities/${id}`, data })
+
+export const updateRewardActivityStatusApi = (id: string, status: number) =>
+ request.put({ url: `/admin/rewards/activities/${id}/status`, params: { status } })
+
export const getRewardRulesApi = () =>
request.get({ url: '/admin/rewards/check-in/rules' })
diff --git a/src/styles/business/index.css b/src/styles/business/index.css
index 415def2..5b52c3e 100644
--- a/src/styles/business/index.css
+++ b/src/styles/business/index.css
@@ -6,6 +6,7 @@
@import './operation-log.css';
@import './app-user-management.css';
@import './console.css';
+@import './reward.css';
@import './creator-center.css';
@import './layout.css';
@import './menu.css';
diff --git a/src/styles/business/reward.css b/src/styles/business/reward.css
new file mode 100644
index 0000000..c1319c7
--- /dev/null
+++ b/src/styles/business/reward.css
@@ -0,0 +1,205 @@
+/* 奖励中心后台:任务、活动、签到与发放记录统一版式。 */
+
+.reward-panel {
+ padding: 16px 20px 20px;
+}
+
+.reward-navigation {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ gap: 16px;
+ padding-bottom: 16px;
+ border-bottom: 1px solid var(--el-border-color-lighter);
+}
+
+.reward-primary-navigation {
+ display: inline-flex;
+ padding: 3px;
+ border-radius: 8px;
+ background: var(--el-fill-color-light);
+}
+
+.reward-navigation-button {
+ min-width: 104px;
+ height: 34px;
+ padding: 0 18px;
+ border: 0;
+ border-radius: 6px;
+ color: var(--el-text-color-secondary);
+ background: transparent;
+ font-size: 14px;
+ line-height: 34px;
+ cursor: pointer;
+ transition:
+ color 0.2s ease,
+ background-color 0.2s ease,
+ box-shadow 0.2s ease;
+}
+
+.reward-navigation-button:hover {
+ color: var(--el-text-color-primary);
+}
+
+.reward-navigation-button.is-active {
+ color: var(--el-color-primary);
+ background: var(--el-bg-color);
+ box-shadow: 0 1px 3px rgb(0 0 0 / 8%);
+ font-weight: 600;
+}
+
+.reward-secondary-navigation {
+ display: flex;
+ align-items: center;
+ gap: 8px;
+}
+
+.reward-toolbar {
+ display: flex;
+ align-items: center;
+ flex-wrap: wrap;
+ gap: 8px;
+ margin: 16px 0 14px;
+}
+
+.reward-toolbar .reward-keyword {
+ flex: 0 1 280px;
+ width: 280px;
+}
+
+.reward-toolbar .reward-filter {
+ flex: 0 0 148px;
+ width: 148px;
+}
+
+.sub-copy {
+ margin-top: 4px;
+ color: var(--el-text-color-secondary);
+ font-size: 12px;
+}
+
+.reward-pagination {
+ display: flex;
+ justify-content: flex-end;
+ margin-top: 16px;
+ padding-top: 14px;
+ border-top: 1px solid var(--el-border-color-lighter);
+}
+
+.reward-tab-footer {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ gap: 16px;
+ margin-top: 18px;
+}
+
+.reward-hint,
+.rule-card small {
+ color: var(--el-text-color-secondary);
+ font-size: 13px;
+}
+
+.rule-grid {
+ display: grid;
+ grid-template-columns: repeat(7, minmax(100px, 1fr));
+ gap: 12px;
+}
+
+.rule-card {
+ display: grid;
+ gap: 8px;
+ padding: 14px;
+ border: 1px solid var(--el-border-color-light);
+ border-radius: 10px;
+ background: var(--el-fill-color-lighter);
+}
+
+.reward-editor-drawer .el-drawer__header {
+ margin-bottom: 8px;
+}
+
+.reward-editor-drawer .el-drawer__body {
+ padding-top: 8px;
+}
+
+.reward-editor-form {
+ padding: 0 4px 20px;
+}
+
+.reward-editor-section + .reward-editor-collapse {
+ margin-top: 18px;
+}
+
+.reward-editor-section h3 {
+ margin: 0 0 14px;
+ color: var(--el-text-color-primary);
+ font-size: 15px;
+}
+
+.reward-editor-grid {
+ display: grid;
+ gap: 12px;
+}
+
+.reward-editor-grid--two {
+ grid-template-columns: repeat(2, minmax(0, 1fr));
+}
+
+.reward-editor-grid--three {
+ grid-template-columns: repeat(3, minmax(0, 1fr));
+}
+
+.reward-editor-grid .el-input-number,
+.reward-editor-grid .el-select,
+.reward-editor-grid .el-date-editor {
+ width: 100%;
+}
+
+.reward-editor-collapse {
+ border-top: 1px solid var(--el-border-color-lighter);
+ border-bottom: 1px solid var(--el-border-color-lighter);
+}
+
+.reward-editor-footer {
+ display: flex;
+ justify-content: flex-end;
+ gap: 8px;
+}
+
+@media (max-width: 1100px) {
+ .rule-grid {
+ grid-template-columns: repeat(4, minmax(100px, 1fr));
+ }
+}
+
+@media (max-width: 720px) {
+ .reward-navigation {
+ align-items: stretch;
+ flex-direction: column;
+ }
+
+ .reward-primary-navigation,
+ .reward-secondary-navigation {
+ width: 100%;
+ }
+
+ .reward-navigation-button {
+ flex: 1;
+ }
+
+ .reward-secondary-navigation .el-button {
+ flex: 1;
+ }
+
+ .reward-editor-grid--three,
+ .reward-editor-grid--two {
+ grid-template-columns: 1fr;
+ }
+
+ .reward-toolbar .reward-keyword,
+ .reward-toolbar .reward-filter {
+ flex: 1 1 100%;
+ width: 100%;
+ }
+}
diff --git a/src/views/commerce/RewardTaskManagementView.vue b/src/views/commerce/RewardTaskManagementView.vue
index 2be1256..46e8022 100644
--- a/src/views/commerce/RewardTaskManagementView.vue
+++ b/src/views/commerce/RewardTaskManagementView.vue
@@ -1,616 +1,229 @@
-
+
新建任务
+ 新建任务
+
+
+ 新建活动
+
人工补发
+ 人工补发
+
-
-
-
-
-
-
-
- 查询重置
-
-
-
- {{ row.titleId }}{{ row.titleZh || row.titleEn }}
- {{
- optionLabel(typeOptions, row.type)
- }}
- {{
- optionLabel(sectionOptions, row.sectionCode)
- }}
- {{ formatCount(row.targetValue) }} / +{{ formatCount(row.rewardCoin) }}
- {{
- optionLabel(cycleOptions, row.cycleType)
- }}
- {{
- row.statusText
- }}
- 编辑{{ row.status === 1 ? '下线' : '上线' }}
-
-
-
-
-
-
+
+
+
+
保存签到规则
-
+ 签到规则
+
+
+ 发放记录
+
+
+
-
- 查询
-
- +{{ formatCount(row.amount) }}{{
- dateCell(row.grantedAt || row.createdAt)
- }}
-
-
-
-
+
+
+
+
-
-
-
- 多语言文案
-
-
- 动作与扩展
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
- 取消保存
+
+ 取消
+ 确认补发
+
-
- 取消确认补发
-
-
diff --git a/src/views/commerce/components/RewardActivityEditorDrawer.vue b/src/views/commerce/components/RewardActivityEditorDrawer.vue
new file mode 100644
index 0000000..fcd8624
--- /dev/null
+++ b/src/views/commerce/components/RewardActivityEditorDrawer.vue
@@ -0,0 +1,119 @@
+
+
+
+
+
+
+
+
+ 基础设置
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/views/commerce/components/RewardActivityPane.vue b/src/views/commerce/components/RewardActivityPane.vue
new file mode 100644
index 0000000..2f1e53c
--- /dev/null
+++ b/src/views/commerce/components/RewardActivityPane.vue
@@ -0,0 +1,90 @@
+
+
+
+
+
+
+
+
+
+
+
+ 搜索
+ 清空筛选
+
+
+
+
+
+ {{ row.titleId }}{{ row.titleZh || row.titleEn || '未填写其他语言' }}
+
+
+
+
+ {{
+ row.statusText
+ }}
+
+
+
+ 编辑
+ {{ row.status === 1 ? '下线' : '上线' }}
+
+
+
+
+
diff --git a/src/views/commerce/components/RewardGrantPane.vue b/src/views/commerce/components/RewardGrantPane.vue
new file mode 100644
index 0000000..943b406
--- /dev/null
+++ b/src/views/commerce/components/RewardGrantPane.vue
@@ -0,0 +1,69 @@
+
+
+
+
+
+
+
+
+
+
+
+
+ 搜索
+ 清空筛选
+
+
+
+
+ +{{ formatCount(row.amount) }}
+
+
+
+ {{
+ dateCell(row.grantedAt || row.createdAt)
+ }}
+
+
+
diff --git a/src/views/commerce/components/RewardRulePane.vue b/src/views/commerce/components/RewardRulePane.vue
new file mode 100644
index 0000000..e6c16ad
--- /dev/null
+++ b/src/views/commerce/components/RewardRulePane.vue
@@ -0,0 +1,33 @@
+
+
+
+
+
+
+
+ 第 {{ day.dayIndex }} 天
+
+ 金币
+
+
+
+
diff --git a/src/views/commerce/components/RewardTaskEditorDrawer.vue b/src/views/commerce/components/RewardTaskEditorDrawer.vue
new file mode 100644
index 0000000..e038bf7
--- /dev/null
+++ b/src/views/commerce/components/RewardTaskEditorDrawer.vue
@@ -0,0 +1,168 @@
+
+
+
+
+
+
+
+
+ 基础设置
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/views/commerce/components/RewardTaskPane.vue b/src/views/commerce/components/RewardTaskPane.vue
new file mode 100644
index 0000000..2bb5d0d
--- /dev/null
+++ b/src/views/commerce/components/RewardTaskPane.vue
@@ -0,0 +1,132 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 搜索
+ 清空筛选
+
+
+
+
+
+
+ {{ row.titleId }}
+ {{ row.titleZh || row.titleEn || '未填写其他语言' }}
+
+
+
+ {{ optionLabel(typeOptions, row.type) }}
+
+
+ {{ optionLabel(sectionOptions, row.sectionCode) }}
+
+
+ {{ formatCount(row.targetValue) }} / +{{ formatCount(row.rewardCoin) }}
+
+
+ {{
+ row.statusText
+ }}
+
+
+
+ 编辑
+ {{ row.status === 1 ? '下线' : '上线' }}
+
+
+
+
+
diff --git a/src/views/commerce/composables/useRewardManagement.js b/src/views/commerce/composables/useRewardManagement.js
new file mode 100644
index 0000000..e838779
--- /dev/null
+++ b/src/views/commerce/composables/useRewardManagement.js
@@ -0,0 +1,457 @@
+// Author: fruit.com.cn
+
+import { onMounted, reactive, ref } from 'vue'
+import { ElMessage } from 'element-plus'
+import { useRbac } from '@/stores/rbac'
+import {
+ createRewardActivityApi,
+ createRewardTaskApi,
+ getRewardRulesApi,
+ manualRewardGrantApi,
+ pageRewardActivitiesApi,
+ pageRewardGrantsApi,
+ pageRewardTasksApi,
+ saveRewardRulesApi,
+ updateRewardActivityApi,
+ updateRewardActivityStatusApi,
+ updateRewardTaskApi,
+ updateRewardTaskStatusApi
+} from '@/api/admin/reward'
+
+/** 奖励中心后台页面状态与操作。 */
+export function useRewardManagement() {
+ const { can } = useRbac()
+ const activeTab = ref('tasks')
+
+ const typeOptions = [
+ ['DAILY_CHECK_IN', '每日签到'],
+ ['WATCH_DURATION', '观看时长'],
+ ['WATCH_EPISODES', '观看集数'],
+ ['FIRST_LOGIN', '首次登录'],
+ ['COMPLETE_PROFILE', '完善资料'],
+ ['FIRST_PURCHASE', '首次购买'],
+ ['FOLLOW_SOCIAL', '关注社交账号'],
+ ['INVITE_FRIEND', '邀请好友'],
+ ['CUSTOM_LINK', '自定义任务']
+ ]
+ const cycleOptions = [
+ ['ONCE', '一次性'],
+ ['DAILY', '每日'],
+ ['WEEKLY', '每周']
+ ]
+ const sectionOptions = [
+ ['CHECK_IN', '签到奖励'],
+ ['DAILY', '每日任务'],
+ ['NEWBIE', '新手任务'],
+ ['ACTIVITY', '活动任务']
+ ]
+ const actionOptions = [
+ ['NONE', '无动作'],
+ ['OPEN_HOME', '打开首页'],
+ ['OPEN_PROFILE', '打开个人资料'],
+ ['OPEN_WALLET', '打开钱包'],
+ ['OPEN_URL', '打开链接']
+ ]
+
+ const tasks = reactive({ rows: [], total: 0, page: 1, size: 10, loading: false })
+ const taskFilters = reactive({
+ keyword: '',
+ type: undefined,
+ sectionCode: undefined,
+ status: undefined
+ })
+ const taskDrawerVisible = ref(false)
+ const taskSaving = ref(false)
+ const editingTaskId = ref(null)
+ const taskForm = reactive(emptyTaskForm())
+
+ const activities = reactive({ rows: [], total: 0, page: 1, size: 10, loading: false })
+ const activityFilters = reactive({ keyword: '', status: undefined })
+ const activityDrawerVisible = ref(false)
+ const activitySaving = ref(false)
+ const editingActivityId = ref(null)
+ const activityForm = reactive(emptyActivityForm())
+
+ const rules = ref([])
+ const rulesLoading = ref(false)
+ const rulesSaving = ref(false)
+ const grants = reactive({
+ rows: [],
+ total: 0,
+ page: 1,
+ size: 10,
+ loading: false,
+ userId: '',
+ status: undefined
+ })
+ const grantVisible = ref(false)
+ const grantSaving = ref(false)
+ const grantForm = reactive({ userId: '', taskId: '', amount: 10, idempotentKey: '', reason: '' })
+ const tabLoaded = { tasks: true, activities: false, rules: false, grants: false }
+
+ function emptyTaskForm() {
+ return {
+ code: '',
+ sectionCode: 'DAILY',
+ type: 'WATCH_DURATION',
+ verifyMode: 'SERVER',
+ targetValue: 1,
+ rewardCoin: 10,
+ cycleType: 'DAILY',
+ cycleLimit: 1,
+ actionType: 'OPEN_HOME',
+ actionUrl: '',
+ iconUrl: '',
+ titleId: '',
+ titleEn: '',
+ titleZh: '',
+ subtitleId: '',
+ subtitleEn: '',
+ subtitleZh: '',
+ ctaId: 'Mulai',
+ ctaEn: 'Start',
+ ctaZh: '去完成',
+ sectionTitleId: 'Tugas harian',
+ sectionTitleEn: 'Daily tasks',
+ sectionTitleZh: '每日任务',
+ configJson: '',
+ sort: 0,
+ startAt: null,
+ endAt: null
+ }
+ }
+
+ function emptyActivityForm() {
+ return {
+ code: '',
+ coverUrl: '',
+ actionType: 'NONE',
+ actionUrl: '',
+ titleId: '',
+ titleEn: '',
+ titleZh: '',
+ summaryId: '',
+ summaryEn: '',
+ summaryZh: '',
+ ctaId: '',
+ ctaEn: '',
+ ctaZh: '',
+ sort: 0,
+ startAt: null,
+ endAt: null
+ }
+ }
+
+ async function loadTasks() {
+ tasks.loading = true
+ try {
+ const res = await pageRewardTasksApi({
+ pageIndex: tasks.page,
+ pageSize: tasks.size,
+ keyword: taskFilters.keyword.trim() || undefined,
+ type: taskFilters.type,
+ sectionCode: taskFilters.sectionCode,
+ status: taskFilters.status
+ })
+ tasks.rows = res.data?.list || []
+ tasks.total = res.data?.total || 0
+ } finally {
+ tasks.loading = false
+ }
+ }
+
+ function queryTasks() {
+ tasks.page = 1
+ loadTasks()
+ }
+
+ function updateTaskFilter(name, value) {
+ taskFilters[name] = value
+ }
+
+ function changeTaskPage(page) {
+ tasks.page = page
+ loadTasks()
+ }
+
+ function resetTaskFilters() {
+ Object.assign(taskFilters, {
+ keyword: '',
+ type: undefined,
+ sectionCode: undefined,
+ status: undefined
+ })
+ queryTasks()
+ }
+
+ function openCreateTask() {
+ editingTaskId.value = null
+ Object.assign(taskForm, emptyTaskForm(), { sort: tasks.total + 1 })
+ taskDrawerVisible.value = true
+ }
+
+ function openEditTask(row) {
+ editingTaskId.value = row.id
+ Object.assign(taskForm, emptyTaskForm(), row)
+ taskDrawerVisible.value = true
+ }
+
+ async function saveTask(data) {
+ if (!data.code?.trim() || !data.titleId?.trim() || !data.sectionTitleId?.trim())
+ return ElMessage.warning('请填写任务编码、印尼语标题和分组标题')
+ if (data.targetValue <= 0 || data.rewardCoin < 0)
+ return ElMessage.warning('目标值和奖励金币不符合要求')
+ taskSaving.value = true
+ try {
+ const payload = {
+ ...data,
+ code: data.code.trim(),
+ titleId: data.titleId.trim(),
+ sectionTitleId: data.sectionTitleId.trim()
+ }
+ if (editingTaskId.value) await updateRewardTaskApi(editingTaskId.value, payload)
+ else await createRewardTaskApi(payload)
+ ElMessage.success(editingTaskId.value ? '任务已更新' : '任务已创建,默认下线')
+ taskDrawerVisible.value = false
+ await loadTasks()
+ } finally {
+ taskSaving.value = false
+ }
+ }
+
+ async function toggleTask(row) {
+ await updateRewardTaskStatusApi(row.id, row.status === 1 ? 0 : 1)
+ ElMessage.success(row.status === 1 ? '任务已下线' : '任务已上线')
+ await loadTasks()
+ }
+
+ async function loadActivities() {
+ activities.loading = true
+ try {
+ const res = await pageRewardActivitiesApi({
+ pageIndex: activities.page,
+ pageSize: activities.size,
+ keyword: activityFilters.keyword.trim() || undefined,
+ status: activityFilters.status
+ })
+ activities.rows = res.data?.list || []
+ activities.total = res.data?.total || 0
+ } finally {
+ activities.loading = false
+ }
+ }
+
+ function queryActivities() {
+ activities.page = 1
+ loadActivities()
+ }
+
+ function updateActivityFilter(name, value) {
+ activityFilters[name] = value
+ }
+
+ function changeActivityPage(page) {
+ activities.page = page
+ loadActivities()
+ }
+
+ function resetActivityFilters() {
+ Object.assign(activityFilters, { keyword: '', status: undefined })
+ queryActivities()
+ }
+
+ function openCreateActivity() {
+ editingActivityId.value = null
+ Object.assign(activityForm, emptyActivityForm(), { sort: activities.total + 1 })
+ activityDrawerVisible.value = true
+ }
+
+ function openEditActivity(row) {
+ editingActivityId.value = row.id
+ Object.assign(activityForm, emptyActivityForm(), row)
+ activityDrawerVisible.value = true
+ }
+
+ async function saveActivity(data) {
+ if (!data.code?.trim() || !data.titleId?.trim())
+ return ElMessage.warning('请填写活动编码和印尼语标题')
+ activitySaving.value = true
+ try {
+ const payload = { ...data, code: data.code.trim(), titleId: data.titleId.trim() }
+ if (editingActivityId.value) await updateRewardActivityApi(editingActivityId.value, payload)
+ else await createRewardActivityApi(payload)
+ ElMessage.success(editingActivityId.value ? '活动已更新' : '活动已创建,默认下线')
+ activityDrawerVisible.value = false
+ await loadActivities()
+ } finally {
+ activitySaving.value = false
+ }
+ }
+
+ async function toggleActivity(row) {
+ await updateRewardActivityStatusApi(row.id, row.status === 1 ? 0 : 1)
+ ElMessage.success(row.status === 1 ? '活动已下线' : '活动已上线')
+ await loadActivities()
+ }
+
+ async function loadRules() {
+ rulesLoading.value = true
+ try {
+ rules.value = (await getRewardRulesApi()).data || []
+ } finally {
+ rulesLoading.value = false
+ }
+ }
+
+ async function saveRules() {
+ rulesSaving.value = true
+ try {
+ await saveRewardRulesApi(
+ rules.value.map(({ dayIndex, rewardCoin }) => ({ dayIndex, rewardCoin }))
+ )
+ ElMessage.success('签到规则已保存')
+ } finally {
+ rulesSaving.value = false
+ }
+ }
+
+ function updateRule(dayIndex, rewardCoin) {
+ const rule = rules.value.find((item) => item.dayIndex === dayIndex)
+ if (rule) rule.rewardCoin = rewardCoin
+ }
+
+ async function loadGrants() {
+ grants.loading = true
+ try {
+ const res = await pageRewardGrantsApi({
+ pageIndex: grants.page,
+ pageSize: grants.size,
+ userId: grants.userId || undefined,
+ status: grants.status
+ })
+ grants.rows = res.data?.list || []
+ grants.total = res.data?.total || 0
+ } finally {
+ grants.loading = false
+ }
+ }
+
+ function queryGrants() {
+ grants.page = 1
+ loadGrants()
+ }
+
+ function updateGrantFilter(name, value) {
+ grants[name] = value
+ }
+
+ function resetGrantFilters() {
+ Object.assign(grants, { userId: '', status: undefined })
+ queryGrants()
+ }
+
+ function changeGrantPage(page) {
+ grants.page = page
+ loadGrants()
+ }
+
+ function openGrant() {
+ Object.assign(grantForm, {
+ userId: grants.userId,
+ taskId: '',
+ amount: 10,
+ idempotentKey: '',
+ reason: ''
+ })
+ grantVisible.value = true
+ }
+
+ async function confirmGrant() {
+ if (!grantForm.userId || grantForm.amount <= 0)
+ return ElMessage.warning('请填写用户 ID 和补发金币')
+ grantSaving.value = true
+ try {
+ await manualRewardGrantApi({
+ ...grantForm,
+ taskId: grantForm.taskId || undefined,
+ idempotentKey: grantForm.idempotentKey || undefined
+ })
+ ElMessage.success('奖励已通过钱包流水补发')
+ grantVisible.value = false
+ await loadGrants()
+ } finally {
+ grantSaving.value = false
+ }
+ }
+
+ function handleTab(name) {
+ if (tabLoaded[name]) return
+ tabLoaded[name] = true
+ if (name === 'activities') loadActivities()
+ if (name === 'rules') loadRules()
+ if (name === 'grants') loadGrants()
+ }
+
+ function optionLabel(options, value) {
+ return options.find((item) => item[0] === value)?.[1] || value || '-'
+ }
+
+ onMounted(loadTasks)
+
+ return {
+ can,
+ activeTab,
+ typeOptions,
+ cycleOptions,
+ sectionOptions,
+ actionOptions,
+ tasks,
+ taskFilters,
+ taskDrawerVisible,
+ taskSaving,
+ editingTaskId,
+ taskForm,
+ activities,
+ activityFilters,
+ activityDrawerVisible,
+ activitySaving,
+ editingActivityId,
+ activityForm,
+ rules,
+ rulesLoading,
+ rulesSaving,
+ grants,
+ grantVisible,
+ grantSaving,
+ grantForm,
+ loadTasks,
+ queryTasks,
+ resetTaskFilters,
+ updateTaskFilter,
+ changeTaskPage,
+ openCreateTask,
+ openEditTask,
+ saveTask,
+ toggleTask,
+ loadActivities,
+ queryActivities,
+ resetActivityFilters,
+ updateActivityFilter,
+ changeActivityPage,
+ openCreateActivity,
+ openEditActivity,
+ saveActivity,
+ toggleActivity,
+ saveRules,
+ updateRule,
+ loadGrants,
+ queryGrants,
+ updateGrantFilter,
+ resetGrantFilters,
+ changeGrantPage,
+ openGrant,
+ confirmGrant,
+ handleTab,
+ optionLabel
+ }
+}