APIRequest.js 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. import { getInstance } from './httpRequest';
  2. import { apiUrl } from './const.js';
  3. //console.log(getInstance().url)
  4. const httpApiUrl = (str) => {
  5. return apiUrl + str;
  6. }
  7. class httpRequestApi {
  8. //课程表首页
  9. static getCourse(data) {
  10. const url = httpApiUrl('wx/course');
  11. return getInstance().header({
  12. uid: 1,
  13. }).url(url).data(data).send();
  14. }
  15. //获取课程详情
  16. static getCourseDetails(id) {
  17. const url = httpApiUrl(`wx/course/${id}`);
  18. return getInstance().header({
  19. uid: 1,
  20. }).url(url).data().send();
  21. }
  22. //收藏或者取消
  23. static getDetailsFavorites(data) {
  24. const url = httpApiUrl('wx/favorites');
  25. return getInstance().header({
  26. uid: 1,
  27. }).url(url).data(data).method('POST').send();
  28. }
  29. //获取收藏列表
  30. static getFavoritesList(data) {
  31. const url = httpApiUrl('wx/favorites');
  32. return getInstance().header({
  33. uid: 1,
  34. }).url(url).data(data).send();
  35. }
  36. //添加评论
  37. static getDetailsPosts(data) {
  38. const url = httpApiUrl('wx/posts');
  39. return getInstance().header({
  40. uid: 1,
  41. }).url(url).data(data).method('POST').send();
  42. }
  43. //获取评论列表
  44. static getPostsList(data) {
  45. const url = httpApiUrl('wx/posts');
  46. return getInstance().header({
  47. uid: 1,
  48. }).url(url).data(data).send();
  49. }
  50. //获取播放记录
  51. static getPlayLogList(data) {
  52. const url = httpApiUrl('wx/playLog');
  53. return getInstance().header({
  54. uid: 1,
  55. }).url(url).data(data).send();
  56. }
  57. }
  58. export default httpRequestApi;