index.js 3.4 KB

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