App.vue 1.5 KB

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