my.js 1.5 KB

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