hotLine.js 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. var app=getApp()
  2. Component({
  3. properties: {
  4. propName: { // 属性名
  5. type: String, // 类型(必填),目前接受的类型包括:String, Number, Boolean, Object, Array, null(表示任意类型)
  6. value: 'val', // 属性初始值(必填)
  7. observer: function (newVal, oldVal) {
  8. // 属性被改变时执行的函数(可选)
  9. }
  10. }
  11. },
  12. data: {
  13. isModalShow: false,
  14. firstAnimation: '',
  15. secondAnimation: '',
  16. thridAnimation: ''
  17. }, // 私有数据,可用于模版渲染
  18. openModal(e) {
  19. const animation = swan.createAnimation()
  20. animation.translateY(-500).step();
  21. this.setData({ isModalShow: true }
  22. , () => {
  23. //如果有参数的话,就不显示hotline组件的第一个弹框,直接显示第二个
  24. console.log(e)
  25. if (e) {
  26. console.log(1)
  27. this.setData({
  28. secondAnimation: animation.export()
  29. })
  30. } else {
  31. console.log(2)
  32. this.setData({
  33. firstAnimation: animation.export()
  34. })
  35. }
  36. }
  37. )
  38. swan.hideTabBar();
  39. },
  40. closeModal(e) {
  41. const animation = swan.createAnimation().translateY(0).step();
  42. const animationClose = animation.export()
  43. this.setData({
  44. firstAnimation: animationClose,
  45. secondAnimation: animationClose,
  46. thridAnimation: animationClose
  47. })
  48. setTimeout(() => {
  49. this.setData({
  50. isModalShow: false
  51. })
  52. swan.showTabBar();
  53. }, 400)
  54. },
  55. showAni(e) {
  56. const animation = swan.createAnimation()
  57. //显示时的动画和消失的动画
  58. const animationClose = animation.translateY(0).step().export();
  59. const animationOpen = animation.translateY(-500).step().export();
  60. this.setData({
  61. firstAnimation: animationClose,
  62. secondAnimation: animationOpen
  63. })
  64. },
  65. makePhoneCall() {
  66. swan.makePhoneCall({
  67. // 需要拨打的电话号码
  68. phoneNumber: '4008819211',
  69. // 接口调用结束的回调函数(调用成功、失败都会执行)
  70. complete: res => {
  71. this.closeModal()
  72. }
  73. });
  74. },
  75. addPhone() {
  76. this.closeModal()
  77. setTimeout(() => {
  78. swan.addPhoneContact({
  79. firstName: '我的社保',
  80. mobilePhoneNumber: '4008819211',
  81. });
  82. }, 400)
  83. },
  84. // goKefu(e){
  85. // swan.navigateTo({
  86. // url: '../../../public/pages/html/html?host=https://www.sobot.com/chat/h5/index.html&sysNum=a73ea222d7284f7c8801e60e6054e985&partnerId=2180427&tel='+ app.globalData.userInfo.phone+'&uname='+ app.globalData.userInfo.phone+'&remark=BDXCX_SHEBAO&titleFlag=3&powered=false&telShowFlag=true&telFlag=true'
  87. // })
  88. // },
  89. // 生命周期函数,可以为函数,或一个在methods段中定义的方法名
  90. attached: function () { },
  91. detached: function () { },
  92. methods: {
  93. onTap: function () {
  94. this.setData({
  95. // 更新属性和数据的方法与更新页面数据的方法类似
  96. });
  97. }
  98. }
  99. });