singleBook.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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. httpRequestApi.getBookDetail(uid, options.id).success((res) => {
  15. console.log(res.data.data)
  16. const bookInfo = res.data.data.product;
  17. const lessonList = res.data.data.lessonList;
  18. this.setData({
  19. titleIcon: bookInfo.iconImg,
  20. title: bookInfo.title,
  21. bookInfo: bookInfo.description
  22. })
  23. const lessonTemp = [];
  24. lessonList.forEach(item => {
  25. const temp = {};
  26. temp.id = item.id;
  27. temp.title = item.title;
  28. temp.readNum = item.readCount;
  29. lessonTemp.push(temp);
  30. });
  31. this.setData({
  32. lessonList: lessonTemp
  33. });
  34. console.log(this.data.lessonList)
  35. });
  36. },
  37. goToClass: function(e){
  38. let id = e.currentTarget.dataset.id;
  39. let title = e.currentTarget.dataset.title;
  40. wx.navigateTo({
  41. url: `../class/class?id=${id}&title=${title}`
  42. })
  43. }
  44. })