You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

84 regels
2.4 KiB

  1. <script>
  2. export default {
  3. // 小程序:onLaunch 仅启动时调用一次
  4. // H5/App:onLaunch 打开网页/用户点刷新/代码热更新时均会调用;
  5. // 考虑到用户刷新网页时会丢失全局数据、页面栈、页面数据等,因此直接跳回首页即可
  6. async onLaunch(param) {
  7. // 版本更新
  8. var newVer = '1.0.2';
  9. var oldVer = localStorage.getItem('version');
  10.     if (newVer != oldVer) {
  11. localStorage.setItem('version', newVer);
  12. this.JUMP_TO("/")
  13. }
  14. // 加载百度地图资源
  15. let ak = this.GET_AK()
  16. var script = document.createElement('script');
  17. script.type = 'text/javascript';
  18. script.src =
  19. 'https://api.map.baidu.com/api?v=1.0&type=webgl&ak=' + ak +
  20. '&callback=' + 'initMap';
  21. document.head.appendChild(script);
  22. // 在App.vue文件中获取到页面到URL (初始化WXsdj)
  23. window.localStorage.setItem('scanUrl',location.href.split('#')[0])
  24. //应用的生命周期 应用启动后触发
  25. // #ifdef H5 || APP-VUE
  26. // H5 刷新时获取当前页面路径
  27. const pagePath = "/" + param.path;
  28. // 如果 H5 刷新后访问的不是首页/登录页/注册页,直接跳转回首页
  29. if (!["/pages/login", "/pages/home", "/pages/signup","/pages/weixinLogin","/pages/wxLogin"].includes(pagePath)) {
  30. this.$nextTick(() => {
  31. this.TAB_TO("/pages/home");
  32. return;
  33. });
  34. }
  35. // #endif
  36. // #ifdef MP-WEIXIN
  37. // 小程序端,处理更新 (支付宝/钉钉暂不支持)
  38. const updateManager = uni.getUpdateManager();
  39. updateManager.onUpdateReady(() => {
  40. this.HIDE_LOADING();
  41. uni.showModal({
  42. title: "更新提示",
  43. content: "小程序新版本已准备好,是否更新应用?",
  44. success: ({
  45. confirm
  46. }) => {
  47. if (confirm) {
  48. updateManager.applyUpdate();
  49. }
  50. },
  51. });
  52. });
  53. // #endif
  54. },
  55. onError(error) {
  56. console.log(error);
  57. },
  58. };
  59. </script>
  60. <style lang="less">
  61. // 现在 CSS 必须在 <style> 中引入,参考:https://ask.dcloud.net.cn/question/86907
  62. // 后续 uni-app 升级后可能会支持直接 import 样式,到时候可以省略下行代码
  63. @import "~@/components/learun-mpui/styles/index.css";
  64. page {
  65. background-color: #f3f3f3;
  66. }
  67. .btn {
  68. width: 50%;
  69. line-height: 34px;
  70. background-color: #0c86d8;
  71. text-align: center;
  72. color: #fff;
  73. border-radius: 4px;
  74. margin: 30px auto;
  75. }
  76. </style>