collection.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. // pages/collection/collection.js
  2. const app = getApp()
  3. let userInfo = app.globalData.userInfo;
  4. let login = app.globalData.login
  5. Page({
  6. /**
  7. * 页面的初始数据
  8. */
  9. data: {
  10. content: [
  11. {
  12. text: "我的收藏"
  13. },
  14. {
  15. text: "我的已购"
  16. },
  17. {
  18. text: "收听历史"
  19. },
  20. {
  21. text: "我的礼包"
  22. }
  23. ]
  24. },
  25. /**
  26. * 生命周期函数--监听页面加载
  27. */
  28. onLoad: function (options) {
  29. var that = this;
  30. // console.log(app)
  31. // console.log("userInfo" +userInfo)
  32. if (app.globalData.userInfo === null){
  33. that.setData({
  34. login:login
  35. })
  36. }else{
  37. console.log("login:" + app.globalData.login)
  38. that.setData({
  39. login: app.globalData.login
  40. })
  41. }
  42. },
  43. /**
  44. * 生命周期函数--监听页面显示
  45. */
  46. onShow: function () {
  47. },
  48. /**
  49. * 用户点击右上角分享
  50. */
  51. onShareAppMessage: function () {
  52. },
  53. // 点击获取头像和昵称
  54. bindGetUserInfo(e) {
  55. var that = this;
  56. wx.getUserInfo({
  57. success: function (res) {
  58. app.globalData.userInfo = e.detail.userInfo;
  59. app.globalData.login = false;
  60. console.log(e.detail.userInfo);
  61. that.setData({
  62. login: app.globalData.login,
  63. })
  64. }
  65. })
  66. },
  67. })