follow.js 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. import httpRequestApi from '../../utils/APIClient';
  2. export const followInit = (that) => {
  3. that.setData({
  4. followData: {
  5. title: '关注',
  6. wareCards: [{
  7. title: "铺满色巴掌的水泥道",
  8. grade: "一年级 上学期",
  9. img: "../../static/image/timg.jpg",
  10. plays: "1",
  11. likes: "2",
  12. classId: "1",
  13. avatar: '../../static/image/timg.jpg',
  14. nickName: '萝莉小猫咪',
  15. time: '11-01 14:14'
  16. },
  17. {
  18. title: "铺满色巴掌的水泥道",
  19. grade: "一年级 上学期",
  20. img: "../../static/image/timg.jpg",
  21. plays: "1",
  22. likes: "2",
  23. classId: "1",
  24. avatar: '../../static/image/timg.jpg',
  25. nickName: '萝莉小猫咪',
  26. time: '11-01 14:14'
  27. },
  28. {
  29. title: "铺满色巴掌的水泥道",
  30. grade: "一年级 上学期",
  31. img: "../../static/image/timg.jpg",
  32. plays: "1",
  33. likes: "2",
  34. classId: "1",
  35. avatar: '../../static/image/timg.jpg',
  36. nickName: '萝莉小猫咪',
  37. time: '11-01 14:14'
  38. },
  39. ]
  40. }
  41. })
  42. //请求数据封装
  43. that.getWorks = (uid, pageNo, pageSize) => {
  44. httpRequestApi.getFollowWorks(uid, pageNo, pageSize).success(res => {
  45. const followData = res.data.data.list;
  46. const followTemp = [];
  47. followData.forEach(item => {
  48. const temp = {};
  49. temp.nickName = item.user.wechatName;
  50. temp.avatar = item.user.avatar;
  51. temp.plays = item.userRead.playAmount;
  52. temp.likes = item.userRead.likeAmount;
  53. temp.id = item.userRead.id;
  54. // 还差一些字段
  55. followTemp.push(temp);
  56. });
  57. console.log(followTemp);
  58. });
  59. }
  60. that.getWorks(1, 1, 10);
  61. }