partner.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. const util = require('../../../utils/util.js');
  2. const app = getApp();
  3. Page({
  4. data: {
  5. datas:[],
  6. friendDatas:[]
  7. },
  8. onLoad(options) {
  9. if(options.aid && options.groupid){//团内同行伙伴
  10. wx.setNavigationBarTitle({
  11. title: '拼团成员列表'
  12. })
  13. this.groupFriend(options.aid,options.groupid)
  14. }else{//全部同行伙伴
  15. this.getData(options.aid)
  16. }
  17. },
  18. getData(aid){
  19. let that = this;
  20. util.ajax({
  21. func:"v2/article/partners",
  22. data:{"aid":aid}
  23. },function(res){
  24. if(res.code == 0){
  25. let datas = res.data;
  26. for(let i in datas){
  27. let users = datas[i].users
  28. for(let l in users){
  29. if(users[l].avatar == ''){
  30. users[l].avatar = '/images/default_logo.jpg';
  31. }
  32. }
  33. }
  34. that.setData({datas});
  35. }
  36. });
  37. },
  38. groupFriend(aid,groupid){
  39. let that = this;
  40. util.ajax({
  41. func:"article/groupusers",
  42. data: { "aid": aid, "groupid":groupid || ""}
  43. },function(res){
  44. if(res.code == 0){
  45. let friendDatas = res.data;
  46. for(let i in friendDatas){
  47. if(!friendDatas[i].avatar){
  48. friendDatas[i].avatar = util.config.imgUrl+'img/default_logo.jpg';
  49. }
  50. if(!friendDatas[i].nickname){
  51. friendDatas[i].nickname = '无名宝贝'
  52. }
  53. }
  54. that.setData({friendDatas});
  55. }
  56. })
  57. }
  58. })