api.js 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  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: 'loading',
  12. title: r.message
  13. })
  14. }
  15. // console.log('api done:', r.data)
  16. cb && cb(r)
  17. },
  18. fail(e) {
  19. console.error('api fail:', e)
  20. wx.showToast({
  21. icon: 'loading',
  22. title: '系统繁忙!'
  23. })
  24. }
  25. }
  26. }
  27. module.exports = {
  28. ilogin: {
  29. loadAT(d, cb) {
  30. post('/mWx/getUserInfo', d).then(resolver(cb).done).catch(resolver(cb).fail)
  31. },
  32. loadUserinfo(d, cb) {
  33. post('small/save_wx_userinfo', d).then(resolver(cb).done).catch(resolver(cb).fail)
  34. },
  35. loadConfig(d ,cb) {
  36. post('small/siteinfo', d).then(resolver(cb).done).catch(resolver(cb).fail)
  37. }
  38. },
  39. ihome: {
  40. loadSponsors(d,cb) {
  41. post('small/zanzhushang_list',d).then(resolver(cb).done).catch(resolver(cb).fail)
  42. },
  43. loadBanners(d,cb) {
  44. post('/home/queryMobileBannerList',d).then(resolver(cb).done).catch(resolver(cb).fail)
  45. },
  46. loadPartners(d,cb) {
  47. post('/home/queryMobilePartnerList',d).then(resolver(cb).done).catch(resolver(cb).fail)
  48. },
  49. loadHotnews(d,cb) {
  50. post('/home/queryMobileHeadlineList',d).then(resolver(cb).done).catch(resolver(cb).fail)
  51. },
  52. },
  53. ihotnews: {
  54. loadNews(d, cb) {
  55. post('small/news_list', d).then(resolver(cb).done).catch(resolver(cb).fail)
  56. },
  57. loadNewsdetails(d, cb) {
  58. post('small/news_detail', d).then(resolver(cb).done).catch(resolver(cb).fail)
  59. },
  60. },
  61. iactivity: {
  62. loadActivities(d, cb) {
  63. post('/mActivity/searchActivityList', d).then(resolver(cb).done).catch(resolver(cb).fail)
  64. },
  65. loadActivitydetails(d, cb) {
  66. post('/mActivity/searchActivityById', d).then(resolver(cb).done).catch(resolver(cb).fail)
  67. },
  68. loadJoinin(d, cb) {
  69. post('small/event_attend', d).then(resolver(cb).done).catch(resolver(cb).fail)
  70. },
  71. },
  72. icommunity: {
  73. uploadPics(f, cb) {
  74. upload('/mUpload/uploadImg', {
  75. }, f).then(resolver(cb).done).catch(resolver(cb).fail)
  76. },
  77. uploadVideos(f, cb) {
  78. upload('/mUpload/uploadVideo', {
  79. }, f).then(resolver(cb).done).catch(resolver(cb).fail)
  80. },
  81. loadPubArticle(d, cb) {
  82. post('/mArticle/saveArticle', d).then(resolver(cb).done).catch(resolver(cb).fail)
  83. },
  84. loadDeleteArticle(d, cb) {
  85. post('/mArticle/deleteMyArticle', d).then(resolver(cb).done).catch(resolver(cb).fail)
  86. },
  87. loadDeleteCollect(d, cb) {
  88. post('/collect/deleteMyCollect', d).then(resolver(cb).done).catch(resolver(cb).fail)
  89. },
  90. loadArticles(d, cb) {
  91. post('/mArticle/searchArticleList', d).then(resolver(cb).done).catch(resolver(cb).fail)
  92. },
  93. loadAddArticle(d, cb) {
  94. post('/collect/addCollect', d).then(resolver(cb).done).catch(resolver(cb).fail)
  95. },
  96. loadAddArticlefavor(d, cb) {
  97. post('small/space_zan_add', d).then(resolver(cb).done).catch(resolver(cb).fail)
  98. },
  99. loadRemoveArticlefavor(d, cb) {
  100. post('small/space_zan_del', d).then(resolver(cb).done).catch(resolver(cb).fail)
  101. },
  102. loadArticledetails(d, cb) {
  103. post('/mArticle/searchArticleById', d).then(resolver(cb).done).catch(resolver(cb).fail)
  104. },
  105. loadArticlecomments(d, cb, hideLoading) {
  106. post('small/space_comment_list', d, hideLoading).then(resolver(cb).done).catch(resolver(cb).fail)
  107. },
  108. loadAddArticlecomment(d, cb) {
  109. post('small/space_comment_add', d).then(resolver(cb).done).catch(resolver(cb).fail)
  110. },
  111. loadArticleCollectionToggle(d, cb) {
  112. post('small/space_follow_opert', d).then(resolver(cb).done).catch(resolver(cb).fail)
  113. },
  114. },
  115. imine: {
  116. loadMyPubarticles(d, cb) {
  117. post('/mArticle/searchMyArticle', d).then(resolver(cb).done).catch(resolver(cb).fail)
  118. },
  119. loadMyCollectedarticles(d, cb) {
  120. post('/collect/searchCollectList', d).then(resolver(cb).done).catch(resolver(cb).fail)
  121. },
  122. loadMyComments(d, cb) {
  123. post('/mComment/queryMyComment', d).then(resolver(cb).done).catch(resolver(cb).fail)
  124. },
  125. loadMyActivities(d, cb) {
  126. post('/mActivity/myApplyActivities', d).then(resolver(cb).done).catch(resolver(cb).fail)
  127. },
  128. loadMyinformation(d,cb) {
  129. post('/user/queryUserById',d).then(resolver(cb).done).catch(resolver(cb).fail)
  130. },
  131. loadEditMyinformation(d, cb) {
  132. post('small/userinfo_modify', d).then(resolver(cb).done).catch(resolver(cb).fail)
  133. },
  134. loadReg(d, cb) {
  135. post('small/userinfo_reg', d).then(resolver(cb).done).catch(resolver(cb).fail)
  136. },
  137. }
  138. }