App.vue 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <script>
  2. const menuButtonInfo = wx.getMenuButtonBoundingClientRect(); //胶囊相关信息
  3. const menuButtonHeight = menuButtonInfo.height; //胶囊高度
  4. const menuButtonTop = menuButtonInfo.top; //胶囊距上边界距离
  5. export default {
  6. onLaunch: function() {
  7. //自定义导航栏适配机型
  8. const systemInfo = wx.getSystemInfoSync();
  9. // 胶囊按钮位置信息
  10. const menuButtonInfo = wx.getMenuButtonBoundingClientRect();
  11. // 导航栏高度 = 状态栏到胶囊的间距(胶囊距上距离-状态栏高度) * 2 + 胶囊高度 + 状态栏高度
  12. this.globalData.navBarHeight = (menuButtonInfo.top - systemInfo.statusBarHeight) * 2 + menuButtonInfo.height + systemInfo.statusBarHeight;
  13. this.globalData.menuBotton = menuButtonInfo.top - systemInfo.statusBarHeight;
  14. this.globalData.menuRight = systemInfo.screenWidth - menuButtonInfo.right;
  15. this.globalData.menuHeight = menuButtonInfo.height;
  16. let f = uni.canIUse('getUpdateManager')
  17. if(f) {
  18. const _u = uni.getUpdateManager()
  19. _u.onCheckForUpdate(res => {
  20. console.log(res.hasUpdate)
  21. if(res.hasUpdate) {
  22. _u.onUpdateReady(() => {
  23. uni.showModal({
  24. title: '更新提示',
  25. content: '新版本已发布,请重启当前应用!',
  26. showCancel: false,
  27. success(c_res) {
  28. if(c_res.confirm) {
  29. _u.applyUpdate()
  30. }
  31. }
  32. })
  33. })
  34. }
  35. })
  36. _u.onUpdateFailed(() => {
  37. uni.showModal({
  38. title: '发现新版本',
  39. content: '请删除当前小程序,重新搜索打开'
  40. })
  41. })
  42. }
  43. },
  44. globalData: {
  45. navBarHeight: 0, // 导航栏高度
  46. menuBotton: 0, // 胶囊距底部间距(保持底部间距一致)
  47. menuRight: 0, // 胶囊距右方间距(方保持左、右间距一致)
  48. menuHeight: 0 // 胶囊高度(自定义内容可与胶囊高度保证一致)
  49. },
  50. onShow: function() {},
  51. onHide: function() {}
  52. };
  53. </script>
  54. <style lang="scss">
  55. @import 'uview-ui/index.scss';
  56. @import './static/css/icon.css';
  57. @import './static/css/editor-icon.css';
  58. page {
  59. height: 100%;
  60. min-height: 100%;
  61. background-color: #f9f9f9;
  62. .container {
  63. width: 100%;
  64. display: flex;
  65. flex-direction: column;
  66. justify-content: flex-start;
  67. }
  68. }
  69. </style>