user.js 2.0 KB

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