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