index.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. const util = require('../../utils/util.js');
  2. const api = require('../../config/api.js');
  3. const user = require('../../services/user.js');
  4. //获取应用实例
  5. const app = getApp()
  6. Page({
  7. data: {
  8. newGoods: [],
  9. hotGoods: [],
  10. topics: [],
  11. brands: [],
  12. floorGoods: [],
  13. banner: [],
  14. channel: []
  15. },
  16. onShareAppMessage: function () {
  17. return {
  18. title: 'NideShop',
  19. desc: '仿网易严选微信小程序商城',
  20. path: '/pages/index/index'
  21. }
  22. },
  23. getIndexData: function () {
  24. let that = this;
  25. util.request(api.IndexUrl).then(function (res) {
  26. if (res.errno === 0) {
  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. })