index.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. // pages/market/index.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. // 商品列表
  12. list: [
  13. { name: '喜羊羊', type_name: '羊肉', money: '22', status: '1', brief: '一份' },
  14. { name: '喜羊羊', type_name: '羊肉', money: '22', status: '0', brief: '一份' },
  15. { name: '喜羊羊', type_name: '羊肉', money: '22', status: '1', brief: '一份' },
  16. ],
  17. // 弹框
  18. dialog: { title: '详细信息', show: false, type: '1' },
  19. // 详细信息
  20. info: {},
  21. },
  22. back: function () {
  23. wx.navigateBack({ url: '/pages/home/index' })
  24. },
  25. // 添加采购申请
  26. toAdd: function () {
  27. wx.navigateTo({ url: `/pages/market/detail` })
  28. },
  29. // 详细信息
  30. toView: function (e) {
  31. let item = e.currentTarget.dataset.item;
  32. this.setData({ info: item })
  33. this.setData({ dialog: { title: '详细信息', show: true, type: '1' } })
  34. },
  35. // 上架,下架
  36. toCheck: function (e) {
  37. wx.showModal({
  38. title: '操作提示',
  39. content: '您确认上架/下架此产品吗?',
  40. success: (res) => {
  41. if (res.confirm) {
  42. wx.showToast({ title: `操作成功`, icon: 'success', duration: 2000 })
  43. }
  44. }
  45. })
  46. },
  47. /**
  48. * 生命周期函数--监听页面加载
  49. */
  50. onLoad: function (options) {
  51. // 计算高度
  52. this.searchHeight();
  53. },
  54. // 计算高度
  55. searchHeight: function () {
  56. let frameStyle = this.data.frameStyle;
  57. let client = app.globalData.client;
  58. // 减去状态栏
  59. let infoHeight = client.windowHeight - (client.statusBarHeight + client.getMenu.height + (client.getMenu.top - client.statusBarHeight) * 2);
  60. // 是否减去底部菜单
  61. if (frameStyle.useBar) infoHeight = infoHeight - 50;
  62. if (infoHeight) this.setData({ infoHeight: infoHeight })
  63. },
  64. /**
  65. * 生命周期函数--监听页面初次渲染完成
  66. */
  67. onReady: function () {
  68. },
  69. /**
  70. * 生命周期函数--监听页面显示
  71. */
  72. onShow: function () {
  73. this.onLoad()
  74. },
  75. /**
  76. * 生命周期函数--监听页面隐藏
  77. */
  78. onHide: function () {
  79. },
  80. /**
  81. * 生命周期函数--监听页面卸载
  82. */
  83. onUnload: function () {
  84. },
  85. /**
  86. * 页面相关事件处理函数--监听用户下拉动作
  87. */
  88. onPullDownRefresh: function () {
  89. },
  90. /**
  91. * 页面上拉触底事件的处理函数
  92. */
  93. onReachBottom: function () {
  94. },
  95. /**
  96. * 用户点击右上角分享
  97. */
  98. onShareAppMessage: function () {
  99. }
  100. })