index.js 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. // pages/login/login.js
  2. import WxValidate from '../../utils/wxValidate'
  3. const app = getApp()
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. frameStyle: { useTop: true, name: '用户管理', leftArrow: true, useBar: false },
  10. // 主体高度
  11. infoHeight: '',
  12. // 信息列表
  13. list: [{ id: '1234567', name: '测试人员', phone: '12345678901', email: '123456@qq.com' }],
  14. // 弹框
  15. dialog: { title: '详细信息', show: false, type: '1' },
  16. // 详细信息
  17. info: { id: '1234567', name: '测试人员', phone: '12345678901', email: '123456@qq.com', address: '1', dept: '1', zw: '1', company: '1', type: '超级管理员' },
  18. },
  19. back: function () {
  20. wx.navigateBack({ url: '/pages/home/index' })
  21. },
  22. // 添加用户
  23. toAdd: function () {
  24. wx.navigateTo({ url: '/pages/user/detail' })
  25. },
  26. // 详细信息
  27. toView: function (e) {
  28. this.setData({ dialog: { title: '详细信息', show: true, type: '1' } })
  29. },
  30. // 信息变更
  31. toEdit: function (e) {
  32. const { id } = e.currentTarget.dataset;
  33. wx.navigateTo({ url: `/pages/user/detail?id=${id}` })
  34. },
  35. // 密码重置
  36. toReset: function (e) {
  37. wx.showToast({ title: `密码重置`, icon: 'error', duration: 1000 })
  38. },
  39. // 刪除信息
  40. toDel: function (e) {
  41. wx.showToast({ title: `刪除信息`, icon: 'error', duration: 1000 })
  42. },
  43. /**
  44. * 生命周期函数--监听页面加载
  45. */
  46. onLoad: function (options) {
  47. // 计算高度
  48. this.searchHeight()
  49. },
  50. // 计算高度
  51. searchHeight: function () {
  52. let frameStyle = this.data.frameStyle;
  53. let client = app.globalData.client;
  54. let infoHeight = client.windowHeight;
  55. // 是否去掉状态栏
  56. if (frameStyle.useTop) infoHeight = infoHeight - (client.statusBarHeight + client.getMenu.height + (client.getMenu.top - client.statusBarHeight) * 2);
  57. // 是否减去底部菜单
  58. if (frameStyle.useBar) infoHeight = infoHeight - 50;
  59. if (infoHeight) this.setData({ infoHeight: infoHeight })
  60. },
  61. /**
  62. * 生命周期函数--监听页面初次渲染完成
  63. */
  64. onReady: function () {
  65. },
  66. /**
  67. * 生命周期函数--监听页面显示
  68. */
  69. onShow: function () {
  70. },
  71. /**
  72. * 生命周期函数--监听页面隐藏
  73. */
  74. onHide: function () {
  75. },
  76. /**
  77. * 生命周期函数--监听页面卸载
  78. */
  79. onUnload: function () {
  80. },
  81. /**
  82. * 页面相关事件处理函数--监听用户下拉动作
  83. */
  84. onPullDownRefresh: function () {
  85. },
  86. /**
  87. * 页面上拉触底事件的处理函数
  88. */
  89. onReachBottom: function () {
  90. },
  91. /**
  92. * 用户点击右上角分享
  93. */
  94. onShareAppMessage: function () {
  95. }
  96. })