pop.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. // components/pop/pop.js
  2. Component({
  3. /**
  4. * 组件的属性列表
  5. */
  6. properties: {
  7. show: {
  8. type: Boolean,
  9. value: false
  10. }
  11. },
  12. observers: {
  13. 'show': function (show) {
  14. let that = this
  15. if (show) {
  16. that.open()
  17. } else {
  18. that.close()
  19. }
  20. }
  21. },
  22. /**
  23. * 组件的初始数据
  24. */
  25. data: {
  26. showPop: false,
  27. animation: ""
  28. },
  29. /**
  30. * 组件的方法列表
  31. */
  32. methods: {
  33. none() {
  34. return
  35. },
  36. open() {
  37. let that = this
  38. that.setData({
  39. showPop: true
  40. })
  41. setTimeout(() => {
  42. that.setData({
  43. animation: "active"
  44. })
  45. }, 50);
  46. },
  47. close() {
  48. let that = this
  49. that.setData({
  50. animation: ""
  51. })
  52. setTimeout(() => {
  53. that.setData({
  54. showPop: false
  55. })
  56. }, 350);
  57. },
  58. closeEvent() {
  59. let that = this
  60. that.triggerEvent('close', false)
  61. }
  62. }
  63. })