contact.js 1.9 KB

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