my.js 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. import APIClient from '../../utils/APIClient';
  2. const app = getApp();
  3. import {
  4. formatDate
  5. } from '../../utils/util';
  6. export const myInit = (that) => {
  7. that.setData({
  8. myData: {
  9. title: '修改资料',
  10. concern: '我的关注',
  11. course: '我的课程',
  12. read: '我的朗读',
  13. keep: '我的收藏',
  14. collage: '我的拼团',
  15. wallet: '我的钱包',
  16. schoolCity: '',
  17. schoolName: '',
  18. user: {},
  19. isIOS: app.globalData.isIOS
  20. },
  21. followData:[]
  22. });
  23. that.getUserWorksInfo();
  24. console.log(that.data.myData)
  25. that.toMyEdit = (e) => {
  26. let title = e.currentTarget.dataset.title;
  27. wx.navigateTo({
  28. url: `../user/myEdit/myEdit?title=修改资料`
  29. });
  30. },
  31. that.toMyConcern = e => {
  32. wx.navigateTo({
  33. url: `../user/myconcern/myconcern?title=我的关注`
  34. });
  35. }
  36. that.toMyRead = e => {
  37. wx.navigateTo({
  38. url: `../user/myread/myread?title=我的朗读`
  39. });
  40. },
  41. that.toMyKeep = e => {
  42. let title = e.currentTarget.dataset.title;
  43. wx.navigateTo({
  44. url: `../user/mycollection/mycollection?title=${title}`
  45. });
  46. },
  47. that.getFollowWorks = (pageNo, pageSize) => {
  48. APIClient.getFollowWorks(pageNo, pageSize).success(res => {
  49. console.log(res)
  50. const followData = res.data.data.list;
  51. // const followTemp = [];
  52. followData.forEach(item => {
  53. const temp = {};
  54. console.log(item.userRead.id)
  55. temp.nickName = item.user.wechatName;
  56. temp.avatar = item.user.avatar;
  57. temp.plays = item.userRead.playAmount;
  58. temp.likes = item.userRead.likeAmount;
  59. temp.img = item.userRead.iconImg;
  60. temp.id = item.userRead.id;
  61. temp.title = item.userRead.title;
  62. temp.summary = item.userRead.summary;
  63. temp.time = formatDate(item.userRead.gmtCreated, 3);
  64. // 还差一些字段
  65. that.data.followData.push(temp);
  66. });
  67. // console.log(followTemp);
  68. that.setData({
  69. followData: that.data.followData,
  70. followPageTotalNo: res.data.data.totalNo
  71. })
  72. });
  73. },
  74. that.toWalletDetail = function(e) {
  75. wx.navigateTo({
  76. url: `../../pages/user/walletDetails/walletDetails?title=资金明细`
  77. });
  78. }
  79. }