App.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. <script>
  2. /**
  3. * vuex管理登录状态,具体可以参考官方登录模板示例
  4. */
  5. import { mapMutations } from "vuex";
  6. import APPUpdate from "@/plugins/APPUpdate";
  7. // 悬浮球
  8. export default {
  9. methods: {
  10. ...mapMutations(["login"]),
  11. },
  12. onLaunch: function () {
  13. // #ifdef APP-PLUS
  14. this.checkArguments(); // 检测启动参数
  15. // 重点是以下: 一定要监听后台恢复 !一定要
  16. plus.globalEvent.addEventListener("newintent", (e) => {
  17. this.checkArguments(); // 检测启动参数
  18. });
  19. // #endif
  20. },
  21. methods: {
  22. // 开屏广告
  23. launch() {
  24. try {
  25. // 获取本地存储中launchFlag标识 开屏广告
  26. const value = uni.getStorageSync("launchFlag");
  27. if (!value) {
  28. this.$u.route("/pages/index/agreement");
  29. } else {
  30. //app启动时打开启动广告页
  31. var w = plus.webview.open(
  32. "/hybrid/html/advertise/advertise.html",
  33. "本地地址",
  34. {
  35. top: 0,
  36. bottom: 0,
  37. zindex: 999,
  38. },
  39. "fade-in",
  40. 500
  41. );
  42. //设置定时器,4s后关闭启动广告页
  43. setTimeout(function () {
  44. plus.webview.close(w);
  45. APPUpdate();
  46. }, 3000);
  47. }
  48. } catch (e) {
  49. // error
  50. uni.setStorage({
  51. key: "launchFlag",
  52. data: true,
  53. success: function () {
  54. console.log("error时存储launchFlag");
  55. },
  56. });
  57. }
  58. },
  59. // 获取h5跳转app的链接并跳转
  60. checkArguments() {
  61. // #ifdef APP-PLUS
  62. setTimeout(() => {
  63. const args = plus.runtime.arguments;
  64. if (args) {
  65. const argsStr = decodeURIComponent(args);
  66. const path = argsStr.split("//")[1];
  67. if (path.indexOf("tabbar")) {
  68. uni.switchTab({
  69. url: `/${path}`,
  70. });
  71. } else {
  72. uni.navigateTo({
  73. url: `/${path}`,
  74. });
  75. }
  76. }
  77. });
  78. // #endif
  79. },
  80. },
  81. };
  82. </script>
  83. <style lang="scss">
  84. @import "uview-ui/index.scss";
  85. @import "./static/font/iconfont/iconfont.css";
  86. // -------适配底部安全区 苹果x系列刘海屏
  87. // #ifdef MP-WEIXIN
  88. .mp-iphonex-bottom {
  89. padding-bottom: constant(safe-area-inset-bottom);
  90. padding-bottom: env(safe-area-inset-bottom);
  91. box-sizing: content-box;
  92. height: auto !important;
  93. padding-top: 10rpx;
  94. }
  95. // #endif
  96. body {
  97. background-color: $bg-color;
  98. }
  99. /************************ */
  100. .w200 {
  101. width: 200rpx !important;
  102. }
  103. .flex1 {
  104. flex: 1; //必须父级设置flex
  105. }
  106. </style>