topic.js 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. var app = getApp();
  2. Component({
  3. /**
  4. * 组件的属性列表
  5. */
  6. properties: {
  7. refresh: {
  8. type: Boolean,
  9. value: false,
  10. observer: function (t) {
  11. if (t) this.setData({ list: [] }), this.getData();
  12. }
  13. },
  14. showPos: {
  15. type: Number,
  16. value: 0
  17. },
  18. diyInfo: {
  19. type: Object,
  20. value: {
  21. specialId: ""
  22. }
  23. }
  24. },
  25. /**
  26. * 组件的初始数据
  27. */
  28. data: {
  29. disabled: false,
  30. list: [],
  31. placeholdeImg: app.globalData.placeholdeImg
  32. },
  33. attached() {
  34. this.getData();
  35. },
  36. /**
  37. * 组件的方法列表
  38. */
  39. methods: {
  40. getData: function () {
  41. var token = wx.getStorageSync('token');
  42. var that = this;
  43. var cur_community = wx.getStorageSync('community');
  44. let params = {};
  45. if(this.data.diyInfo&&this.data.diyInfo.specialId) {
  46. params.id = this.data.diyInfo.specialId;
  47. }
  48. app.util.request({
  49. url: 'entry/wxapp/index',
  50. data: {
  51. controller: 'marketing.get_special_list',
  52. token: token,
  53. head_id: cur_community.communityId,
  54. ...params
  55. },
  56. dataType: 'json',
  57. success: function (res) {
  58. if (res.data.code == 0) {
  59. let list = res.data.data;
  60. that.setData({ list })
  61. }
  62. }
  63. })
  64. },
  65. goSpecial: function(e){
  66. let id = e.currentTarget.dataset.id;
  67. id && wx.navigateTo({
  68. url: `/lionfish_comshop/moduleA/special/index?id=${id}`,
  69. })
  70. },
  71. openSku: function (e) {
  72. let idx = e.currentTarget.dataset.idx;
  73. let gidx = e.currentTarget.dataset.gidx;
  74. this.setData({ disabled: false })
  75. let spuItem = this.data.list[idx].list[gidx];
  76. this.triggerEvent("openSku", {
  77. actId: spuItem.actId,
  78. skuList: spuItem.skuList,
  79. promotionDTO: spuItem.promotionDTO || '',
  80. is_take_vipcard: spuItem.is_take_vipcard,
  81. is_mb_level_buy: spuItem.is_mb_level_buy,
  82. allData: {
  83. spuName: spuItem.spuName,
  84. skuImage: spuItem.skuImage,
  85. actPrice: spuItem.actPrice,
  86. canBuyNum: spuItem.spuCanBuyNum,
  87. stock: spuItem.spuCanBuyNum,
  88. marketPrice: spuItem.marketPrice
  89. }
  90. })
  91. }
  92. }
  93. })