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