From 6505b48d3a0fc2c3a88905f946787d1d175909c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E5=BF=A0=E6=9E=97?= <170083662@qq.com> Date: Fri, 26 Sep 2025 08:25:06 +0800 Subject: [PATCH] =?UTF-8?q?feat(cms):=20=E6=96=B0=E5=A2=9E=E5=B9=BF?= =?UTF-8?q?=E5=91=8A=E4=BD=8D=E6=9F=A5=E8=AF=A2=E6=8E=A5=E5=8F=A3=E5=92=8C?= =?UTF-8?q?=E4=B8=BB=E9=A2=98=E5=AD=97=E6=AE=B5=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 新增根据code查询广告位的API接口 - 在网站字段模型中添加theme主题字段 - 实现启动时自动设置用户主题功能 - 移除调试用的邀请信息打印逻辑 -优化导入路径引用方式 --- src/api/cms/cmsAd/index.ts | 13 +++++++++++++ src/api/cms/cmsWebsiteField/model/index.ts | 1 + src/api/shop/shopUserAddress/model/index.ts | 2 +- src/app.ts | 17 ++++++++++++----- 4 files changed, 27 insertions(+), 6 deletions(-) diff --git a/src/api/cms/cmsAd/index.ts b/src/api/cms/cmsAd/index.ts index 9cd1dcc..a9b1ca7 100644 --- a/src/api/cms/cmsAd/index.ts +++ b/src/api/cms/cmsAd/index.ts @@ -100,3 +100,16 @@ export async function getCmsAd(id: number) { } return Promise.reject(new Error(res.message)); } + +/** + * 根据id查询广告位 + */ +export async function getCmsAdByCode(code: string) { + const res = await request.get>( + '/cms/cms-ad/getByCode/' + code + ); + if (res.code === 0 && res.data) { + return res.data; + } + return Promise.reject(new Error(res.message)); +} diff --git a/src/api/cms/cmsWebsiteField/model/index.ts b/src/api/cms/cmsWebsiteField/model/index.ts index 3a13b4a..d757a89 100644 --- a/src/api/cms/cmsWebsiteField/model/index.ts +++ b/src/api/cms/cmsWebsiteField/model/index.ts @@ -48,6 +48,7 @@ export interface Config { loginBgImg?: string; address?: string; tel?: string; + theme?: string; workDay?: string; kefu2?: string; kefu1?: string; diff --git a/src/api/shop/shopUserAddress/model/index.ts b/src/api/shop/shopUserAddress/model/index.ts index fff978c..9bf7f50 100644 --- a/src/api/shop/shopUserAddress/model/index.ts +++ b/src/api/shop/shopUserAddress/model/index.ts @@ -1,4 +1,4 @@ -import type { PageParam } from '@/api/index'; +import type { PageParam } from '@/api'; /** * 收货地址 diff --git a/src/app.ts b/src/app.ts index 9eba816..83dac88 100644 --- a/src/app.ts +++ b/src/app.ts @@ -6,7 +6,8 @@ import './app.scss' import {loginByOpenId} from "@/api/layout"; import {TenantId} from "@/config/app"; import {saveStorageByLoginUser} from "@/utils/server"; -import {parseInviteParams, saveInviteParams, trackInviteSource, handleInviteRelation, debugInviteInfo} from "@/utils/invite"; +import {parseInviteParams, saveInviteParams, trackInviteSource, handleInviteRelation} from "@/utils/invite"; +import {configWebsiteField} from "@/api/cms/cmsWebsiteField"; function App(props: { children: any; }) { const reload = () => { @@ -52,6 +53,7 @@ function App(props: { children: any; }) { // 处理小程序启动参数中的邀请信息 const options = Taro.getLaunchOptionsSync() handleLaunchOptions(options) + handleTheme() }) // 处理启动参数 @@ -80,10 +82,6 @@ function App(props: { children: any; }) { }) }, 1000) - // 打印调试信息 - setTimeout(() => { - debugInviteInfo() - }, 2000) } else { console.log('❌ 未检测到邀请参数') } @@ -94,6 +92,15 @@ function App(props: { children: any; }) { } } + const handleTheme = () => { + configWebsiteField().then(data => { + // 设置主题 + if(data.theme && !Taro.getStorageSync('user_theme')){ + Taro.setStorageSync('user_theme', data.theme) + } + }) + } + // 对应 onHide useDidHide(() => { })