queryCurrent.js 1.1 KB
Newer Older
钟是志's avatar
钟是志 committed
1
import request from '@/webPublic/zyd_public/request/request';
2

3
window.differenceBetweenServerAndClientTime = 0;
4
export const getTime = () => {
5 6
  const config = window.specialImportantSystemConfig || {};
  if (config.mockServer) {
7
    return request(
8
      `${config.mockServer}/${config.gateWayUrl.zydxg}/InstructorConfigApi/getCurrentDate`,
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
      {
        method: 'POST',
        body: {},
      },
    )
      .then(t => {
        if (t) {
          window.differenceBetweenServerAndClientTime = t - new Date().getTime(); // 服务器时间 与 客户端时间的差值
        }
        return true;
      });
  } else {
    return new Promise((resolve) => {
      window.differenceBetweenServerAndClientTime = 0;
      resolve(true);
    });
  }
钟是志's avatar
钟是志 committed
26 27 28 29
};

export async function queryCurrent() {
  let t = await getTime();
30 31
  const config = window.specialImportantSystemConfig || {};
  if (config.mockServer) {
32
    return request(
33
      `${config.mockServer}/${config.gateWayUrl.zydxg}/UserApi/queryCurrent`,
34 35 36 37 38 39
      {
        method: 'POST',
        body: {},
      },
    );
  }
钟是志's avatar
钟是志 committed
40
}