feat(cms): 新增广告位查询接口和主题字段支持

- 新增根据code查询广告位的API接口
- 在网站字段模型中添加theme主题字段
- 实现启动时自动设置用户主题功能
- 移除调试用的邀请信息打印逻辑
-优化导入路径引用方式
This commit is contained in:
2025-09-26 08:25:06 +08:00
parent 555c348799
commit 6505b48d3a
4 changed files with 27 additions and 6 deletions

View File

@@ -100,3 +100,16 @@ export async function getCmsAd(id: number) {
} }
return Promise.reject(new Error(res.message)); return Promise.reject(new Error(res.message));
} }
/**
* 根据id查询广告位
*/
export async function getCmsAdByCode(code: string) {
const res = await request.get<ApiResult<CmsAd>>(
'/cms/cms-ad/getByCode/' + code
);
if (res.code === 0 && res.data) {
return res.data;
}
return Promise.reject(new Error(res.message));
}

View File

@@ -48,6 +48,7 @@ export interface Config {
loginBgImg?: string; loginBgImg?: string;
address?: string; address?: string;
tel?: string; tel?: string;
theme?: string;
workDay?: string; workDay?: string;
kefu2?: string; kefu2?: string;
kefu1?: string; kefu1?: string;

View File

@@ -1,4 +1,4 @@
import type { PageParam } from '@/api/index'; import type { PageParam } from '@/api';
/** /**
* 收货地址 * 收货地址

View File

@@ -6,7 +6,8 @@ import './app.scss'
import {loginByOpenId} from "@/api/layout"; import {loginByOpenId} from "@/api/layout";
import {TenantId} from "@/config/app"; import {TenantId} from "@/config/app";
import {saveStorageByLoginUser} from "@/utils/server"; 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; }) { function App(props: { children: any; }) {
const reload = () => { const reload = () => {
@@ -52,6 +53,7 @@ function App(props: { children: any; }) {
// 处理小程序启动参数中的邀请信息 // 处理小程序启动参数中的邀请信息
const options = Taro.getLaunchOptionsSync() const options = Taro.getLaunchOptionsSync()
handleLaunchOptions(options) handleLaunchOptions(options)
handleTheme()
}) })
// 处理启动参数 // 处理启动参数
@@ -80,10 +82,6 @@ function App(props: { children: any; }) {
}) })
}, 1000) }, 1000)
// 打印调试信息
setTimeout(() => {
debugInviteInfo()
}, 2000)
} else { } else {
console.log('❌ 未检测到邀请参数') 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 // 对应 onHide
useDidHide(() => { useDidHide(() => {
}) })