index.js 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. var app = getApp();
  2. Component({
  3. /**
  4. * 组件的属性列表
  5. */
  6. properties: {
  7. },
  8. /**
  9. * 组件的初始数据
  10. */
  11. data: {
  12. disabled: false,
  13. list: []
  14. },
  15. attached() {
  16. this.getData();
  17. },
  18. /**
  19. * 组件的方法列表
  20. */
  21. methods: {
  22. getData: function () {
  23. var token = wx.getStorageSync('token');
  24. var that = this;
  25. var cur_community = wx.getStorageSync('community');
  26. app.util.request({
  27. 'url': 'entry/wxapp/index',
  28. 'data': {
  29. controller: 'index.load_gps_goodslist',
  30. token: token,
  31. pageNum: 1,
  32. is_random: 1,
  33. head_id: cur_community.communityId
  34. },
  35. dataType: 'json',
  36. success: function (res) {
  37. if (res.data.code == 0) {
  38. let oldList = that.data.list;
  39. let list = oldList.concat(res.data.list);
  40. that.setData({ list })
  41. } else {
  42. that.setData({ noMore: true })
  43. }
  44. }
  45. })
  46. },
  47. openSku: function (e) {
  48. let idx = e.currentTarget.dataset.idx;
  49. this.setData({ disabled: false })
  50. let spuItem = this.data.list[idx];
  51. this.triggerEvent("openSku", {
  52. actId: spuItem.actId,
  53. skuList: spuItem.skuList,
  54. promotionDTO: spuItem.promotionDTO || '',
  55. allData: {
  56. spuName: spuItem.spuName,
  57. skuImage: spuItem.skuImage,
  58. actPrice: spuItem.actPrice,
  59. canBuyNum: spuItem.spuCanBuyNum,
  60. stock: spuItem.spuCanBuyNum,
  61. marketPrice: spuItem.marketPrice
  62. }
  63. })
  64. }
  65. }
  66. })