brandDetail.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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. size: 1000
  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, { id: that.data.id }).then(function (res) {
  23. if (res.errno === 0) {
  24. that.setData({
  25. brand: res.data.brand
  26. });
  27. that.getGoodsList();
  28. }
  29. });
  30. },
  31. getGoodsList() {
  32. var that = this;
  33. util.request(api.GoodsList, { brandId: that.data.id, page: that.data.page, size: that.data.size})
  34. .then(function (res) {
  35. if (res.errno === 0) {
  36. that.setData({
  37. goodsList: res.data.goodsList
  38. });
  39. }
  40. });
  41. },
  42. onReady: function () {
  43. // 页面渲染完成
  44. },
  45. onShow: function () {
  46. // 页面显示
  47. },
  48. onHide: function () {
  49. // 页面隐藏
  50. },
  51. onUnload: function () {
  52. // 页面关闭
  53. }
  54. })