beerBoxDetail.js 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. // pages/beerBoxDetail/beerBoxDetail.js
  2. const request = require("../../utils/request.js");
  3. const login = require("../../utils/login.js");
  4. const app = getApp();
  5. Page({
  6. /**
  7. * 页面的初始数据
  8. */
  9. data: {
  10. statusBar_top: app.globalData.menuTop,
  11. navBarHeight: app.globalData.navBarHeight,
  12. popover_Status: true,
  13. boxId: null,
  14. beerBoxDetail: {},
  15. topViewStatus: true
  16. },
  17. /**
  18. * 生命周期函数--监听页面加载
  19. */
  20. onLoad(options) {
  21. if(options.boxId) {
  22. this.setData({
  23. boxId: options.boxId
  24. })
  25. }
  26. this.geBoxtDetail()
  27. },
  28. /**
  29. * 生命周期函数--监听页面初次渲染完成
  30. */
  31. onReady() {
  32. },
  33. /**
  34. * 生命周期函数--监听页面显示
  35. */
  36. onShow() {
  37. },
  38. /**
  39. * 生命周期函数--监听页面隐藏
  40. */
  41. onHide() {
  42. },
  43. /**
  44. * 生命周期函数--监听页面卸载
  45. */
  46. onUnload() {
  47. },
  48. /**
  49. * 页面相关事件处理函数--监听用户下拉动作
  50. */
  51. onPullDownRefresh() {
  52. },
  53. onPageScroll(e) {
  54. // console.log('距顶距离',e.scrollTop)
  55. if(e.scrollTop>120) {
  56. this.setData({
  57. topViewStatus: false
  58. })
  59. }else{
  60. this.setData({
  61. topViewStatus: true
  62. })
  63. }
  64. },
  65. /**
  66. * 页面上拉触底事件的处理函数
  67. */
  68. onReachBottom() {
  69. },
  70. /**
  71. * 用户点击右上角分享
  72. */
  73. onShareAppMessage() {
  74. },
  75. geBoxtDetail() {
  76. let that = this;
  77. request.getData(
  78. 'app/box/detail',{boxId: that.data.boxId},
  79. res => {
  80. that.setData({
  81. beerBoxDetail: res.data.data
  82. })
  83. },
  84. res => {
  85. console.log(res)
  86. }
  87. )
  88. },
  89. backFun() {
  90. wx.navigateBack({
  91. delta: 1
  92. })
  93. },
  94. popoverFun() {
  95. this.setData({
  96. popover_Status: !this.data.popover_Status
  97. })
  98. },
  99. toBeerDetail(event) {
  100. login.ifLogin('../beerDetail/beerDetail?productId=' + event.currentTarget.dataset.pid)
  101. },
  102. toPay() {
  103. wx.navigateTo({
  104. url: '../beerBoxPayment/beerBoxPayment?boxId='+this.data.boxId
  105. })
  106. }
  107. })