// import { getCurrentUser, getToken } from '@/webPublic/one_stop_public/utils/token';
import Md5 from './md5';

import { getCurrentUser } from '@/H5Public/utils/2022new/currentUser';
import { getIsBei_Dian, getToken } from '@/H5Public/utils/authority';
import { getUrlParams } from '@/H5Public/utils/handleString';
const isTest = getUrlParams().test;

export function getHeaders(url = '') {
  const token = getToken();
  const currentInfo = getCurrentUser();
  const timestamp = new Date().getTime() + window.differenceBetweenServerAndClientTime;
  const secretString = token + currentInfo.xgUserId + timestamp;

  const res = {
    headers: {
      Authorization: `bearer ${token}`,
    },
  };

  return res;

  if(getIsBei_Dian() && currentInfo?.userid){
    res.headers.auth = Md5(secretString);
    res.headers.timestamp = timestamp;
    if (isTest) {
      console.log(
        {
          secretString,
          md5S: Md5(secretString),
          timestamp,
          xgUserId: currentInfo.xgUserId,
          typeString: currentInfo.typeString,
          differenceBetweenServerAndClientTime: window.differenceBetweenServerAndClientTime,
        },
      );
    }
  }
  return res;
}
