index.js 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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. list: [],
  13. // 弹框
  14. dialog: { title: '详细信息', show: false, type: '1' },
  15. // 详细信息
  16. info: {},
  17. },
  18. back: function () {
  19. wx.navigateBack({ url: '/pages/home/index' })
  20. },
  21. // 添加采购申请
  22. toAdd: function () {
  23. wx.navigateTo({ url: `/pages/type/detail` })
  24. },
  25. // 详细信息
  26. toView: function (e) {
  27. this.setData({ dialog: { title: '详细信息', show: true, type: '1' } })
  28. },
  29. // 信息变更
  30. toEdit: function (e) {
  31. const { id } = e.currentTarget.dataset;
  32. wx.navigateTo({ url: `/pages/type/detail?id=${id}` })
  33. },
  34. /**
  35. * 生命周期函数--监听页面加载
  36. */
  37. onLoad: function (options) {
  38. // 监听用户是否登录
  39. this.watchLogin();
  40. // 计算高度
  41. this.searchHeight()
  42. },
  43. // 监听用户是否登录
  44. watchLogin: function () {
  45. let data = [{ id: '1234567', code: '8', name: '其他' }]
  46. this.setData({ list: data })
  47. // wx.getStorage({
  48. // key: 'user',
  49. // success: res => {
  50. // if (res.data) {
  51. // // 查询菜单
  52. // if (res.data) this.searchRouter(res.data);
  53. // res.data.type = type.find((i) => i.value == res.data.type).label;
  54. // if (res.data) this.setData({ userInfo: res.data });
  55. // if (res.data && res.data.avatarUrl) this.setData({ avatarUrl: res.data.avatarUrl });
  56. // } else {
  57. // wx.redirectTo({ url: '/pages/login/index', })
  58. // }
  59. // }
  60. // })
  61. },
  62. // 计算高度
  63. searchHeight: function () {
  64. let frameStyle = this.data.frameStyle;
  65. let client = app.globalData.client;
  66. let infoHeight = client.windowHeight;
  67. // 是否去掉状态栏
  68. if (frameStyle.useTop) infoHeight = infoHeight - (client.statusBarHeight + client.getMenu.height + (client.getMenu.top - client.statusBarHeight) * 2);
  69. // 是否减去底部菜单
  70. if (frameStyle.useBar) infoHeight = infoHeight - 50;
  71. if (infoHeight) this.setData({ infoHeight: infoHeight })
  72. },
  73. /**
  74. * 生命周期函数--监听页面初次渲染完成
  75. */
  76. onReady: function () {
  77. },
  78. /**
  79. * 生命周期函数--监听页面显示
  80. */
  81. onShow: function () {
  82. },
  83. /**
  84. * 生命周期函数--监听页面隐藏
  85. */
  86. onHide: function () {
  87. },
  88. /**
  89. * 生命周期函数--监听页面卸载
  90. */
  91. onUnload: function () {
  92. },
  93. /**
  94. * 页面相关事件处理函数--监听用户下拉动作
  95. */
  96. onPullDownRefresh: function () {
  97. },
  98. /**
  99. * 页面上拉触底事件的处理函数
  100. */
  101. onReachBottom: function () {
  102. },
  103. /**
  104. * 用户点击右上角分享
  105. */
  106. onShareAppMessage: function () {
  107. }
  108. })