my.js 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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. isVIP: true
  21. },
  22. followData:[]
  23. });
  24. that.getUserWorksInfo();
  25. console.log(that.data.myData)
  26. that.toMyEdit = (e) => {
  27. let title = e.currentTarget.dataset.title;
  28. wx.navigateTo({
  29. url: `../user/myEdit/myEdit?title=修改资料`
  30. });
  31. },
  32. that.toMyConcern = e => {
  33. wx.navigateTo({
  34. url: `../user/myconcern/myconcern?title=我的关注`
  35. });
  36. }
  37. that.toMyRead = e => {
  38. wx.navigateTo({
  39. url: `../user/myread/myread?title=我的朗读`
  40. });
  41. },
  42. that.toMyKeep = e => {
  43. let title = e.currentTarget.dataset.title;
  44. wx.navigateTo({
  45. url: `../user/mycollection/mycollection?title=${title}`
  46. });
  47. },
  48. that.getFollowWorks = (pageNo, pageSize) => {
  49. APIClient.getFollowWorks(pageNo, pageSize).success(res => {
  50. console.log(res)
  51. const followData = res.data.data.list;
  52. // const followTemp = [];
  53. followData.forEach(item => {
  54. const temp = {};
  55. console.log(item.userRead.id)
  56. temp.nickName = item.user.wechatName;
  57. temp.avatar = item.user.avatar;
  58. temp.uid = item.user.uid;
  59. temp.plays = item.userRead.playAmount;
  60. temp.likes = item.userRead.likeAmount;
  61. temp.img = item.userRead.iconImg;
  62. temp.id = item.userRead.id;
  63. temp.title = item.userRead.title;
  64. temp.summary = item.userRead.summary;
  65. temp.time = formatDate(item.userRead.gmtCreated, 3);
  66. // 还差一些字段
  67. that.data.followData.push(temp);
  68. });
  69. // console.log(followTemp);
  70. that.setData({
  71. followData: that.data.followData,
  72. followPageTotalNo: res.data.data.totalNo
  73. })
  74. });
  75. },
  76. that.toWalletDetail = function(e) {
  77. wx.navigateTo({
  78. url: `../../pages/user/walletDetails/walletDetails?title=资金明细`
  79. });
  80. },
  81. that.toVIPBuy = function(e) {
  82. // wx.navigateTo({
  83. // url: `../../pages/vipPage/vip/vip`
  84. // });
  85. wx.navigateTo({
  86. url: `../../pages/vipPage/vipCode/vipCode`
  87. });
  88. },
  89. that.getFollowWorks(1, 3);
  90. }