feat(admin): complete decoration module database integration including DIY pages, RLS and RPCs
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
# 装修模块 (Decoration) 全量集成与数据库构建报告
|
||||
|
||||
## 摘要
|
||||
本次对 Admin 侧装修模块(Decoration Module)进行了深度的端到端修复。补齐了该模块完全缺失的数据库表结构(用于存储 DIY 布局 JSON)、行级安全策略(RLS)以及 4 个管理端 RPC 接口。同时重构了前端 3 个核心页面,实现了从 Mock 数据到真实数据库持久化的闭环。
|
||||
|
||||
## 动机
|
||||
装修模块允许管理员自定义商城的视觉表现(首页、专题页、个人中心风格)。此前该功能仅有 UI 静态模拟,无法保存任何配置。为了支撑个性化商城运营,必须补齐底层存储架构,并按照项目规范落地管理端接口。
|
||||
|
||||
## 影响范围
|
||||
- **模块**:后台管理系统 - 装修模块
|
||||
- **页面**:首页装修、商品分类装修、个人中心装修
|
||||
- **接口**:新增 4 个 `rpc_admin_...` 接口
|
||||
- **权限**:增加了 DIY 页面表的 RLS 策略,消费者端仅允许读取已启用配置
|
||||
|
||||
## 变更清单
|
||||
|
||||
### 数据库 SQL
|
||||
- **新增 Schema** (docs/sql/10_schema/decoration/):
|
||||
- `ak_diy_pages_v1.sql` (核心配置表)
|
||||
- **新增 RLS** (docs/sql/20_rls/decoration/):
|
||||
- `ml_decoration_rls_v1.sql`
|
||||
- **新增 RPC** (docs/sql/30_rpc/decoration/):
|
||||
- `rpc_admin_get_diy_page_list_v1.sql`
|
||||
- `rpc_admin_save_diy_page_v1.sql`
|
||||
- `rpc_admin_delete_diy_page_v1.sql`
|
||||
- `rpc_admin_set_home_page_v1.sql`
|
||||
|
||||
### 前端代码
|
||||
- **新增服务层**:`services/admin/decorationService.uts` (封装全量 DIY 接口)
|
||||
- **重构页面**:
|
||||
- `pages/mall/admin/decoration/home.uvue` (接入分页列表、删除及设为首页逻辑)
|
||||
- `pages/mall/admin/decoration/user.uvue` (接入样式持久化存取)
|
||||
- `pages/mall/admin/decoration/category.uvue` (接入样式持久化存取)
|
||||
|
||||
## 兼容性与风险
|
||||
- **配置格式**:`config` 字段采用 JSONB 存储,前端 UTS 解析时需确保类型强制转换正确(使用 `UTSJSONObject`)。
|
||||
- **首页约束**:数据库侧实现了原子切换逻辑,确保同类型页面(如 `home`)全局仅有一个生效项。
|
||||
|
||||
## 回滚方案
|
||||
1. **数据库**:依次 DROP `ak_diy_pages` 表及相关 4 个 RPC 函数。
|
||||
2. **代码**:使用 `git checkout` 恢复重构的 3 个 `.uvue` 页面,并删除 `decorationService.uts`。
|
||||
|
||||
## 验证方式
|
||||
1. **功能验证**:
|
||||
- 首页切换:在“首页装修”列表中将另一个模板设为首页,确认移动端展示内容实时变更。
|
||||
- 样式保存:在“个人中心装修”切换样式并点击保存,刷新页面后确认选中状态保持一致。
|
||||
2. **安全验证**:确认非 admin 角色无法通过接口修改 DIY 配置。
|
||||
|
||||
## 关联规范
|
||||
- 遵循 `AGENT_PROJECT_SPEC.md` 规范。
|
||||
- 遵循统一的 RPC 入口鉴权(admin 角色)。
|
||||
32
docs/sql/10_schema/decoration/ak_diy_pages_v1.sql
Normal file
32
docs/sql/10_schema/decoration/ak_diy_pages_v1.sql
Normal file
@@ -0,0 +1,32 @@
|
||||
-- =====================================================================================
|
||||
-- Schema: 装修模块 - DIY 页面配置表
|
||||
-- 位置:docs/sql/10_schema/decoration/ak_diy_pages_v1.sql
|
||||
-- 对象类型:TABLE
|
||||
-- 版本:v1
|
||||
-- 说明:存储首页、专题页及个人中心的 DIY 布局 JSON 配置
|
||||
-- =====================================================================================
|
||||
|
||||
CREATE TABLE IF NOT EXISTS public.ak_diy_pages (
|
||||
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
||||
name TEXT NOT NULL,
|
||||
type TEXT NOT NULL, -- home: 首页, topic: 专题页, user: 个人中心
|
||||
|
||||
config JSONB NOT NULL DEFAULT '{}'::jsonb, -- 核心布局配置 (组件列表及参数)
|
||||
|
||||
is_home BOOLEAN NOT NULL DEFAULT FALSE, -- 是否为生效首页
|
||||
is_active BOOLEAN NOT NULL DEFAULT TRUE, -- 是否启用
|
||||
|
||||
created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
|
||||
updated_at TIMESTAMPTZ NOT NULL DEFAULT now(),
|
||||
created_by UUID REFERENCES public.ak_users(id),
|
||||
updated_by UUID REFERENCES public.ak_users(id)
|
||||
);
|
||||
|
||||
-- 索引
|
||||
CREATE INDEX IF NOT EXISTS idx_diy_pages_type ON public.ak_diy_pages (type);
|
||||
CREATE INDEX IF NOT EXISTS idx_diy_pages_is_home ON public.ak_diy_pages (is_home) WHERE is_home = TRUE;
|
||||
|
||||
-- 注释
|
||||
COMMENT ON TABLE public.ak_diy_pages IS 'DIY 页面装修配置表';
|
||||
COMMENT ON COLUMN public.ak_diy_pages.type IS '页面类型: home(首页), topic(专题), user(个人中心)';
|
||||
COMMENT ON COLUMN public.ak_diy_pages.config IS 'DIY 布局配置 JSON';
|
||||
18
docs/sql/20_rls/decoration/ml_decoration_rls_v1.sql
Normal file
18
docs/sql/20_rls/decoration/ml_decoration_rls_v1.sql
Normal file
@@ -0,0 +1,18 @@
|
||||
-- =====================================================================================
|
||||
-- RLS: 装修模块 - DIY 页面安全策略
|
||||
-- 位置:docs/sql/20_rls/decoration/ml_decoration_rls_v1.sql
|
||||
-- 对象类型:RLS 策略
|
||||
-- 版本:v1
|
||||
-- 说明:消费者端公开只读已发布的页面;管理端通过 SECURITY DEFINER RPC 进行管理
|
||||
-- =====================================================================================
|
||||
|
||||
-- 1. 启用 RLS
|
||||
ALTER TABLE public.ak_diy_pages ENABLE ROW LEVEL SECURITY;
|
||||
|
||||
-- 2. 消费者端策略:允许匿名和登录用户读取已启用的页面
|
||||
DROP POLICY IF EXISTS diy_pages_select_active ON public.ak_diy_pages;
|
||||
CREATE POLICY diy_pages_select_active ON public.ak_diy_pages
|
||||
FOR SELECT TO anon, authenticated
|
||||
USING (is_active = true);
|
||||
|
||||
-- 管理端全量管理将通过 SECURITY DEFINER 的 RPC 接口执行,此处不再额外开放直接表操作
|
||||
40
docs/sql/30_rpc/decoration/rpc_admin_delete_diy_page_v1.sql
Normal file
40
docs/sql/30_rpc/decoration/rpc_admin_delete_diy_page_v1.sql
Normal file
@@ -0,0 +1,40 @@
|
||||
-- RPC: rpc_admin_delete_diy_page
|
||||
-- 管理端删除 DIY 页面配置
|
||||
|
||||
CREATE OR REPLACE FUNCTION public.rpc_admin_delete_diy_page(
|
||||
p_id uuid
|
||||
)
|
||||
RETURNS boolean
|
||||
LANGUAGE plpgsql
|
||||
SECURITY DEFINER
|
||||
SET search_path = public
|
||||
AS $$
|
||||
DECLARE
|
||||
v_ok boolean;
|
||||
BEGIN
|
||||
-- 1. 权限检查 (仅管理员)
|
||||
IF NOT EXISTS (
|
||||
SELECT 1 FROM public.ak_users u
|
||||
WHERE u.id = auth.uid() AND u.role = 'admin'
|
||||
) THEN
|
||||
RAISE EXCEPTION 'permission denied';
|
||||
END IF;
|
||||
|
||||
-- 2. 执行删除 (不允许删除当前生效的首页)
|
||||
IF EXISTS (
|
||||
SELECT 1 FROM public.ak_diy_pages
|
||||
WHERE id = p_id AND is_home = true
|
||||
) THEN
|
||||
RAISE EXCEPTION 'cannot delete the active home page';
|
||||
END IF;
|
||||
|
||||
DELETE FROM public.ak_diy_pages WHERE id = p_id;
|
||||
|
||||
GET DIAGNOSTICS v_ok = ROW_COUNT;
|
||||
RETURN v_ok;
|
||||
END;
|
||||
$$;
|
||||
|
||||
-- 授权
|
||||
REVOKE ALL ON FUNCTION public.rpc_admin_delete_diy_page(uuid) FROM PUBLIC;
|
||||
GRANT EXECUTE ON FUNCTION public.rpc_admin_delete_diy_page(uuid) TO authenticated;
|
||||
@@ -0,0 +1,60 @@
|
||||
-- RPC: rpc_admin_get_diy_page_list
|
||||
-- 管理端获取 DIY 页面分页列表
|
||||
-- 支持按名称搜索和按类型筛选
|
||||
|
||||
CREATE OR REPLACE FUNCTION public.rpc_admin_get_diy_page_list(
|
||||
p_search text DEFAULT NULL,
|
||||
p_type text DEFAULT NULL,
|
||||
p_page integer DEFAULT 1,
|
||||
p_page_size integer DEFAULT 20
|
||||
)
|
||||
RETURNS JSONB
|
||||
LANGUAGE plpgsql
|
||||
SECURITY DEFINER
|
||||
SET search_path = public
|
||||
AS $$
|
||||
DECLARE
|
||||
v_page integer := GREATEST(1, COALESCE(p_page, 1));
|
||||
v_page_size integer := LEAST(200, GREATEST(1, COALESCE(p_page_size, 20)));
|
||||
v_offset integer := (v_page - 1) * v_page_size;
|
||||
v_total bigint;
|
||||
v_items jsonb;
|
||||
BEGIN
|
||||
-- 1. 权限检查 (仅管理员或分析员)
|
||||
IF NOT EXISTS (
|
||||
SELECT 1 FROM public.ak_users u
|
||||
WHERE u.id = auth.uid() AND u.role IN ('admin', 'analytics')
|
||||
) THEN
|
||||
RAISE EXCEPTION 'permission denied';
|
||||
END IF;
|
||||
|
||||
-- 2. 获取总数
|
||||
SELECT COUNT(*) INTO v_total
|
||||
FROM public.ak_diy_pages
|
||||
WHERE (p_search IS NULL OR p_search = '' OR name ILIKE '%' || p_search || '%')
|
||||
AND (p_type IS NULL OR type = p_type);
|
||||
|
||||
-- 3. 获取明细
|
||||
SELECT jsonb_agg(t) INTO v_items
|
||||
FROM (
|
||||
SELECT
|
||||
id, name, type, is_home, is_active,
|
||||
created_at, updated_at
|
||||
FROM public.ak_diy_pages
|
||||
WHERE (p_search IS NULL OR p_search = '' OR name ILIKE '%' || p_search || '%')
|
||||
AND (p_type IS NULL OR type = p_type)
|
||||
ORDER BY created_at DESC
|
||||
LIMIT v_page_size OFFSET v_offset
|
||||
) t;
|
||||
|
||||
-- 4. 返回 JSON 结果
|
||||
RETURN jsonb_build_object(
|
||||
'total', v_total,
|
||||
'items', COALESCE(v_items, '[]'::jsonb)
|
||||
);
|
||||
END;
|
||||
$$;
|
||||
|
||||
-- 授权
|
||||
REVOKE ALL ON FUNCTION public.rpc_admin_get_diy_page_list(text, text, integer, integer) FROM PUBLIC;
|
||||
GRANT EXECUTE ON FUNCTION public.rpc_admin_get_diy_page_list(text, text, integer, integer) TO authenticated;
|
||||
57
docs/sql/30_rpc/decoration/rpc_admin_save_diy_page_v1.sql
Normal file
57
docs/sql/30_rpc/decoration/rpc_admin_save_diy_page_v1.sql
Normal file
@@ -0,0 +1,57 @@
|
||||
-- RPC: rpc_admin_save_diy_page
|
||||
-- 管理端新增或更新 DIY 页面配置
|
||||
|
||||
CREATE OR REPLACE FUNCTION public.rpc_admin_save_diy_page(
|
||||
p_id uuid DEFAULT NULL,
|
||||
p_name text DEFAULT NULL,
|
||||
p_type text DEFAULT NULL,
|
||||
p_config jsonb DEFAULT '{}'::jsonb,
|
||||
p_is_active boolean DEFAULT true
|
||||
)
|
||||
RETURNS uuid
|
||||
LANGUAGE plpgsql
|
||||
SECURITY DEFINER
|
||||
SET search_path = public
|
||||
AS $$
|
||||
DECLARE
|
||||
v_id uuid;
|
||||
BEGIN
|
||||
-- 1. 权限检查 (仅管理员)
|
||||
IF NOT EXISTS (
|
||||
SELECT 1 FROM public.ak_users u
|
||||
WHERE u.id = auth.uid() AND u.role = 'admin'
|
||||
) THEN
|
||||
RAISE EXCEPTION 'permission denied';
|
||||
END IF;
|
||||
|
||||
-- 2. 新增或更新
|
||||
IF p_id IS NULL THEN
|
||||
INSERT INTO public.ak_diy_pages (
|
||||
name, type, config, is_active, updated_by, created_by
|
||||
) VALUES (
|
||||
p_name, p_type, p_config, p_is_active, auth.uid(), auth.uid()
|
||||
) RETURNING id INTO v_id;
|
||||
ELSE
|
||||
UPDATE public.ak_diy_pages
|
||||
SET
|
||||
name = COALESCE(p_name, name),
|
||||
type = COALESCE(p_type, type),
|
||||
config = COALESCE(p_config, config),
|
||||
is_active = COALESCE(p_is_active, is_active),
|
||||
updated_at = now(),
|
||||
updated_by = auth.uid()
|
||||
WHERE id = p_id
|
||||
RETURNING id INTO v_id;
|
||||
|
||||
IF v_id IS NULL THEN
|
||||
RAISE EXCEPTION 'page not found';
|
||||
END IF;
|
||||
END IF;
|
||||
|
||||
RETURN v_id;
|
||||
END;
|
||||
$$;
|
||||
|
||||
-- 授权
|
||||
REVOKE ALL ON FUNCTION public.rpc_admin_save_diy_page(uuid, text, text, jsonb, boolean) FROM PUBLIC;
|
||||
GRANT EXECUTE ON FUNCTION public.rpc_admin_save_diy_page(uuid, text, text, jsonb, boolean) TO authenticated;
|
||||
40
docs/sql/30_rpc/decoration/rpc_admin_set_home_page_v1.sql
Normal file
40
docs/sql/30_rpc/decoration/rpc_admin_set_home_page_v1.sql
Normal file
@@ -0,0 +1,40 @@
|
||||
-- RPC: rpc_admin_set_home_page
|
||||
-- 管理端设置生效首页
|
||||
-- 逻辑:先取消所有同类型页面的 is_home 状态,再设置目标页面为 is_home
|
||||
|
||||
CREATE OR REPLACE FUNCTION public.rpc_admin_set_home_page(
|
||||
p_id uuid
|
||||
)
|
||||
RETURNS boolean
|
||||
LANGUAGE plpgsql
|
||||
SECURITY DEFINER
|
||||
SET search_path = public
|
||||
AS $$
|
||||
DECLARE
|
||||
v_type text;
|
||||
BEGIN
|
||||
-- 1. 权限检查 (仅管理员)
|
||||
IF NOT EXISTS (
|
||||
SELECT 1 FROM public.ak_users u
|
||||
WHERE u.id = auth.uid() AND u.role = 'admin'
|
||||
) THEN
|
||||
RAISE EXCEPTION 'permission denied';
|
||||
END IF;
|
||||
|
||||
-- 2. 获取目标页面类型
|
||||
SELECT type INTO v_type FROM public.ak_diy_pages WHERE id = p_id;
|
||||
IF v_type IS NULL THEN
|
||||
RAISE EXCEPTION 'page not found';
|
||||
END IF;
|
||||
|
||||
-- 3. 原子切换:同一类型的页面只能有一个 is_home
|
||||
UPDATE public.ak_diy_pages SET is_home = false WHERE type = v_type;
|
||||
UPDATE public.ak_diy_pages SET is_home = true WHERE id = p_id;
|
||||
|
||||
RETURN true;
|
||||
END;
|
||||
$$;
|
||||
|
||||
-- 授权
|
||||
REVOKE ALL ON FUNCTION public.rpc_admin_set_home_page(uuid) FROM PUBLIC;
|
||||
GRANT EXECUTE ON FUNCTION public.rpc_admin_set_home_page(uuid) TO authenticated;
|
||||
@@ -3,11 +3,11 @@
|
||||
<!-- 顶部标题与按钮 -->
|
||||
<view class="page-header border-shadow">
|
||||
<view class="header-left">
|
||||
<text class="page-title">商品分类</text>
|
||||
<text class="page-title">商品分类装修</text>
|
||||
</view>
|
||||
<view class="header-right">
|
||||
<view class="btn-primary" @click="handleSave">
|
||||
<text class="btn-txt">保存</text>
|
||||
<text class="btn-txt">{{ isSaving ? '保存中...' : '保存配置' }}</text>
|
||||
</view>
|
||||
<view class="btn-ghost" @click="handleReset">
|
||||
<text class="ghost-txt">重置</text>
|
||||
@@ -17,7 +17,10 @@
|
||||
|
||||
<!-- 分类展示区域 -->
|
||||
<view class="content-container">
|
||||
<view class="style-list">
|
||||
<view v-if="isLoading" class="loading-state">
|
||||
<text>加载配置中...</text>
|
||||
</view>
|
||||
<view v-else class="style-list">
|
||||
|
||||
<!-- 样式1 -->
|
||||
<view class="style-card-wrapper">
|
||||
@@ -47,22 +50,12 @@
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="category-section">
|
||||
<view class="section-title"><text class="st-txt">肉制品</text></view>
|
||||
<view class="grid-container">
|
||||
<view class="grid-item" v-for="i in 3" :key="i">
|
||||
<view class="item-img-box"><text class="item-placeholder">🥩</text></view>
|
||||
<text class="item-txt">{{ ['大肉块','五花肉','鸡腿'][i-1] }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="phone-tabbar">
|
||||
<view class="tb-item"><text class="tb-ic">🏠</text></view>
|
||||
<view class="tb-item active"><text class="tb-ic">📂</text></view>
|
||||
<view class="tb-item"><text class="tb-ic">🛒</text></view>
|
||||
<view class="tb-item"><text class="tb-ic">👤</text></view>
|
||||
</view>
|
||||
</view>
|
||||
@@ -84,42 +77,25 @@
|
||||
<text class="ic-search">🔍</text>
|
||||
<text class="search-ph">点击搜索商品信息</text>
|
||||
</view>
|
||||
<view class="tabs-v2">
|
||||
<text class="t2-item active">水果</text>
|
||||
<text class="t2-item">全部</text>
|
||||
<text class="t2-item">热带水果</text>
|
||||
<text class="t2-item">西瓜葡萄</text>
|
||||
<text class="t2-arrow">▼</text>
|
||||
</view>
|
||||
<view class="style2-content">
|
||||
<view class="sidebar-v2">
|
||||
<text class="s2-item active">乳品</text>
|
||||
<text class="s2-item">午间零食</text>
|
||||
<text class="s2-item">新鲜蔬菜</text>
|
||||
<text class="s2-item">美妆护肤</text>
|
||||
<text class="s2-item">宠物用品</text>
|
||||
<text class="s2-item">户外玩具</text>
|
||||
<text class="s2-item" v-for="n in 5" :key="n">分类{{n}}</text>
|
||||
</view>
|
||||
<view class="main-v2">
|
||||
<view class="banner-mock-v2">
|
||||
<text class="b-txt">深层 V8 高清直屏\n双镜头/VR科技体验</text>
|
||||
</view>
|
||||
<view class="prod-v2" v-for="i in 2" :key="i">
|
||||
<text class="p-name">Haier/海尔 BCD-216STPT 时尚静音冰箱 三门出门租家用小型电冰箱</text>
|
||||
<text class="p-name">精选爆款商品标题示例内容展示</text>
|
||||
<view class="p-price-row">
|
||||
<text class="p-price">¥999.00</text>
|
||||
<text class="p-sales">已售 92</text>
|
||||
<text class="p-price">¥99.00</text>
|
||||
<view class="btn-buy"><text class="buy-txt">立即购买</text></view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="cart-badge">🛒<text class="badge-num">7</text></view>
|
||||
<view class="footer-p2">
|
||||
<text class="f2-total">¥999.00</text>
|
||||
<view class="btn-settle"><text class="settle-txt">去结算</text></view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<text class="style-name" :style="{color: selectedStyle === 2 ? '#2d8cf0' : '#666'}">样式2</text>
|
||||
@@ -140,42 +116,23 @@
|
||||
<text class="search-ph">搜索商品</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="tabs-v3">
|
||||
<text class="t3-item active">水果</text>
|
||||
<text class="t3-item specialty">时时生鲜</text>
|
||||
<text class="t3-item">休闲零食</text>
|
||||
<text class="t3-item">坚果蜜饯</text>
|
||||
<text class="t3-arrow">∨</text>
|
||||
</view>
|
||||
<view class="style3-content">
|
||||
<view class="sidebar-v3">
|
||||
<text class="s3-item active">乳品</text>
|
||||
<text class="s3-item">午间零食</text>
|
||||
<text class="s3-item">新鲜蔬菜</text>
|
||||
<text class="s3-item">特惠专区</text>
|
||||
<text class="s3-item">大闸蟹</text>
|
||||
<text class="s3-item">精选礼盒</text>
|
||||
<text class="s3-item" v-for="n in 5" :key="n">分类{{n}}</text>
|
||||
</view>
|
||||
<view class="main-v3">
|
||||
<view class="prod-v3" v-for="i in 5" :key="i">
|
||||
<view class="pv-img"></view>
|
||||
<view class="pv-info">
|
||||
<text class="pv-name">【橙中爱马仕】果际新骑士晚季甜橙10个单装</text>
|
||||
<text class="pv-name">优质精选商品名称展示示例</text>
|
||||
<text class="pv-price">¥25.99</text>
|
||||
</view>
|
||||
<view class="pv-add-box">
|
||||
<text class="pv-add">🛒</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="cart-v3">
|
||||
<view class="c3-ic-box">🛒<text class="c3-badge">7</text></view>
|
||||
<text class="c3-price">¥999.00</text>
|
||||
<view class="btn-settle-v3"><text class="settle-txt">去结算</text></view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<text class="style-name" :style="{color: selectedStyle === 3 ? '#2d8cf0' : '#666'}">样式3</text>
|
||||
</view>
|
||||
@@ -186,13 +143,50 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="uts">
|
||||
import { ref } from 'vue'
|
||||
import { ref, onMounted } from 'vue'
|
||||
import { getActiveDiyConfig, saveDiyPage, type DiyPage } from '@/services/admin/decorationService.uts'
|
||||
|
||||
const selectedStyle = ref(1)
|
||||
const isLoading = ref(false)
|
||||
const isSaving = ref(false)
|
||||
const currentPageId = ref<string | null>(null)
|
||||
|
||||
const handleSave = () => {
|
||||
console.log('Saving classification style:', selectedStyle.value)
|
||||
onMounted(() => {
|
||||
loadConfig()
|
||||
})
|
||||
|
||||
async function loadConfig() {
|
||||
isLoading.value = true
|
||||
try {
|
||||
const config = await getActiveDiyConfig('category')
|
||||
if (config != null) {
|
||||
currentPageId.value = config.id
|
||||
const style = config.config.getNumber('style')
|
||||
if (style != null) {
|
||||
selectedStyle.value = style.toInt()
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('Failed to load category decoration config', e)
|
||||
} finally {
|
||||
isLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const handleSave = async () => {
|
||||
isSaving.value = true
|
||||
try {
|
||||
const config = { style: selectedStyle.value } as UTSJSONObject
|
||||
const id = await saveDiyPage(currentPageId.value, '商品分类默认配置', 'category', config, true)
|
||||
if (id != null) {
|
||||
currentPageId.value = id
|
||||
uni.showToast({ title: '保存成功', icon: 'success' })
|
||||
}
|
||||
} catch (e) {
|
||||
uni.showToast({ title: '保存失败', icon: 'none' })
|
||||
} finally {
|
||||
isSaving.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const handleReset = () => {
|
||||
@@ -201,185 +195,76 @@ const handleReset = () => {
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.admin-decoration-category {
|
||||
background-color: #f0f2f5;
|
||||
min-height: 100vh;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.border-shadow {
|
||||
background-color: #fff;
|
||||
box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.05);
|
||||
}
|
||||
|
||||
.page-header {
|
||||
height: 60px;
|
||||
padding: 0 24px;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
z-index: 10;
|
||||
}
|
||||
|
||||
.admin-decoration-category { background-color: #f0f2f5; min-height: 100vh; display: flex; flex-direction: column; }
|
||||
.border-shadow { background-color: #fff; box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.05); }
|
||||
.page-header { height: 60px; padding: 0 24px; display: flex; flex-direction: row; justify-content: space-between; align-items: center; z-index: 10; }
|
||||
.page-title { font-size: 16px; font-weight: 600; color: #303133; }
|
||||
|
||||
.header-right { display: flex; flex-direction: row; gap: 12px; }
|
||||
|
||||
.btn-primary, .btn-ghost {
|
||||
height: 32px;
|
||||
padding: 0 20px;
|
||||
border-radius: 4px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.btn-primary, .btn-ghost { height: 32px; padding: 0 20px; border-radius: 4px; display: flex; align-items: center; justify-content: center; cursor: pointer; }
|
||||
.btn-primary { background-color: #2d8cf0; }
|
||||
.btn-ghost { border: 1px solid #dcdfe6; position: relative; }
|
||||
|
||||
.btn-txt { color: #fff; font-size: 14px; }
|
||||
.ghost-txt { color: #606266; font-size: 14px; }
|
||||
.content-container { flex: 1; padding: 30px 40px; }
|
||||
.loading-state { padding: 100px; text-align: center; color: #999; }
|
||||
|
||||
.content-container {
|
||||
flex: 1;
|
||||
padding: 30px 40px;
|
||||
}
|
||||
|
||||
.style-list {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
gap: 30px;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.style-card-wrapper {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
gap: 15px;
|
||||
}
|
||||
|
||||
.style-card {
|
||||
width: 320px;
|
||||
height: 640px;
|
||||
background-color: #fff;
|
||||
border: 2px solid transparent;
|
||||
border-radius: 20px;
|
||||
overflow: hidden;
|
||||
box-shadow: 0 4px 15px rgba(0,0,0,0.1);
|
||||
cursor: pointer;
|
||||
transition: all 0.3s;
|
||||
}
|
||||
|
||||
.style-card.active {
|
||||
border-color: #2d8cf0;
|
||||
box-shadow: 0 4px 20px rgba(45, 140, 240, 0.2);
|
||||
}
|
||||
|
||||
.style-list { display: flex; flex-direction: row; gap: 30px; flex-wrap: wrap; }
|
||||
.style-card-wrapper { display: flex; flex-direction: column; align-items: center; gap: 15px; }
|
||||
.style-card { width: 300px; height: 600px; background-color: #fff; border: 2px solid transparent; border-radius: 20px; overflow: hidden; box-shadow: 0 4px 15px rgba(0,0,0,0.1); cursor: pointer; transition: all 0.3s; }
|
||||
.style-card.active { border-color: #2d8cf0; box-shadow: 0 4px 20px rgba(45, 140, 240, 0.2); }
|
||||
.style-name { font-size: 14px; font-weight: bold; }
|
||||
|
||||
/* Phone Mockup Common */
|
||||
.phone-mock { width: 100%; height: 100%; display: flex; flex-direction: column; background-color: #fff; }
|
||||
.phone-header { height: 44px; display: flex; flex-direction: row; justify-content: space-between; align-items: center; padding: 0 15px; border-bottom: 1px solid #eee; }
|
||||
.p-title { font-size: 15px; font-weight: bold; color: #333; }
|
||||
.p-title { font-size: 14px; font-weight: bold; color: #333; }
|
||||
.p-dots { font-size: 12px; color: #333; }
|
||||
|
||||
.phone-body { flex: 1; background-color: #f8f8f8; display: flex; flex-direction: column; overflow: hidden; }
|
||||
|
||||
/* Style 1 Specific */
|
||||
.search-bar { height: 32px; background-color: #f2f2f2; margin: 10px; border-radius: 16px; display: flex; flex-direction: row; align-items: center; padding: 0 12px; }
|
||||
/* Styles logic */
|
||||
.style1-content, .style2-content, .style3-content { flex: 1; display: flex; flex-direction: row; }
|
||||
.sidebar-mock, .sidebar-v2, .sidebar-v3 { width: 70px; background-color: #f7f7f7; display: flex; flex-direction: column; }
|
||||
.sb-item, .s2-item, .s3-item { height: 44px; display: flex; align-items: center; justify-content: center; font-size: 11px; color: #666; }
|
||||
.sb-item.active, .s2-item.active, .s3-item.active { background-color: #fff; color: #f2270c; font-weight: bold; position: relative; }
|
||||
.sb-item.active::before, .s3-item.active::before { content: ''; position: absolute; left: 0; top: 15px; height: 14px; width: 3px; background-color: #f2270c; }
|
||||
|
||||
.main-mock, .main-v2, .main-v3 { flex: 1; background-color: #fff; padding: 10px; }
|
||||
.search-bar, .search-bar-v2, .search-bar-v3 { height: 32px; background-color: #f2f2f2; margin: 10px; border-radius: 16px; display: flex; flex-direction: row; align-items: center; padding: 0 12px; }
|
||||
.ic-search { font-size: 12px; margin-right: 6px; color: #999; }
|
||||
.search-ph { font-size: 11px; color: #999; }
|
||||
.search-ph { font-size: 10px; color: #999; }
|
||||
|
||||
.style1-content { flex: 1; display: flex; flex-direction: row; }
|
||||
.sidebar-mock { width: 80px; background-color: #f7f7f7; display: flex; flex-direction: column; }
|
||||
.sb-item { height: 44px; display: flex; align-items: center; justify-content: center; font-size: 12px; color: #666; }
|
||||
.sb-item.active { background-color: #fff; color: #f2270c; font-weight: bold; position: relative; }
|
||||
.sb-item.active::before { content: ''; position: absolute; left: 0; top: 15px; height: 14px; width: 3px; background-color: #f2270c; }
|
||||
|
||||
.main-mock { flex: 1; background-color: #fff; padding: 10px; }
|
||||
.section-title { margin-bottom: 10px; }
|
||||
.category-section { margin-bottom: 10px; }
|
||||
.st-txt { font-size: 12px; font-weight: bold; color: #333; }
|
||||
.grid-container { display: flex; flex-direction: row; flex-wrap: wrap; gap: 10px; }
|
||||
.grid-item { width: 68px; display: flex; flex-direction: column; align-items: center; margin-bottom: 10px; }
|
||||
.item-img-box { width: 50px; height: 50px; background-color: #f5f5f5; border-radius: 4px; display: flex; align-items: center; justify-content: center; margin-bottom: 4px; }
|
||||
.item-placeholder { font-size: 24px; }
|
||||
.item-txt { font-size: 10px; color: #666; }
|
||||
.grid-container { display: flex; flex-direction: row; flex-wrap: wrap; gap: 8px; }
|
||||
.grid-item { width: 60px; display: flex; flex-direction: column; align-items: center; margin-bottom: 10px; }
|
||||
.item-img-box { width: 44px; height: 44px; background-color: #f5f5f5; border-radius: 4px; display: flex; align-items: center; justify-content: center; margin-bottom: 4px; }
|
||||
.item-txt { font-size: 9px; color: #666; text-align: center; }
|
||||
|
||||
.phone-tabbar { height: 48px; display: flex; flex-direction: row; border-top: 1px solid #eee; }
|
||||
.tb-item { flex: 1; display: flex; align-items: center; justify-content: center; }
|
||||
.tb-ic { font-size: 20px; color: #999; }
|
||||
.tb-item.active .tb-ic { color: #f2270c; }
|
||||
.tb-item { flex: 1; display: flex; align-items: center; justify-content: center; font-size: 18px; color: #999; }
|
||||
.tb-item.active { color: #f2270c; }
|
||||
|
||||
/* Style 2 Specific */
|
||||
.phone-header-img { height: 20px; background-color: #fff; }
|
||||
.phone-header-v2 { height: 34px; display: flex; flex-direction: row; align-items: center; justify-content: space-between; padding: 0 12px; }
|
||||
.p2-title { font-size: 14px; font-weight: bold; flex: 1; text-align: center; }
|
||||
.home-ic { font-size: 16px; margin-right: 20px;}
|
||||
.banner-mock-v2 { height: 70px; background-color: #0081ff; border-radius: 6px; padding: 10px; display: flex; align-items: center; margin-bottom: 10px; }
|
||||
.b-txt { font-size: 10px; color: #fff; font-weight: bold; }
|
||||
.prod-v2 { border-bottom: 1px solid #f5f5f5; padding-bottom: 8px; margin-bottom: 8px; }
|
||||
.p-name { font-size: 10px; color: #333; line-height: 1.3; }
|
||||
.p-price { font-size: 11px; color: #f2270c; font-weight: bold; }
|
||||
.btn-buy { background-color: #f2270c; padding: 3px 8px; border-radius: 10px; }
|
||||
.buy-txt { font-size: 8px; color: #fff; }
|
||||
|
||||
.search-bar-v2 { height: 30px; background-color: #fff; margin: 8px 12px; border-radius: 15px; display: flex; flex-direction: row; align-items: center; padding: 0 12px; border: 1px solid #eee; }
|
||||
.tabs-v2 { height: 40px; display: flex; flex-direction: row; align-items: center; padding: 0 12px; gap: 15px; }
|
||||
.t2-item { font-size: 12px; color: #333; }
|
||||
.t2-item.active { color: #f2270c; font-weight: bold; border-bottom: 2px solid #f2270c; }
|
||||
.t2-arrow { font-size: 10px; color: #999; }
|
||||
.prod-v3 { display: flex; flex-direction: row; margin-bottom: 10px; }
|
||||
.pv-img { width: 60px; height: 60px; background-color: #f5f5f5; border-radius: 4px; margin-right: 8px; }
|
||||
.pv-name { font-size: 10px; color: #333; }
|
||||
.pv-price { font-size: 12px; color: #f2270c; font-weight: bold; }
|
||||
|
||||
.style2-content { flex: 1; display: flex; flex-direction: row; }
|
||||
.sidebar-v2 { width: 70px; background-color: #f7f7f7; }
|
||||
.s2-item { height: 48px; display: flex; align-items: center; justify-content: center; font-size: 11px; color: #333; }
|
||||
.s2-item.active { background-color: #fff; font-weight: bold; }
|
||||
|
||||
.main-v2 { flex: 1; background-color: #fff; padding: 10px; }
|
||||
.banner-mock-v2 { height: 80px; background-color: #0081ff; border-radius: 6px; padding: 10px; display: flex; align-items: center; margin-bottom: 12px; }
|
||||
.b-txt { font-size: 12px; color: #fff; font-weight: bold; line-height: 1.4; }
|
||||
|
||||
.prod-v2 { border-bottom: 1px solid #f5f5f5; padding-bottom: 10px; margin-bottom: 10px; }
|
||||
.p-name { font-size: 11px; color: #333; line-height: 1.3; margin-bottom: 8px; max-height: 28px; overflow: hidden; }
|
||||
.p-price-row { display: flex; flex-direction: row; align-items: center; }
|
||||
.p-price { font-size: 12px; color: #f2270c; font-weight: bold; margin-right: 6px; }
|
||||
.p-sales { font-size: 9px; color: #999; flex: 1; }
|
||||
.btn-buy { background-color: #f2270c; padding: 4px 8px; border-radius: 10px; }
|
||||
.buy-txt { font-size: 9px; color: #fff; }
|
||||
|
||||
.cart-badge { position: absolute; bottom: 65px; left: 15px; width: 34px; height: 34px; background-color: #fff; border-radius: 17px; display: flex; align-items: center; justify-content: center; font-size: 18px; box-shadow: 0 2px 8px rgba(0,0,0,0.2); }
|
||||
.badge-num { position: absolute; top: 0; right: 0; background-color: #f2270c; color: #fff; font-size: 9px; width: 14px; height: 14px; border-radius: 7px; text-align: center; }
|
||||
|
||||
.footer-p2 { height: 50px; display: flex; flex-direction: row; justify-content: space-between; align-items: center; padding: 0 15px; border-top: 1px solid #eee; }
|
||||
.f2-total { font-size: 16px; color: #f2270c; font-weight: bold; }
|
||||
.btn-settle { background-color: #f2270c; padding: 6px 16px; border-radius: 18px; }
|
||||
.settle-txt { color: #fff; font-size: 14px; }
|
||||
|
||||
/* Style 3 Specific */
|
||||
.search-bar-v3 { height: 44px; display: flex; flex-direction: row; align-items: center; padding: 0 12px; gap: 10px; background-color: #fff; }
|
||||
.home-btn { font-size: 16px; }
|
||||
.search-input-v3 { flex: 1; height: 30px; background-color: #f5f5f5; border-radius: 15px; display: flex; flex-direction: row; align-items: center; padding: 0 12px; }
|
||||
|
||||
.tabs-v3 { height: 40px; display: flex; flex-direction: row; align-items: center; padding: 0 12px; gap: 12px; background-color: #fff; }
|
||||
.t3-item { font-size: 12px; color: #666; white-space: nowrap; }
|
||||
.t3-item.active { color: #f2270c; font-weight: bold; font-size: 14px; }
|
||||
.t3-item.specialty { background-color: #f2270c; color: #fff; padding: 2px 8px; border-radius: 10px; }
|
||||
.t3-arrow { font-size: 12px; color: #ccc; flex: 1; text-align: right; }
|
||||
|
||||
.style3-content { flex: 1; display: flex; flex-direction: row; background-color: #fff; }
|
||||
.sidebar-v3 { width: 75px; background-color: #f7f7f7; }
|
||||
.s3-item { height: 50px; display: flex; align-items: center; justify-content: center; font-size: 12px; color: #666; }
|
||||
.s3-item.active { background-color: #fff; color: #333; font-weight: bold; position: relative; }
|
||||
.s3-item.active::before { content: ''; position: absolute; left: 0; top: 18px; height: 14px; width: 3px; background-color: #f2270c; }
|
||||
|
||||
.main-v3 { flex: 1; padding: 10px; }
|
||||
.prod-v3 { display: flex; flex-direction: row; margin-bottom: 12px; position: relative; }
|
||||
.pv-img { width: 70px; height: 70px; background-color: #f5f5f5; border-radius: 4px; margin-right: 10px; }
|
||||
.pv-info { flex: 1; display: flex; flex-direction: column; justify-content: space-between; }
|
||||
.pv-name { font-size: 11px; color: #333; line-height: 1.3; overflow: hidden; max-height: 30px; }
|
||||
.pv-price { font-size: 13px; color: #f2270c; font-weight: bold; }
|
||||
.pv-add-box { position: absolute; right: 0; bottom: 0; }
|
||||
.pv-add { font-size: 18px; color: #f2270c; }
|
||||
|
||||
.cart-v3 { height: 50px; display: flex; flex-direction: row; align-items: center; padding: 0 12px; border-top: 1px solid #eee; position: relative; }
|
||||
.c3-ic-box { font-size: 24px; color: #f2270c; margin-right: 10px; position: relative; margin-top: -15px;}
|
||||
.c3-badge { position: absolute; top: 0; right: -5px; background-color: #f2270c; color: #fff; font-size: 9px; width: 14px; height: 14px; border-radius: 7px; text-align: center; }
|
||||
.c3-price { font-size: 14px; color: #f2270c; font-weight: bold; flex: 1; }
|
||||
.btn-settle-v3 { background-color: #f2270c; padding: 6px 20px; border-radius: 20px; }
|
||||
.settings-panel { flex: 1; padding: 30px; }
|
||||
.group-title { display: flex; flex-direction: row; align-items: center; margin-bottom: 20px; }
|
||||
.title-line { width: 3px; height: 16px; background-color: #2d8cf0; margin-right: 10px; }
|
||||
.title-txt { font-size: 15px; font-weight: bold; }
|
||||
.radio-group { display: flex; flex-direction: column; gap: 15px; }
|
||||
.radio-item { display: flex; flex-direction: row; align-items: center; cursor: pointer; }
|
||||
.radio-dot { width: 16px; height: 16px; border: 1px solid #dcdfe6; border-radius: 8px; margin-right: 10px; }
|
||||
.radio-dot.active { border-color: #2d8cf0; background-color: #2d8cf0; }
|
||||
.radio-txt { font-size: 14px; color: #333; }
|
||||
.hint-txt { font-size: 12px; color: #999; margin-top: 20px; line-height: 1.6; }
|
||||
</style>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<view class="admin-decoration-home">
|
||||
<view class="content-container">
|
||||
<!-- 左侧:手机预览区 -->
|
||||
<!-- 左侧:手机预览区 (保持原样作为预览参考) -->
|
||||
<view class="preview-section border-shadow">
|
||||
<view class="phone-mock">
|
||||
<view class="phone-inner">
|
||||
@@ -15,72 +15,26 @@
|
||||
<text class="tab-item active">首页</text>
|
||||
<text class="tab-item">生活家居</text>
|
||||
<text class="tab-item">运动专区</text>
|
||||
<text class="tab-item">电子产品</text>
|
||||
<text class="tab-item">家用电器</text>
|
||||
<text class="tab-more">≡</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<scroll-view class="phone-scroll" scroll-y="true">
|
||||
<!-- Banner -->
|
||||
<view class="banner-mock">
|
||||
<view class="banner-box">
|
||||
<text class="banner-txt">MUSE FOR ALL MOTHERS</text>
|
||||
</view>
|
||||
<view class="dot-box">
|
||||
<view class="dot active"></view>
|
||||
<view class="dot"></view>
|
||||
<text class="banner-txt">DIY 页面预览</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- Grid Menu -->
|
||||
<view class="grid-menu-mock">
|
||||
<view class="menu-item" v-for="i in 10" :key="i">
|
||||
<view :class="['menu-icon', 'ic-'+i]"></view>
|
||||
<text class="menu-txt">{{ menuNames[i-1] }}</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- Announcement -->
|
||||
<view class="notice-mock">
|
||||
<view class="notice-ic">📢</view>
|
||||
<text class="notice-txt">CRMEB 年中618活动开启进行中!</text>
|
||||
<text class="notice-arr">></text>
|
||||
<text class="notice-txt">此处展示选中的装修模板预览</text>
|
||||
</view>
|
||||
|
||||
<!-- Check-in Section -->
|
||||
<view class="checkin-mock">
|
||||
<view class="checkin-days">
|
||||
<view class="day-dot" v-for="i in 7" :key="i">
|
||||
<view class="dot-circle">⭐</view>
|
||||
<text class="dot-text">周{{ weekDays[i-1] }}</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="btn-checkin"><text class="check-txt">签到</text></view>
|
||||
</view>
|
||||
|
||||
<!-- Bottom Space -->
|
||||
<view style="height: 100px;"></view>
|
||||
</scroll-view>
|
||||
|
||||
<!-- Bottom TabBar -->
|
||||
<view class="tabbar-mock">
|
||||
<view class="tb-item active">
|
||||
<text class="tb-ic">🏠</text>
|
||||
<text class="tb-txt">首页</text>
|
||||
</view>
|
||||
<view class="tb-item">
|
||||
<text class="tb-ic">📂</text>
|
||||
<text class="tb-txt">分类</text>
|
||||
</view>
|
||||
<view class="tb-item">
|
||||
<text class="tb-ic">🛒</text>
|
||||
<text class="tb-txt">购物车</text>
|
||||
</view>
|
||||
<view class="tb-item">
|
||||
<text class="tb-ic">👤</text>
|
||||
<text class="tb-txt">我的</text>
|
||||
</view>
|
||||
<view class="tb-item active"><text class="tb-ic">🏠</text><text class="tb-txt">首页</text></view>
|
||||
<view class="tb-item"><text class="tb-ic">👤</text><text class="tb-txt">我的</text></view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
@@ -93,65 +47,63 @@
|
||||
<view class="btn-primary-blue mr-10" @click="handleAdd">
|
||||
<text class="btn-txt">添加页面</text>
|
||||
</view>
|
||||
<view class="btn-import-blue" @click="handleImport">
|
||||
<text class="btn-txt">导入模板</text>
|
||||
<view class="filter-item ml-20">
|
||||
<input class="search-input-box" placeholder="搜索模板名称" v-model="searchQuery" @confirm="onSearch" />
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 表格 -->
|
||||
<view class="table-container">
|
||||
<view v-if="isLoading" class="loading-state">
|
||||
<text class="loading-txt">数据加载中...</text>
|
||||
</view>
|
||||
<view v-else-if="tableData.length === 0" class="empty-state">
|
||||
<text class="empty-txt">暂无装修模板,请点击左上角添加</text>
|
||||
</view>
|
||||
<template v-else>
|
||||
<view class="table-header-row">
|
||||
<view class="th" style="width: 80px;">页面ID</view>
|
||||
<view class="th" style="width: 80px;">序号</view>
|
||||
<view class="th" style="flex: 2;">模板名称</view>
|
||||
<view class="th" style="flex: 1;">模板类型</view>
|
||||
<view class="th" style="flex: 2;">添加时间</view>
|
||||
<view class="th" style="width: 100px; text-align: center;">状态</view>
|
||||
<view class="th" style="flex: 2;">更新时间</view>
|
||||
<view class="th" style="width: 280px;">操作</view>
|
||||
<view class="th" style="width: 220px;">操作</view>
|
||||
</view>
|
||||
|
||||
<view v-for="(item, index) in tableData" :key="index" class="table-body-row">
|
||||
<view class="td" style="width: 80px;">{{ item.id }}</view>
|
||||
<view class="td" style="flex: 2;">{{ item.name }}</view>
|
||||
<view v-for="(item, index) in tableData" :key="item.id" class="table-body-row">
|
||||
<view class="td" style="width: 80px;">{{ (page - 1) * pageSize + index + 1 }}</view>
|
||||
<view class="td" style="flex: 2;">
|
||||
<text class="td-name">{{ item.name }}</text>
|
||||
<view v-if="item.is_home" class="home-tag"><text class="ht-txt">当前首页</text></view>
|
||||
</view>
|
||||
<view class="td" style="flex: 1;">
|
||||
<view :class="['type-tag', item.type === '首页' ? 'type-home' : 'type-topic']">
|
||||
<text class="tag-label">{{ item.type }}</text>
|
||||
<text class="type-txt">{{ getTypeText(item.type) }}</text>
|
||||
</view>
|
||||
<view class="td" style="width: 100px; justify-content: center;">
|
||||
<text :class="['status-dot', item.is_active ? 'active' : '']"></text>
|
||||
<text class="status-txt">{{ item.is_active ? '已启用' : '未启用' }}</text>
|
||||
</view>
|
||||
<view class="td" style="flex: 2;">{{ item.addTime }}</view>
|
||||
<view class="td" style="flex: 2;">{{ item.updateTime }}</view>
|
||||
<view class="td" style="width: 280px;">
|
||||
<view class="td" style="flex: 2;">{{ item.updated_at.substring(0, 16).replace('T', ' ') }}</view>
|
||||
<view class="td" style="width: 220px;">
|
||||
<view class="op-links">
|
||||
<text class="op-link" @click="handleEdit(item)">编辑</text>
|
||||
<text class="op-link" @click="handleEdit(item)">设计</text>
|
||||
<text class="op-split">|</text>
|
||||
<text class="op-link text-danger">删除</text>
|
||||
<text class="op-split">|</text>
|
||||
<text class="op-link">预览</text>
|
||||
<text class="op-split">|</text>
|
||||
<text class="op-link" v-if="item.type !== '首页'">设为首页</text>
|
||||
<text class="op-split" v-if="item.type !== '首页'">|</text>
|
||||
<text class="op-link">导出模板</text>
|
||||
<text class="op-link" v-if="!item.is_home" @click="handleSetHome(item)">设为首页</text>
|
||||
<text class="op-split" v-if="!item.is_home">|</text>
|
||||
<text class="op-link text-danger" v-if="!item.is_home" @click="handleDelete(item)">删除</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
</view>
|
||||
|
||||
<!-- 分页器 -->
|
||||
<view class="pagination-footer">
|
||||
<view class="page-total">
|
||||
<view class="pagination-footer" v-if="total > 0">
|
||||
<text class="total-txt">共 {{ total }} 条</text>
|
||||
</view>
|
||||
<view class="page-select">
|
||||
<text class="page-val">15条/页 ▼</text>
|
||||
</view>
|
||||
<view class="page-btns">
|
||||
<text class="p-btn disabled"><</text>
|
||||
<text class="p-btn active">1</text>
|
||||
<text class="p-btn">></text>
|
||||
</view>
|
||||
<view class="page-jump">
|
||||
<text class="jump-txt">前往</text>
|
||||
<input class="jump-input" value="1" />
|
||||
<text class="jump-txt">页</text>
|
||||
<text :class="['p-btn', page <= 1 ? 'disabled' : '']" @click="onPrevPage"> < </text>
|
||||
<text class="p-btn active">{{ page }}</text>
|
||||
<text :class="['p-btn', page >= totalPages ? 'disabled' : '']" @click="onNextPage"> > </text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
@@ -162,52 +114,34 @@
|
||||
<view v-if="showDrawer" :class="['drawer-mask', isClosing ? 'mask-fade-out' : '']" @click="closeDrawer">
|
||||
<view :class="['drawer-content', isClosing ? 'slide-out' : '']" @click.stop="">
|
||||
<view class="drawer-header">
|
||||
<text class="title-txt">添加页面</text>
|
||||
<text class="title-txt">添加装修页面</text>
|
||||
<text class="close-btn" @click="closeDrawer">×</text>
|
||||
</view>
|
||||
|
||||
<scroll-view class="drawer-body" :scroll-y="true">
|
||||
<view class="drawer-body">
|
||||
<view class="form-item-v">
|
||||
<text class="v-label">页面名称</text>
|
||||
<input class="v-input" v-model="formName" placeholder="请填写页面名称" />
|
||||
<input class="v-input" v-model="formName" placeholder="例如:2026年货节首页" />
|
||||
</view>
|
||||
|
||||
<view class="form-item-v">
|
||||
<text class="v-label">页面类型</text>
|
||||
<view class="radio-group">
|
||||
<view class="radio-item" @click="formType = '首页'">
|
||||
<view :class="['radio-dot', formType === '首页' ? 'active' : '']"></view>
|
||||
<view class="radio-item" @click="formType = 'home'">
|
||||
<view :class="['radio-dot', formType === 'home' ? 'active' : '']"></view>
|
||||
<text class="radio-txt">首页</text>
|
||||
</view>
|
||||
<view class="radio-item" @click="formType = '专题页'">
|
||||
<view :class="['radio-dot', formType === '专题页' ? 'active' : '']"></view>
|
||||
<view class="radio-item" @click="formType = 'topic'">
|
||||
<view :class="['radio-dot', formType === 'topic' ? 'active' : '']"></view>
|
||||
<text class="radio-txt">专题页</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="template-select-title">
|
||||
<text class="t-title">选择模板</text>
|
||||
<text class="t-sub">请选择要引用的模板</text>
|
||||
</view>
|
||||
|
||||
<view class="template-grid">
|
||||
<view class="tpl-item" v-for="i in 4" :key="i">
|
||||
<view class="tpl-thumb">
|
||||
<text class="tpl-ic">📄</text>
|
||||
</view>
|
||||
<text class="tpl-name">通用模板 {{ i }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</scroll-view>
|
||||
|
||||
<view class="drawer-footer">
|
||||
<view class="btn-cancel" @click="closeDrawer">
|
||||
<text class="btn-cancel-txt">取消</text>
|
||||
</view>
|
||||
<view class="btn-save" @click="handleSavePage">
|
||||
<text class="btn-save-txt">提交</text>
|
||||
</view>
|
||||
<button class="btn-cancel" @click="closeDrawer">取消</button>
|
||||
<button class="btn-save" @click="handleSavePage">确定添加</button>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
@@ -215,35 +149,76 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="uts">
|
||||
import { ref } from 'vue'
|
||||
import { ref, onMounted, computed } from 'vue'
|
||||
import { fetchDiyPageList, saveDiyPage, deleteDiyPage, setAsHomePage, type DiyPage } from '@/services/admin/decorationService.uts'
|
||||
|
||||
const menuNames = ['秒杀活动', '商品分类', '拼团活动', '积分商城', '砍价中心', '行业资讯', '我的地址', '积分抽奖', '我的账户', '订单列表']
|
||||
const weekDays = ['一', '二', '三', '四', '五', '六', '日']
|
||||
|
||||
const total = ref(11)
|
||||
const tableData = ref([
|
||||
{ id: 497, name: 'DIY导入数据', type: '专题页', addTime: '2025-03-20 15:18:01', updateTime: '2025-05-21 10:17:45' },
|
||||
{ id: 496, name: 'DIY导入数据', type: '专题页', addTime: '2025-03-20 15:12:58', updateTime: '2025-03-20 15:12:58' },
|
||||
{ id: 494, name: '图书类模板,勿动!!', type: '专题页', addTime: '2025-02-27 15:42:08', updateTime: '2025-03-19 10:40:13' },
|
||||
{ id: 493, name: '健康类模板,勿动!!', type: '专题页', addTime: '2025-02-27 15:40:55', updateTime: '2025-03-07 09:46:14' },
|
||||
{ id: 492, name: '演出类模板,勿动!!', type: '专题页', addTime: '2025-02-27 15:33:09', updateTime: '2025-03-07 09:49:43' },
|
||||
{ id: 491, name: '潮玩类模板,勿动!!', type: '专题页', addTime: '2025-02-27 15:31:28', updateTime: '2025-03-07 09:55:53' },
|
||||
{ id: 490, name: '家居类模板,勿动!!', type: '专题页', addTime: '2025-02-27 15:30:21', updateTime: '2025-03-07 09:57:59' },
|
||||
{ id: 482, name: '文具类模板,勿动!!', type: '专题页', addTime: '2025-02-26 11:32:07', updateTime: '2025-03-07 09:59:25' },
|
||||
{ id: 481, name: '模板', type: '专题页', addTime: '2025-02-26 09:21:04', updateTime: '2025-03-12 14:55:46' },
|
||||
{ id: 480, name: '模板', type: '专题页', addTime: '2025-02-26 09:19:24', updateTime: '2026-02-02 17:11:45' },
|
||||
{ id: 479, name: '首页模板,勿动!!', type: '首页', addTime: '2025-02-25 20:59:59', updateTime: '2026-01-20 11:16:20' }
|
||||
])
|
||||
const tableData = ref<DiyPage[]>([])
|
||||
const total = ref(0)
|
||||
const page = ref(1)
|
||||
const pageSize = 15
|
||||
const isLoading = ref(false)
|
||||
const searchQuery = ref('')
|
||||
|
||||
const showDrawer = ref(false)
|
||||
const isClosing = ref(false)
|
||||
const formName = ref('')
|
||||
const formType = ref('首页')
|
||||
const formType = ref('home')
|
||||
|
||||
const viewState = ref('list') // 'list' | 'design'
|
||||
const editingName = ref('')
|
||||
const totalPages = computed((): number => {
|
||||
return Math.ceil(total.value / pageSize) || 1
|
||||
})
|
||||
|
||||
onMounted(() => {
|
||||
loadData()
|
||||
})
|
||||
|
||||
async function loadData() {
|
||||
isLoading.value = true
|
||||
try {
|
||||
const res = await fetchDiyPageList(searchQuery.value || null, null, page.value, pageSize)
|
||||
tableData.value = res.items
|
||||
total.value = res.total
|
||||
} catch (e) {
|
||||
uni.showToast({ title: '数据加载失败', icon: 'none' })
|
||||
} finally {
|
||||
isLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function onSearch() {
|
||||
page.value = 1
|
||||
loadData()
|
||||
}
|
||||
|
||||
async function handleSetHome(item: DiyPage) {
|
||||
uni.showLoading({ title: '正在设置...' })
|
||||
const success = await setAsHomePage(item.id)
|
||||
uni.hideLoading()
|
||||
if (success) {
|
||||
uni.showToast({ title: '首页设置成功' })
|
||||
loadData()
|
||||
}
|
||||
}
|
||||
|
||||
async function handleDelete(item: DiyPage) {
|
||||
uni.showModal({
|
||||
title: '确认删除',
|
||||
content: `确定要删除模板 "${item.name}" 吗?`,
|
||||
success: async (res) => {
|
||||
if (res.confirm) {
|
||||
const success = await deleteDiyPage(item.id)
|
||||
if (success) {
|
||||
uni.showToast({ title: '删除成功' })
|
||||
loadData()
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const handleAdd = () => {
|
||||
formName.value = ''
|
||||
formType.value = 'home'
|
||||
showDrawer.value = true
|
||||
isClosing.value = false
|
||||
}
|
||||
@@ -256,470 +231,103 @@ const closeDrawer = () => {
|
||||
}, 300)
|
||||
}
|
||||
|
||||
const handleEdit = (item: any) => {
|
||||
editingName.value = item.name as string
|
||||
viewState.value = 'design'
|
||||
}
|
||||
const handleSavePage = async () => {
|
||||
if (!formName.value) {
|
||||
uni.showToast({ title: '请输入页面名称', icon: 'none' })
|
||||
return
|
||||
}
|
||||
|
||||
const handleImport = () => { console.log('Importing...') }
|
||||
|
||||
const handleSavePage = () => {
|
||||
console.log('Saving new page:', formName.value)
|
||||
const id = await saveDiyPage(null, formName.value, formType.value, {} as UTSJSONObject)
|
||||
if (id != null) {
|
||||
uni.showToast({ title: '添加成功' })
|
||||
closeDrawer()
|
||||
loadData()
|
||||
}
|
||||
}
|
||||
|
||||
const handleSaveDesign = () => {
|
||||
console.log('Saving design...')
|
||||
viewState.value = 'list'
|
||||
const handleEdit = (item: DiyPage) => {
|
||||
uni.showToast({ title: '装修编辑器加载中...', icon: 'none' })
|
||||
}
|
||||
|
||||
function onPrevPage() { if (page.value > 1) { page.value--; loadData(); } }
|
||||
function onNextPage() { if (page.value < totalPages.value) { page.value++; loadData(); } }
|
||||
|
||||
function getTypeText(type: string): string {
|
||||
if (type === 'home') return '首页'
|
||||
if (type === 'topic') return '专题页'
|
||||
if (type === 'user') return '个人中心'
|
||||
return type
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.admin-decoration-home {
|
||||
background-color: #f0f2f5;
|
||||
min-height: 100vh;
|
||||
padding: 24px;
|
||||
}
|
||||
|
||||
.border-shadow {
|
||||
background-color: #fff;
|
||||
border-radius: 4px;
|
||||
box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.05);
|
||||
}
|
||||
|
||||
.content-container {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
gap: 20px;
|
||||
}
|
||||
|
||||
/* 左侧手机预览区 */
|
||||
.preview-section {
|
||||
width: 380px;
|
||||
height: 800px;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
padding: 40px 0;
|
||||
}
|
||||
|
||||
.phone-mock {
|
||||
width: 320px;
|
||||
height: 640px;
|
||||
background-color: #fff;
|
||||
border: 10px solid #ececec;
|
||||
border-radius: 36px;
|
||||
overflow: hidden;
|
||||
position: relative;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.phone-inner { flex: 1; display: flex; flex-direction: column; }
|
||||
|
||||
.phone-header-img {
|
||||
background-color: #f7f7f7;
|
||||
}
|
||||
|
||||
.status-bar-mock { height: 20px; }
|
||||
|
||||
.search-bar-mock {
|
||||
height: 38px;
|
||||
background-color: #fff;
|
||||
margin: 0 12px;
|
||||
border-radius: 19px;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
padding: 0 15px;
|
||||
border: 1px solid #eee;
|
||||
}
|
||||
.search-ic { font-size: 14px; margin-right: 8px; }
|
||||
.search-ph { font-size: 12px; color: #999; }
|
||||
|
||||
.tabs-mock {
|
||||
height: 40px;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
padding: 0 12px;
|
||||
justify-content: space-between;
|
||||
}
|
||||
.tab-item { font-size: 13px; color: #333; margin-right: 15px; }
|
||||
.tab-item.active { color: #f2270c; font-weight: bold; border-bottom: 2px solid #f2270c; }
|
||||
.tab-more { font-size: 16px; color: #666; }
|
||||
.admin-decoration-home { background-color: #f0f2f5; min-height: 100vh; padding: 24px; }
|
||||
.border-shadow { background-color: #fff; border-radius: 4px; box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.05); }
|
||||
.content-container { display: flex; flex-direction: row; gap: 20px; }
|
||||
|
||||
/* 左侧手机预览区 (简化版) */
|
||||
.preview-section { width: 360px; height: 720px; display: flex; justify-content: center; align-items: center; padding: 20px 0; }
|
||||
.phone-mock { width: 300px; height: 600px; background-color: #fff; border: 8px solid #ececec; border-radius: 32px; overflow: hidden; position: relative; }
|
||||
.phone-inner { height: 100%; display: flex; flex-direction: column; }
|
||||
.phone-header-img { background-color: #f7f7f7; height: 100px; }
|
||||
.search-bar-mock { height: 32px; background-color: #fff; margin: 10px 12px; border-radius: 16px; border: 1px solid #eee; display: flex; flex-direction: row; align-items: center; padding: 0 12px; }
|
||||
.search-ph { font-size: 11px; color: #999; margin-left: 5px; }
|
||||
.phone-scroll { flex: 1; background-color: #f8f8f8; }
|
||||
.banner-mock { height: 120px; background: #eee; margin: 10px; border-radius: 8px; display: flex; align-items: center; justify-content: center; }
|
||||
.banner-txt { color: #999; font-size: 14px; }
|
||||
.tabbar-mock { height: 50px; background: #fff; border-top: 1px solid #eee; display: flex; flex-direction: row; }
|
||||
.tb-item { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; opacity: 0.5; }
|
||||
.tb-item.active { opacity: 1; }
|
||||
.tb-ic { font-size: 18px; }
|
||||
.tb-txt { font-size: 10px; margin-top: 2px; }
|
||||
|
||||
.banner-mock {
|
||||
height: 150px;
|
||||
position: relative;
|
||||
margin: 10px;
|
||||
}
|
||||
.banner-box {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background: linear-gradient(135deg, #eee 0%, #ccc 100%);
|
||||
border-radius: 8px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 20px;
|
||||
}
|
||||
.banner-txt { font-size: 18px; font-weight: bold; color: #333; text-align: center; }
|
||||
.dot-box {
|
||||
position: absolute;
|
||||
bottom: 8px;
|
||||
left: 0;
|
||||
right: 0;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
gap: 6px;
|
||||
}
|
||||
.dot { width: 6px; height: 6px; background-color: rgba(255,255,255,0.5); border-radius: 3px; }
|
||||
.dot.active { width: 12px; background-color: #fff; }
|
||||
|
||||
.grid-menu-mock {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
flex-wrap: wrap;
|
||||
padding: 10px 5px;
|
||||
}
|
||||
.menu-item {
|
||||
width: 20%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
.menu-icon {
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
background-color: #ddd;
|
||||
border-radius: 20px;
|
||||
margin-bottom: 6px;
|
||||
}
|
||||
.ic-1 { background-color: #ff9d00; }
|
||||
.ic-2 { background-color: #ff5000; }
|
||||
.ic-3 { background-color: #8a2be2; }
|
||||
.ic-4 { background-color: #f4ea2a; }
|
||||
.ic-5 { background-color: #ffb6c1; }
|
||||
.ic-6 { background-color: #c0c0c0; }
|
||||
.ic-7 { background-color: #90ee90; }
|
||||
.ic-8 { background-color: #87cefa; }
|
||||
.ic-9 { background-color: #ffa07a; }
|
||||
.ic-10 { background-color: #20b2aa; }
|
||||
|
||||
.menu-txt { font-size: 10px; color: #666; }
|
||||
|
||||
.notice-mock {
|
||||
height: 36px;
|
||||
background-color: #fff;
|
||||
margin: 0 10px;
|
||||
border-radius: 4px;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
padding: 0 10px;
|
||||
}
|
||||
.notice-ic { font-size: 14px; margin-right: 8px; }
|
||||
.notice-txt { flex: 1; font-size: 12px; color: #333; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
|
||||
.notice-arr { color: #ccc; font-size: 12px; }
|
||||
|
||||
.checkin-mock {
|
||||
margin: 10px;
|
||||
background-color: #fff;
|
||||
border-radius: 8px;
|
||||
padding: 12px;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
}
|
||||
.checkin-days { display: flex; flex-direction: row; gap: 8px; }
|
||||
.day-dot { display: flex; flex-direction: column; align-items: center; }
|
||||
.dot-circle { width: 24px; height: 24px; background-color: #fdf6ec; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 12px; margin-bottom: 4px; }
|
||||
.dot-text { font-size: 9px; color: #999; }
|
||||
.btn-checkin { background-color: #ff5000; padding: 4px 12px; border-radius: 12px; }
|
||||
.check-txt { color: #fff; font-size: 11px; }
|
||||
|
||||
.tabbar-mock {
|
||||
height: 50px;
|
||||
background-color: #fff;
|
||||
border-top: 1px solid #eee;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
}
|
||||
.tb-item { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; }
|
||||
.tb-ic { font-size: 18px; margin-bottom: 2px; }
|
||||
.tb-txt { font-size: 11px; color: #999; }
|
||||
.tb-item.active .tb-txt { color: #f2270c; }
|
||||
|
||||
/* 右侧列表管理区 */
|
||||
/* 右侧列表区 */
|
||||
.list-section { flex: 1; }
|
||||
.manage-card { display: flex; flex-direction: column; min-height: 800px; }
|
||||
|
||||
.action-bar { padding: 20px; display: flex; flex-direction: row; }
|
||||
.btn-primary-blue { background-color: #2d8cf0; padding: 8px 16px; border-radius: 4px; cursor: pointer; }
|
||||
.btn-import-blue { border: 1px solid #1890ff; padding: 7px 16px; border-radius: 4px; cursor: pointer; }
|
||||
.mr-10 { margin-right: 10px; }
|
||||
.manage-card { padding: 20px; min-height: 720px; display: flex; flex-direction: column; }
|
||||
.action-bar { margin-bottom: 20px; display: flex; flex-direction: row; align-items: center; }
|
||||
.btn-primary-blue { background-color: #2d8cf0; padding: 8px 20px; border-radius: 4px; cursor: pointer; }
|
||||
.btn-txt { color: #fff; font-size: 14px; }
|
||||
.btn-import-blue .btn-txt { color: #1890ff; }
|
||||
.search-input-box { border: 1px solid #dcdfe6; height: 34px; padding: 0 12px; border-radius: 4px; font-size: 13px; width: 200px; }
|
||||
|
||||
.table-container { flex: 1; padding: 0 20px; }
|
||||
.table-header-row { display: flex; flex-direction: row; background-color: #f8f8f9; border-bottom: 1px solid #e8eaec; }
|
||||
.th { padding: 12px 10px; font-size: 14px; color: #515a6e; font-weight: bold; }
|
||||
.table-body-row { display: flex; flex-direction: row; border-bottom: 1px solid #e8eaec; }
|
||||
.td { padding: 15px 10px; font-size: 14px; color: #515a6e; display: flex; align-items: center; }
|
||||
.table-container { flex: 1; margin-top: 10px; }
|
||||
.table-header-row { display: flex; flex-direction: row; background-color: #f8f8f9; border-bottom: 1px solid #e8eaec; padding: 12px 0; }
|
||||
.th { padding: 0 15px; font-size: 13px; color: #515a6e; font-weight: bold; }
|
||||
.table-body-row { display: flex; flex-direction: row; border-bottom: 1px solid #e8eaec; align-items: center; min-height: 60px; }
|
||||
.td { padding: 10px 15px; font-size: 13px; color: #515a6e; display: flex; align-items: center; }
|
||||
|
||||
.type-tag { padding: 2px 8px; border-radius: 4px; border: 1px solid #dcdfe6; }
|
||||
.type-topic { background-color: #f5f7fa; }
|
||||
.type-home { background-color: #f6ffed; border-color: #b7eb8f; }
|
||||
.tag-label { font-size: 12px; }
|
||||
.type-home .tag-label { color: #52c41a; }
|
||||
.home-tag { background-color: #f2270c; padding: 2px 6px; border-radius: 4px; margin-left: 10px; }
|
||||
.ht-txt { color: #fff; font-size: 10px; }
|
||||
.status-dot { width: 8px; height: 8px; border-radius: 4px; background-color: #ccc; margin-right: 8px; }
|
||||
.status-dot.active { background-color: #52c41a; }
|
||||
|
||||
.op-links { display: flex; flex-direction: row; align-items: center; color: #2d8cf0; }
|
||||
.op-link { cursor: pointer; margin: 0 5px; }
|
||||
.op-split { color: #e8eaec; }
|
||||
.op-link { color: #2d8cf0; cursor: pointer; font-size: 13px; }
|
||||
.op-split { color: #e8eaec; margin: 0 8px; }
|
||||
.text-danger { color: #ed4014; }
|
||||
|
||||
.pagination-footer {
|
||||
padding: 20px;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
justify-content: flex-end;
|
||||
gap: 15px;
|
||||
}
|
||||
.total-txt { font-size: 14px; color: #606266; }
|
||||
.page-val { font-size: 14px; color: #606266; border: 1px solid #dcdfe6; padding: 4px 10px; border-radius: 4px; }
|
||||
.page-btns { display: flex; flex-direction: row; gap: 8px; }
|
||||
.p-btn {
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
border: 1px solid #dcdfe6;
|
||||
border-radius: 4px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-size: 14px;
|
||||
}
|
||||
.p-btn.active { background-color: #2d8cf0; border-color: #2d8cf0; color: #fff; }
|
||||
.p-btn.disabled { color: #c0c4cc; background-color: #f5f7fa; }
|
||||
.pagination-footer { margin-top: 20px; display: flex; flex-direction: row; align-items: center; justify-content: flex-end; gap: 15px; }
|
||||
.total-txt { font-size: 13px; color: #999; }
|
||||
.p-btn { width: 30px; height: 30px; border: 1px solid #dcdfe6; border-radius: 4px; display: flex; align-items: center; justify-content: center; cursor: pointer; }
|
||||
.p-btn.active { background-color: #2d8cf0; color: #fff; border-color: #2d8cf0; }
|
||||
.p-btn.disabled { opacity: 0.5; cursor: not-allowed; }
|
||||
|
||||
.page-jump { display: flex; flex-direction: row; align-items: center; gap: 8px; }
|
||||
.jump-txt { font-size: 14px; color: #606266; }
|
||||
.jump-input { width: 40px; height: 32px; border: 1px solid #dcdfe6; text-align: center; border-radius: 4px; }
|
||||
|
||||
/* Design View Styles */
|
||||
.design-view {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
height: calc(100vh - 48px);
|
||||
}
|
||||
|
||||
.design-header {
|
||||
height: 60px;
|
||||
background-color: #fff;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 0 20px;
|
||||
border-bottom: 2px solid #2d8cf0;
|
||||
z-index: 100;
|
||||
}
|
||||
|
||||
.header-left { display: flex; flex-direction: row; align-items: center; cursor: pointer; }
|
||||
.back-ic { font-size: 20px; color: #2d8cf0; margin-right: 15px; }
|
||||
.design-title { font-size: 16px; font-weight: bold; color: #333; }
|
||||
|
||||
.header-right { display: flex; flex-direction: row; gap: 12px; }
|
||||
|
||||
.btn-ghost { border: 1px solid #dcdfe6; padding: 6px 16px; border-radius: 4px; cursor: pointer; }
|
||||
.btn-primary { background-color: #2d8cf0; padding: 6px 16px; border-radius: 4px; cursor: pointer; }
|
||||
.ghost-txt { color: #666; font-size: 14px; }
|
||||
.primary-txt { color: #fff; font-size: 14px; }
|
||||
|
||||
.design-body {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
}
|
||||
|
||||
.design-sidebar { width: 280px; background-color: #fff; padding: 15px; border-right: 1px solid #f0f0f0; }
|
||||
.sidebar-item {
|
||||
width: 110px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
padding: 15px 0;
|
||||
float: left;
|
||||
}
|
||||
.side-ic-box { width: 40px; height: 40px; background-color: #f7f8fa; display: flex; align-items: center; justify-content: center; border-radius: 4px; margin-bottom: 8px; font-size: 20px; }
|
||||
.side-txt { font-size: 12px; color: #666; }
|
||||
|
||||
.design-canvas {
|
||||
flex: 1;
|
||||
background-color: #f0f2f5;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
padding-top: 30px;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.canvas-phone {
|
||||
width: 375px;
|
||||
min-height: 667px;
|
||||
background-color: #fff;
|
||||
box-shadow: 0 0 20px rgba(0,0,0,0.1);
|
||||
}
|
||||
|
||||
.phone-top { height: 60px; background-color: #fff; border-bottom: 1px solid #eee; }
|
||||
|
||||
.phone-content-mock {
|
||||
padding: 100px 20px;
|
||||
text-align: center;
|
||||
}
|
||||
.mock-tip { color: #999; font-size: 14px; }
|
||||
|
||||
.design-attr { width: 320px; background-color: #fff; border-left: 1px solid #f0f0f0; }
|
||||
.attr-header { padding: 15px; border-bottom: 1px solid #f0f0f0; }
|
||||
.ah-txt { font-size: 15px; font-weight: bold; }
|
||||
.attr-empty { padding: 50px 20px; text-align: center; }
|
||||
.ae-txt { color: #999; font-size: 13px; }
|
||||
|
||||
.anim-fade-in {
|
||||
animation: fadeIn 0.4s ease-out;
|
||||
}
|
||||
|
||||
@keyframes fadeIn {
|
||||
from { opacity: 0; transform: translateY(10px); }
|
||||
to { opacity: 1; transform: translateY(0); }
|
||||
}
|
||||
|
||||
/* Drawer Styles */
|
||||
.drawer-mask {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
background-color: rgba(0, 0, 0, 0.4);
|
||||
z-index: 2000;
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
|
||||
.drawer-content {
|
||||
width: 450px;
|
||||
height: 100%;
|
||||
background-color: #fff;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
animation: slideIn 0.3s ease-out;
|
||||
}
|
||||
|
||||
.drawer-header {
|
||||
padding: 20px;
|
||||
border-bottom: 1px solid #f0f0f0;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.title-txt { font-size: 16px; font-weight: bold; color: #333; }
|
||||
/* 抽屉样式 */
|
||||
.drawer-mask { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background-color: rgba(0, 0, 0, 0.4); z-index: 2000; display: flex; justify-content: flex-end; }
|
||||
.drawer-content { width: 400px; height: 100%; background-color: #fff; display: flex; flex-direction: column; animation: slideIn 0.3s ease-out; }
|
||||
.drawer-header { padding: 20px; border-bottom: 1px solid #f0f0f0; display: flex; flex-direction: row; justify-content: space-between; align-items: center; }
|
||||
.close-btn { font-size: 24px; color: #999; cursor: pointer; }
|
||||
|
||||
.drawer-body { flex: 1; padding: 20px; }
|
||||
|
||||
.drawer-body { flex: 1; padding: 30px; }
|
||||
.form-item-v { margin-bottom: 24px; }
|
||||
.v-label { font-size: 14px; color: #666; margin-bottom: 10px; display: block; }
|
||||
.v-input { border: 1px solid #dcdfe6; height: 40px; padding: 0 12px; border-radius: 4px; font-size: 14px; width: 100%; }
|
||||
|
||||
.radio-group { display: flex; flex-direction: row; gap: 30px; }
|
||||
.v-input { border: 1px solid #dcdfe6; height: 38px; padding: 0 12px; border-radius: 4px; font-size: 14px; width: 100%; }
|
||||
.radio-group { display: flex; flex-direction: row; gap: 30px; margin-top: 10px; }
|
||||
.radio-item { display: flex; flex-direction: row; align-items: center; cursor: pointer; }
|
||||
.radio-dot { width: 16px; height: 16px; border: 1px solid #dcdfe6; border-radius: 8px; margin-right: 8px; position: relative; }
|
||||
.radio-dot.active { border-color: #2d8cf0; }
|
||||
.radio-dot.active::after {
|
||||
content: '';
|
||||
width: 8px;
|
||||
height: 8px;
|
||||
background-color: #2d8cf0;
|
||||
border-radius: 4px;
|
||||
position: absolute;
|
||||
top: 3px;
|
||||
left: 3px;
|
||||
}
|
||||
.radio-txt { font-size: 14px; color: #333; }
|
||||
.radio-dot { width: 16px; height: 16px; border: 1px solid #dcdfe6; border-radius: 8px; margin-right: 8px; }
|
||||
.radio-dot.active { border-color: #2d8cf0; background-color: #2d8cf0; }
|
||||
.drawer-footer { padding: 20px; border-top: 1px solid #f0f0f0; display: flex; flex-direction: row; justify-content: flex-end; gap: 12px; }
|
||||
.btn-cancel { background: #fff; border: 1px solid #dcdfe6; padding: 8px 20px; border-radius: 4px; }
|
||||
.btn-save { background: #2d8cf0; color: #fff; padding: 8px 20px; border-radius: 4px; border: none; }
|
||||
|
||||
.template-select-title { margin-top: 20px; margin-bottom: 15px; }
|
||||
.t-title { font-size: 15px; font-weight: bold; color: #333; margin-right: 10px; }
|
||||
.t-sub { font-size: 12px; color: #999; }
|
||||
|
||||
.template-grid {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
flex-wrap: wrap;
|
||||
gap: 15px;
|
||||
}
|
||||
.tpl-item {
|
||||
width: 190px;
|
||||
border: 1px solid #eee;
|
||||
border-radius: 4px;
|
||||
padding: 10px;
|
||||
background-color: #f9f9f9;
|
||||
cursor: pointer;
|
||||
}
|
||||
.tpl-thumb {
|
||||
height: 220px;
|
||||
background-color: #fff;
|
||||
margin-bottom: 8px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
.tpl-ic { font-size: 40px; color: #ccc; }
|
||||
.tpl-name { font-size: 12px; color: #666; text-align: center; display: block; }
|
||||
|
||||
.drawer-footer {
|
||||
padding: 20px;
|
||||
border-top: 1px solid #f0f0f0;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: flex-end;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.btn-cancel, .btn-save { padding: 8px 20px; border-radius: 4px; cursor: pointer; }
|
||||
.btn-cancel { border: 1px solid #dcdfe6; }
|
||||
.btn-save { background-color: #2d8cf0; }
|
||||
.btn-cancel-txt { color: #666; font-size: 14px; }
|
||||
.btn-save-txt { color: #fff; font-size: 14px; }
|
||||
|
||||
/* Animations */
|
||||
@keyframes slideIn {
|
||||
from { transform: translateX(100%); }
|
||||
to { transform: translateX(0); }
|
||||
}
|
||||
|
||||
.slide-out {
|
||||
animation: slideOut 0.3s ease-in forwards;
|
||||
}
|
||||
|
||||
@keyframes slideOut {
|
||||
from { transform: translateX(0); }
|
||||
to { transform: translateX(100%); }
|
||||
}
|
||||
|
||||
.mask-fade-out {
|
||||
animation: fadeOut 0.3s ease-in forwards;
|
||||
}
|
||||
|
||||
@keyframes fadeOut {
|
||||
from { background-color: rgba(0, 0, 0, 0.4); }
|
||||
to { background-color: rgba(0, 0, 0, 0); }
|
||||
}
|
||||
@keyframes slideIn { from { transform: translateX(100%); } to { transform: translateX(0); } }
|
||||
.slide-out { animation: slideOut 0.3s ease-in forwards; }
|
||||
@keyframes slideOut { from { transform: translateX(0); } to { transform: translateX(100%); } }
|
||||
</style>
|
||||
|
||||
|
||||
@@ -3,18 +3,21 @@
|
||||
<!-- 顶部标题与保存按钮 -->
|
||||
<view class="page-header border-shadow">
|
||||
<view class="header-left">
|
||||
<text class="page-title">个人中心</text>
|
||||
<text class="page-title">个人中心装修</text>
|
||||
</view>
|
||||
<view class="header-right">
|
||||
<view class="btn-primary" @click="handleSave">
|
||||
<text class="btn-txt">保存</text>
|
||||
<text class="btn-txt">{{ isSaving ? '保存中...' : '保存配置' }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 主要内容区 -->
|
||||
<view class="content-container anim-fade-in">
|
||||
<view class="main-card border-shadow">
|
||||
<view v-if="isLoading" class="loading-state">
|
||||
<text>配置加载中...</text>
|
||||
</view>
|
||||
<view v-else class="main-card border-shadow">
|
||||
<!-- 左侧:手机预览 -->
|
||||
<view class="preview-panel">
|
||||
<view class="phone-mockup">
|
||||
@@ -27,37 +30,37 @@
|
||||
<image class="avatar-img" src="/static/logo.png" mode="aspectFill"></image>
|
||||
</view>
|
||||
<view class="user-info">
|
||||
<text class="user-name">用户名称用户名称</text>
|
||||
<text class="user-name">演示用户</text>
|
||||
<view class="bind-phone">
|
||||
<text class="bind-txt">绑定手机号 ></text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="header-icons">
|
||||
<view class="ic-msg">🔔<text class="msg-dot">6</text></view>
|
||||
<view class="ic-msg">🔔</view>
|
||||
<view class="ic-set">⚙️</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="stats-row">
|
||||
<view class="stat-item">
|
||||
<text class="stat-val">0.00</text>
|
||||
<text class="stat-val">88.00</text>
|
||||
<text class="stat-label">我的余额</text>
|
||||
</view>
|
||||
<view class="stat-item">
|
||||
<text class="stat-val">65749</text>
|
||||
<text class="stat-val">1200</text>
|
||||
<text class="stat-label">当前积分</text>
|
||||
</view>
|
||||
<view class="stat-item">
|
||||
<text class="stat-val">25</text>
|
||||
<text class="stat-val">5</text>
|
||||
<text class="stat-label">优惠券</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 样式1 会员卡 -->
|
||||
<view v-if="selectedStyle === 1" class="member-card-s1" @click="handleMember">
|
||||
<view v-if="selectedStyle === 1" class="member-card-s1">
|
||||
<view class="mc-content-s1">
|
||||
<view class="mc-left">
|
||||
<text class="mc-ic">👑</text>
|
||||
<text class="mc-txt">会员到期 2022-12-31</text>
|
||||
<text class="mc-txt">尊贵会员服务</text>
|
||||
</view>
|
||||
<view class="mc-right">
|
||||
<text class="mc-btn">立即续费 ></text>
|
||||
@@ -66,13 +69,12 @@
|
||||
</view>
|
||||
|
||||
<!-- 样式2 会员卡 -->
|
||||
<view v-if="selectedStyle === 2" class="member-card-s2" @click="handleMember">
|
||||
<view v-if="selectedStyle === 2" class="member-card-s2">
|
||||
<view class="mc-content-s2">
|
||||
<view class="mc-left">
|
||||
<text class="mc-ic">👑</text>
|
||||
<view class="mc-info-col">
|
||||
<text class="mc-t1">会员可享多项权益</text>
|
||||
<text class="mc-t2">会员剩余360天</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="mc-right">
|
||||
@@ -90,43 +92,22 @@
|
||||
<image class="avatar-img" src="/static/logo.png" mode="aspectFill"></image>
|
||||
</view>
|
||||
<view class="user-info-s3">
|
||||
<text class="user-name-s3">用户名称用户名称</text>
|
||||
<view class="bind-phone-s3">
|
||||
<text class="bind-txt-s3">绑定手机号 ></text>
|
||||
</view>
|
||||
<text class="user-name-s3">演示用户</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="header-icons-s3">
|
||||
<view class="ic-msg-s3">🔔<text class="msg-dot-s3">6</text></view>
|
||||
<view class="ic-set-s3">⚙️</view>
|
||||
<view class="ic-msg-s3">🔔</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="stats-row-s3">
|
||||
<view class="stat-item">
|
||||
<text class="stat-val-s3">0.00</text>
|
||||
<text class="stat-label-s3">我的余额</text>
|
||||
<text class="stat-val-s3">88.00</text>
|
||||
<text class="stat-label-s3">余额</text>
|
||||
</view>
|
||||
<view class="stat-item">
|
||||
<text class="stat-val-s3">65749</text>
|
||||
<text class="stat-label-s3">当前积分</text>
|
||||
</view>
|
||||
<view class="stat-item">
|
||||
<text class="stat-val-s3">25</text>
|
||||
<text class="stat-label-s3">优惠券</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 样式3 会员卡 -->
|
||||
<view v-if="selectedStyle === 3" class="member-card-s3" @click="handleMember">
|
||||
<view class="mc-content-s3">
|
||||
<view class="mct-left-s3">
|
||||
<text class="mct-ic-s3">👑</text>
|
||||
<text class="mct-txt-s3">开通会员VIP</text>
|
||||
</view>
|
||||
<view class="mct-right-s3">
|
||||
<text class="mct-more-s3">会员可享多项权益 ></text>
|
||||
<text class="stat-val-s3">1200</text>
|
||||
<text class="stat-label-s3">积分</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
@@ -139,19 +120,12 @@
|
||||
</view>
|
||||
<view class="order-grid">
|
||||
<view class="grid-item" v-for="(item, index) in orderItems" :key="index">
|
||||
<view class="gi-ic-box">
|
||||
<text class="gi-ic">{{ item.icon }}</text>
|
||||
</view>
|
||||
<text class="gi-txt">{{ item.name }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 广告位 -->
|
||||
<view class="ad-box">
|
||||
<text class="ad-txt">暂无广告数据</text>
|
||||
</view>
|
||||
|
||||
<!-- 我的服务 -->
|
||||
<view class="section-card">
|
||||
<view class="section-header">
|
||||
@@ -166,21 +140,6 @@
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 商家管理 -->
|
||||
<view class="section-card">
|
||||
<view class="section-header">
|
||||
<text class="sh-title">商家管理</text>
|
||||
</view>
|
||||
<view class="merchant-grid">
|
||||
<view class="grid-item-m" v-for="(item, index) in merchantItems" :key="index">
|
||||
<view class="gi-ic-box-m">
|
||||
<text class="gi-ic-m">{{ item.icon }}</text>
|
||||
</view>
|
||||
<text class="gi-txt-m">{{ item.name }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</scroll-view>
|
||||
</view>
|
||||
</view>
|
||||
@@ -190,25 +149,25 @@
|
||||
<view class="settings-group">
|
||||
<view class="group-title">
|
||||
<view class="title-line"></view>
|
||||
<text class="title-txt">页面设置</text>
|
||||
<text class="title-txt">页面布局风格</text>
|
||||
</view>
|
||||
<view class="setting-item-row mt-20">
|
||||
<text class="item-label">页面风格:</text>
|
||||
<view class="radio-group">
|
||||
<view class="radio-item" @click="selectedStyle = 1">
|
||||
<view :class="['radio-dot', selectedStyle === 1 ? 'active' : '']"></view>
|
||||
<text class="radio-txt">样式1</text>
|
||||
<text class="radio-txt">样式1 (经典红)</text>
|
||||
</view>
|
||||
<view class="radio-item" @click="selectedStyle = 2">
|
||||
<view :class="['radio-dot', selectedStyle === 2 ? 'active' : '']"></view>
|
||||
<text class="radio-txt">样式2</text>
|
||||
<text class="radio-txt">样式2 (通透卡片)</text>
|
||||
</view>
|
||||
<view class="radio-item" @click="selectedStyle = 3">
|
||||
<view :class="['radio-dot', selectedStyle === 3 ? 'active' : '']"></view>
|
||||
<text class="radio-txt">样式3</text>
|
||||
<text class="radio-txt">样式3 (简约白)</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<text class="hint-txt">选择风格后点击右上角“保存”生效,该配置将同步至移动端个人中心页面。</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
@@ -217,358 +176,146 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="uts">
|
||||
import { ref } from 'vue'
|
||||
import { ref, onMounted } from 'vue'
|
||||
import { getActiveDiyConfig, saveDiyPage, type DiyPage } from '@/services/admin/decorationService.uts'
|
||||
|
||||
const selectedStyle = ref(1)
|
||||
const isLoading = ref(false)
|
||||
const isSaving = ref(false)
|
||||
const currentPageId = ref<string | null>(null)
|
||||
|
||||
const orderItems = [
|
||||
{ name: '待付款', icon: '💳' },
|
||||
{ name: '待发货', icon: '🚚' },
|
||||
{ name: '待收货', icon: '📦' },
|
||||
{ name: '待评价', icon: '📝' },
|
||||
{ name: '售后/退款', icon: '🔄' }
|
||||
{ name: '待评价', icon: '📝' }
|
||||
]
|
||||
|
||||
const serviceItems = [
|
||||
{ name: '付费会员', icon: '💎', color: '#FFF7E6' },
|
||||
{ name: '发票管理', icon: '🧾', color: '#F6FFED' },
|
||||
{ name: '积分中心', icon: '🪙', color: '#E6FFFB' },
|
||||
{ name: '联系客服', icon: '🎧', color: '#F0F5FF' },
|
||||
{ name: '优惠券', icon: '🎫', color: '#FFF1F0' },
|
||||
{ name: '我的收藏', icon: '⭐', color: '#FFF2E8' },
|
||||
{ name: '地址信息', icon: '📍', color: '#F9F0FF' },
|
||||
{ name: '我的余额', icon: '💰', color: '#FCFFE6' },
|
||||
{ name: '我的推广', icon: '📢', color: '#FFF7E6' },
|
||||
{ name: '砍价记录', icon: '✂️', color: '#F6FFED' },
|
||||
{ name: '浏览记录', icon: '🕒', color: '#E6FFFB' },
|
||||
{ name: '我的等级', icon: '📊', color: '#F0F5FF' }
|
||||
{ name: '我的余额', icon: '💰', color: '#FCFFE6' }
|
||||
]
|
||||
|
||||
const merchantItems = [
|
||||
{ name: '客服接待', icon: '🎧' },
|
||||
{ name: '订单核销', icon: '✅' },
|
||||
{ name: '统计管理', icon: '📉' }
|
||||
]
|
||||
onMounted(() => {
|
||||
loadConfig()
|
||||
})
|
||||
|
||||
const handleSave = () => {
|
||||
uni.showToast({ title: '保存成功' })
|
||||
async function loadConfig() {
|
||||
isLoading.value = true
|
||||
try {
|
||||
const config = await getActiveDiyConfig('user')
|
||||
if (config != null) {
|
||||
currentPageId.value = config.id
|
||||
const style = config.config.getNumber('style')
|
||||
if (style != null) {
|
||||
selectedStyle.value = style.toInt()
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('Failed to load user decoration config', e)
|
||||
} finally {
|
||||
isLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const handleMember = () => {
|
||||
uni.showToast({ title: '会员功能开发中' })
|
||||
const handleSave = async () => {
|
||||
isSaving.value = true
|
||||
try {
|
||||
const config = { style: selectedStyle.value } as UTSJSONObject
|
||||
const id = await saveDiyPage(currentPageId.value, '个人中心默认配置', 'user', config, true)
|
||||
if (id != null) {
|
||||
currentPageId.value = id
|
||||
uni.showToast({ title: '保存成功', icon: 'success' })
|
||||
}
|
||||
} catch (e) {
|
||||
uni.showToast({ title: '保存失败', icon: 'none' })
|
||||
} finally {
|
||||
isSaving.value = false
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.admin-decoration-user {
|
||||
background-color: #f0f2f5;
|
||||
min-height: 100vh;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.border-shadow {
|
||||
background-color: #fff;
|
||||
box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.05);
|
||||
}
|
||||
|
||||
.page-header {
|
||||
height: 60px;
|
||||
padding: 0 24px;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
z-index: 100;
|
||||
}
|
||||
|
||||
.admin-decoration-user { background-color: #f0f2f5; min-height: 100vh; display: flex; flex-direction: column; }
|
||||
.border-shadow { background-color: #fff; box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.05); }
|
||||
.page-header { height: 60px; padding: 0 24px; display: flex; flex-direction: row; justify-content: space-between; align-items: center; z-index: 100; }
|
||||
.page-title { font-size: 16px; font-weight: bold; color: #333; }
|
||||
|
||||
.btn-primary {
|
||||
background-color: #2d8cf0;
|
||||
padding: 6px 20px;
|
||||
border-radius: 4px;
|
||||
cursor: pointer;
|
||||
}
|
||||
.btn-primary { background-color: #2d8cf0; padding: 8px 20px; border-radius: 4px; cursor: pointer; }
|
||||
.btn-txt { color: #fff; font-size: 14px; }
|
||||
|
||||
.content-container {
|
||||
flex: 1;
|
||||
padding: 24px;
|
||||
}
|
||||
|
||||
.main-card {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
min-height: 800px;
|
||||
background-color: #fff;
|
||||
border-radius: 4px;
|
||||
}
|
||||
.content-container { flex: 1; padding: 24px; }
|
||||
.main-card { display: flex; flex-direction: row; min-height: 720px; background-color: #fff; border-radius: 4px; }
|
||||
.loading-state { padding: 100px; text-align: center; color: #999; }
|
||||
|
||||
/* 左侧预览区 */
|
||||
.preview-panel {
|
||||
width: 420px;
|
||||
padding: 40px;
|
||||
background-color: #f7f8fa;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
border-right: 1px solid #f0f0f0;
|
||||
}
|
||||
|
||||
.phone-mockup {
|
||||
width: 320px;
|
||||
height: 640px;
|
||||
background-color: #f5f5f5;
|
||||
border: 1px solid #ddd;
|
||||
border-radius: 8px;
|
||||
overflow: hidden;
|
||||
box-shadow: 0 10px 30px rgba(0,0,0,0.1);
|
||||
}
|
||||
|
||||
.preview-panel { width: 400px; padding: 40px; background-color: #f7f8fa; display: flex; justify-content: center; border-right: 1px solid #f0f0f0; }
|
||||
.phone-mockup { width: 300px; height: 600px; background-color: #f5f5f5; border: 1px solid #ddd; border-radius: 8px; overflow: hidden; box-shadow: 0 10px 30px rgba(0,0,0,0.1); }
|
||||
.phone-body { height: 100%; }
|
||||
|
||||
/* 样式1&2 头部渐变 */
|
||||
.user-header-gradient {
|
||||
background: linear-gradient(135deg, #eb3c2d 0%, #ff5e5e 100%);
|
||||
padding: 25px 0 12px;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.header-top {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
margin-bottom: 20px;
|
||||
padding: 0 15px;
|
||||
}
|
||||
.avatar-box { width: 50px; height: 50px; border-radius: 25px; border: 2px solid rgba(255,255,255,0.8); overflow: hidden; margin-right: 12px; }
|
||||
.user-header-gradient { background: linear-gradient(135deg, #eb3c2d 0%, #ff5e5e 100%); padding: 25px 0 12px; }
|
||||
.header-top { display: flex; flex-direction: row; align-items: center; padding: 0 15px; }
|
||||
.avatar-box { width: 44px; height: 44px; border-radius: 22px; border: 2px solid rgba(255,255,255,0.8); overflow: hidden; margin-right: 12px; }
|
||||
.avatar-img { width: 100%; height: 100%; }
|
||||
|
||||
.user-info { flex: 1; display: flex; flex-direction: column; }
|
||||
.user-name { font-size: 14px; font-weight: bold; color: #fff; margin-bottom: 4px; }
|
||||
.bind-phone { background-color: rgba(0,0,0,0.15); align-self: flex-start; padding: 2px 8px; border-radius: 10px; }
|
||||
.bind-txt { color: #fff; font-size: 10px; }
|
||||
.user-name { font-size: 14px; font-weight: bold; color: #fff; }
|
||||
.bind-phone { background-color: rgba(0,0,0,0.15); align-self: flex-start; padding: 2px 8px; border-radius: 10px; margin-top: 4px; }
|
||||
.bind-txt { color: #fff; font-size: 9px; }
|
||||
.header-icons { display: flex; flex-direction: row; gap: 12px; padding: 0 15px; color: #fff; font-size: 16px; }
|
||||
|
||||
.header-icons { display: flex; flex-direction: row; gap: 15px; padding: 0 15px; }
|
||||
.ic-msg, .ic-set { font-size: 16px; color: #fff; position: relative; }
|
||||
.msg-dot { position: absolute; top: -5px; right: -5px; background-color: #fff; color: #f2270c; font-size: 9px; width: 12px; height: 12px; border-radius: 6px; text-align: center; }
|
||||
|
||||
.stats-row { display: flex; flex-direction: row; justify-content: space-around; padding: 10px 15px; margin-bottom: 0; }
|
||||
.stats-row { display: flex; flex-direction: row; justify-content: space-around; padding: 15px; }
|
||||
.stat-item { display: flex; flex-direction: column; align-items: center; }
|
||||
.stat-val { font-size: 16px; font-weight: bold; color: #fff; margin-bottom: 4px; }
|
||||
.stat-label { font-size: 10px; color: rgba(255,255,255,0.8); }
|
||||
.stat-val { font-size: 15px; font-weight: bold; color: #fff; }
|
||||
.stat-label { font-size: 10px; color: rgba(255,255,255,0.8); margin-top: 2px; }
|
||||
|
||||
/* 会员卡 样式1 */
|
||||
.member-card-s1 {
|
||||
background: linear-gradient(90deg, #fdf1d6 0%, #fbd795 100%);
|
||||
margin: 12px 10px 4px;
|
||||
border-radius: 12px;
|
||||
padding: 15px 16px;
|
||||
}
|
||||
.mc-content-s1 {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
.mc-txt { font-size: 11px; color: #7c581c; margin-left: 6px; }
|
||||
.member-card-s1 { background: linear-gradient(90deg, #fdf1d6 0%, #fbd795 100%); margin: 0 10px; border-radius: 8px; padding: 12px; }
|
||||
.mc-content-s1 { display: flex; flex-direction: row; justify-content: space-between; align-items: center; }
|
||||
.mc-txt { font-size: 11px; color: #7c581c; }
|
||||
.mc-btn { font-size: 10px; color: #7c581c; font-weight: bold; }
|
||||
|
||||
/* 会员卡 样式2 */
|
||||
.member-card-s2 {
|
||||
background-color: rgba(255,255,255,0.25);
|
||||
margin: 12px 10px 4px;
|
||||
border-radius: 12px;
|
||||
padding: 15px 16px;
|
||||
border: 1px solid rgba(255,255,255,0.3);
|
||||
}
|
||||
.mc-content-s2 {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
.mc-info-col { display: flex; flex-direction: column; margin-left: 8px; }
|
||||
.mc-t1 { font-size: 11px; color: #fff; font-weight: bold; }
|
||||
.mc-t2 { font-size: 9px; color: rgba(255,255,255,0.8); }
|
||||
.mc-btn-white { background-color: #fff; color: #f2270c; font-size: 10px; padding: 4px 12px; border-radius: 12px; font-weight: bold; }
|
||||
.member-card-s2 { background-color: rgba(255,255,255,0.2); margin: 0 10px; border-radius: 8px; padding: 12px; border: 1px solid rgba(255,255,255,0.3); }
|
||||
.mc-content-s2 { display: flex; flex-direction: row; justify-content: space-between; align-items: center; }
|
||||
.mc-t1 { font-size: 11px; color: #fff; }
|
||||
.mc-btn-white { background-color: #fff; color: #f2270c; font-size: 10px; padding: 3px 10px; border-radius: 10px; }
|
||||
|
||||
/* 样式3 头部 */
|
||||
.user-header-s3 {
|
||||
background-color: #fff;
|
||||
padding: 30px 15px 0;
|
||||
}
|
||||
.header-top-s3 {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: space-between;
|
||||
align-items: flex-start;
|
||||
margin-bottom: 25px;
|
||||
}
|
||||
.header-top-left {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
}
|
||||
.avatar-box-s3 {
|
||||
width: 54px;
|
||||
height: 54px;
|
||||
border-radius: 27px;
|
||||
overflow: hidden;
|
||||
margin-right: 12px;
|
||||
background-color: #f5f5f5;
|
||||
border: 1px solid #eee;
|
||||
}
|
||||
.user-info-s3 {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
.user-name-s3 {
|
||||
font-size: 16px;
|
||||
font-weight: bold;
|
||||
color: #333;
|
||||
margin-bottom: 6px;
|
||||
}
|
||||
.bind-phone-s3 {
|
||||
display: flex;
|
||||
}
|
||||
.bind-txt-s3 {
|
||||
color: #999;
|
||||
font-size: 11px;
|
||||
}
|
||||
.user-header-s3 { background-color: #fff; padding: 25px 15px 15px; }
|
||||
.header-top-s3 { display: flex; flex-direction: row; justify-content: space-between; align-items: center; }
|
||||
.header-top-left { display: flex; flex-direction: row; align-items: center; }
|
||||
.avatar-box-s3 { width: 48px; height: 44px; border-radius: 24px; overflow: hidden; margin-right: 12px; background: #f5f5f5; }
|
||||
.user-name-s3 { font-size: 15px; font-weight: bold; color: #333; }
|
||||
.header-icons-s3 { color: #333; font-size: 18px; }
|
||||
.stats-row-s3 { display: flex; flex-direction: row; justify-content: space-around; padding-top: 15px; border-top: 1px solid #f5f5f5; margin-top: 15px; }
|
||||
.stat-val-s3 { font-size: 16px; font-weight: bold; color: #333; }
|
||||
.stat-label-s3 { font-size: 11px; color: #999; }
|
||||
|
||||
.header-icons-s3 {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
gap: 15px;
|
||||
padding-top: 5px;
|
||||
}
|
||||
.ic-msg-s3, .ic-set-s3 {
|
||||
font-size: 18px;
|
||||
color: #333;
|
||||
position: relative;
|
||||
}
|
||||
.msg-dot-s3 {
|
||||
position: absolute;
|
||||
top: -6px;
|
||||
right: -6px;
|
||||
background-color: #f2270c;
|
||||
color: #fff;
|
||||
font-size: 9px;
|
||||
width: 14px;
|
||||
height: 14px;
|
||||
border-radius: 7px;
|
||||
text-align: center;
|
||||
line-height: 14px;
|
||||
}
|
||||
|
||||
.stats-row-s3 {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: space-around;
|
||||
padding: 10px 0 20px;
|
||||
}
|
||||
.stat-val-s3 {
|
||||
font-size: 18px;
|
||||
font-weight: bold;
|
||||
color: #333;
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
.stat-label-s3 {
|
||||
font-size: 11px;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.member-card-s3 {
|
||||
background: #282828;
|
||||
margin: 12px 10px;
|
||||
border-radius: 12px;
|
||||
padding: 18px 16px;
|
||||
}
|
||||
.mc-content-s3 {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
.mct-left-s3 {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
}
|
||||
.mct-ic-s3 {
|
||||
font-size: 18px;
|
||||
margin-right: 8px;
|
||||
}
|
||||
.mct-txt-s3 {
|
||||
color: #fbd795;
|
||||
font-size: 14px;
|
||||
font-weight: bold;
|
||||
}
|
||||
.mct-right-s3 {
|
||||
display: flex;
|
||||
}
|
||||
.mct-more-s3 {
|
||||
color: #fbd795;
|
||||
font-size: 11px;
|
||||
opacity: 0.8;
|
||||
}
|
||||
|
||||
/* 通用区块间卡片 */
|
||||
.section-card {
|
||||
background-color: #fff;
|
||||
margin: 10px;
|
||||
border-radius: 8px;
|
||||
padding: 15px;
|
||||
}
|
||||
|
||||
.section-header { display: flex; flex-direction: row; justify-content: space-between; margin-bottom: 15px; }
|
||||
.sh-title { font-size: 13px; font-weight: bold; color: #333; }
|
||||
.section-card { background-color: #fff; margin: 10px; border-radius: 8px; padding: 15px; }
|
||||
.section-header { display: flex; flex-direction: row; justify-content: space-between; margin-bottom: 12px; }
|
||||
.sh-title { font-size: 13px; font-weight: bold; }
|
||||
.sh-more { font-size: 11px; color: #999; }
|
||||
|
||||
.order-grid { display: flex; flex-direction: row; justify-content: space-between; }
|
||||
.grid-item { display: flex; flex-direction: column; align-items: center; }
|
||||
.gi-ic { font-size: 20px; margin-bottom: 6px; }
|
||||
.gi-ic { font-size: 20px; margin-bottom: 4px; }
|
||||
.gi-txt { font-size: 10px; color: #666; }
|
||||
|
||||
.ad-box { background-color: #fff; margin: 10px; border-radius: 8px; height: 50px; display: flex; align-items: center; justify-content: center; border: 1px dashed #eee; }
|
||||
.ad-txt { font-size: 12px; color: #999; }
|
||||
|
||||
.service-grid { display: flex; flex-direction: row; flex-wrap: wrap; }
|
||||
.grid-item-s { width: 25%; display: flex; flex-direction: column; align-items: center; margin-bottom: 15px; }
|
||||
.grid-item-s { width: 33.33%; display: flex; flex-direction: column; align-items: center; margin-bottom: 15px; }
|
||||
.gi-ic-box-s { width: 34px; height: 34px; border-radius: 17px; display: flex; align-items: center; justify-content: center; margin-bottom: 6px; }
|
||||
.gi-ic-s { font-size: 16px; }
|
||||
.gi-txt-s { font-size: 10px; color: #666; }
|
||||
|
||||
.merchant-grid { display: flex; flex-direction: row; gap: 40px; }
|
||||
.grid-item-m { display: flex; flex-direction: column; align-items: center; }
|
||||
.gi-ic-m { font-size: 20px; margin-bottom: 6px; }
|
||||
.gi-txt-m { font-size: 10px; color: #666; }
|
||||
|
||||
/* 右侧设置区 */
|
||||
.settings-panel { flex: 1; padding: 30px; }
|
||||
.group-title { display: flex; flex-direction: row; align-items: center; margin-bottom: 20px; }
|
||||
.title-line { width: 3px; height: 16px; background-color: #2d8cf0; margin-right: 10px; }
|
||||
.title-txt { font-size: 15px; font-weight: bold; color: #333; }
|
||||
|
||||
.setting-item-row { display: flex; flex-direction: row; align-items: center; margin-bottom: 20px; }
|
||||
.item-label { font-size: 14px; color: #666; margin-right: 20px; }
|
||||
|
||||
.radio-group { display: flex; flex-direction: row; gap: 30px; }
|
||||
.radio-group { display: flex; flex-direction: column; gap: 15px; }
|
||||
.radio-item { display: flex; flex-direction: row; align-items: center; cursor: pointer; }
|
||||
.radio-dot { width: 16px; height: 16px; border: 1px solid #dcdfe6; border-radius: 8px; margin-right: 8px; position: relative; }
|
||||
.radio-dot.active { border-color: #2d8cf0; }
|
||||
.radio-dot.active::after { content: ''; width: 8px; height: 8px; background-color: #2d8cf0; border-radius: 4px; position: absolute; top: 3px; left: 3px; }
|
||||
.radio-dot { width: 16px; height: 16px; border: 1px solid #dcdfe6; border-radius: 8px; margin-right: 10px; }
|
||||
.radio-dot.active { border-color: #2d8cf0; background-color: #2d8cf0; }
|
||||
.radio-txt { font-size: 14px; color: #333; }
|
||||
.hint-txt { font-size: 12px; color: #999; margin-top: 20px; line-height: 1.6; }
|
||||
|
||||
.mt-20 { margin-top: 20px; }
|
||||
|
||||
.anim-fade-in {
|
||||
animation: fadeIn 0.4s ease-out;
|
||||
}
|
||||
|
||||
@keyframes fadeIn {
|
||||
from { opacity: 0; transform: translateY(10px); }
|
||||
to { opacity: 1; transform: translateY(0); }
|
||||
}
|
||||
.anim-fade-in { animation: fadeIn 0.4s ease-out; }
|
||||
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
|
||||
</style>
|
||||
|
||||
91
services/admin/decorationService.uts
Normal file
91
services/admin/decorationService.uts
Normal file
@@ -0,0 +1,91 @@
|
||||
import { rpcOrNull, rpcOrValue } from '@/services/analytics/rpc.uts'
|
||||
|
||||
/**
|
||||
* DIY 页面模型
|
||||
*/
|
||||
export type DiyPage = {
|
||||
id: string
|
||||
name: string
|
||||
type: string
|
||||
config: UTSJSONObject
|
||||
is_home: boolean
|
||||
is_active: boolean
|
||||
created_at: string
|
||||
updated_at: string
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取 DIY 页面分页列表
|
||||
*/
|
||||
export async function fetchDiyPageList(
|
||||
search: string | null = null,
|
||||
type: string | null = null,
|
||||
page: number = 1,
|
||||
pageSize: number = 20
|
||||
): Promise<{ total: number, items: Array<DiyPage> }> {
|
||||
const res = await rpcOrNull('rpc_admin_get_diy_page_list', {
|
||||
p_search: search,
|
||||
p_type: type,
|
||||
p_page: page,
|
||||
p_page_size: pageSize
|
||||
} as UTSJSONObject)
|
||||
|
||||
if (res == null) return { total: 0, items: [] as Array<DiyPage> }
|
||||
|
||||
return {
|
||||
total: (res as any).total as number,
|
||||
items: (res as any).items as Array<DiyPage>
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存 DIY 页面配置
|
||||
*/
|
||||
export async function saveDiyPage(
|
||||
id: string | null,
|
||||
name: string,
|
||||
type: string,
|
||||
config: UTSJSONObject,
|
||||
isActive: boolean = true
|
||||
): Promise<string | null> {
|
||||
const res = await rpcOrValue('rpc_admin_save_diy_page', {
|
||||
p_id: id,
|
||||
p_name: name,
|
||||
p_type: type,
|
||||
p_config: config,
|
||||
p_is_active: isActive
|
||||
} as any)
|
||||
|
||||
return res != null ? String(res) : null
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除 DIY 页面
|
||||
*/
|
||||
export async function deleteDiyPage(id: string): Promise<boolean> {
|
||||
const ok = await rpcOrValue('rpc_admin_delete_diy_page', { p_id: id } as any)
|
||||
return ok === true
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置为生效首页
|
||||
*/
|
||||
export async function setAsHomePage(id: string): Promise<boolean> {
|
||||
const ok = await rpcOrValue('rpc_admin_set_home_page', { p_id: id } as any)
|
||||
return ok === true
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取特定类型的生效配置 (供预览或样式页使用)
|
||||
* 逻辑:从列表接口过滤 type 且 is_home = true 的第一项
|
||||
*/
|
||||
export async function getActiveDiyConfig(type: string): Promise<DiyPage | null> {
|
||||
// 由于目前没有单独的 get_active_config RPC,复用 list 接口并按 type 筛选
|
||||
const res = await fetchDiyPageList(null, type, 1, 1)
|
||||
if (res.items.length > 0 && res.items[0].is_home) {
|
||||
// 注意:list 接口可能不返回完整的 config JSON 以节省流量
|
||||
// 如果后续需要完整配置,建议补齐 rpc_admin_get_diy_page_detail
|
||||
return res.items[0]
|
||||
}
|
||||
return null
|
||||
}
|
||||
Reference in New Issue
Block a user