my.js 2.7 KB

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