App.vue 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <script>
  2. export default {
  3. onLaunch: function() {
  4. //更新版本
  5. this.updateApp()
  6. },
  7. async onShow() {
  8. await this.initPlatformParams();
  9. },
  10. methods:{
  11. async initPlatformParams(){
  12. const {ACTIVE_SETTING,PAGE_INTERFACE_SHOW} = (await this.$api.platform.getPlatformParams({
  13. keys: 'ACTIVE_SETTING,PAGE_INTERFACE_SHOW'
  14. })).data.data;
  15. this.$u.vuex('vuex_active_setting', JSON.parse(ACTIVE_SETTING));
  16. this.$u.vuex('vuex_page_interface_show', JSON.parse(PAGE_INTERFACE_SHOW));
  17. },
  18. updateApp(){
  19. const updateManager = uni.getUpdateManager();
  20. updateManager.onCheckForUpdate(function (res) {
  21. // 请求完新版本信息的回调
  22. console.log("是否有新版本:",res.hasUpdate);
  23. });
  24. updateManager.onUpdateReady(function (res) {
  25. uni.showModal({
  26. title: '更新提示',
  27. content: '新版本已经准备好,是否重启应用?',
  28. success(res) {
  29. if (res.confirm) {
  30. // 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
  31. updateManager.applyUpdate();
  32. }
  33. }
  34. });
  35. });
  36. updateManager.onUpdateFailed(function (res) {
  37. // 新的版本下载失败
  38. });
  39. }
  40. }
  41. }
  42. </script>
  43. <style lang="scss">
  44. @import "uview-ui/index.scss";
  45. @import "assets/colorui/main.css";
  46. @import "assets/colorui/icon.css";
  47. @import "assets/colorui/app.scss";
  48. </style>