index.js 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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: [{ id: '1234567', code: '8', name: '其他' }],
  13. // 弹框
  14. dialog: { title: '详细信息', show: false, type: '1' },
  15. // 详细信息
  16. info: { id: '1234567', code: '8', name: '其他' },
  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.searchHeight()
  40. },
  41. // 计算高度
  42. searchHeight: function () {
  43. let frameStyle = this.data.frameStyle;
  44. let client = app.globalData.client;
  45. let infoHeight = client.windowHeight;
  46. // 是否去掉状态栏
  47. if (frameStyle.useTop) infoHeight = infoHeight - (client.statusBarHeight + client.getMenu.height + (client.getMenu.top - client.statusBarHeight) * 2);
  48. // 是否减去底部菜单
  49. if (frameStyle.useBar) infoHeight = infoHeight - 50;
  50. if (infoHeight) this.setData({ infoHeight: infoHeight })
  51. },
  52. /**
  53. * 生命周期函数--监听页面初次渲染完成
  54. */
  55. onReady: function () {
  56. },
  57. /**
  58. * 生命周期函数--监听页面显示
  59. */
  60. onShow: function () {
  61. },
  62. /**
  63. * 生命周期函数--监听页面隐藏
  64. */
  65. onHide: function () {
  66. },
  67. /**
  68. * 生命周期函数--监听页面卸载
  69. */
  70. onUnload: function () {
  71. },
  72. /**
  73. * 页面相关事件处理函数--监听用户下拉动作
  74. */
  75. onPullDownRefresh: function () {
  76. },
  77. /**
  78. * 页面上拉触底事件的处理函数
  79. */
  80. onReachBottom: function () {
  81. },
  82. /**
  83. * 用户点击右上角分享
  84. */
  85. onShareAppMessage: function () {
  86. }
  87. })