/**
 * SKU定价API请求文件
 * 负责获取外部数据的API请求
 */

class ApiLogistics {
    constructor() {
        this.api = window.api;
        this.logisticsData = {};//记录已经请求过的物流数据
        this.routeIds = [];//记录已经请求过的ID

    }

    
    async batchInstallLogisticData(data){
        console.log('batchInstallLogisticData', window.api);
        const res = await this.api.post('/ali/logisticData/batch', data);
        console.log("请求成功：", res);
        return res;
    }


    async listByRouteId(params){

        // 检查是否已经请求过
        if(this.routeIds.includes(params.routeId)){
            console.log('listByRouteId', params.routeId, '已经请求过');
            return this.logisticsData[params.routeId];
        }

        const res = await this.api.get('/ali/logisticData/listByRouteId', params);
        this.routeIds.push(params.routeId);
        // 记录请求数据
        this.logisticsData[params.routeId] = res.data;
        console.log("/ali/logisticData/listByRouteId请求成功：", res);
        return res.data;
    }

}

// 创建全局实例
window.apiLogistics = new ApiLogistics();

/**
 * API-A 模块
 * 提供多种API调用示例
 */

