discover.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. // pages/discover/discover.js
  2. const getReq = require('./../../config.js').getReq
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. special_datas: {},
  9. direction: 'backward',
  10. function_items: []
  11. },
  12. /**
  13. * 生命周期函数--监听页面加载
  14. */
  15. onLoad: function (options) {
  16. this.getDatas()
  17. this.getFunctions()
  18. },
  19. getDatas() {
  20. var self = this
  21. getReq({
  22. act: 'brand',
  23. op: 'home'
  24. }, function (res) {
  25. if (res.code == 200) {
  26. self.setData({
  27. special_datas: res.datas
  28. })
  29. }
  30. })
  31. },
  32. secTabs: function (e) {
  33. wx.pageScrollTo({
  34. scrollTop: 0,
  35. duration: 16
  36. })
  37. let direction = e.currentTarget.dataset.item
  38. if (direction == this.data.direction) {
  39. return
  40. }
  41. this.setData({
  42. direction
  43. })
  44. },
  45. getFunctions() {
  46. var self = this
  47. getReq({
  48. act: 'category',
  49. op: 'index'
  50. }, function (res) {
  51. if (res.code == 200) {
  52. self.setData({
  53. function_items: res.datas.items
  54. })
  55. }
  56. })
  57. },
  58. /**
  59. * 生命周期函数--监听页面初次渲染完成
  60. */
  61. onReady: function () {
  62. },
  63. /**
  64. * 生命周期函数--监听页面显示
  65. */
  66. onShow: function () {
  67. },
  68. /**
  69. * 生命周期函数--监听页面隐藏
  70. */
  71. onHide: function () {
  72. },
  73. /**
  74. * 生命周期函数--监听页面卸载
  75. */
  76. onUnload: function () {
  77. },
  78. /**
  79. * 页面相关事件处理函数--监听用户下拉动作
  80. */
  81. onPullDownRefresh: function () {
  82. },
  83. /**
  84. * 页面上拉触底事件的处理函数
  85. */
  86. onReachBottom: function () {
  87. }
  88. })