my.js 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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.toMyCourse = e => {
  37. let title = e.currentTarget.dataset.title;
  38. wx.navigateTo({
  39. url: `../user/mycourse/mycourse?title=${title}`
  40. });
  41. },
  42. that.toMyRead = e => {
  43. wx.navigateTo({
  44. url: `../user/myread/myread?title=我的朗读`
  45. });
  46. },
  47. that.toMyKeep = e => {
  48. let title = e.currentTarget.dataset.title;
  49. wx.navigateTo({
  50. url: `../user/mycollection/mycollection?title=${title}`
  51. });
  52. },
  53. that.getFollowWorks = (pageNo, pageSize) => {
  54. APIClient.getFollowWorks(pageNo, pageSize).success(res => {
  55. console.log(res)
  56. const followData = res.data.data.list;
  57. // const followTemp = [];
  58. followData.forEach(item => {
  59. const temp = {};
  60. console.log(item.userRead.id)
  61. temp.nickName = item.user.wechatName;
  62. temp.avatar = item.user.avatar;
  63. temp.plays = item.userRead.playAmount;
  64. temp.likes = item.userRead.likeAmount;
  65. temp.img = item.userRead.iconImg;
  66. temp.id = item.userRead.id;
  67. temp.title = item.userRead.title;
  68. temp.summary = item.userRead.summary;
  69. temp.time = formatDate(item.userRead.gmtCreated, 3);
  70. // 还差一些字段
  71. that.data.followData.push(temp);
  72. });
  73. // console.log(followTemp);
  74. that.setData({
  75. followData: that.data.followData,
  76. followPageTotalNo: res.data.data.totalNo
  77. })
  78. });
  79. },
  80. that.toWalletDetail = function(e) {
  81. wx.navigateTo({
  82. url: `../../pages/user/walletDetails/walletDetails?title=资金明细`
  83. });
  84. }
  85. }