index.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. goodsCount: 0,
  9. newGoods: [],
  10. hotGoods: [],
  11. topics: [],
  12. brands: [],
  13. floorGoods: [],
  14. banner: [],
  15. channel: []
  16. },
  17. onShareAppMessage: function () {
  18. return {
  19. title: 'NideShop',
  20. desc: '仿网易严选微信小程序商城',
  21. path: '/pages/index/index'
  22. }
  23. },
  24. getIndexData: function () {
  25. let that = this;
  26. util.request(api.IndexUrl).then(function (res) {
  27. if (res.errno === 0) {
  28. that.setData({
  29. newGoods: res.data.newGoodsList,
  30. hotGoods: res.data.hotGoodsList,
  31. topics: res.data.topicList,
  32. brand: res.data.brandList,
  33. floorGoods: res.data.categoryList,
  34. banner: res.data.banner,
  35. channel: res.data.channel
  36. });
  37. }
  38. });
  39. },
  40. onLoad: function (options) {
  41. this.getIndexData();
  42. util.request(api.GoodsCount).then(res => {
  43. this.setData({
  44. goodsCount: res.data.goodsCount
  45. });
  46. });
  47. },
  48. onReady: function () {
  49. // 页面渲染完成
  50. },
  51. onShow: function () {
  52. // 页面显示
  53. },
  54. onHide: function () {
  55. // 页面隐藏
  56. },
  57. onUnload: function () {
  58. // 页面关闭
  59. },
  60. })