lefengyang
2026-08-20 d01a28cb030b2cb0ff1d42273c877a0f728519a6
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import {ApiUrlBase, IPage, ISearchItem, ISearchParam} from "/src-com";
import {cacheFetch} from "../lib/cacheFetch";
 
export async function executeSearch(param: ISearchParam): Promise<IPage<ISearchItem>> {
    const url = 'http://localhost:3090/search';
    const resp = await cacheFetch(url, {
        method: 'POST',
        body: JSON.stringify(param),
        headers: {
            'Content-Type': 'application/json'
        }
    });
    const text = await resp.text();
    try {
        const result = JSON.parse(text);
        result.dataList || (result.dataList = []);
        return {...param, ...result};
    } catch {
    }
    return {...param, dataList: [], error: text || resp.statusText};
}
 
export async function commitSearchTask(page: IPage<any>): Promise<any> {
    const url = `${ApiUrlBase}/searchGoods/callbackTask`
    return await fetch(url, {
        method: 'POST',
        headers: {
            'Content-Type': 'application/json'
        },
        body: JSON.stringify({...page})
    }).then(r => r.json());
}