singleBook.js 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. import httpRequestApi from '../../../utils/APIClient';
  2. Page({
  3. data: {
  4. titleIcon: '',
  5. title: '',
  6. bookInfo: '',
  7. lessonList: []
  8. },
  9. onLoad: function (options) {
  10. wx.setNavigationBarTitle({
  11. title: options.title
  12. })
  13. const uid= wx.getStorageSync('uid');
  14. console.log(options.id)
  15. httpRequestApi.getBookDetail(uid, options.id).success((res) => {
  16. console.log(res.data.data)
  17. const bookInfo = res.data.data.product;
  18. const lessonList = res.data.data.lessonList;
  19. this.setData({
  20. titleIcon: bookInfo.bgImg,
  21. title: bookInfo.title,
  22. bookInfo: bookInfo.description
  23. })
  24. const lessonTemp = [];
  25. lessonList.forEach(item => {
  26. const temp = {};
  27. temp.id = item.id;
  28. temp.title = item.title;
  29. temp.readNum = item.readCount;
  30. lessonTemp.push(temp);
  31. });
  32. this.setData({
  33. lessonList: lessonTemp
  34. });
  35. console.log(this.data.lessonList)
  36. });
  37. },
  38. goToClass: function(e){
  39. let id = e.currentTarget.dataset.id;
  40. let title = e.currentTarget.dataset.title;
  41. wx.navigateTo({
  42. url: `../class/class?id=${id}&title=${title}`
  43. })
  44. }
  45. })