index.js 2.2 KB

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