home.js 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. // pages/home/home.js
  2. const { getCategoryAPI,getClassifyGoods} = require('../../API/appraise')
  3. Page({
  4. /**
  5. * 页面初始数据
  6. */
  7. data: {
  8. //存放分类列表
  9. classifyList: [],
  10. //用于存放页面上划高度
  11. scrollTop: 0,
  12. },
  13. userTo() {
  14. wx.switchTab({
  15. url: '/pages/user/user',
  16. })
  17. },
  18. classifyTo() {
  19. wx.switchTab({//tabBar页面跳转要用wx.switchTab
  20. url: '/pages/classify/classify',
  21. })
  22. },
  23. searchTo() {
  24. wx.navigateTo({
  25. url: '/pages/search/search',
  26. })
  27. },
  28. //获取点击分类的id
  29. detailClassifyTo({ currentTarget }) {
  30. const id = currentTarget.dataset.num;
  31. const title = currentTarget.dataset.title;
  32. wx.navigateTo({
  33. url: '/pages/classify_detail/classify_detail?classify_id=' + id + '&title=' + title,
  34. })
  35. },
  36. /**
  37. * 生命周期函数--监听页面加载
  38. */
  39. onLoad(options) {
  40. this.getClassifyList();
  41. this.setData({
  42. avatarUrl:wx.getStorageSync('avatarUrl'),
  43. nickName: wx.getStorageSync('nickName')
  44. })
  45. },
  46. getClassifyList() {
  47. getCategoryAPI(this.data)
  48. .then((res) => {
  49. const { code, data, mesage } = res.data;
  50. this.setData({
  51. classifyList: data
  52. })
  53. })
  54. },
  55. // getGoodsList() {
  56. // getClassifyGoods(this.data).then((data) => {
  57. // console.log(data);
  58. // })
  59. // },
  60. /**
  61. * 生命周期函数--监听页面初次渲染完成
  62. */
  63. onReady() {
  64. },
  65. /**
  66. * 生命周期函数--监听页面显示
  67. */
  68. onShow() {
  69. },
  70. /**
  71. * 生命周期函数--监听页面隐藏
  72. */
  73. onHide() {
  74. },
  75. /**
  76. * 生命周期函数--监听页面卸载
  77. */
  78. onUnload() {
  79. },
  80. /**
  81. * 页面相关事件处理函数--监听用户下拉动作
  82. */
  83. onPullDownRefresh() {
  84. },
  85. /**
  86. * 页面上拉触底事件的处理函数
  87. */
  88. onReachBottom() {
  89. },
  90. /**
  91. * 用户点击右上角分享
  92. */
  93. onShareAppMessage() {
  94. },
  95. // /**
  96. // * 监听页面滑动
  97. // */
  98. // onPageScroll(data) {
  99. // // console.log(data.scrollTop);
  100. // this.setData({
  101. // scrollTop: data.scrollTop
  102. // })
  103. // }
  104. })