hot.js 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. import httpRequestApi from '../../utils/APIClient';
  2. export const hotInit = (that) => {
  3. that.setData({
  4. hotData: {
  5. title: '热门',
  6. imgUrls: [
  7. '../../static/image/timg.jpg',
  8. '../../static/image/timg.jpg',
  9. '../../static/image/timg.jpg'
  10. ],
  11. indicatorDots: true,
  12. autoplay: true,
  13. interval: 5000,
  14. duration: 700,
  15. circular: true,
  16. hotWareCardFirst: 'hotWareCardFirst',
  17. hotWareCard : 'hotWareCard',
  18. hotSearch: '鹅鹅鹅',
  19. wareCards:[
  20. {
  21. title:"铺满色巴掌的水泥道1",
  22. grade:"一年级 上学期",
  23. img: "../../static/image/timg.jpg",
  24. plays: "1",
  25. likes: "2",
  26. classId: "1001"
  27. },
  28. {
  29. title:"铺满金色巴掌的水泥道2",
  30. grade:"一年级 上学期",
  31. img: "../../static/image/timg.jpg",
  32. plays: "12345",
  33. likes: "54321",
  34. classId: "1002"
  35. },
  36. {
  37. title:"铺满金色巴掌的水泥道3",
  38. grade:"一年级 上学期",
  39. img: "../../static/image/timg.jpg",
  40. plays: "12345",
  41. likes: "54321",
  42. classId: "1003"
  43. },
  44. ]
  45. }
  46. }),
  47. // 搜索方法
  48. that.searchHandler = () => {
  49. console.log('搜索按钮')
  50. console.log(that.data.hotInput);
  51. if(that.data.hotInput.lenght !== 0){
  52. wx.navigateTo({
  53. url: `../main/searchResult/searchResult?keyWords=${that.data.hotInput}`
  54. })
  55. }
  56. },
  57. // 输入框输入
  58. that.inputHandler = (e) => {
  59. that.setData({
  60. hotInput: e.detail.value
  61. });
  62. console.log(that.data.hotInput)
  63. }
  64. // 打开课程页面
  65. that.openBooks = (e) =>{
  66. wx.navigateTo({
  67. url: `../main/books/books`
  68. })
  69. }
  70. // 打开课程页面
  71. that.openClass = (e) =>{
  72. let id = e.currentTarget.dataset.classid;
  73. let title = e.currentTarget.dataset.title;
  74. wx.navigateTo({
  75. url: `../main/class/class?id=${id}&title=${title}`
  76. })
  77. }
  78. // 打开用户作品页面
  79. that.openWorks = (e) =>{
  80. let uid = e.currentTarget.dataset.uid;
  81. let title = e.currentTarget.dataset.title;
  82. wx.navigateTo({
  83. url: `../social/works/works?id=${uid}&title=${title}`
  84. })
  85. }
  86. that.getIndex = (uid)=>{
  87. httpRequestApi.getIndex({
  88. uid
  89. }).success((res)=>{
  90. console.log(res);
  91. })
  92. }
  93. that.getHotRecommend = (uid,pageNo,pageSize)=>{
  94. httpRequestApi.getHotRecommend(
  95. uid,
  96. pageNo,
  97. pageSize
  98. ).success((res)=>{
  99. console.log(res);
  100. })
  101. }
  102. // 去全部课本
  103. that.goToBooks = () =>{
  104. wx.navigateTo({
  105. url: `../main/books/books`
  106. })
  107. }
  108. that.getIndex(1);
  109. that.getHotRecommend(1,1,3)
  110. }