APIClient.js 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  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. likeCommend(uid,likeUid){
  144. let url = getBaseUrl(`wx/posts/attribute/${likeUid}`);
  145. return request.getInstance().header({
  146. uid
  147. }).url(url).method('GET').send();
  148. },
  149. // 发布讨论
  150. postReply(uid, data){
  151. let url = getBaseUrl(`wx/posts`);
  152. return request.getInstance().header({
  153. uid
  154. }).url(url).data(data).method('POST').send();
  155. },
  156. // 获取推荐团购信息
  157. getGroupList () {
  158. let url = getBaseUrl(`wx/groupPurchaseInfo/recommend`);
  159. return request.getInstance().header({
  160. uid: wx.getStorageSync('uid')
  161. }).url(url).send();
  162. },
  163. // 获取课程团购信息
  164. getGroupPurchaseInfo (productId) {
  165. let url = getBaseUrl(`wx/groupPurchaseInfo/info/${productId}`);
  166. return request.getInstance().header({
  167. uid: wx.getStorageSync('uid')
  168. }).url(url).send();
  169. },
  170. // 发起团购
  171. SendGroupPurchas (data) {
  172. let url = getBaseUrl(`wx/groupPurchase/create`);
  173. return request.getInstance().header({
  174. uid: wx.getStorageSync('uid')
  175. }).url(url).data(data).method('POST').send();
  176. },
  177. // 参加团购
  178. JoinGroupPurchas (orderId) {
  179. let url = getBaseUrl(`wx/groupPurchase/join`);
  180. return request.getInstance().header({
  181. uid: wx.getStorageSync('uid')
  182. }).url(url).data({
  183. orderId
  184. }).method('POST').send();
  185. },
  186. // 收藏课程
  187. collectClass(uid, data){
  188. let url = getProductUrl(`wx/favorites`);
  189. return request.getInstance().header({
  190. uid
  191. }).url(url).data(data).method('POST').send();
  192. },
  193. //我的团
  194. getMygroup () {
  195. let url = getBaseUrl(`wx/groupPurchase/my`);
  196. return request.getInstance().header({
  197. uid: wx.getStorageSync('uid')
  198. }).url(url).data({
  199. pageNo: 1,
  200. pageSize: 100
  201. }).send();
  202. },
  203. //获取团购详情
  204. getMygroupInfo (orderId) {
  205. let url = getBaseUrl(`wx/groupPurchase/info/${orderId}`);
  206. return request.getInstance().header({
  207. uid: wx.getStorageSync('uid')
  208. }).url(url).send();
  209. },
  210. // 发起奖励
  211. rewardMoney(uid, data){
  212. let url = getBaseUrl(`wx/wallet/award`);
  213. return request.getInstance().header({
  214. uid
  215. }).url(url).data(data).method('POST').send();
  216. },
  217. // 修改资料
  218. settingUserInfo( wechatName, birthday, gender, eyeshield){
  219. let url = getBaseUrl(`wx/user`);
  220. return request.getInstance().header({
  221. uid: wx.getStorageSync('uid')
  222. }).data({
  223. wechatName: wechatName,
  224. birthday: birthday,
  225. gender: gender,
  226. eyeshield: eyeshield
  227. }).url(url).method('PUT').send();
  228. },
  229. //获取个人信息
  230. getUserInfo () {
  231. let url = getBaseUrl(`wx/user`);
  232. return request.getInstance().header({
  233. uid: wx.getStorageSync('uid')
  234. }).data({
  235. uid: wx.getStorageSync('uid')
  236. }).url(url).send();
  237. }
  238. }