my.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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. if (this.data.avatarUrl == '') {
  68. var that = this;
  69. wx.getUserProfile({
  70. desc:"授权信息",
  71. success:function(res){
  72. if(res.userInfo){
  73. that.setData({
  74. name:res.userInfo.nickName,
  75. avatarUrl:res.userInfo.avatarUrl,
  76. pageLogin: true
  77. })
  78. app.globalData.userInfo.login = true
  79. }
  80. },
  81. })
  82. }
  83. },
  84. /**
  85. * 生命周期函数--监听页面显示
  86. */
  87. onShow() {
  88. this.setData({
  89. pageLogin: app.globalData.userInfo.login
  90. })
  91. },
  92. // 路由跳转
  93. handleNavTo (e) {
  94. var url = e.currentTarget.dataset.url
  95. this.authNavTo(url)
  96. },
  97. /**
  98. * 路由拦截
  99. * **/
  100. authNavTo (url) {
  101. if (itt.loginAuth()) {
  102. wx.navigateTo({
  103. url: url,
  104. })
  105. } else {
  106. itt.errorToast('请先授权登录')
  107. }
  108. }
  109. })