contact.js 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. Component({
  2. /**
  3. * 组件的属性列表
  4. */
  5. properties: {
  6. show: {
  7. type: Boolean,
  8. observer: 'show'
  9. },
  10. showHeight: {
  11. type: Number,
  12. value: -68
  13. }
  14. },
  15. /**
  16. * 组件的初始数据
  17. */
  18. data: {
  19. hidden: true,
  20. animation: {}
  21. },
  22. /**
  23. * 组件的方法列表
  24. */
  25. methods: {
  26. call: function (sender) {
  27. this.hidden()
  28. wx.makePhoneCall({
  29. phoneNumber: '02028834746',
  30. })
  31. },
  32. cancel: function (sender) {
  33. this.hidden()
  34. },
  35. hidden: function () {
  36. var animation = wx.createAnimation({
  37. duration: 300,
  38. timingFunction: 'ease',
  39. })
  40. animation.bottom('-532rpx').step()
  41. this.setData({
  42. animation: animation.export()
  43. })
  44. setTimeout(function () {
  45. this.data.show = false
  46. this.data.hidden = true
  47. this.setData({
  48. hidden: this.data.hidden
  49. })
  50. this.triggerEvent('hiddenContact', {}, {})
  51. }.bind(this), 300)
  52. },
  53. show: function () {
  54. if (!this.data.hidden) {
  55. return
  56. }
  57. this.data.hidden = false
  58. this.setData({
  59. hidden: this.data.hidden
  60. })
  61. setTimeout(function () {
  62. var animation = wx.createAnimation({
  63. duration: 300,
  64. timingFunction: 'ease',
  65. })
  66. var bottom = this.data.showHeight + 'rpx'
  67. animation.bottom(bottom).step()
  68. this.setData({
  69. animation: animation.export(),
  70. })
  71. }.bind(this), 100)
  72. },
  73. }
  74. })