index.js 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. var util = require('../../utils/util.js');
  2. var api = require('../../config/api.js');
  3. //获取应用实例
  4. var app = getApp()
  5. Page({
  6. data: {
  7. newGoods: [],
  8. hotGoods: [],
  9. topics: [],
  10. brands: [],
  11. floorGoods: [],
  12. banner: [],
  13. channel: []
  14. },
  15. onShareAppMessage: function () {
  16. return {
  17. title: 'YouApp',
  18. desc: '仿网易严选微信小程序商城',
  19. path: '/pages/index/index'
  20. }
  21. },
  22. getIndexData: function () {
  23. let that = this;
  24. util.request(api.IndexUrl).then(function (res) {
  25. if(res.errno === 0) {
  26. console.log(res.data);
  27. that.setData({
  28. newGoods: res.data.newGoodsList,
  29. hotGoods: res.data.hotGoodsList,
  30. topics: res.data.topicList,
  31. brand: res.data.brandList,
  32. floorGoods: res.data.categoryList,
  33. banner: res.data.banner,
  34. channel: res.data.channel
  35. });
  36. }
  37. });
  38. },
  39. onLoad: function (options) {
  40. this.getIndexData();
  41. },
  42. onReady: function () {
  43. // 页面渲染完成
  44. },
  45. onShow: function () {
  46. // 页面显示
  47. },
  48. onHide: function () {
  49. // 页面隐藏
  50. },
  51. onUnload: function () {
  52. // 页面关闭
  53. },
  54. onReachBottom: function () {
  55. if (this.data.bottomLoadDone === true || this.data.bottomLoading === true) {
  56. return false;
  57. }
  58. this.setData({
  59. bottomLoading: true
  60. });
  61. this.getFloorCategory();
  62. }
  63. })