Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.
 
 
 
 
 
 

80 wiersze
2.3 KiB

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