api.js 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. export const ossUrl = process.env.OSS_URL;
  2. export const apiServer = process.env.VUE_APP_BASE_URL;
  3. // console.log("ossUrl", ossUrl);
  4. // console.log("apiServer", apiServer);
  5. export const token = '';
  6. // export const token = '5c654da466ad325c6a1121e6d9e18f21';
  7. // 卡片基本信息查询
  8. export const apiCardBaseQuery = apiServer + 'CardBaseQuery';
  9. // 卡片对应活动或赛事详情查询
  10. export const apiCardDetailQuery = apiServer + 'CardDetailQuery';
  11. // 排名查询
  12. export const apiCardRankDetailQuery = apiServer + 'CardRankDetailQuery';
  13. // 卡片用户当前排名查询
  14. export const apiUserCurrentRankNumQuery = apiServer + 'UserCurrentRankNumQuery';
  15. // 用户是否已经报名卡片对应赛事查询
  16. export const apiUserJoinCardQuery = apiServer + 'UserJoinCardQuery';
  17. // 线上赛报名页面信息详情
  18. export const apiOnlineMcSignUpDetail = apiServer + 'OnlineMcSignUpDetail';
  19. // 线上赛报名(重新分组)
  20. export const apiOnlineMcSignUp = apiServer + 'OnlineMcSignUp';
  21. // 是否允许重新分组(报名)
  22. export const apiIsAllowMcSignUp = apiServer + 'IsAllowMcSignUp';
  23. // 玩家当前月挑战记录查询
  24. export const apiCurrentMonthlyChallengeQuery = apiServer + 'CurrentMonthlyChallengeQuery';
  25. // 卡片配置信息查询
  26. export const apiCardConfigQuery = apiServer + 'CardConfigQuery';
  27. // 玩家所有月挑战记录查询
  28. export const apiMonthlyChallengeQuery = apiServer + 'MonthlyChallengeQuery';
  29. // 玩家活动成就查询
  30. export const apiAchievementQuery = apiServer + 'AchievementQuery';
  31. // 未读消息列表查询
  32. export const apiUnReadMessageQuery = apiServer + 'UnReadMessageQuery';
  33. // 标记消息已读
  34. export const apiReadMessage = apiServer + 'ReadMessage';
  35. // 检测request的返回值
  36. export function checkResCode(res) {
  37. if (res.data.code == 0) {
  38. return true;
  39. } else if (res.statusCode == 401) { // 未登录
  40. uni.showToast({
  41. title: `您尚未登录`,
  42. icon: 'none',
  43. duration: 3000
  44. });
  45. window.location.href = `action://to_login/`;
  46. return false;
  47. } else {
  48. uni.showToast({
  49. title: `${res.data.message}`,
  50. icon: 'none',
  51. duration: 3000
  52. });
  53. return false;
  54. }
  55. };
  56. // 检测token
  57. export function checkToken(token) {
  58. const regex = /^[0-9A-Za-f]{32}$/;
  59. if (regex.test(token)) {
  60. return true;
  61. } else { // 未登录
  62. console.log('checkToken err: ', token);
  63. uni.showToast({
  64. title: `您尚未登录`,
  65. icon: 'none',
  66. duration: 3000
  67. });
  68. window.location.href = `action://to_login/`;
  69. return false;
  70. }
  71. };