index.js 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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-kuaibananjian', title: '办案人员', router: 'user' },
  17. { icon: 'icon-shanghuguanli', title: '商户信息', router: 'merchant' },
  18. { icon: 'icon-shouye', title: '检查历史', router: 'inspect' },
  19. { icon: 'icon-shangpinxinxi', title: '商品信息', router: 'market' },
  20. { icon: 'icon-bangdingweixin', title: '绑定微信', router: '', is_routine: '1' },
  21. { icon: 'icon-xiugaimima', title: '修改密码', router: 'password', },
  22. { icon: 'icon-tuichudenglu', title: '退出登录', router: 'login' },
  23. ]
  24. },
  25. // 获取头像
  26. onChooseAvatar(e) {
  27. const { avatarUrl } = e.detail;
  28. this.setData({ avatarUrl })
  29. },
  30. // 跳转页面
  31. toPath: function (e) {
  32. const { data } = e.currentTarget.dataset;
  33. if (data.is_routine && data.is_routine == '1') {
  34. wx.showToast({ title: `绑定微信成功`, icon: 'success', duration: 2000 })
  35. } else {
  36. wx.navigateTo({ url: `/pages/${data.router}/index` })
  37. }
  38. },
  39. /**
  40. * 生命周期函数--监听页面加载
  41. */
  42. onLoad: function (options) {
  43. // 计算高度
  44. this.searchHeight()
  45. let userInfo = app.globalData.userInfo;
  46. if (userInfo) this.setData({ userInfo: userInfo })
  47. },
  48. // 计算高度
  49. searchHeight: function () {
  50. let frameStyle = this.data.frameStyle;
  51. let client = app.globalData.client;
  52. // 减去状态栏
  53. let infoHeight = client.windowHeight - (client.statusBarHeight + client.getMenu.height + (client.getMenu.top - client.statusBarHeight) * 2);
  54. // 是否减去底部菜单
  55. if (frameStyle.useBar) infoHeight = infoHeight - 50;
  56. if (infoHeight) this.setData({ infoHeight: infoHeight })
  57. },
  58. /**
  59. * 生命周期函数--监听页面初次渲染完成
  60. */
  61. onReady: function () {
  62. },
  63. /**
  64. * 生命周期函数--监听页面显示
  65. */
  66. onShow: function () {
  67. },
  68. /**
  69. * 生命周期函数--监听页面隐藏
  70. */
  71. onHide: function () {
  72. },
  73. /**
  74. * 生命周期函数--监听页面卸载
  75. */
  76. onUnload: function () {
  77. },
  78. /**
  79. * 页面相关事件处理函数--监听用户下拉动作
  80. */
  81. onPullDownRefresh: function () {
  82. },
  83. /**
  84. * 页面上拉触底事件的处理函数
  85. */
  86. onReachBottom: function () {
  87. },
  88. /**
  89. * 用户点击右上角分享
  90. */
  91. onShareAppMessage: function () {
  92. }
  93. })