user.js 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. // pages/user/user.js
  2. const app = getApp()
  3. let userInfo = app.globalData.userInfo;
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. timeout: [
  10. { text: "不开启" },
  11. { text: "播放当前声音关闭" },
  12. { text: "播放2首声音关闭" },
  13. { text: "播放3首声音关闭" },
  14. { text: "播放4首声音关闭" },
  15. { text: "10分钟后" },
  16. { text: "20分钟后" },
  17. { text: "30分钟后" },
  18. ],
  19. activeIndex: 0,
  20. login: true,
  21. avatarUrl: "",
  22. nickName: ""
  23. },
  24. onLoad(options) {
  25. var that = this;
  26. //获得设备信息
  27. wx.getSystemInfo({
  28. success(res) {
  29. that.setData({
  30. phoneHeight: res.windowHeight,
  31. })
  32. }
  33. })
  34. // 查看是否授权
  35. wx.getStorage({
  36. key: 'login',
  37. success(res) {
  38. if (res.data === 200) {
  39. that.setData({
  40. login: false
  41. })
  42. } else {
  43. that.setData({
  44. login: true
  45. })
  46. }
  47. }
  48. })
  49. },
  50. // 获取用户的头像和昵称信息
  51. bindGetUserInfo(e) {
  52. var that = this;
  53. wx.getUserInfo({
  54. success: function (res) {
  55. app.globalData.userInfo = e.detail.userInfo;
  56. wx.setStorage({
  57. key: "login",
  58. data: 200
  59. })
  60. that.setData({
  61. login: false,
  62. avatarUrl: e.detail.userInfo.avatarUrl,
  63. nickName: e.detail.userInfo.nickName
  64. })
  65. }
  66. })
  67. },
  68. phoneLogin() {
  69. wx.navigateTo({
  70. url: './phoneLogin/phoneLogin',
  71. });
  72. },
  73. gotoLogin() {
  74. wx.navigateTo({
  75. url: './phoneLogin/phoneLogin',
  76. });
  77. },
  78. openSwitch() {
  79. var that = this;
  80. that.setData({
  81. show: true
  82. })
  83. },
  84. close() {
  85. var that = this;
  86. that.setData({
  87. show: false
  88. })
  89. },
  90. chooseTimeOut(e) {
  91. var that = this;
  92. that.setData({
  93. activeIndex: e.currentTarget.dataset.activeindex
  94. })
  95. }
  96. })