diff --git a/apps/miniapp/pages/booking/index.js b/apps/miniapp/pages/booking/index.js index 68cd9e6..cca6178 100644 --- a/apps/miniapp/pages/booking/index.js +++ b/apps/miniapp/pages/booking/index.js @@ -11,7 +11,7 @@ Page({ template: getTemplate("personal"), }, onLoad(query) { - Promise.all([request("/public/services"), request("/public/brand")]) + Promise.all([request("/public/offerings"), request("/public/brand")]) .then(([services, brand]) => { const list = Array.isArray(services) ? services : []; const service = diff --git a/apps/miniapp/pages/index/index.js b/apps/miniapp/pages/index/index.js index 496632d..886fd34 100644 --- a/apps/miniapp/pages/index/index.js +++ b/apps/miniapp/pages/index/index.js @@ -9,7 +9,7 @@ Page({ }, load() { this.setData({ loading: true, error: "" }); - Promise.all([request("/public/brand"), request("/public/services")]) + Promise.all([request("/public/brand"), request("/public/offerings")]) .then(([brand, services]) => { getApp().globalData.brand = brand; wx.setNavigationBarTitle({ title: brand.name || "个人品牌" }); diff --git a/apps/miniapp/pages/services/index.js b/apps/miniapp/pages/services/index.js index fab200d..9a8c149 100644 --- a/apps/miniapp/pages/services/index.js +++ b/apps/miniapp/pages/services/index.js @@ -9,12 +9,12 @@ Page({ this.setData({ loading: true, error: "" }); Promise.all([ request("/public/offerings"), - request("/public/services"), + request("/public/offerings"), request("/public/brand"), ]) .then(([offerings, services, brand]) => { const labels = getTemplate(brand.templateKey); - const source = offerings.length ? offerings : services; + const source = offerings; const mapped = source.map((item) => ({ ...item, coverUrl: diff --git a/packages/api-client/src/index.ts b/packages/api-client/src/index.ts index 9196954..555629d 100644 --- a/packages/api-client/src/index.ts +++ b/packages/api-client/src/index.ts @@ -37,6 +37,7 @@ export interface ServiceUpdate { categoryKey?: string; config?: Record; } +export type OfferingUpdate = ServiceUpdate; export interface TrustContent { id: string; type: string; @@ -271,7 +272,7 @@ export class ApiClient { return this.request("/public/brand"); } listServices(): Promise { - return this.request("/public/services"); + return this.request("/public/offerings"); } getPublicWorkspace(): Promise { return this.request("/public/workspace"); @@ -440,18 +441,23 @@ export class ApiClient { }); } updateAdminService(id: string, body: ServiceUpdate): Promise { - return this.request(`/admin/config/services/${encodeURIComponent(id)}`, { + const { categoryKey, ...rest } = body; + return this.request(`/admin/workspace/offerings/${encodeURIComponent(id)}`, { method: "PATCH", - body, + body: { ...rest, ...(categoryKey ? { kind: categoryKey } : {}) }, }); } listAdminServices(): Promise { - return this.request("/admin/config/services"); + return this.request("/admin/workspace/offerings"); } createAdminService( body: ServiceUpdate & { name: string; description: string }, ): Promise { - return this.request("/admin/config/services", { method: "POST", body }); + const { categoryKey, bookingEnabled: _bookingEnabled, ...rest } = body; + return this.request("/admin/workspace/offerings", { + method: "POST", + body: { ...rest, kind: categoryKey ?? "service" }, + }); } listAdminTrustContent(): Promise { return this.request("/admin/config/trust-content"); diff --git a/packages/types/src/index.ts b/packages/types/src/index.ts index 1b24b0a..f68cd5e 100644 --- a/packages/types/src/index.ts +++ b/packages/types/src/index.ts @@ -38,3 +38,4 @@ export interface PublicService { categoryKey?: string; config?: Record | null; } +export type PublicOffering = PublicService;