my.js 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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=${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.toMyCollage = e => {
  54. if(app.globalData.isIOS){
  55. wx.navigateTo({
  56. url: `../../pages/groupPage/my-group/my-group?title=我的助力`
  57. });
  58. }else {
  59. wx.navigateTo({
  60. url: `../../pages/groupPage/my-group/my-group?title=我的拼团`
  61. });
  62. }
  63. },
  64. that.getFollowWorks = (pageNo, pageSize) => {
  65. APIClient.getFollowWorks(pageNo, pageSize).success(res => {
  66. console.log(res)
  67. const followData = res.data.data.list;
  68. // const followTemp = [];
  69. followData.forEach(item => {
  70. const temp = {};
  71. console.log(item.userRead.id)
  72. temp.nickName = item.user.wechatName;
  73. temp.avatar = item.user.avatar;
  74. temp.plays = item.userRead.playAmount;
  75. temp.likes = item.userRead.likeAmount;
  76. temp.img = item.userRead.iconImg;
  77. temp.id = item.userRead.id;
  78. temp.title = item.userRead.title;
  79. temp.summary = item.userRead.summary;
  80. temp.time = formatDate(item.userRead.gmtCreated, 3);
  81. // 还差一些字段
  82. that.data.followData.push(temp);
  83. });
  84. // console.log(followTemp);
  85. that.setData({
  86. followData: that.data.followData,
  87. followPageTotalNo: res.data.data.totalNo
  88. })
  89. });
  90. },
  91. that.toWalletDetail = function(e) {
  92. wx.navigateTo({
  93. url: `../../pages/user/walletDetails/walletDetails?title=资金明细`
  94. });
  95. }
  96. }