my.js 1.6 KB

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