index.js 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. // pages/login/login.js
  2. const app = getApp()
  3. const defaultAvatarUrl = 'https://mmbiz.qpic.cn/mmbiz/icTdbqWNOwNRna42FI242Lcia07jQodd2FJGIYQfG0LAJGFxM4FbnQP6yfMxBgJ0F3YRqJCJ1aPAK2dQagdusBZg/0'
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. frameStyle: { useTop: true, name: '个人中心', leftArrow: false, useBar: false },
  10. // 主体高度
  11. infoHeight: '',
  12. avatarUrl: defaultAvatarUrl,
  13. userInfo: {},
  14. routerList: [
  15. { icon: 'icon-quxiantongxunlu', title: '区县人员', router: 'county' },
  16. { icon: 'icon-bangdingweixin', title: '绑定微信', router: '', is_routine: '1' },
  17. { icon: 'icon-xiugaimima', title: '修改密码', router: 'password', },
  18. { icon: 'icon-tuichudenglu', title: '退出登录', router: 'login' },
  19. ]
  20. },
  21. // 获取头像
  22. onChooseAvatar(e) {
  23. const { avatarUrl } = e.detail;
  24. this.setData({ avatarUrl })
  25. },
  26. // 跳转页面
  27. toPath: function (e) {
  28. const { data } = e.currentTarget.dataset;
  29. if (data.is_routine && data.is_routine == '1') {
  30. wx.showToast({ title: `绑定微信成功`, icon: 'success', duration: 2000 })
  31. } else {
  32. wx.navigateTo({ url: `/pages/${data.router}/index` })
  33. }
  34. },
  35. /**
  36. * 生命周期函数--监听页面加载
  37. */
  38. onLoad: function (options) {
  39. // 计算高度
  40. this.searchHeight()
  41. let userInfo = app.globalData.userInfo;
  42. if (userInfo) this.setData({ userInfo: userInfo })
  43. },
  44. // 计算高度
  45. searchHeight: function () {
  46. let frameStyle = this.data.frameStyle;
  47. let client = app.globalData.client;
  48. // 减去状态栏
  49. let infoHeight = client.windowHeight - (client.statusBarHeight + client.getMenu.height + (client.getMenu.top - client.statusBarHeight) * 2);
  50. // 是否减去底部菜单
  51. if (frameStyle.useBar) infoHeight = infoHeight - 50;
  52. if (infoHeight) this.setData({ infoHeight: infoHeight })
  53. },
  54. /**
  55. * 生命周期函数--监听页面初次渲染完成
  56. */
  57. onReady: function () {
  58. },
  59. /**
  60. * 生命周期函数--监听页面显示
  61. */
  62. onShow: function () {
  63. },
  64. /**
  65. * 生命周期函数--监听页面隐藏
  66. */
  67. onHide: function () {
  68. },
  69. /**
  70. * 生命周期函数--监听页面卸载
  71. */
  72. onUnload: function () {
  73. },
  74. /**
  75. * 页面相关事件处理函数--监听用户下拉动作
  76. */
  77. onPullDownRefresh: function () {
  78. },
  79. /**
  80. * 页面上拉触底事件的处理函数
  81. */
  82. onReachBottom: function () {
  83. },
  84. /**
  85. * 用户点击右上角分享
  86. */
  87. onShareAppMessage: function () {
  88. }
  89. })