App.vue 2.1 KB

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