App.vue 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. <script>
  2. export default {
  3. onLaunch: function() {
  4. console.log('App Launch');
  5. // 看小程序需不需更新
  6. this.initUpd();
  7. },
  8. onShow: function(options) {
  9. console.log('App Show');
  10. },
  11. onHide: function() {
  12. console.log('App Hide');
  13. },
  14. methods: {
  15. // 更新小程序
  16. initUpd() {
  17. //获取小程序更新机制兼容
  18. if (uni.canIUse('getUpdateManager')) {
  19. const updateManager = uni.getUpdateManager();
  20. updateManager.onCheckForUpdate(function(res) {
  21. // 请求完新版本信息的回调
  22. if (res.hasUpdate) {
  23. updateManager.onUpdateReady(function() {
  24. uni.showModal({
  25. title: '更新提示',
  26. content: '新版本已经准备好,是否重启应用?',
  27. showCancel: false,
  28. confirmColor: '#3c9cff',
  29. success: function(res) {
  30. if (res.confirm) {
  31. // 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
  32. updateManager.applyUpdate();
  33. }
  34. }
  35. });
  36. });
  37. updateManager.onUpdateFailed(function() {
  38. // 新的版本下载失败
  39. uni.showModal({
  40. title: '已经有新版本了哟~',
  41. content: '新版本已经上线啦~,请您删除当前小程序,重新搜索打开哟~'
  42. });
  43. });
  44. }
  45. });
  46. } else {
  47. // 如果希望用户在最新版本的客户端上体验您的小程序,可以这样子提示
  48. uni.showModal({
  49. title: '提示',
  50. content: '当前微信版本过低,无法更好体验程序,请升级到最新微信版本后重试。'
  51. });
  52. }
  53. }
  54. }
  55. };
  56. </script>
  57. <style lang="scss">
  58. /*每个页面公共css */
  59. @import '@/uni_modules/uview-ui/index.scss';
  60. @import 'static/style/css/common.scss';
  61. // 全部页面背景色
  62. page {
  63. background-color: #f4f4f4;
  64. width: 100%;
  65. height: 100%;
  66. }
  67. view,
  68. scroll-view,
  69. swiper,
  70. swiper-item,
  71. cover-view,
  72. cover-image,
  73. icon,
  74. text,
  75. rich-text,
  76. progress,
  77. button,
  78. checkbox,
  79. form,
  80. input,
  81. label,
  82. radio,
  83. slider,
  84. switch,
  85. textarea,
  86. navigator,
  87. audio,
  88. camera,
  89. image,
  90. video {
  91. box-sizing: border-box;
  92. font-size: 14px;
  93. }
  94. // 改变uview的步进器大小
  95. .chgUNumBox {
  96. /deep/ .u-number-box {
  97. width: 100% !important;
  98. }
  99. /deep/ .u-number-box__plus {
  100. width: 30% !important;
  101. }
  102. /deep/ .u-number-box__input {
  103. width: 40% !important;
  104. }
  105. /deep/ .u-number-box__minus {
  106. width: 30% !important;
  107. }
  108. }
  109. </style>