freeTrialBtn.vue 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <template>
  2. <span class="free-btn" v-bind="$attrs" @click="btnClick">免费试用</span>
  3. </template>
  4. <script>
  5. export default {
  6. name: "freeTrialBtn",
  7. props: {
  8. myType: {
  9. type: String,
  10. default: 'kaoshi'
  11. }
  12. },
  13. methods: {
  14. isPC() {
  15. const browserWidth = document.documentElement.clientWidth;
  16. if (browserWidth <= 768) {
  17. return false;
  18. } else {
  19. return true;
  20. }
  21. },
  22. btnClick() {
  23. // 执行业务
  24. this.FreeTrial();
  25. // 执行通知
  26. if (this.isPC()) {
  27. this.$emit('active-pc', this.myType)
  28. } else {
  29. this.$emit('active-h5', this.myType)
  30. }
  31. },
  32. FreeTrial() {
  33. if (!this.isPC()) {
  34. // H5
  35. if (this.myType === 'kaoshi') {
  36. window.open('https://cdnks.mtavip.com/mdist/#/webRegister?flug=1')
  37. } else {
  38. window.open('https://cdnks.mtavip.com/mdist/#/webRegister?flug=2')
  39. }
  40. } else {
  41. if (this.myType === 'kaoshi') {
  42. window.open('https://cdnks.mtavip.com/a/register?flug=1')
  43. } else {
  44. window.open('https://cdnks.mtavip.com/a/register?flug=2')
  45. }
  46. }
  47. },
  48. }
  49. }
  50. </script>
  51. <style lang="scss">
  52. .free-btn {
  53. width: 154px;
  54. height: 48px;
  55. line-height: 48px;
  56. background: #00b96b;
  57. border-radius: 24px;
  58. color: #fff;
  59. cursor: pointer;
  60. display: inline-block;
  61. text-align: center;
  62. @media (max-width: 768px) {
  63. width: 44%;height:35px;line-height:35px;max-width: 120px;margin: 0 3%;display: inline-block;
  64. padding: 0;text-align: center;font-size: 14px;
  65. }
  66. }
  67. </style>