APIClient.js 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380
  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. cancerFollow(uid, followUid) {
  114. let url = getBaseUrl(`wx/fans`);
  115. return request.getInstance().header({
  116. uid
  117. }).url(url).data({
  118. "uid": followUid
  119. }).method('PUT').send();
  120. },
  121. //获取关注的用户列表
  122. getFollowUsers(uid, pageNo, pageSize) {
  123. let url = getBaseUrl(`wx/fans`);
  124. return request.getInstance().header({
  125. uid
  126. }).url(url).data({
  127. pageNo: pageNo,
  128. pageSize: pageSize
  129. }).send();
  130. },
  131. // 获取关注用户的作品列表
  132. getFollowWorks(pageNo, pageSize) {
  133. let url = getBaseUrl(`wx/fans/interest`);
  134. return request.getInstance().header({
  135. uid: wx.getStorageSync('uid')
  136. }).url(url).data({
  137. pageNo: pageNo,
  138. pageSize: pageSize
  139. }).send();
  140. },
  141. // 搜索
  142. getSearchResult(uid, key, pageNo, pageSize) {
  143. let url = getProductUrl(`wx/lesson`);
  144. return request.getInstance().header({
  145. uid
  146. }).url(url).data({
  147. title: key,
  148. productId: '',
  149. pageNo: pageNo,
  150. pageSize: pageSize
  151. }).send();
  152. },
  153. // 获取回复信息
  154. getReply(uid, columnId, pageNo, pageSize) {
  155. let url = getBaseUrl(`wx/posts/reply`);
  156. return request.getInstance().header({
  157. uid
  158. }).url(url).data({
  159. columnId: columnId,
  160. pageNo: pageNo,
  161. pageSize: pageSize
  162. }).send();
  163. },
  164. // 获取回复(楼中楼)
  165. getReplyComment(uid, postId) {
  166. let url = getBaseUrl(`wx/posts/one/${postId}`);
  167. return request.getInstance().header({
  168. uid
  169. }).url(url).send();
  170. },
  171. // 发布回复(楼中楼)
  172. postReplyComment(uid, data) {
  173. let url = getBaseUrl(`wx/reply`);
  174. return request.getInstance().header({
  175. uid
  176. }).url(url).data(data).method('POST').send();
  177. },
  178. // 点赞评论
  179. likeCommend(uid, likeUid) {
  180. let url = getBaseUrl(`wx/posts/attribute/${likeUid}`);
  181. return request.getInstance().header({
  182. uid
  183. }).url(url).method('GET').send();
  184. },
  185. // 发布讨论
  186. postReply(uid, data) {
  187. let url = getBaseUrl(`wx/posts`);
  188. return request.getInstance().header({
  189. uid
  190. }).url(url).data(data).method('POST').send();
  191. },
  192. // 获取推荐团购信息
  193. getGroupList(pageNo) {
  194. let url = getBaseUrl(`wx/groupPurchaseInfo/recommend`);
  195. return request.getInstance().header({
  196. uid: wx.getStorageSync('uid')
  197. }).url(url).data({
  198. pageNo,
  199. pageSize: 3
  200. }).send();
  201. },
  202. // 获取课程团购信息
  203. getGroupPurchaseInfo(productId) {
  204. let url = getBaseUrl(`wx/groupPurchaseInfo/info/${productId}`);
  205. return request.getInstance().header({
  206. uid: wx.getStorageSync('uid')
  207. }).url(url).send();
  208. },
  209. // 发起团购
  210. SendGroupPurchas(data) {
  211. let url = getBaseUrl(`wx/groupPurchase/create`);
  212. return request.getInstance().header({
  213. uid: wx.getStorageSync('uid')
  214. }).url(url).data(data).method('POST').send();
  215. },
  216. // 参加团购
  217. JoinGroupPurchas(orderId) {
  218. let url = getBaseUrl(`wx/groupPurchase/join`);
  219. return request.getInstance().header({
  220. uid: wx.getStorageSync('uid')
  221. }).url(url).data({
  222. orderId
  223. }).method('POST').send();
  224. },
  225. // 收藏课程
  226. collectClass(uid, data) {
  227. let url = getProductUrl(`wx/favorites`);
  228. return request.getInstance().header({
  229. uid
  230. }).url(url).data(data).method('POST').send();
  231. },
  232. //我的团
  233. getMygroup() {
  234. let url = getBaseUrl(`wx/groupPurchase/my`);
  235. return request.getInstance().header({
  236. uid: wx.getStorageSync('uid')
  237. }).url(url).data({
  238. pageNo: 1,
  239. pageSize: 100
  240. }).send();
  241. },
  242. //获取团购详情
  243. getMygroupInfo(orderId) {
  244. let url = getBaseUrl(`wx/groupPurchase/info/${orderId}`);
  245. return request.getInstance().header({
  246. uid: wx.getStorageSync('uid')
  247. }).url(url).send();
  248. },
  249. //团购是否成功
  250. groupSuccess(orderId) {
  251. let url = getBaseUrl(`wx/groupPurchase/joinStatus`);
  252. return request.getInstance().header({
  253. uid: wx.getStorageSync('uid')
  254. }).url(url).data({
  255. orderId
  256. }).send();
  257. },
  258. // 发起奖励
  259. rewardMoney(uid, data) {
  260. let url = getBaseUrl(`wx/wallet/award`);
  261. return request.getInstance().header({
  262. uid
  263. }).url(url).data(data).method('POST').send();
  264. },
  265. // 修改资料
  266. settingUserInfo(data) {
  267. let url = getBaseUrl(`wx/user`);
  268. return request.getInstance().header({
  269. uid: wx.getStorageSync('uid')
  270. }).data(data).url(url).method('PUT').send();
  271. },
  272. //获取个人信息
  273. getUserInfo() {
  274. let url = getBaseUrl(`wx/user`);
  275. return request.getInstance().header({
  276. uid: wx.getStorageSync('uid')
  277. }).url(url).send();
  278. },
  279. // 获取播放量等数据
  280. getUserWorksInfo() {
  281. let url = getBaseUrl(`wx/user/my`);
  282. return request.getInstance().header({
  283. uid: wx.getStorageSync('uid')
  284. }).url(url).send();
  285. },
  286. // 生成二维码
  287. createQRCode(data) {
  288. let url = getBaseUrl(`wx/qrCode`);
  289. return request.getInstance().header({
  290. uid: wx.getStorageSync('uid')
  291. }).data(data).url(url).send();
  292. },
  293. // 我的奖金
  294. myWallet() {
  295. let url = getBaseUrl('wx/wallet/bonus');
  296. return request.getInstance().header({
  297. uid: wx.getStorageSync('uid')
  298. }).url(url).send();
  299. },
  300. // 資金明細
  301. myWalletDetails() {
  302. let url = getBaseUrl('wx/wallet/record');
  303. return request.getInstance().header({
  304. uid: wx.getStorageSync('uid')
  305. }).url(url).send();
  306. },
  307. // 我的課程
  308. myCourse() {
  309. let url = getBaseUrl('wx/groupPurchase/myCourse');
  310. return request.getInstance().header({
  311. uid: wx.getStorageSync('uid')
  312. }).url(url).send();
  313. },
  314. // 我的朗读
  315. myRead() {
  316. let url = getBaseUrl('wx/userRead/my');
  317. return request.getInstance().header({
  318. uid: wx.getStorageSync('uid')
  319. }).url(url).send();
  320. },
  321. // 我的收藏
  322. myFavorites() {
  323. let url = getProductUrl(`wx/favorites`);
  324. return request.getInstance().header({
  325. uid: wx.getStorageSync('uid')
  326. }).url(url).send();
  327. },
  328. // 我的关注
  329. myFans() {
  330. let url = getBaseUrl(`wx/fans`);
  331. return request.getInstance().header({
  332. uid: wx.getStorageSync('uid')
  333. }).url(url).send();
  334. },
  335. // 课程鉴权
  336. areYouSuper(productArr) {
  337. let url = getBaseUrl(`wx/groupPurchase/auth`);
  338. return request.getInstance().header({
  339. uid: wx.getStorageSync('uid')
  340. }).url(url).data(productArr).method('POST').send();
  341. },
  342. // // 课本鉴权
  343. // areYouBookSuper(productArr){
  344. // let url = getBaseUrl(`wx/groupPurchase/auth`);
  345. // return request.getInstance().header({
  346. // uid: wx.getStorageSync('uid')
  347. // }).url(url).data(productArr).method('POST').send();
  348. // },
  349. // 找到课程对应的课本
  350. checkLesson(lessonId) {
  351. let url = getProductUrl(`wx/lesson/product/${lessonId}`);
  352. return request.getInstance().header({
  353. uid: wx.getStorageSync('uid')
  354. }).url(url).send();
  355. },
  356. // 获取 用户朗读的作品
  357. userWorks(followUid, pageNo, pageSize) {
  358. let url = getBaseUrl('wx/userRead');
  359. return request.getInstance().header({
  360. uid: wx.getStorageSync('uid')
  361. }).data({
  362. uid: followUid,
  363. pageNo: pageNo,
  364. pageSize: pageSize
  365. }).url(url).send();
  366. },
  367. // 获取用户信息
  368. getUserMsg(followUid, pageNo, pageSize) {
  369. let url = getBaseUrl('wx/user/info');
  370. return request.getInstance().header({
  371. uid: wx.getStorageSync('uid')
  372. }).data({
  373. uid: followUid,
  374. pageNo: pageNo,
  375. pageSize: pageSize
  376. }).url(url).send();
  377. },
  378. }