import request from '@/utils/request1';

const interfaceRequest = async (option) => {
  let params = {};
  (option.params || []).forEach(e => {
    Object.keys(e.value).forEach(v => {
      if (Object.keys(params).includes(v)) {
        params[v] = params[v] + ',' + e.value[v];
      } else {
        params[v] = e.value[v];
      }
    });
  });

  const res = await request({
    method: option.method,
    url: option.url || '',
    data: params,
    params: params
  });
  return {
    status: res.code === 200,
    data: res
  };
};
const customRequest = (_this) => {
  console.log(_this.$request);
};

export {
  interfaceRequest,
  customRequest
};
