index.js 1.4 KB

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