index.vue 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. <template>
  2. <view>
  3. <!-- #ifdef H5 -->
  4. <view class="wrapper" v-if="!weChat" @click="openApp()">
  5. <!-- 左侧图标 -->
  6. <image class="img" :src="logo"></image>
  7. <view class="open">
  8. 打开{{config.name}}
  9. </view>
  10. </view>
  11. <!-- #endif -->
  12. </view>
  13. </template>
  14. <script>
  15. import config from "@/config/config";
  16. export default {
  17. data() {
  18. return {
  19. config, // 设置工具类
  20. weChat: false, // 是否微信浏览器,该项为true时不显示 当前整个页面
  21. logo: require("@/icon.png"), //显示的圆形logo
  22. };
  23. },
  24. mounted() {
  25. // #ifdef H5
  26. // 判断是否是微信浏览器
  27. var ua = navigator.userAgent.toLowerCase();
  28. var isWeixin = ua.indexOf("micromessenger") != -1;
  29. if (isWeixin) {
  30. this.weChat = true;
  31. } else {
  32. this.weChat = false;
  33. }
  34. // #endif
  35. },
  36. methods: {
  37. /**
  38. * 跳转到下载app页面
  39. */
  40. downloadApp() {
  41. setTimeout(function () {
  42. window.location.href = config.downloadLink;
  43. }, 2000);
  44. },
  45. /**
  46. * 打开app 仅在h5生效 使用ifream唤醒app
  47. */
  48. openApp() {
  49. let src;
  50. if (location.href) {
  51. src = location.href.split("/pages")[1];
  52. }
  53. let t = `${config.schemeLink}pages${src}`;
  54. try {
  55. var e = navigator.userAgent.toLowerCase(),
  56. n = e.match(/cpu iphone os (.*?) like mac os/);
  57. if (
  58. ((n = null !== n ? n[1].replace(/_/g, ".") : 0), parseInt(n) >= 9)
  59. ) {
  60. window.location.href = t;
  61. this.downloadApp();
  62. } else {
  63. var r = document.createElement("iframe");
  64. (r.src = t), (r.style.display = "none"), document.body.appendChild(r);
  65. this.downloadApp();
  66. }
  67. } catch (e) {
  68. window.location.href = t;
  69. this.downloadApp();
  70. }
  71. },
  72. },
  73. };
  74. </script>
  75. <style scoped lang="scss">
  76. .img {
  77. margin: 0 4rpx;
  78. width: 50rpx;
  79. height: 50rpx;
  80. border-radius: 50%;
  81. border: 5rpx solid #fff;
  82. }
  83. .open {
  84. margin: 0 10rpx;
  85. text-align: center;
  86. font-size: 26rpx;
  87. }
  88. .wrapper:hover {
  89. transform: translateX(0);
  90. }
  91. .wrapper {
  92. transform: translateX(160rpx);
  93. transition: 0.35s;
  94. align-items: center;
  95. justify-content: center;
  96. display: flex;
  97. border-top-left-radius: 20px;
  98. border-bottom-left-radius: 20px;
  99. color: #fff;
  100. // width: 220rpx;
  101. background: $light-color;
  102. position: fixed;
  103. top: 25%;
  104. right: 0;
  105. height: 60rpx;
  106. z-index: 9;
  107. }
  108. </style>