my.js 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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. gridList: [
  14. {
  15. id: 0,
  16. title: '我的地址',
  17. url: '/pages/address/address?form=my',
  18. imgUrl: '../../imaes/dizhi@2x.png'
  19. },
  20. {
  21. id: 1,
  22. title: '我的档案',
  23. url: '/pages/myFile/myFile?form=my',
  24. imgUrl: '../../imaes/dangan@2x.png'
  25. },
  26. {
  27. id: 2,
  28. title: '我的预约',
  29. url: '/pages/myAppointment/myAppointment?form=my',
  30. imgUrl: '../../imaes/yuyue@2x.png'
  31. },
  32. {
  33. id: 3,
  34. title: '我的记录',
  35. url: '/pages/myRecord/myRecord?form=my',
  36. imgUrl: '../../imaes/jilu@2x.png'
  37. },
  38. {
  39. id: 4,
  40. title: '我的报告',
  41. url: '/pages/report/report?form=my',
  42. imgUrl: '../../imaes/baogao2@2x.png'
  43. },
  44. {
  45. id: 5,
  46. title: '开通区域',
  47. url: '/pages/openArea/openArea?form=my',
  48. imgUrl: '../../imaes/quyu@2x.png'
  49. },
  50. {
  51. id: 6,
  52. title: '设置',
  53. url: '/pages/set/set?form=my',
  54. imgUrl: '../../imaes/shezhi@2x.png'
  55. }
  56. ]
  57. },
  58. /**
  59. * 生命周期函数--监听页面加载
  60. */
  61. onLoad(options) {
  62. },
  63. /**
  64. * 获取用户信息
  65. */
  66. getUserProfile() {
  67. var that = this;
  68. wx.getUserProfile({
  69. desc:"授权信息",
  70. success:function(res){
  71. if(res.userInfo){
  72. that.setData({
  73. name:res.userInfo.nickName,
  74. avatarUrl:res.userInfo.avatarUrl,
  75. pageLogin: true
  76. })
  77. app.globalData.userInfo.login = true
  78. }
  79. },
  80. })
  81. },
  82. /**
  83. * 生命周期函数--监听页面显示
  84. */
  85. onShow() {
  86. this.setData({
  87. pageLogin: app.globalData.userInfo.login
  88. })
  89. },
  90. // 路由跳转
  91. handleNavTo (e) {
  92. var url = e.currentTarget.dataset.url
  93. this.authNavTo(url)
  94. },
  95. /**
  96. * 路由拦截
  97. * **/
  98. authNavTo (url) {
  99. if (itt.loginAuth()) {
  100. wx.navigateTo({
  101. url: url,
  102. })
  103. } else {
  104. itt.errorToast('请先授权登录')
  105. }
  106. }
  107. })