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.
 
 
 
 
 
 

50 lines
1.5 KiB

  1. <script>
  2. export default {
  3. // 小程序:onLaunch 仅启动时调用一次
  4. // H5/App:onLaunch 打开网页/用户点刷新/代码热更新时均会调用;
  5. // 考虑到用户刷新网页时会丢失全局数据、页面栈、页面数据等,因此直接跳回首页即可
  6. async onLaunch(param) {
  7. // #ifdef H5 || APP-VUE
  8. // H5 刷新时获取当前页面路径
  9. const pagePath = '/' + param.path
  10. // 如果 H5 刷新后访问的不是首页/登录页/注册页,直接跳转回首页
  11. if (!['/pages/login', '/pages/home', '/pages/signup'].includes(pagePath)) {
  12. this.$nextTick(() => {
  13. this.TAB_TO('/pages/home')
  14. return
  15. })
  16. }
  17. // #endif
  18. // #ifdef MP-WEIXIN
  19. // 小程序端,处理更新 (支付宝/钉钉暂不支持)
  20. const updateManager = uni.getUpdateManager()
  21. updateManager.onUpdateReady(() => {
  22. this.HIDE_LOADING()
  23. uni.showModal({
  24. title: '更新提示',
  25. content: '小程序新版本已准备好,是否更新应用?',
  26. success: ({ confirm }) => {
  27. if (confirm) {
  28. updateManager.applyUpdate()
  29. }
  30. }
  31. })
  32. })
  33. // #endif
  34. }
  35. }
  36. </script>
  37. <style lang="less">
  38. // 现在 CSS 必须在 <style> 中引入,参考:https://ask.dcloud.net.cn/question/86907
  39. // 后续 uni-app 升级后可能会支持直接 import 样式,到时候可以省略下行代码
  40. @import '~@/components/learun-mpui/styles/index.css';
  41. page {
  42. background-color: #f3f3f3;
  43. }
  44. </style>