index.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. Component({
  2. /**
  3. * 组件的属性列表
  4. */
  5. properties: {},
  6. /**
  7. * 组件的初始数据
  8. */
  9. data: {
  10. //弹窗显示控制
  11. showModalStatus: true
  12. },
  13. /**
  14. * 组件的方法列表
  15. */
  16. methods: {
  17. //底部弹出框
  18. showModal: function () {
  19. // 背景遮罩层
  20. var animation = wx.createAnimation({
  21. duration: 200,
  22. timingFunction: "linear",
  23. delay: 0
  24. })
  25. animation.translateY(300).step()
  26. this.setData({
  27. animationData: animation.export(),
  28. showModalStatus: true
  29. })
  30. setTimeout(function () {
  31. animation.translateY(0).step()
  32. this.setData({
  33. animationData: animation.export()
  34. })
  35. }.bind(this), 200)
  36. },
  37. //点击背景面任意一处时,弹出框隐藏
  38. hideModal: function () {
  39. //弹出框消失动画
  40. var animation = wx.createAnimation({
  41. duration: 200,
  42. timingFunction: "linear",
  43. delay: 0
  44. })
  45. animation.translateY(300).step()
  46. this.setData({
  47. animationData: animation.export(),
  48. })
  49. setTimeout(function () {
  50. animation.translateY(0).step()
  51. this.setData({
  52. animationData: animation.export(),
  53. showModalStatus: false
  54. })
  55. }.bind(this), 200)
  56. },
  57. }
  58. })