import request from "../../../core/utils/request"; // 变量声明
// 扫码通行api

export const getCommunityInfoUrl = 'api/v1/proxy/getCommunityInfo';
export const getVisitReasonUrl = 'api/v1/proxy/visitReason';
export const recordVisitRegistrationUrl = 'api/v1/proxy/recordVisitRegistration';
export const getFloorListUrl = '/api/v1/proxy/getFloorInfo';
export const getQrCodeUrl = '/api/v1/proxy/generateQrCode'; // 根据小区code获取小区信息

export async function getCommunityInfo(communityCode) {
  const params = {
    url: getCommunityInfoUrl,
    method: 'get',
    data: {
      communityCode
    }
  };
  const [err, res = {}] = await request(params);
  if (err) return null;
  return res;
} // 获取拜访原因列表

export async function getVisitReason(sceneCode) {
  sceneCode = sceneCode && sceneCode !== 'undefined' ? sceneCode : '';
  const params = {
    url: getVisitReasonUrl,
    method: 'get',
    isShowLoading: true,
    data: {
      sceneCode
    }
  };
  const [res] = await request(params);
  return res;
} // 获取楼房列表

export async function getFloorList(params) {
  const data = {
    url: getFloorListUrl,
    method: 'get',
    isShowLoading: true,
    data: params
  };
  const [res] = await request(data);
  return res;
} // 提交来访原因

export async function visitRegistration(params) {
  const [err, res] = await request({
    url: recordVisitRegistrationUrl,
    method: 'post',
    data: params,
    isShowLoading: true
  });
  return [err, res];
} // 提交来访原因

export async function getQrCode(params) {
  const [err, res] = await request({
    url: getQrCodeUrl,
    method: 'get',
    data: params
  });
  return [err, res];
}