brandDetail.js 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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. wx.setNavigationBarTitle({
  28. title: res.data.brand.name//页面标题为路由参数
  29. })
  30. that.getGoodsList();
  31. }
  32. });
  33. },
  34. getGoodsList() {
  35. var that = this;
  36. util.request(api.GoodsList, { brandId: that.data.id, page: that.data.page, size: that.data.size})
  37. .then(function (res) {
  38. if (res.errno === 0) {
  39. that.setData({
  40. goodsList: res.data.goodsList,
  41. loadSuccess: true
  42. });
  43. }
  44. });
  45. },
  46. onReady: function () {
  47. // 页面渲染完成
  48. },
  49. onShow: function () {
  50. // 页面显示
  51. },
  52. onHide: function () {
  53. // 页面隐藏
  54. },
  55. onUnload: function () {
  56. // 页面关闭
  57. }
  58. })