import { requestByGet, requestByPost } from "@dage/service";

export const wechatLoginApi = (code: string) => {
  return requestByGet("/api/show/wx/login/" + code, undefined, {
    meta: {
      showError: true,
    },
  });
};

export const setUserInfoApi = (params: any) => {
  return requestByPost("/api/cms/game/editUser", params, {
    meta: {
      showError: true,
    },
  });
};

export const checkLoginApi = () => {
  return requestByGet("/api/show/checkLogin");
};

export const setVistorName = (name: string) => {
  return requestByPost(`/api/show/saveNickname/${name}`);
};

export const feedbackApi = (params: any) => {
  return requestByPost("/api/cms/game/message", params, {
    meta: {
      showError: true,
      showLoading: true,
    },
  });
};

export const getUserPointApi = () => {
  return requestByGet("/api/cms/game/getPoint");
};

export const getPointRecordListApi = () => {
  return requestByGet("/api/cms/game/point/getList", undefined, {
    meta: {
      showLoading: true,
    },
  });
};

export const getProductListApi = (params: any) => {
  return requestByPost("/api/cms/game/prize/pageList", params, {
    meta: {
      showLoading: true,
    },
  });
};

export const redeemApi = (params: any) => {
  return requestByPost("/api/cms/game/prize/redeem", params, {
    meta: {
      showLoading: true,
    },
  });
};

export const getSignListApi = (params: any) => {
  return requestByGet("/api/show/visit/getList", params, {
    meta: {
      showLoading: true,
    },
  });
};

export const addVisitApi = (params: any) => {
  return requestByPost("/api/show/visit/addVisit", params);
};

export const validateNickName = (name: string) => {
  return requestByPost(`/api/show/saveNickname/${name}`, undefined, {
    meta: {
      showError: true,
    },
  });
};
