APIClient.js 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  1. var constant = require('const.js');
  2. const HOST_PRODUCT = constant.productApi;
  3. const HOST_BASE = constant.baseApi;
  4. let request = require('WXHttpRequest.js');
  5. const httputil = require('httpUtil.js');
  6. function getProductUrl(action) {
  7. return HOST_PRODUCT + action;
  8. }
  9. function getBaseUrl(action) {
  10. return HOST_BASE + action;
  11. }
  12. module.exports = {
  13. //获取推荐首页信息
  14. getIndex(uid) {
  15. let url = getProductUrl('wx/index');
  16. return request.getInstance().header({
  17. uid
  18. }).url(url).send();
  19. },
  20. // 获取首页人气推荐
  21. getHotRecommend(uid, pageNo, pageSize) {
  22. let url = getBaseUrl('wx/userRead/recommend');
  23. return request.getInstance().header({
  24. uid
  25. }).data({
  26. pageNo,
  27. pageSize,
  28. }).url(url).send();
  29. },
  30. // 获取用户朗读详细信息
  31. getWorksDetail(uid, readId) {
  32. let url = getBaseUrl(`wx/userRead/info/${readId}`);
  33. return request.getInstance().header({
  34. uid
  35. }).url(url).send();
  36. },
  37. // 获取全部课本
  38. getAllBooks(pageNo,pageSize) {
  39. let url = getProductUrl('wx/product');
  40. return request.getInstance().header({
  41. uid: wx.getStorageSync('uid')
  42. }).url(url).data({
  43. pageNo,
  44. pageSize
  45. }).send();
  46. },
  47. // 获取课本详情
  48. getBookDetail(id) {
  49. let url = getProductUrl(`wx/product/${id}`);
  50. return request.getInstance().header({
  51. uid: wx.getStorageSync('uid')
  52. }).url(url).send();
  53. },
  54. // 获取单课详情
  55. getClassDetail(uid,id) {
  56. let url = getProductUrl(`wx/lesson/${id}`);
  57. return request.getInstance().header({
  58. uid
  59. }).url(url).send();
  60. },
  61. // 获取单课朗读信息
  62. getClassRead(uid,data){
  63. let url = getBaseUrl(`wx/userRead`);
  64. return request.getInstance().header({
  65. uid
  66. }).data(data).url(url).send();
  67. },
  68. // 发布作品
  69. postWork(uid, data) {
  70. console.log(data);
  71. let url = getBaseUrl(`wx/userRead`);
  72. return request.getInstance().header({
  73. uid
  74. }).url(url).data(data).method('POST').send();
  75. },
  76. // 关注用户
  77. followUser(uid, followUid) {
  78. let url = getBaseUrl(`wx/fans`);
  79. return request.getInstance().header({
  80. uid
  81. }).url(url).data({
  82. "uid": followUid
  83. }).method('POST').send();
  84. },
  85. //获取关注的用户列表
  86. getFollowUsers(uid, pageNo, pageSize) {
  87. let url = getBaseUrl(`wx/fans`);
  88. return request.getInstance().header({
  89. uid
  90. }).url(url).data({
  91. pageNo: pageNo,
  92. pageSize: pageSize
  93. }).send();
  94. },
  95. // 获取关注用户的作品列表
  96. getFollowWorks(uid, pageNo, pageSize) {
  97. let url = getBaseUrl(`wx/fans/interest`);
  98. return request.getInstance().header({
  99. uid
  100. }).url(url).data({
  101. pageNo: pageNo,
  102. pageSize: pageSize
  103. }).send();
  104. },
  105. // 搜索
  106. getSearchResult(uid,key,pageNo,pageSize){
  107. let url = getProductUrl(`wx/lesson`);
  108. return request.getInstance().header({
  109. uid
  110. }).url(url).data({
  111. title:key,
  112. productId: '',
  113. pageNo: pageNo,
  114. pageSize: pageSize
  115. }).send();
  116. },
  117. // 获取回复信息
  118. getReply(uid, columnId, pageNo, pageSize){
  119. let url = getBaseUrl(`wx/posts/reply`);
  120. return request.getInstance().header({
  121. uid
  122. }).url(url).data({
  123. columnId: columnId,
  124. pageNo: pageNo,
  125. pageSize: pageSize
  126. }).send();
  127. },
  128. // 获取回复(楼中楼)
  129. getReplyComment(uid, postId){
  130. let url = getBaseUrl(`wx/posts/one/${postId}`);
  131. return request.getInstance().header({
  132. uid
  133. }).url(url).send();
  134. },
  135. // 发布回复(楼中楼)
  136. postReplyComment(uid, data){
  137. let url = getBaseUrl(`wx/reply`);
  138. return request.getInstance().header({
  139. uid
  140. }).url(url).data(data).method('POST').send();
  141. },
  142. // 发布讨论
  143. postReply(uid, data){
  144. let url = getBaseUrl(`wx/posts`);
  145. return request.getInstance().header({
  146. uid
  147. }).url(url).data(data).method('POST').send();
  148. },
  149. // 获取推荐团购信息
  150. getGroupList () {
  151. let url = getBaseUrl(`wx/groupPurchaseInfo/recommend`);
  152. return request.getInstance().header({
  153. uid: wx.getStorageSync('uid')
  154. }).url(url).send();
  155. },
  156. // 获取课程团购信息
  157. getGroupPurchaseInfo (productId) {
  158. let url = getBaseUrl(`wx/groupPurchaseInfo/info/${productId}`);
  159. return request.getInstance().header({
  160. uid: wx.getStorageSync('uid')
  161. }).url(url).send();
  162. },
  163. // 发起团购
  164. SendGroupPurchas (data) {
  165. let url = getBaseUrl(`wx/groupPurchase/create`);
  166. return request.getInstance().header({
  167. uid: wx.getStorageSync('uid')
  168. }).url(url).data(data).method('POST').send();
  169. },
  170. // 参加团购
  171. JoinGroupPurchas (orderId) {
  172. let url = getBaseUrl(`wx/groupPurchase/join`);
  173. return request.getInstance().header({
  174. uid: wx.getStorageSync('uid')
  175. }).url(url).data({
  176. orderId
  177. }).method('POST').send();
  178. },
  179. // 收藏课程
  180. collectBook(uid, data){
  181. let url = getBaseUrl(`wx/favorites`);
  182. return request.getInstance().header({
  183. uid
  184. }).url(url).data(data).method('POST').send();
  185. },
  186. //我的团
  187. getMygroup () {
  188. let url = getBaseUrl(`wx/groupPurchase/my`);
  189. return request.getInstance().header({
  190. uid: wx.getStorageSync('uid')
  191. }).url(url).data({
  192. pageNo: 1,
  193. pageSize: 100
  194. }).send();
  195. },
  196. //获取团购详情
  197. getMygroupInfo (orderId) {
  198. let url = getBaseUrl(`wx/groupPurchase/info/${orderId}`);
  199. return request.getInstance().header({
  200. uid: wx.getStorageSync('uid')
  201. }).url(url).send();
  202. },
  203. // 发起奖励
  204. rewardMoney(uid, data){
  205. let url = getBaseUrl(`wx/wallet/award`);
  206. return request.getInstance().header({
  207. uid
  208. }).url(url).data(data).method('POST').send();
  209. },
  210. // 修改资料
  211. settingUserInfo( wechatName, birthday, gender, eyeshield){
  212. let url = getBaseUrl(`wx/user`);
  213. return request.getInstance().header({
  214. uid: wx.getStorageSync('uid')
  215. }).data({
  216. wechatName: wechatName,
  217. birthday: birthday,
  218. gender: gender,
  219. eyeshield: eyeshield
  220. }).url(url).method('PUT').send();
  221. },
  222. //获取个人信息
  223. getUserInfo () {
  224. let url = getBaseUrl(`wx/user`);
  225. return request.getInstance().header({
  226. uid: wx.getStorageSync('uid')
  227. }).data({
  228. uid: wx.getStorageSync('uid')
  229. }).url(url).send();
  230. }
  231. }