index.js 3.2 KB

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