collection.js 1.1 KB

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