my.js 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. // import APIClient from '../../utils/httpUtil.js'
  2. export const myInit = (that) => {
  3. that.setData({
  4. myData: {
  5. title: '修改资料',
  6. concern: '我的关注',
  7. course: '我的课程',
  8. read: '我的朗读',
  9. keep: '我的收藏',
  10. wallet: '我的钱包',
  11. address:['北京海淀','中关村','三小'],
  12. schoolCity: '青岛市',
  13. schoolName: '黄岛区志贤中学',
  14. playNum: 31549,
  15. attentionCount: 10254,
  16. point: 6317,
  17. flowerNum: 56245,
  18. user: {}
  19. }
  20. })
  21. that.toMyEdit = (e) => {
  22. let title = e.currentTarget.dataset.title;
  23. wx.navigateTo({
  24. url: `../user/myEdit/myEdit?title=${title}`
  25. });
  26. },
  27. that.toMyConcern = e => {
  28. let title = e.currentTarget.dataset.title;
  29. wx.navigateTo({
  30. url: `../user/myconcern/myconcern?title=${title}`
  31. });
  32. }
  33. that.toMyWallet = e => {
  34. let title = e.currentTarget.dataset.title;
  35. wx.navigateTo({
  36. url: `../user/myWallet/myWallet?title=${title}`
  37. });
  38. },
  39. that.toMyCourse = e => {
  40. let title = e.currentTarget.dataset.title;
  41. wx.navigateTo({
  42. url: `../user/mycourse/mycourse?title=${title}`
  43. });
  44. },
  45. that.toMyRead = e => {
  46. let title = e.currentTarget.dataset.title;
  47. wx.navigateTo({
  48. url: `../user/myread/myread?title=${title}`
  49. });
  50. },
  51. that.toMyKeep = e => {
  52. let title = e.currentTarget.dataset.title;
  53. wx.navigateTo({
  54. url: `../user/mycollection/mycollection?title=${title}`
  55. });
  56. },
  57. that.userInfo = function () {
  58. const userInfo = wx.getStorageSync('user');
  59. console.log(userInfo.data.data.data);
  60. that.data.myData.user = userInfo.data.data.data;//直接赋值 给 myData的user对象。
  61. that.setData({
  62. myData: that.data.myData,
  63. },()=>{
  64. console.log('myData的user对象,赋值成功')
  65. console.log(that.data.myData);
  66. });
  67. // APIClient.getOpenidSessionKey(res => {
  68. // console.log(res.data.data.data);
  69. // that.data.myData.user = res.data.data.data;//挂载user对象。
  70. // that.setData({
  71. // myData: that.data.myData
  72. // },() => {
  73. // console.log(that.data.myData)
  74. // });
  75. // });
  76. }()
  77. }