api.js 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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. // 检测request的返回值
  25. export function checkResCode(res) {
  26. if (res.data.code == 0) {
  27. return true;
  28. } else if (res.statusCode == 401) { // 未登录
  29. uni.showToast({
  30. title: `您尚未登录`,
  31. icon: 'none',
  32. duration: 3000
  33. });
  34. window.location.href = `action://to_login/`;
  35. return false;
  36. } else {
  37. uni.showToast({
  38. title: `${res.data.message}`,
  39. icon: 'none',
  40. duration: 3000
  41. });
  42. return false;
  43. }
  44. };
  45. // 检测token
  46. export function checkToken(token) {
  47. const regex = /^[0-9A-Za-f]{32}$/;
  48. if (regex.test(token)) {
  49. return true;
  50. } else { // 未登录
  51. console.log('checkToken err: ', token);
  52. uni.showToast({
  53. title: `您尚未登录`,
  54. icon: 'none',
  55. duration: 3000
  56. });
  57. window.location.href = `action://to_login/`;
  58. return false;
  59. }
  60. };