follow.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. import httpRequestApi from '../../utils/APIClient';
  2. import {
  3. formatDate
  4. } from '../../utils/util';
  5. export const followInit = (that) => {
  6. that.setData({
  7. followData: []
  8. })
  9. //请求数据封装
  10. that.getWorks = (pageNo, pageSize) => {
  11. httpRequestApi.getFollowWorks(pageNo, pageSize).success(res => {
  12. console.log(res)
  13. const followData = res.data.data.list;
  14. // const followTemp = [];
  15. followData.forEach(item => {
  16. const temp = {};
  17. console.log(item.userRead.id)
  18. temp.nickName = item.user.wechatName;
  19. temp.avatar = item.user.avatar;
  20. temp.plays = item.userRead.playAmount;
  21. temp.likes = item.userRead.likeAmount;
  22. temp.img = item.userRead.iconImg;
  23. temp.id = item.userRead.id;
  24. temp.title = item.userRead.title;
  25. temp.summary = item.userRead.summary;
  26. temp.time = formatDate(item.userRead.gmtCreated, 3);
  27. // 还差一些字段
  28. that.data.followData.push(temp);
  29. });
  30. // console.log(followTemp);
  31. that.setData({
  32. followData: that.data.followData,
  33. followPageTotalNo: res.data.data.totalNo
  34. })
  35. httpRequestApi.userIntoPage('pages/index/index','首页动态').success((res)=>{
  36. })
  37. });
  38. }
  39. that.getWorks(1, 5);
  40. }