my.js 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. import APIClient from '../../utils/APIClient';
  2. const app = getApp();
  3. import {
  4. formatDate
  5. } from '../../utils/util';
  6. export const myInit = (that) => {
  7. console.log(123123123, app.globalData.isIOS)
  8. that.setData({
  9. myData: {
  10. title: '修改资料',
  11. concern: '我的关注',
  12. course: '我的课程',
  13. read: '我的朗读',
  14. keep: '我的收藏',
  15. collage: '我的拼团',
  16. wallet: '我的钱包',
  17. schoolCity: '',
  18. schoolName: '',
  19. user: {},
  20. isIOS: app.globalData.isIOS,
  21. isVIP: true
  22. },
  23. followData: []
  24. });
  25. that.getUserWorksInfo();
  26. that.getUserAuth(); //用户鉴权
  27. // that.getMyRead();
  28. console.log(that.data.myData)
  29. that.toMyEdit = (e) => {
  30. let title = e.currentTarget.dataset.title;
  31. wx.navigateTo({
  32. url: `../user/myEdit/myEdit?title=修改资料`
  33. });
  34. },
  35. that.toMyConcern = e => {
  36. wx.navigateTo({
  37. url: `../user/myconcern/myconcern?title=我的关注`
  38. });
  39. }
  40. that.toMyRead = e => {
  41. wx.navigateTo({
  42. url: `../user/myread/myread?title=我的朗读`
  43. });
  44. },
  45. that.toMyKeep = e => {
  46. let title = e.currentTarget.dataset.title;
  47. wx.navigateTo({
  48. url: `../user/mycollection/mycollection?title=${title}`
  49. });
  50. },
  51. that.getFollowWorks = (pageNo, pageSize) => {
  52. APIClient.getFollowWorks(pageNo, pageSize).success(res => {
  53. console.log(res)
  54. const followData = res.data.data.list;
  55. // const followTemp = [];
  56. followData.forEach(item => {
  57. const temp = {};
  58. console.log(item.userRead.id)
  59. temp.nickName = item.user.wechatName;
  60. temp.avatar = item.user.avatar;
  61. temp.uid = item.user.uid;
  62. temp.plays = item.userRead.playAmount;
  63. temp.likes = item.userRead.likeAmount;
  64. temp.commentAmount = item.userRead.commentAmount ? item.userRead.commentAmount : 0;
  65. temp.classId = item.userRead.exampleId ? item.userRead.exampleId : 1605097720036046;
  66. temp.img = item.userRead.iconImg;
  67. temp.id = item.userRead.id;
  68. temp.title = item.userRead.title;
  69. temp.summary = item.userRead.summary;
  70. temp.type = item.userRead.type;
  71. temp.isLike = item.isLike;
  72. temp.isFavorite = item.isFavorites;
  73. temp.time = formatDate(item.userRead.gmtCreated, 3);
  74. // 还差一些字段
  75. that.data.followData.push(temp);
  76. });
  77. // console.log(followTemp);
  78. that.setData({
  79. followData: that.data.followData,
  80. followPageTotalNo: res.data.data.totalNo
  81. })
  82. });
  83. },
  84. that.toWalletDetail = function (e) {
  85. wx.navigateTo({
  86. url: `../../pages/user/walletDetails/walletDetails?title=资金明细`
  87. });
  88. },
  89. that.toVIPBuy = function (e) {
  90. if (app.globalData.isIOS) {
  91. wx.navigateTo({
  92. url: `../../pages/vipPage/vipCode/vipCode`
  93. });
  94. } else {
  95. wx.navigateTo({
  96. url: `../../pages/vipPage/vip/vip`
  97. });
  98. }
  99. },
  100. that.getFollowWorks(1, 3);
  101. }