import request from '@/utils/request';
import { API_BASE_URL } from '@/config/setting';
const BASE_URL = API_BASE_URL;
let reqPromise;

/**
 * 获取省市区数据
 */
export function getRegionsData() {
  if (!reqPromise) {
    reqPromise = new Promise((resolve, reject) => {
      request
        .get(BASE_URL + '/common/autoBrands', {
          baseURL: ''
        })
        .then((res) => {
          resolve(res.data ?? []);
        })
        .catch((e) => {
          reject(e);
        });
    });
  }
  return reqPromise;
}
