App.vue 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <style lang="scss">
  2. /* 注意要写在第一行,同时给style标签加入lang="scss"属性 */
  3. @import 'uview-ui/index.scss';
  4. @import './style/common.scss';
  5. image {
  6. image-rendering: -moz-crisp-edges;
  7. image-rendering: -o-crisp-edges;
  8. image-rendering: -webkit-optimize-contrast;
  9. image-rendering: crisp-edges;
  10. -ms-interpolation-mode: nearest-neighbor;
  11. }
  12. </style>
  13. <script>
  14. import store from './store'
  15. export default {
  16. onLaunch: function () {
  17. console.log('App Launch')
  18. const updateManager = uni.getUpdateManager()
  19. updateManager.onCheckForUpdate(function (res) {
  20. // 请求完新版本信息的回调
  21. if (res.hasUpdate) {
  22. updateManager.onUpdateReady(function (res2) {
  23. uni.showModal({
  24. title: '更新提示',
  25. content: '发现新版本,是否重启应用?',
  26. cancelColor: '#eeeeee',
  27. confirmColor: '#FF0000',
  28. success(res2) {
  29. if (res2.confirm) {
  30. // 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
  31. updateManager.applyUpdate()
  32. }
  33. },
  34. })
  35. })
  36. }
  37. })
  38. updateManager.onUpdateFailed(function (res) {
  39. // 新的版本下载失败
  40. uni.showModal({
  41. title: '提示',
  42. content: '检查到有新版本,但下载失败,请检查网络设置',
  43. success(res) {
  44. if (res.confirm) {
  45. // 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
  46. updateManager.applyUpdate()
  47. }
  48. },
  49. })
  50. })
  51. },
  52. onShow: function () {
  53. store.dispatch('getUserInfo')
  54. // console.log('App Show')
  55. },
  56. onHide: function () {
  57. // console.log('App Hide')
  58. },
  59. }
  60. </script>