my.js 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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.uid = item.user.uid;
  58. temp.plays = item.userRead.playAmount;
  59. temp.likes = item.userRead.likeAmount;
  60. temp.img = item.userRead.iconImg;
  61. temp.id = item.userRead.id;
  62. temp.title = item.userRead.title;
  63. temp.summary = item.userRead.summary;
  64. temp.time = formatDate(item.userRead.gmtCreated, 3);
  65. // 还差一些字段
  66. that.data.followData.push(temp);
  67. });
  68. // console.log(followTemp);
  69. that.setData({
  70. followData: that.data.followData,
  71. followPageTotalNo: res.data.data.totalNo
  72. })
  73. });
  74. },
  75. that.toWalletDetail = function(e) {
  76. wx.navigateTo({
  77. url: `../../pages/user/walletDetails/walletDetails?title=资金明细`
  78. });
  79. },
  80. that.getFollowWorks(1, 3);
  81. }