Browse Source

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

- 新增根据code查询广告位的API接口
- 在网站字段模型中添加theme主题字段
- 实现启动时自动设置用户主题功能
- 移除调试用的邀请信息打印逻辑
-优化导入路径引用方式
master
科技小王子 3 days ago
parent
commit
6505b48d3a
  1. 13
      src/api/cms/cmsAd/index.ts
  2. 1
      src/api/cms/cmsWebsiteField/model/index.ts
  3. 2
      src/api/shop/shopUserAddress/model/index.ts
  4. 17
      src/app.ts

13
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<ApiResult<CmsAd>>(
'/cms/cms-ad/getByCode/' + code
);
if (res.code === 0 && res.data) {
return res.data;
}
return Promise.reject(new Error(res.message));
}

1
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;

2
src/api/shop/shopUserAddress/model/index.ts

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

17
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(() => {
})

Loading…
Cancel
Save