Files
longli-mp/src/request/api/content.js
T

32 lines
1.5 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* 内容接口(/v1/*)—— 商家权益平台
* ---------------------------------------------------------------------------
* 与旧网关(biz.nianxx.cn)是两套后端,差异:
* - 无 clientId 头;鉴权只靠 Authorization: Bearer <token>
* - 成功响应即业务对象本身,没有 { code, data, message } 包装
* - 失败返回 { error: { code, message } },401 表示登录失效
* - 分页只有 limit / offset(limit 1–100,默认 20),未声明的 query 会 400
* - 时间为 RFC3339 UTC,展示前需转北京时间
*/
import { BASE_URL_V1 } from "@/config/env";
import request from "../base/request";
const V1 = `${BASE_URL_V1}/v1`;
/** /v1 通道:不带 clientId */
const V1_CONFIG = { noClientId: true };
/** 首页聚合(品牌 / hero / 板块卡 / 精选推荐 / 导览 / 页脚) */
export const fetchHomepage = () => request.get(`${V1}/homepage`, {}, V1_CONFIG);
/** 板块分类导航(section_key = scenic / stay / food / specialty) */
export const fetchCategories = (sectionKey) =>
request.get(`${V1}/categories`, { section_key: sectionKey }, V1_CONFIG);
/** 商家列表:传 section_key 一次取全(前端按 category_id 归组),或传 category_id 取单分类 */
export const fetchMerchants = (params = {}) =>
request.get(`${V1}/merchants`, { limit: 100, ...params }, V1_CONFIG);
/** 商家详情:一次返回商家 + 权益 + 同类推荐 */
export const fetchMerchantDetail = (id) => request.get(`${V1}/merchants/${id}/detail`, {}, V1_CONFIG);