微信

majorProjects.js 1.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. import Ajax from '../../util/ajax'
  2. import api from '../../util/api'
  3. // 请求数据
  4. export default {
  5. namespaced: true,
  6. state: {
  7. projectInfo: {},
  8. courseDetail: {},
  9. },
  10. mutations: {
  11. setPageInfo (state, data) { // 设置页面信息
  12. state.projectInfo = data
  13. },
  14. setCourseDetailInfo (state, data) { // 设置课程详情信息
  15. state.courseDetail = data
  16. }
  17. },
  18. actions: {
  19. placeOrderForCourse (context, { order, coupons = [] }) { // 课程下单
  20. return new Promise((resolve, reject) => {
  21. Ajax(api.majorProjects.placeCourseOrder.url, {
  22. method: api.majorProjects.placeCourseOrder.method,
  23. data: {
  24. info: window.JSON.stringify(order),
  25. coupons: window.JSON.stringify(coupons),
  26. }
  27. }).then(res => {
  28. resolve(res)
  29. }).catch((err) => {
  30. reject(err)
  31. })
  32. })
  33. },
  34. getProjectInfo (context, { id }) { // 获取课程列表
  35. return new Promise((resolve) => {
  36. Ajax(api.majorProjects.getCourseList.url, {
  37. method: api.majorProjects.getCourseList.method,
  38. urlData: {
  39. id,
  40. }
  41. }).then(res => {
  42. context.commit('setPageInfo', res)
  43. resolve(res)
  44. }).catch((err) => {
  45. reject(err)
  46. })
  47. })
  48. },
  49. getCourseDetailInfo (context, { id }) { // 获取课程列表
  50. return new Promise((resolve) => {
  51. Ajax(api.majorProjects.getCourseDetail.url, {
  52. method: api.majorProjects.getCourseDetail.method,
  53. urlData: {
  54. id,
  55. }
  56. }).then(res => {
  57. context.commit('setCourseDetailInfo', res)
  58. resolve(res)
  59. }).catch((err) => {
  60. reject(err)
  61. })
  62. })
  63. },
  64. }
  65. }