App.vue 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <script>
  2. import {
  3. mapState,
  4. mapMutations
  5. } from "vuex"
  6. export default {
  7. onLaunch: function() {
  8. console.log('App Launch')
  9. if(this.setting.forceUpdate) {
  10. this.Upload()
  11. }
  12. },
  13. onShow: function() {
  14. console.log('App Show')
  15. },
  16. onHide: function() {
  17. console.log('App Hide')
  18. },
  19. onLoad() {
  20. console.log("卸载了")
  21. let set = this.setting
  22. set[keepscreenon] = false
  23. setTimeout(function() {
  24. this.setTing(set)
  25. }, 100);
  26. },
  27. computed: {
  28. ...mapState({
  29. setting: state => state.global.setting
  30. })
  31. },
  32. methods:{
  33. ...mapMutations(["setTing"]),
  34. // 更新
  35. Upload() {
  36. console.log("哈哈")
  37. const updateManager = uni.getUpdateManager();
  38. updateManager.onCheckForUpdate(function (res) {
  39. // 请求完新版本信息的回调
  40. console.log(res.hasUpdate,"-------888-------");
  41. });
  42. updateManager.onUpdateReady(function (res) {
  43. uni.showModal({
  44. title: '更新提示',
  45. content: '新版本已经准备好,是否重启应用?',
  46. success(res) {
  47. if (res.confirm) {
  48. // 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
  49. updateManager.applyUpdate();
  50. }
  51. }
  52. });
  53. });
  54. updateManager.onUpdateFailed(function (res) {
  55. // 新的版本下载失败
  56. console.log(res)
  57. });
  58. }
  59. }
  60. }
  61. </script>
  62. <style lang="scss">
  63. @import "colorui/main.css";
  64. @import "colorui/icon.css";
  65. @import "common/main.css"; /* 你的项目css */
  66. @import "common/iconfont.css"
  67. </style>