follow.js 2.3 KB

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