index.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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. wx.showToast({ title: `操作成功`, icon: 'success', duration: 2000 })
  42. }
  43. })
  44. },
  45. /**
  46. * 生命周期函数--监听页面加载
  47. */
  48. onLoad: function (options) {
  49. // 计算高度
  50. this.searchHeight();
  51. },
  52. // 计算高度
  53. searchHeight: function () {
  54. let frameStyle = this.data.frameStyle;
  55. let client = app.globalData.client;
  56. // 减去状态栏
  57. let infoHeight = client.windowHeight - (client.statusBarHeight + client.getMenu.height + (client.getMenu.top - client.statusBarHeight) * 2);
  58. // 是否减去底部菜单
  59. if (frameStyle.useBar) infoHeight = infoHeight - 50;
  60. if (infoHeight) this.setData({ infoHeight: infoHeight })
  61. },
  62. /**
  63. * 生命周期函数--监听页面初次渲染完成
  64. */
  65. onReady: function () {
  66. },
  67. /**
  68. * 生命周期函数--监听页面显示
  69. */
  70. onShow: function () {
  71. this.onLoad()
  72. },
  73. /**
  74. * 生命周期函数--监听页面隐藏
  75. */
  76. onHide: function () {
  77. },
  78. /**
  79. * 生命周期函数--监听页面卸载
  80. */
  81. onUnload: function () {
  82. },
  83. /**
  84. * 页面相关事件处理函数--监听用户下拉动作
  85. */
  86. onPullDownRefresh: function () {
  87. },
  88. /**
  89. * 页面上拉触底事件的处理函数
  90. */
  91. onReachBottom: function () {
  92. },
  93. /**
  94. * 用户点击右上角分享
  95. */
  96. onShareAppMessage: function () {
  97. }
  98. })