test.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. //获取应用实例
  2. var app = getApp();
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. showPop: true,
  9. animationData: {},
  10. },
  11. // 显示底部弹层
  12. showModal: function() {
  13. var _this = this;
  14. var animation = wx.createAnimation({
  15. duration: 500,
  16. timingFunction: 'ease',
  17. delay: 0
  18. })
  19. _this.animation = animation
  20. animation.translateY(300).step()
  21. _this.setData({
  22. animationData: animation.export(),
  23. showPop: true
  24. })
  25. setTimeout(function() {
  26. animation.translateY(0).step()
  27. _this.setData({
  28. animationData: animation.export()
  29. })
  30. }.bind(_this), 50)
  31. },
  32. // 隐藏底部弹层
  33. hideModal: function() {
  34. var _this = this;
  35. // 隐藏遮罩层
  36. var animation = wx.createAnimation({
  37. duration: 500,
  38. timingFunction: "ease",
  39. delay: 0
  40. })
  41. _this.animation = animation
  42. animation.translateY(300).step()
  43. _this.setData({
  44. animationData: animation.export(),
  45. })
  46. setTimeout(function() {
  47. animation.translateY(0).step()
  48. _this.setData({
  49. animationData: animation.export(),
  50. showPop: false
  51. })
  52. }.bind(this), 200)
  53. },
  54. })