discover.js 1.8 KB

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