api.js 2.4 KB

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