api.js 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. import {
  2. post,
  3. upload
  4. } from '../utils/http.js';
  5. const resolver = function(cb) {
  6. return {
  7. done(r) {
  8. console.log(r)
  9. if (r.state != 100) {
  10. return wx.showToast({
  11. icon: 'none',
  12. title: r.msg
  13. })
  14. }
  15. cb && cb(r)
  16. },
  17. fail(e) {
  18. console.error('api fail:', e)
  19. wx.showToast({
  20. icon: 'loading',
  21. title: '系统繁忙!'
  22. })
  23. }
  24. }
  25. }
  26. module.exports = {
  27. ilogin: {
  28. loadAT(d, cb) {
  29. post('/mWx/getUserInfo', d).then(resolver(cb).done).catch(resolver(cb).fail)
  30. },
  31. loadUserinfo(d, cb) {
  32. post('small/save_wx_userinfo', d).then(resolver(cb).done).catch(resolver(cb).fail)
  33. },
  34. loadConfig(d ,cb) {
  35. post('small/siteinfo', d).then(resolver(cb).done).catch(resolver(cb).fail)
  36. }
  37. },
  38. ihome: {
  39. loadSponsors(d,cb) {
  40. post('small/zanzhushang_list',d).then(resolver(cb).done).catch(resolver(cb).fail)
  41. },
  42. loadBanners(d,cb) {
  43. post('/home/queryMobileBannerList',d).then(resolver(cb).done).catch(resolver(cb).fail)
  44. },
  45. loadPartners(d,cb) {
  46. post('/home/queryMobilePartnerList',d).then(resolver(cb).done).catch(resolver(cb).fail)
  47. },
  48. loadHotnews(d,cb) {
  49. post('/home/queryMobileHeadlineList',d).then(resolver(cb).done).catch(resolver(cb).fail)
  50. },
  51. },
  52. ihotnews: {
  53. loadNews(d, cb) {
  54. post('small/news_list', d).then(resolver(cb).done).catch(resolver(cb).fail)
  55. },
  56. loadNewsdetails(d, cb) {
  57. post('small/news_detail', d).then(resolver(cb).done).catch(resolver(cb).fail)
  58. },
  59. },
  60. iactivity: {
  61. loadActivities(d, cb) {
  62. post('/mActivity/searchActivityList', d).then(resolver(cb).done).catch(resolver(cb).fail)
  63. },
  64. loadActivitydetails(d, cb) {
  65. post('/mActivity/searchActivityById', d).then(resolver(cb).done).catch(resolver(cb).fail)
  66. },
  67. loadSaveApply(d, cb) {
  68. post('/mActivity/saveApply', d).then(resolver(cb).done).catch(resolver(cb).fail)
  69. },
  70. },
  71. icommunity: {
  72. uploadPics(f, cb) {
  73. upload('/mUpload/uploadImg', {
  74. }, f).then(resolver(cb).done).catch(resolver(cb).fail)
  75. },
  76. uploadVideos(f, cb) {
  77. upload('/mUpload/uploadVideo', {
  78. }, f).then(resolver(cb).done).catch(resolver(cb).fail)
  79. },
  80. loadPubArticle(d, cb) {
  81. post('/mArticle/saveArticle', d).then(resolver(cb).done).catch(resolver(cb).fail)
  82. },
  83. loadDeleteArticle(d, cb) {
  84. post('/mArticle/deleteMyArticle', d).then(resolver(cb).done).catch(resolver(cb).fail)
  85. },
  86. loadDeleteCollect(d, cb) {
  87. post('/collect/deleteMyCollect', d).then(resolver(cb).done).catch(resolver(cb).fail)
  88. },
  89. loadArticles(d, cb) {
  90. post('/mArticle/searchArticleList', d).then(resolver(cb).done).catch(resolver(cb).fail)
  91. },
  92. loadAddArticle(d, cb) {
  93. post('/collect/addCollect', d).then(resolver(cb).done).catch(resolver(cb).fail)
  94. },
  95. loadAddArticlefavor(d, cb) {
  96. post('small/space_zan_add', d).then(resolver(cb).done).catch(resolver(cb).fail)
  97. },
  98. loadRemoveArticlefavor(d, cb) {
  99. post('small/space_zan_del', d).then(resolver(cb).done).catch(resolver(cb).fail)
  100. },
  101. loadArticledetails(d, cb) {
  102. post('/mArticle/searchArticleById', d).then(resolver(cb).done).catch(resolver(cb).fail)
  103. },
  104. loadArticlecomments(d, cb, hideLoading) {
  105. post('small/space_comment_list', d, hideLoading).then(resolver(cb).done).catch(resolver(cb).fail)
  106. },
  107. loadAddArticlecomment(d, cb) {
  108. post('small/space_comment_add', d).then(resolver(cb).done).catch(resolver(cb).fail)
  109. },
  110. loadArticleCollectionToggle(d, cb) {
  111. post('small/space_follow_opert', d).then(resolver(cb).done).catch(resolver(cb).fail)
  112. },
  113. },
  114. imine: {
  115. loadMyPubarticles(d, cb) {
  116. post('/mArticle/searchMyArticle', d).then(resolver(cb).done).catch(resolver(cb).fail)
  117. },
  118. loadMyCollectedarticles(d, cb) {
  119. post('/collect/searchCollectList', d).then(resolver(cb).done).catch(resolver(cb).fail)
  120. },
  121. loadMyComments(d, cb) {
  122. post('/mComment/queryMyComment', d).then(resolver(cb).done).catch(resolver(cb).fail)
  123. },
  124. loadMyActivities(d, cb) {
  125. post('/mActivity/myApplyActivities', d).then(resolver(cb).done).catch(resolver(cb).fail)
  126. },
  127. loadMyinformation(d,cb) {
  128. post('/user/queryUserById',d).then(resolver(cb).done).catch(resolver(cb).fail)
  129. },
  130. updateUser(d,cb) {
  131. post('/user/updateUser',d).then(resolver(cb).done).catch(resolver(cb).fail)
  132. },
  133. queryAllArea(d,cb) {
  134. post('/user/queryAllArea',d).then(resolver(cb).done).catch(resolver(cb).fail)
  135. },
  136. querySchoolByAreaId(d,cb) {
  137. post('/user/querySchoolByAreaId',d).then(resolver(cb).done).catch(resolver(cb).fail)
  138. },
  139. },
  140. answer: {
  141. attendContest(d, cb) {
  142. post('/mCompetition/attendContest', d).then(resolver(cb).done).catch(resolver(cb).fail)
  143. },
  144. checkPermission(d, cb) {
  145. post('/mCompetition/checkPermission', d).then(resolver(cb).done).catch(resolver(cb).fail)
  146. },
  147. getLeaderBoard(d, cb) {
  148. post('/mCompetition/getLeaderBoard', d).then(resolver(cb).done).catch(resolver(cb).fail)
  149. },
  150. submitUserAnswer(d, cb) {
  151. post('/mCompetition/submitUserAnswer', d).then(resolver(cb).done).catch(resolver(cb).fail)
  152. },
  153. submitReviews(d, cb) {
  154. post('/mCompetition/submitReviews', d).then(resolver(cb).done).catch(resolver(cb).fail)
  155. }
  156. }
  157. }