product-list.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. // components/product-list/product-list.js
  2. // 获取应用实例
  3. const {API} = require('../../service/api.js');
  4. Component({
  5. properties: {
  6. // header嵌入的位置,index:首页
  7. position:{
  8. type:String,
  9. value:''
  10. }
  11. },
  12. data: {
  13. goodsList: [
  14. {
  15. name: "哪吒魔童闹海周边哪吒魔童闹海周边哪吒魔童闹海周边",
  16. price: 49.5,
  17. image:'/images/index/hot-item.png'
  18. },
  19. {
  20. name: "若来十二生肖盲盒 桌面手办若来十二生肖盲盒 桌面手办若来十二生肖盲盒 桌面手办",
  21. price: 49.5,
  22. image:'/images/index/hot-item.png'
  23. },
  24. {
  25. name: "官方正版姜子牙电影四不像",
  26. price: 49.5,
  27. image:'/images/index/hot-item.png'
  28. },
  29. {
  30. name: "若来十二生肖盲盒 十二节气祖国版",
  31. price: 49.5,
  32. image:'/images/index/hot-item.png'
  33. },
  34. {
  35. name: "哪吒魔童闹海周边哪吒魔童闹海周边哪吒魔童闹海周边",
  36. price: 49.5,
  37. image:'/images/index/hot-item.png'
  38. },
  39. {
  40. name: "若来十二生肖盲盒 桌面手办若来十二生肖盲盒 桌面手办若来十二生肖盲盒 桌面手办",
  41. price: 49.5,
  42. image:'/images/index/hot-item.png'
  43. },
  44. {
  45. name: "官方正版姜子牙电影四不像",
  46. price: 49.5,
  47. image:'/images/index/hot-item.png'
  48. },
  49. {
  50. name: "若来十二生肖盲盒 十二节气祖国版",
  51. price: 49.5,
  52. image:'/images/index/hot-item.png'
  53. },
  54. ],
  55. },
  56. methods: {
  57. // 获取今日热门商品列表
  58. getHotCommodity(){
  59. API.getLeftProds().then(res=>{
  60. console.log(res);
  61. })
  62. },
  63. // 获取上新商品列表
  64. getNewCommodity(){
  65. API.getMiddleProds().then(res=>{
  66. console.log(res);
  67. })
  68. },
  69. // 获取预售商品列表
  70. getPresaleCommodity(){
  71. API.getRightProds().then(res=>{
  72. console.log(res);
  73. })
  74. }
  75. },
  76. ready: function(){
  77. if(this.data.position === 'hot') this.getHotCommodity();
  78. if(this.data.position === 'new') this.getNewCommodity();
  79. if(this.data.position === 'presale') this.getPresaleCommodity();
  80. }
  81. })