App.vue 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <script>
  2. import { ref, getCurrentInstance } from 'vue'
  3. export default {
  4. onLaunch: function () {
  5. if (process.env.NODE_ENV === 'development') {
  6. } else {
  7. const { $Http } = getCurrentInstance().proxy;
  8. if (uni.getStorageSync('userMsg').token) {
  9. $Http.basic({
  10. "classname": "webmanage.site.site",
  11. "method": "querySite_Parameter", //查询站点数据
  12. content: {
  13. nocache: true
  14. }
  15. }).then(res => {
  16. if (res.code == 1) {
  17. uni.removeStorageSync('siteP');
  18. uni.setStorageSync("siteP", res.data)
  19. try {
  20. let currentPages = getCurrentPages().pop();
  21. if (currentPages.route == 'pages/login/login' || currentPages.$page.fullPath == "/pages/login/login") uni.redirectTo({
  22. url: '/pages/index/index',
  23. });
  24. } catch (error) {
  25. uni.redirectTo({
  26. url: '/pages/index/index',
  27. });
  28. }
  29. }
  30. })
  31. }
  32. }
  33. },
  34. onShow: function () {
  35. try {
  36. const { $Http } = getCurrentInstance().proxy;
  37. $Http.uploadNumber && $Http.uploadNumber();
  38. } catch (error) {
  39. }
  40. try {
  41. const updateManager = uni.getUpdateManager()
  42. updateManager.onCheckForUpdate(function (res) {
  43. // 请求完新版本信息的回调
  44. console.log("是否有新版本", res.hasUpdate)
  45. })
  46. updateManager.onUpdateReady(function () {
  47. uni.showModal({
  48. title: '更新提示',
  49. content: '新版本已经准备好,是否重启应用?',
  50. showCancel: false,
  51. success: function (res) {
  52. if (res.confirm) {
  53. // 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
  54. updateManager.applyUpdate()
  55. }
  56. }
  57. })
  58. })
  59. updateManager.onUpdateFailed(function () {
  60. // 新版本下载失败
  61. })
  62. } catch (error) {
  63. }
  64. },
  65. onHide: function () {
  66. }
  67. }
  68. </script>
  69. <style lang="scss">
  70. /* 注意要写在第一行,注意不能引入至uni.scss,同时给style标签加入lang="scss"属性 */
  71. @import "@/uni_modules/uview-plus/index.scss";
  72. @import '/static/iconfont.css';
  73. page {
  74. background-color: #F7F7FF;
  75. }
  76. </style>