my.js 2.7 KB

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