searchResult.js 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. import httpRequestApi from '../../../utils/APIClient';
  2. Page({
  3. data: {
  4. wareCards:[
  5. {
  6. title:"铺满色巴掌的水泥道1",
  7. grade:"一年级 上学期",
  8. img: "../../../static/image/timg.jpg",
  9. plays: "1",
  10. likes: "2",
  11. classId: "1001"
  12. },
  13. {
  14. title:"铺满金色巴掌的水泥道2",
  15. grade:"一年级 上学期",
  16. img: "../../../static/image/timg.jpg",
  17. plays: "12345",
  18. likes: "54321",
  19. classId: "1002"
  20. },
  21. {
  22. title:"铺满金色巴掌的水泥道3",
  23. grade:"一年级 上学期",
  24. img: "../../../static/image/timg.jpg",
  25. plays: "12345",
  26. likes: "54321",
  27. classId: "1003"
  28. },
  29. ]
  30. },
  31. onLoad: function (option) {
  32. console.log(option);
  33. wx.setNavigationBarTitle({
  34. title: '搜索' //页面标题为路由参数
  35. })
  36. console.log(option.keyWords)
  37. this.search(option.keyWords);
  38. // httpRequestApi.getClassDetail(uid, option.id).success(res => {
  39. // console.log(res);
  40. // this.setData({
  41. // title: res.data.data.title,
  42. // videoUrl:res.data.data.playUrl
  43. // })
  44. // })
  45. },
  46. search: function(key){
  47. httpRequestApi.getSearchResult(1,key,1,10).success(res =>{
  48. console.log(res);
  49. const result = res.data.data.list;
  50. const resultTemp = [];
  51. result.forEach(item => {
  52. console.log(item)
  53. const temp = {};
  54. temp.title = item.lesson.title;
  55. temp.grade = item.lesson.gradeClassify;
  56. temp.img = item.lesson.iconImg;
  57. temp.classId = item.lesson.id
  58. resultTemp .push(temp);
  59. });
  60. this.setData({
  61. wareCards: resultTemp
  62. })
  63. console.log(this.data.wareCards)
  64. });
  65. },
  66. openClass: (e) =>{
  67. let id = e.currentTarget.dataset.classid;
  68. let title = e.currentTarget.dataset.title;
  69. wx.navigateTo({
  70. url: `../class/class?id=${id}&title=${title}`
  71. })
  72. }
  73. })