my.js 3.1 KB

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