books.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  1. import httpRequestApi from '../../../utils/APIClient';
  2. Page({
  3. data: {
  4. allBooks: []
  5. },
  6. onLoad: function (options) {
  7. wx.setNavigationBarTitle({
  8. title: '全部课本'
  9. })
  10. httpRequestApi.getAllBooks(1, 10).success((res) => {
  11. const books = res.data.data.list;
  12. const booksTemp = [];
  13. books.forEach(item => {
  14. let temp = {};
  15. temp.id = item.id;
  16. temp.iconImg = item.iconImg;
  17. temp.title = item.subTitle;
  18. booksTemp.push(temp);
  19. });
  20. this.setData({
  21. allBooks: booksTemp
  22. })
  23. console.log(this.data.allBooks)
  24. });
  25. },
  26. goToBook: function(e){
  27. console.log(e.currentTarget.dataset)
  28. let id = e.currentTarget.dataset.id;
  29. let title = e.currentTarget.dataset.title;
  30. wx.navigateTo({
  31. // url: `../singleBook/singleBook?id=${id}&title=${title}`
  32. url: `../../groupPage/grade-details/grade-details?productId=${id}&title=${title}`
  33. })
  34. }
  35. })