index.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. var app = getApp();
  2. Component({
  3. properties: {
  4. value: {
  5. type: Object,
  6. value: {}
  7. },
  8. idx: {
  9. type: Number,
  10. value: 0
  11. }
  12. },
  13. data: {
  14. // list: [],
  15. _lock: false
  16. },
  17. attached: function() {
  18. this.setData({_lock: true },()=>{
  19. this.getGoodsList();
  20. })
  21. },
  22. pageLifetimes: {
  23. show: function () {
  24. this.data._lock || this.getGoodsList();
  25. }
  26. },
  27. methods: {
  28. getGoodsList() {
  29. var token = wx.getStorageSync('token');
  30. var that = this;
  31. var cur_community = wx.getStorageSync('community');
  32. let value = this.data.value;
  33. let sources = value.sources;
  34. let params = {};
  35. if(sources=='category') {
  36. params.gid = value.categoryId;
  37. params.is_random = 0;
  38. } else {
  39. params.is_random = 1;
  40. }
  41. app.util.request({
  42. url: 'entry/wxapp/index',
  43. data: {
  44. controller: 'index.load_gps_goodslist',
  45. token,
  46. pageNum: 1,
  47. head_id: cur_community.communityId || '',
  48. per_page: value.goodsCount,
  49. ...params
  50. },
  51. dataType: 'json',
  52. success: function (res) {
  53. that.setData({ _lock: false })
  54. that.triggerEvent('diyGoodsList', { id: that.data.idx, data: res.data });
  55. }
  56. })
  57. }
  58. }
  59. })