App.vue 1.7 KB

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