my.js 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. // pages/my/my.js
  2. import itt from '../../utils/util'
  3. const app = getApp()
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. pageLogin: false,
  10. name: '点击授权登录',
  11. avatarUrl: '',
  12. count: 0
  13. },
  14. /**
  15. * 生命周期函数--监听页面加载
  16. */
  17. onLoad(options) {
  18. },
  19. /**
  20. * 获取用户信息
  21. */
  22. getUserProfile() {
  23. var that = this;
  24. wx.getUserProfile({
  25. desc:"授权信息",
  26. success:function(res){
  27. if(res.userInfo){
  28. that.setData({
  29. name:res.userInfo.nickName,
  30. avatarUrl:res.userInfo.avatarUrl,
  31. pageLogin: true
  32. })
  33. app.globalData.userInfo.login = true
  34. }
  35. },
  36. })
  37. },
  38. /**
  39. * 生命周期函数--监听页面显示
  40. */
  41. onShow() {
  42. this.setData({
  43. pageLogin: app.globalData.userInfo.login
  44. })
  45. },
  46. /* 我的档案 */
  47. handleMyFile () {
  48. this.authNavTo('/pages/myFile/myFile')
  49. },
  50. /**
  51. * 我的预约
  52. */
  53. handleMyAppointment() {
  54. this.authNavTo('/pages/myAppointment/myAppointment')
  55. },
  56. /**
  57. * 点击充值记录
  58. */
  59. handleMyRecord() {
  60. this.authNavTo('/pages/myRecord/myRecord')
  61. },
  62. /**
  63. * 点击开通区域
  64. */
  65. handleOpenarea() {
  66. this.authNavTo('/pages/openArea/openArea')
  67. },
  68. /**
  69. * 点击设置
  70. */
  71. handleSet() {
  72. this.authNavTo('/pages/set/set')
  73. },
  74. /**
  75. * 用户点击地址
  76. */
  77. handleMyAddress() {
  78. this.authNavTo('/pages/address/address')
  79. },
  80. /**
  81. * 我的报告
  82. * **/
  83. handleMyReport () {
  84. this.authNavTo('/pages/report/report')
  85. },
  86. handleAppoint () {
  87. this.authNavTo('/pages/appointment/appointment')
  88. },
  89. authNavTo (url) {
  90. if (itt.loginAuth()) {
  91. wx.navigateTo({
  92. url: url,
  93. })
  94. } else {
  95. itt.errorToast('请先授权登录')
  96. }
  97. }
  98. })