searchResult.js 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. import httpRequestApi from '../../../utils/APIClient';
  2. Page({
  3. data: {
  4. wareCards: []
  5. },
  6. onLoad: function(option) {
  7. console.log(option);
  8. wx.setNavigationBarTitle({
  9. title: '搜索' //页面标题为路由参数
  10. })
  11. console.log(option.keyWords)
  12. this.search(option.keyWords);
  13. // httpRequestApi.getClassDetail(uid, option.id).success(res => {
  14. // console.log(res);
  15. // this.setData({
  16. // title: res.data.data.title,
  17. // videoUrl:res.data.data.playUrl
  18. // })
  19. // })
  20. },
  21. search: function(key) {
  22. httpRequestApi.getSearchResult(1, key, 1, 10).success(res => {
  23. console.log(res);
  24. const result = res.data.data.list;
  25. const resultTemp = [];
  26. result.forEach(item => {
  27. console.log(item)
  28. const temp = {};
  29. temp.title = item.lesson.title;
  30. temp.grade = item.lesson.gradeClassify;
  31. temp.img = item.lesson.iconImg;
  32. temp.classId = item.lesson.id
  33. resultTemp.push(temp);
  34. });
  35. this.setData({
  36. wareCards: resultTemp
  37. })
  38. console.log(this.data.wareCards)
  39. });
  40. },
  41. openClass: (e) => {
  42. let id = e.currentTarget.dataset.classid;
  43. let title = e.currentTarget.dataset.title;
  44. wx.navigateTo({
  45. url: `../class/class?id=${id}&title=${title}`
  46. })
  47. }
  48. })