com.js 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. import lib from '../lib/lib';
  2. export default {
  3. getUser(callback, loading = true) {
  4. let url = "user/home";
  5. let gym_id = lib.getParam('gym_id');
  6. let data = {gym_id};
  7. lib.post(url, data, (ret) => {
  8. if (ret.code == 0) {
  9. callback(ret.data);
  10. } else {
  11. lib.showErrorTip(ret.msg);
  12. }
  13. }, {
  14. loading,
  15. cache : true
  16. });
  17. },
  18. card(uid, callback, loading = true) {
  19. let url = "user/card";
  20. let gym_id = lib.getParam('gym_id');
  21. let data = {uid, gym_id};
  22. lib.post(url, data, (ret) => {
  23. if (ret.code == 0) {
  24. callback(ret.data);
  25. } else {
  26. lib.showErrorTip(ret.msg);
  27. }
  28. }, {
  29. loading,
  30. cache : true
  31. });
  32. },
  33. detailInfo(uid, callback, loading = true) {
  34. let url = "user/detailInfo";
  35. let data = {uid};
  36. lib.post(url, data, (ret) => {
  37. if (ret.code == 0) {
  38. callback(ret.data);
  39. } else {
  40. lib.showErrorTip(ret.msg);
  41. }
  42. }, {
  43. loading,
  44. cache : true
  45. });
  46. },
  47. redPoint() {
  48. let url = "user/redPoint";
  49. lib.get(url, (ret) => {
  50. if (ret.code == 0) {
  51. let localData = localStorage.getItem('redPoint');
  52. if (localData) {
  53. localData = JSON.parse(localData);
  54. }
  55. localData = localData || {};
  56. for (let name in ret.data) {
  57. if (ret.data[name]) {
  58. if (localData[name]) {
  59. if (ret.data[name] > localData[name]) {
  60. $(`[data-redPointName='${name}']`).find('.weui-badge_dot').show();
  61. }
  62. } else {
  63. $(`[data-redPointName='${name}']`).find('.weui-badge_dot').show();
  64. }
  65. }
  66. $(`[data-redPointName='${name}']`).attr('data-redPointVal', ret.data[name]);
  67. }
  68. } else {
  69. lib.showErrorTip(ret.msg);
  70. }
  71. }, {
  72. cache : true
  73. });
  74. }
  75. }