user.js 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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. },
  21. onLoad: function (options) {
  22. var that = this;
  23. //获得设备信息
  24. wx.getSystemInfo({
  25. success (res) {
  26. console.log(res.windowHeight);
  27. that.setData({
  28. phoneHeight: res.windowHeight,
  29. })
  30. }
  31. })
  32. // 查看是否授权
  33. if (app.globalData.userInfo === null) {
  34. that.setData({
  35. login: true
  36. })
  37. } else {
  38. that.setData({
  39. login: false,
  40. avatarUrl: app.globalData.userInfo.avatarUrl,
  41. nickName: app.globalData.userInfo.nickName
  42. })
  43. }
  44. },
  45. // 获取用户的头像和昵称信息
  46. bindGetUserInfo(e) {
  47. var that = this;
  48. wx.getUserInfo({
  49. success: function(res) {
  50. console.log(e.detail.userInfo);
  51. app.globalData.userInfo = e.detail.userInfo;
  52. that.setData({
  53. login: false,
  54. avatarUrl: e.detail.userInfo.avatarUrl,
  55. nickName: e.detail.userInfo.nickName
  56. })
  57. }
  58. })
  59. },
  60. phoneLogin:function(){
  61. wx.navigateTo({
  62. url: './phoneLogin/phoneLogin',
  63. });
  64. },
  65. gotoLogin(){
  66. wx.navigateTo({
  67. url: './phoneLogin/phoneLogin',
  68. });
  69. },
  70. openSwitch:function(){
  71. var that = this;
  72. that.setData({
  73. show:true
  74. })
  75. },
  76. close:function(){
  77. var that = this;
  78. that.setData({
  79. show:false
  80. })
  81. },
  82. chooseTimeOut:function(e){
  83. var that = this;
  84. console.log(e)
  85. that.setData({
  86. activeIndex:e.currentTarget.dataset.activeindex
  87. })
  88. }
  89. })