discover.js 1.7 KB

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