App.vue 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <script>
  2. export default {
  3. onLaunch: function() {
  4. console.log('App Launch')
  5. },
  6. onShow: function() {
  7. console.log('App Show')
  8. this.autoUpdate();
  9. if(uni.getStorageSync('userInfo')) uni.reLaunch({ url:'/pages/home/index' })
  10. else uni.reLaunch({ url:'/pages/login/index' })
  11. },
  12. onHide: function() {
  13. console.log('App Hide')
  14. },
  15. methods: {
  16. autoUpdate() {
  17. if (wx.canIUse('getUpdateManager')) {
  18. const updateManager = wx.getUpdateManager();
  19. updateManager.onCheckForUpdate(res => {
  20. if (res.hasUpdate) {
  21. updateManager.onUpdateReady(() => {
  22. wx.showModal({
  23. title: '更新提示',
  24. content: '发现新版本,是否更新?',
  25. success: function(res) {
  26. if (res.confirm) {
  27. updateManager.applyUpdate();
  28. }
  29. }
  30. })
  31. });
  32. updateManager.onUpdateFailed(function() {
  33. wx.showModal({
  34. title: '最新版提示',
  35. content: '新版本已上线,请您删除当前小程序,重新搜索打开',
  36. showCancel: false
  37. })
  38. });
  39. }
  40. })
  41. } else {
  42. wx.showModal({
  43. title: '提示',
  44. content: '当前微信版本过低,无法使用该功能,请升级到最新微信版本后重试。',
  45. showCancel: false
  46. })
  47. }
  48. }
  49. }
  50. }
  51. </script>
  52. <style lang="scss">
  53. /* 注意要写在第一行,同时给style标签加入lang="scss"属性 */
  54. @import "@/uni_modules/uview-ui/index.scss";
  55. * {
  56. padding: 0;
  57. margin: 0;
  58. box-sizing: border-box;
  59. font-family: PingFangSC-Regular, PingFang SC;
  60. }
  61. html,body {
  62. font-family: PingFangSC-Regular, PingFang SC;
  63. font-size: 24rpx;
  64. width: 100%;
  65. height: 100%;
  66. }
  67. </style>