my.js 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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.img = item.userRead.iconImg;
  65. temp.id = item.userRead.id;
  66. temp.title = item.userRead.title;
  67. temp.summary = item.userRead.summary;
  68. temp.time = formatDate(item.userRead.gmtCreated, 3);
  69. // 还差一些字段
  70. that.data.followData.push(temp);
  71. });
  72. // console.log(followTemp);
  73. that.setData({
  74. followData: that.data.followData,
  75. followPageTotalNo: res.data.data.totalNo
  76. })
  77. });
  78. },
  79. that.toWalletDetail = function (e) {
  80. wx.navigateTo({
  81. url: `../../pages/user/walletDetails/walletDetails?title=资金明细`
  82. });
  83. },
  84. that.toVIPBuy = function (e) {
  85. if (app.globalData.isIOS) {
  86. wx.navigateTo({
  87. url: `../../pages/vipPage/vipCode/vipCode`
  88. });
  89. } else {
  90. wx.navigateTo({
  91. url: `../../pages/vipPage/vip/vip`
  92. });
  93. }
  94. },
  95. that.getFollowWorks(1, 3);
  96. }