collection.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. const app = getApp()
  2. Page({
  3. data: {
  4. currentIndex:0,
  5. height:0,
  6. content: [
  7. {text: "我的收藏"},
  8. {text: "我的已购"},
  9. {text: "收听历史"},
  10. {text: "我的礼包"}
  11. ],
  12. login: true
  13. },
  14. onLoad(options) {
  15. const that = this;
  16. wx.getSystemInfo({
  17. success (res) {
  18. that.setData({
  19. height :res.windowHeight
  20. })
  21. }
  22. })
  23. wx.getStorage({
  24. key: 'login',
  25. success(res){
  26. if(res.data === 200){
  27. that.setData({
  28. login: false,
  29. })
  30. }
  31. }
  32. })
  33. },
  34. // 点击获取头像和昵称
  35. bindGetUserInfo(e) {
  36. const that = this;
  37. wx.getUserInfo({
  38. success: function (res) {
  39. app.globalData.userInfo = e.detail.userInfo;
  40. wx.setStorage({
  41. key: "login",
  42. data: 200
  43. })
  44. that.setData({
  45. login: false,
  46. })
  47. }
  48. })
  49. },
  50. checkItem(e) {
  51. const that = this;
  52. if (this.data.currentIndex === e.target.dataset.current) {
  53. return false;
  54. } else {
  55. that.setData({
  56. currentIndex: e.target.dataset.index
  57. })
  58. }
  59. },
  60. // 滑动切换tab
  61. changeTab(e) {
  62. const that = this;
  63. that.setData({
  64. currentIndex:e.detail.current
  65. })
  66. }
  67. })