index.js 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. import { getGroomList } from '../../api/store.js';
  2. const app = getApp();
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. parameter: {
  9. 'navbar': '1',
  10. 'return': '1',
  11. 'title': '首发新品'
  12. },
  13. imgUrls: [],
  14. bastList:[],
  15. name:'',
  16. icon:'',
  17. type:0,
  18. status:0,
  19. },
  20. /**
  21. * 生命周期函数--监听页面加载
  22. */
  23. onLoad: function (options) {
  24. this.setData({ type: options.type });
  25. },
  26. /**
  27. * 生命周期函数--监听页面初次渲染完成
  28. */
  29. onReady: function () {
  30. },
  31. /**
  32. * 生命周期函数--监听页面显示
  33. */
  34. onShow: function () {
  35. var type = this.data.type;
  36. if (type == 1){
  37. this.setData({ 'parameter.title': '精品推荐', name: '精品推荐', icon: 'icon-jingpintuijian'});
  38. } else if (type == 2) {
  39. this.setData({ 'parameter.title': '热门榜单', name: '热门榜单', icon: 'icon-remen', status: 1});
  40. } else if (type == 3) {
  41. this.setData({ 'parameter.title': '首发新品', name: '首发新品', icon: 'icon-xinpin' });
  42. } else if (type == 4) {
  43. this.setData({ 'parameter.title': '促销单品', name: '促销单品', icon: 'icon-cuxiaoguanli' });
  44. }else{
  45. this.setData({ 'parameter.title': '首发新品', name: '首发新品', icon: 'icon-xinpin' });
  46. }
  47. this.getIndexGroomList();
  48. },
  49. getIndexGroomList: function () {
  50. var that = this;
  51. getGroomList(that.data.type).then(res=>{
  52. that.setData({ imgUrls: res.data.banner, bastList: res.data.list })
  53. });
  54. },
  55. /**
  56. * 生命周期函数--监听页面隐藏
  57. */
  58. onHide: function () {
  59. },
  60. /**
  61. * 生命周期函数--监听页面卸载
  62. */
  63. onUnload: function () {
  64. },
  65. /**
  66. * 页面相关事件处理函数--监听用户下拉动作
  67. */
  68. onPullDownRefresh: function () {
  69. },
  70. /**
  71. * 页面上拉触底事件的处理函数
  72. */
  73. onReachBottom: function () {
  74. },
  75. /**
  76. * 用户点击右上角分享
  77. */
  78. onShareAppMessage: function () {
  79. }
  80. })