collection.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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. onShow: function () {
  36. },
  37. /**
  38. * 用户点击右上角分享
  39. */
  40. onShareAppMessage: function () {
  41. },
  42. // 点击获取头像和昵称
  43. bindGetUserInfo(e) {
  44. var that = this;
  45. wx.getUserInfo({
  46. success: function (res) {
  47. app.globalData.userInfo = e.detail.userInfo;
  48. console.log(e.detail.userInfo);
  49. that.setData({
  50. login: false,
  51. })
  52. }
  53. })
  54. },
  55. checkItem(e){
  56. console.log(e)
  57. var that = this;
  58. that.setData({
  59. currentIndex : e.target.dataset.index
  60. })
  61. }
  62. })