index.js 2.7 KB

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