index.js 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. // pages/login/login.js
  2. const app = getApp();
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. frameStyle: { useTop: true, name: '入库管理', leftArrow: true, useBar: false },
  9. // 主体高度
  10. infoHeight: '',
  11. userInfo: {},
  12. // 采购申请
  13. list: [],
  14. // 弹框
  15. dialog: { title: '详细信息', show: false, type: '1' },
  16. // 详细信息
  17. info: {},
  18. },
  19. back: function () {
  20. wx.navigateBack({ url: '/pages/home/index' })
  21. },
  22. // 添加入库
  23. toAdd: function () {
  24. wx.navigateTo({ url: `/pages/indepot/detail` })
  25. },
  26. // 详细信息
  27. toView: function (e) {
  28. const { id } = e.currentTarget.dataset;
  29. wx.request({
  30. url: app.globalData.publicUrl + `/api/hc/marketEnter/${id}`,
  31. method: "get",
  32. data: {},
  33. header: {},
  34. success: (res) => {
  35. if (res.data.errcode == '0') {
  36. this.setData({ info: res.data.data })
  37. this.setData({ dialog: { title: '详细信息', show: true, type: '1' } })
  38. } else {
  39. wx.showToast({ title: `${res.data.errmsg}`, icon: 'error', duration: 2000 })
  40. }
  41. },
  42. })
  43. },
  44. /**
  45. * 生命周期函数--监听页面加载
  46. */
  47. onLoad: function (options) {
  48. // 查询用户是否登录
  49. wx.getStorage({
  50. key: 'user',
  51. success: res => {
  52. if (res.data) {
  53. if (res.data) this.setData({ userInfo: res.data });
  54. this.search();
  55. } else {
  56. wx.redirectTo({ url: '/pages/login/index', })
  57. }
  58. }
  59. })
  60. // 计算高度
  61. this.searchHeight();
  62. },
  63. search: function () {
  64. // 查询采购列表
  65. if (this.data.userInfo && this.data.userInfo.id) {
  66. wx.request({
  67. url: app.globalData.publicUrl + `/api/hc/marketEnter`,
  68. method: "get",
  69. data: { operate_id: this.data.userInfo.id },
  70. header: {},
  71. success: (res) => {
  72. if (res.data.errcode == '0') {
  73. this.setData({ list: res.data.data })
  74. } else {
  75. wx.showToast({ title: `${res.data.errmsg}`, icon: 'error', duration: 2000 })
  76. }
  77. },
  78. })
  79. }
  80. },
  81. // 计算高度
  82. searchHeight: function () {
  83. let frameStyle = this.data.frameStyle;
  84. let client = app.globalData.client;
  85. // 减去状态栏
  86. let infoHeight = client.windowHeight - (client.statusBarHeight + client.getMenu.height + (client.getMenu.top - client.statusBarHeight) * 2);
  87. // 是否减去底部菜单
  88. if (frameStyle.useBar) infoHeight = infoHeight - 50;
  89. if (infoHeight) this.setData({ infoHeight: infoHeight })
  90. },
  91. /**
  92. * 生命周期函数--监听页面初次渲染完成
  93. */
  94. onReady: function () {
  95. },
  96. /**
  97. * 生命周期函数--监听页面显示
  98. */
  99. onShow: function () {
  100. this.search();
  101. },
  102. /**
  103. * 生命周期函数--监听页面隐藏
  104. */
  105. onHide: function () {
  106. },
  107. /**
  108. * 生命周期函数--监听页面卸载
  109. */
  110. onUnload: function () {
  111. },
  112. /**
  113. * 页面相关事件处理函数--监听用户下拉动作
  114. */
  115. onPullDownRefresh: function () {
  116. },
  117. /**
  118. * 页面上拉触底事件的处理函数
  119. */
  120. onReachBottom: function () {
  121. },
  122. /**
  123. * 用户点击右上角分享
  124. */
  125. onShareAppMessage: function () {
  126. }
  127. })