APIClient.js 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339
  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(uid, id) {
  49. let url = getProductUrl(`wx/product/${id}`);
  50. return request.getInstance().header({
  51. 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. classIsLike(uid, data) {
  63. let url = getProductUrl(`wx/favorites/isLike`);
  64. return request.getInstance().header({
  65. uid
  66. }).url(url).data(data).send();
  67. },
  68. getClassDetail(uid, id) {
  69. let url = getProductUrl(`wx/lesson/${id}`);
  70. return request.getInstance().header({
  71. uid
  72. }).url(url).send();
  73. },
  74. // 获取单课朗读信息
  75. getClassRead(uid, data) {
  76. let url = getBaseUrl(`wx/userRead`);
  77. return request.getInstance().header({
  78. uid
  79. }).data(data).url(url).send();
  80. },
  81. // 作品播放了+1
  82. playWorks(uid, readId) {
  83. let url = getBaseUrl(`wx/userRead/play/${readId}`);
  84. return request.getInstance().header({
  85. uid
  86. }).url(url).send();
  87. },
  88. // 发布作品
  89. postWork(uid, data) {
  90. console.log(data);
  91. let url = getBaseUrl(`wx/userRead`);
  92. return request.getInstance().header({
  93. uid
  94. }).url(url).data(data).method('POST').send();
  95. },
  96. // 点赞作品
  97. likeWorks(uid, readId) {
  98. let url = getBaseUrl(`wx/userRead/like/${readId}`);
  99. return request.getInstance().header({
  100. uid
  101. }).url(url).send();
  102. },
  103. // 关注用户
  104. followUser(uid, followUid) {
  105. let url = getBaseUrl(`wx/fans`);
  106. return request.getInstance().header({
  107. uid
  108. }).url(url).data({
  109. "uid": followUid
  110. }).method('POST').send();
  111. },
  112. //获取关注的用户列表
  113. getFollowUsers(uid, pageNo, pageSize) {
  114. let url = getBaseUrl(`wx/fans`);
  115. return request.getInstance().header({
  116. uid
  117. }).url(url).data({
  118. pageNo: pageNo,
  119. pageSize: pageSize
  120. }).send();
  121. },
  122. // 获取关注用户的作品列表
  123. getFollowWorks(uid, pageNo, pageSize) {
  124. let url = getBaseUrl(`wx/fans/interest`);
  125. return request.getInstance().header({
  126. uid
  127. }).url(url).data({
  128. pageNo: pageNo,
  129. pageSize: pageSize
  130. }).send();
  131. },
  132. // 搜索
  133. getSearchResult(uid, key, pageNo, pageSize) {
  134. let url = getProductUrl(`wx/lesson`);
  135. return request.getInstance().header({
  136. uid
  137. }).url(url).data({
  138. title: key,
  139. productId: '',
  140. pageNo: pageNo,
  141. pageSize: pageSize
  142. }).send();
  143. },
  144. // 获取回复信息
  145. getReply(uid, columnId, pageNo, pageSize) {
  146. let url = getBaseUrl(`wx/posts/reply`);
  147. return request.getInstance().header({
  148. uid
  149. }).url(url).data({
  150. columnId: columnId,
  151. pageNo: pageNo,
  152. pageSize: pageSize
  153. }).send();
  154. },
  155. // 获取回复(楼中楼)
  156. getReplyComment(uid, postId) {
  157. let url = getBaseUrl(`wx/posts/one/${postId}`);
  158. return request.getInstance().header({
  159. uid
  160. }).url(url).send();
  161. },
  162. // 发布回复(楼中楼)
  163. postReplyComment(uid, data) {
  164. let url = getBaseUrl(`wx/reply`);
  165. return request.getInstance().header({
  166. uid
  167. }).url(url).data(data).method('POST').send();
  168. },
  169. // 点赞评论
  170. likeCommend(uid, likeUid) {
  171. let url = getBaseUrl(`wx/posts/attribute/${likeUid}`);
  172. return request.getInstance().header({
  173. uid
  174. }).url(url).method('GET').send();
  175. },
  176. // 发布讨论
  177. postReply(uid, data) {
  178. let url = getBaseUrl(`wx/posts`);
  179. return request.getInstance().header({
  180. uid
  181. }).url(url).data(data).method('POST').send();
  182. },
  183. // 获取推荐团购信息
  184. getGroupList() {
  185. let url = getBaseUrl(`wx/groupPurchaseInfo/recommend`);
  186. return request.getInstance().header({
  187. uid: wx.getStorageSync('uid')
  188. }).url(url).send();
  189. },
  190. // 获取课程团购信息
  191. getGroupPurchaseInfo(productId) {
  192. let url = getBaseUrl(`wx/groupPurchaseInfo/info/${productId}`);
  193. return request.getInstance().header({
  194. uid: wx.getStorageSync('uid')
  195. }).url(url).send();
  196. },
  197. // 发起团购
  198. SendGroupPurchas(data) {
  199. let url = getBaseUrl(`wx/groupPurchase/create`);
  200. return request.getInstance().header({
  201. uid: wx.getStorageSync('uid')
  202. }).url(url).data(data).method('POST').send();
  203. },
  204. // 参加团购
  205. JoinGroupPurchas(orderId) {
  206. let url = getBaseUrl(`wx/groupPurchase/join`);
  207. return request.getInstance().header({
  208. uid: wx.getStorageSync('uid')
  209. }).url(url).data({
  210. orderId
  211. }).method('POST').send();
  212. },
  213. // 收藏课程
  214. collectClass(uid, data) {
  215. let url = getProductUrl(`wx/favorites`);
  216. return request.getInstance().header({
  217. uid
  218. }).url(url).data(data).method('POST').send();
  219. },
  220. //我的团
  221. getMygroup() {
  222. let url = getBaseUrl(`wx/groupPurchase/my`);
  223. return request.getInstance().header({
  224. uid: wx.getStorageSync('uid')
  225. }).url(url).data({
  226. pageNo: 1,
  227. pageSize: 100
  228. }).send();
  229. },
  230. //获取团购详情
  231. getMygroupInfo(orderId) {
  232. let url = getBaseUrl(`wx/groupPurchase/info/${orderId}`);
  233. return request.getInstance().header({
  234. uid: wx.getStorageSync('uid')
  235. }).url(url).send();
  236. },
  237. //团购是否成功
  238. groupSuccess(orderId) {
  239. let url = getBaseUrl(`wx/groupPurchase/joinStatus`);
  240. return request.getInstance().header({
  241. uid: wx.getStorageSync('uid')
  242. }).url(url).data({
  243. orderId
  244. }).send();
  245. },
  246. // 发起奖励
  247. rewardMoney(uid, data) {
  248. let url = getBaseUrl(`wx/wallet/award`);
  249. return request.getInstance().header({
  250. uid
  251. }).url(url).data(data).method('POST').send();
  252. },
  253. // 修改资料
  254. settingUserInfo(data) {
  255. let url = getBaseUrl(`wx/user`);
  256. return request.getInstance().header({
  257. uid: wx.getStorageSync('uid')
  258. }).data(data).url(url).method('PUT').send();
  259. },
  260. //获取个人信息
  261. getUserInfo() {
  262. let url = getBaseUrl(`wx/user`);
  263. return request.getInstance().header({
  264. uid: wx.getStorageSync('uid')
  265. }).url(url).send();
  266. },
  267. // 获取播放量等数据
  268. getUserWorksInfo() {
  269. let url = getBaseUrl(`wx/user/my`);
  270. return request.getInstance().header({
  271. uid: wx.getStorageSync('uid')
  272. }).url(url).send();
  273. },
  274. // 生成二维码
  275. createQRCode(data) {
  276. let url = getBaseUrl(`wx/qrCode`);
  277. return request.getInstance().header({
  278. uid: wx.getStorageSync('uid')
  279. }).data(data).url(url).send();
  280. },
  281. // 我的奖金
  282. myWallet() {
  283. let url = getBaseUrl('wx/wallet/bonus');
  284. return request.getInstance().header({
  285. uid: wx.getStorageSync('uid')
  286. }).url(url).send();
  287. },
  288. // 資金明細
  289. myWalletDetails() {
  290. let url = getBaseUrl('wx/wallet/record');
  291. return request.getInstance().header({
  292. uid: wx.getStorageSync('uid')
  293. }).url(url).send();
  294. },
  295. // 我的課程
  296. myCourse() {
  297. let url = getBaseUrl('wx/groupPurchase/myCourse');
  298. return request.getInstance().header({
  299. uid: wx.getStorageSync('uid')
  300. }).url(url).send();
  301. },
  302. // 我的朗读
  303. myRead() {
  304. let url = getBaseUrl('wx/userRead/my');
  305. return request.getInstance().header({
  306. uid: wx.getStorageSync('uid')
  307. }).url(url).send();
  308. },
  309. // 我的收藏
  310. myFavorites() {
  311. let url = getProductUrl(`wx/favorites`);
  312. return request.getInstance().header({
  313. uid: wx.getStorageSync('uid')
  314. }).url(url).send();
  315. },
  316. // 我的关注
  317. myFans() {
  318. let url = getBaseUrl(`wx/fans`);
  319. return request.getInstance().header({
  320. uid: wx.getStorageSync('uid')
  321. }).url(url).send();
  322. },
  323. // 产品鉴权
  324. areYouSuper(productArr){
  325. let url = getBaseUrl(`wx/groupPurchase/auth`);
  326. return request.getInstance().header({
  327. uid: wx.getStorageSync('uid')
  328. }).url(url).data(productArr).method('POST').send();
  329. },
  330. // 找到课程对应的课本
  331. checkLesson(lessonId){
  332. let url = getProductUrl(`wx/lesson/product/${lessonId}`);
  333. return request.getInstance().header({
  334. uid: wx.getStorageSync('uid')
  335. }).url(url).send();
  336. }
  337. }