index.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. // index.js
  2. const { API } = require('../../service/api.js');
  3. const App = getApp();
  4. Page({
  5. data: {
  6. bannerList: [],
  7. ipInfoList: [],
  8. prodClassList: [],
  9. showAddCartModal: false,
  10. currentProduct: null
  11. },
  12. // 显示商品属性模态框
  13. showAddCartModal(e) {
  14. const product = e.detail;
  15. this.setData({
  16. showAddCartModal: true,
  17. currentProduct:product
  18. });
  19. },
  20. // 关闭商品属性模态框
  21. handleCloseAddCartModal() {
  22. this.setData({ showAddCartModal: false });
  23. },
  24. onLoad: async function (options) {
  25. // 生命周期函数--监听页面加载
  26. console.log("onLoad");
  27. console.log('App.globalData', App.globalData);
  28. const resBanner = await API.getBanners({});
  29. console.log('resBanner', resBanner);
  30. this.setData({
  31. bannerList : resBanner.bannerList
  32. });
  33. const resBrand = await API.getIpInfos({});
  34. console.log('resBrand', resBrand);
  35. this.setData({
  36. ipInfoList : resBrand.ipInfoList
  37. });
  38. const resCategory = await API.getProdClasses({});
  39. console.log('resCategory', resCategory);
  40. this.setData({
  41. prodClassList : resCategory.prodClassList
  42. });
  43. },
  44. })