index.js 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. // lionfish_comshop/components/new-comer/index.js
  2. var app = getApp();
  3. Component({
  4. /**
  5. * 组件的属性列表
  6. */
  7. properties: {
  8. refresh: {
  9. type: Boolean,
  10. value: false,
  11. observer: function (t) {
  12. if (t) this.setData({ pageNum: 1, noMore: false, list: []}),this.getData();
  13. }
  14. }
  15. },
  16. /**
  17. * 组件的初始数据
  18. */
  19. data: {
  20. disabled: false,
  21. list: [],
  22. pageNum: 1,
  23. noMore: false
  24. },
  25. attached() {
  26. this.getData();
  27. },
  28. /**
  29. * 组件的方法列表
  30. */
  31. methods: {
  32. getData: function() {
  33. var token = wx.getStorageSync('token');
  34. var that = this;
  35. var cur_community = wx.getStorageSync('community');
  36. app.util.request({
  37. 'url': 'entry/wxapp/index',
  38. 'data': {
  39. controller: 'index.load_new_buy_goodslist',
  40. token: token,
  41. pageNum: that.data.pageNum,
  42. head_id: cur_community.communityId
  43. },
  44. dataType: 'json',
  45. success: function (res) {
  46. if (res.data.code == 0) {
  47. let oldList = that.data.list;
  48. let list = oldList.concat(res.data.list);
  49. that.setData({ list })
  50. } else {
  51. that.setData({ noMore: true })
  52. }
  53. }
  54. })
  55. },
  56. getMore: function(){
  57. if(this.data.noMore) return;
  58. let that = this;
  59. let pageNum = that.data.pageNum+1;
  60. console.log(pageNum)
  61. this.setData({ pageNum },
  62. ()=>{
  63. that.getData();
  64. })
  65. },
  66. openSku: function (e) {
  67. let idx = e.currentTarget.dataset.idx;
  68. this.setData({ disabled: false })
  69. let spuItem = this.data.list[idx];
  70. this.triggerEvent("openSku", {
  71. actId: spuItem.actId,
  72. skuList: spuItem.skuList,
  73. promotionDTO: spuItem.promotionDTO || '',
  74. allData: {
  75. spuName: spuItem.spuName,
  76. skuImage: spuItem.skuImage,
  77. actPrice: spuItem.actPrice,
  78. canBuyNum: spuItem.spuCanBuyNum,
  79. stock: spuItem.spuCanBuyNum,
  80. marketPrice: spuItem.marketPrice
  81. }
  82. })
  83. }
  84. }
  85. })