discover.js 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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. wx.showLoading({
  21. title: '加载中',
  22. })
  23. var self = this
  24. getReq({
  25. act: 'brand',
  26. op: 'home'
  27. }, function (res) {
  28. wx.hideLoading()
  29. if (res.code == 200) {
  30. self.setData({
  31. special_datas: res.datas
  32. })
  33. }
  34. })
  35. },
  36. secTabs: function (e) {
  37. wx.pageScrollTo({
  38. scrollTop: 0,
  39. duration: 16
  40. })
  41. let direction = e.currentTarget.dataset.item
  42. if (direction == this.data.direction) {
  43. return
  44. }
  45. this.setData({
  46. direction
  47. })
  48. },
  49. getFunctions() {
  50. var self = this
  51. getReq({
  52. act: 'category',
  53. op: 'index'
  54. }, function (res) {
  55. if (res.code == 200) {
  56. self.setData({
  57. function_items: res.datas.items
  58. })
  59. }
  60. })
  61. },
  62. /**
  63. * 生命周期函数--监听页面初次渲染完成
  64. */
  65. onReady: function () {
  66. },
  67. /**
  68. * 生命周期函数--监听页面显示
  69. */
  70. onShow: function () {
  71. },
  72. /**
  73. * 生命周期函数--监听页面隐藏
  74. */
  75. onHide: function () {
  76. },
  77. /**
  78. * 生命周期函数--监听页面卸载
  79. */
  80. onUnload: function () {
  81. },
  82. /**
  83. * 页面相关事件处理函数--监听用户下拉动作
  84. */
  85. onPullDownRefresh: function () {
  86. },
  87. /**
  88. * 页面上拉触底事件的处理函数
  89. */
  90. onReachBottom: function () {
  91. }
  92. })