my.js 3.6 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. isVIP: wx.getStorageSync('vip'),
  11. price: wx.getStorageSync('price'),
  12. date: wx.getStorageSync('date')
  13. },
  14. followData: []
  15. });
  16. that.getUserWorksInfo();
  17. // that.getUserAuth(); //用户鉴权
  18. // that.getMyRead();
  19. console.log(that.data.myData)
  20. that.toMyEdit = (e) => {
  21. let title = e.currentTarget.dataset.title;
  22. wx.navigateTo({
  23. url: `../user/myEdit/myEdit?title=修改资料`
  24. });
  25. APIClient.userEvent('MY_INFO');
  26. },
  27. that.toMyConcern = e => {
  28. wx.navigateTo({
  29. url: `../myconcern/myconcern?title=我的关注`
  30. });
  31. APIClient.userEvent('MY_SUBSCRIBE');
  32. }
  33. that.toMyRead = e => {
  34. wx.navigateTo({
  35. url: `../user/myread/myread?title=我的朗读`
  36. });
  37. },
  38. that.toMyKeep = e => {
  39. wx.navigateTo({
  40. url: `../mycollection/mycollection`
  41. });
  42. APIClient.userEvent('MY_FAVORITES');
  43. },
  44. that.getFollowWorks = (pageNo, pageSize) => {
  45. APIClient.getFollowWorks(pageNo, pageSize).success(res => {
  46. console.log(res)
  47. const followData = res.data.data.list;
  48. // const followTemp = [];
  49. followData.forEach(item => {
  50. const temp = {};
  51. console.log(item.userRead.id)
  52. temp.nickName = item.user.nickName;
  53. temp.avatar = item.user.avatar;
  54. temp.uid = item.user.uid;
  55. temp.plays = item.userRead.playAmount;
  56. temp.likes = item.userRead.likeAmount;
  57. temp.commentAmount = item.userRead.commentAmount ? item.userRead.commentAmount : 0;
  58. temp.classId = item.userRead.exampleId ? item.userRead.exampleId : 1605097720036046;
  59. temp.img = item.userRead.iconImg;
  60. temp.id = item.userRead.id;
  61. temp.title = item.userRead.title;
  62. temp.summary = item.userRead.summary;
  63. temp.type = item.userRead.type;
  64. temp.isLike = item.isLike;
  65. temp.isFavorite = item.isFavorites;
  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. /**创建支付订单 */
  94. that.moneyBuy = function() {
  95. // that.messageAuth();
  96. that.goToPruduct();
  97. }
  98. that.getFollowWorks(1, 3);
  99. }