index.js 2.6 KB

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