recommend.js 684 B

12345678910111213141516171819202122232425262728293031
  1. const util = require('../../utils/util.js');
  2. Component({
  3. properties: {
  4. aid: {
  5. type: String,
  6. observer: function(newVal) {
  7. this.setData({ aid: newVal });
  8. this.getRecommend();
  9. }
  10. }
  11. },
  12. data: {
  13. imgUrl: util.config.imgPath,
  14. recommendList: []
  15. },
  16. methods: {
  17. getRecommend() {//获取推荐
  18. let that = this;
  19. util.ajax({
  20. func: "article/recommend",
  21. data: { "aid": (that.data.aid == -1 ? '' : that.data.aid) || '' },
  22. load: false
  23. }, function (res) {
  24. if(res.code == 0) {
  25. that.setData({ recommendList: res.data ? res.data.recommendList : [] });
  26. }
  27. })
  28. }
  29. }
  30. })