brandDetail.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. var util = require('../../utils/util.js');
  2. var api = require('../../config/api.js');
  3. var app = getApp();
  4. Page({
  5. data: {
  6. id: 0,
  7. brand: {},
  8. goodsList: [],
  9. page: 1,
  10. limit: 10
  11. },
  12. onLoad: function(options) {
  13. // 页面初始化 options为页面跳转所带来的参数
  14. var that = this;
  15. that.setData({
  16. id: parseInt(options.id)
  17. });
  18. this.getBrand();
  19. },
  20. getBrand: function() {
  21. let that = this;
  22. util.request(api.BrandDetail, {
  23. id: that.data.id
  24. }).then(function(res) {
  25. if (res.errno === 0) {
  26. that.setData({
  27. brand: res.data
  28. });
  29. that.getGoodsList();
  30. }
  31. });
  32. },
  33. getGoodsList() {
  34. var that = this;
  35. util.request(api.GoodsList, {
  36. brandId: that.data.id,
  37. page: that.data.page,
  38. limit: that.data.limit
  39. })
  40. .then(function(res) {
  41. if (res.errno === 0) {
  42. that.setData({
  43. goodsList: res.data.list
  44. });
  45. }
  46. });
  47. },
  48. onReady: function() {
  49. // 页面渲染完成
  50. },
  51. onShow: function() {
  52. // 页面显示
  53. },
  54. onHide: function() {
  55. // 页面隐藏
  56. },
  57. onUnload: function() {
  58. // 页面关闭
  59. }
  60. })