// components/product-list/product-list.js // 获取应用实例 const {API} = require('../../service/api.js'); Component({ properties: { // header嵌入的位置,index:首页 position:{ type:String, value:'' } }, data: { goodsList: [ { name: "哪吒魔童闹海周边哪吒魔童闹海周边哪吒魔童闹海周边", price: 49.5, image:'/images/index/hot-item.png' }, { name: "若来十二生肖盲盒 桌面手办若来十二生肖盲盒 桌面手办若来十二生肖盲盒 桌面手办", price: 49.5, image:'/images/index/hot-item.png' }, { name: "官方正版姜子牙电影四不像", price: 49.5, image:'/images/index/hot-item.png' }, { name: "若来十二生肖盲盒 十二节气祖国版", price: 49.5, image:'/images/index/hot-item.png' }, { name: "哪吒魔童闹海周边哪吒魔童闹海周边哪吒魔童闹海周边", price: 49.5, image:'/images/index/hot-item.png' }, { name: "若来十二生肖盲盒 桌面手办若来十二生肖盲盒 桌面手办若来十二生肖盲盒 桌面手办", price: 49.5, image:'/images/index/hot-item.png' }, { name: "官方正版姜子牙电影四不像", price: 49.5, image:'/images/index/hot-item.png' }, { name: "若来十二生肖盲盒 十二节气祖国版", price: 49.5, image:'/images/index/hot-item.png' }, ], }, methods: { // 获取今日热门商品列表 getHotCommodity(){ API.getLeftProds().then(res=>{ console.log(res); }) }, // 获取上新商品列表 getNewCommodity(){ API.getMiddleProds().then(res=>{ console.log(res); }) }, // 获取预售商品列表 getPresaleCommodity(){ API.getRightProds().then(res=>{ console.log(res); }) } }, ready: function(){ if(this.data.position === 'hot') this.getHotCommodity(); if(this.data.position === 'new') this.getNewCommodity(); if(this.data.position === 'presale') this.getPresaleCommodity(); } })