APIClient.js 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  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. groupSuccess (orderId) {
  205. let url = getBaseUrl(`wx/groupPurchase/joinStatus`);
  206. return request.getInstance().header({
  207. uid: wx.getStorageSync('uid')
  208. }).url(url).data({
  209. orderId
  210. }).send();
  211. },
  212. // 发起奖励
  213. rewardMoney(uid, data){
  214. let url = getBaseUrl(`wx/wallet/award`);
  215. return request.getInstance().header({
  216. uid
  217. }).url(url).data(data).method('POST').send();
  218. },
  219. // 修改资料
  220. settingUserInfo( wechatName, birthday, gender, eyeshield){
  221. let url = getBaseUrl(`wx/user`);
  222. return request.getInstance().header({
  223. uid: wx.getStorageSync('uid')
  224. }).data({
  225. wechatName: wechatName,
  226. birthday: birthday,
  227. gender: gender,
  228. eyeshield: eyeshield
  229. }).url(url).method('PUT').send();
  230. },
  231. //获取个人信息
  232. getUserInfo () {
  233. let url = getBaseUrl(`wx/user`);
  234. return request.getInstance().header({
  235. uid: wx.getStorageSync('uid')
  236. }).data({
  237. uid: wx.getStorageSync('uid')
  238. }).url(url).send();
  239. }
  240. }