App.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. <script>
  2. import Vue from 'vue'
  3. // import TIM from 'tim-wx-sdk';
  4. // import COS from 'cos-wx-sdk-v5';
  5. export default {
  6. onError(err) {
  7. console.error('全局错误捕获:', err);
  8. },
  9. onLaunch: function() {
  10. uni.hideTabBar({ animation: true })
  11. // uni.$TUIKit = TIM.create({
  12. // SDKAppID: 1400693126
  13. // });
  14. // uni.$TUIKit.registerPlugin({
  15. // 'cos-wx-sdk': COS
  16. // });
  17. // uni.$TUIKitTIM = TIM;
  18. // uni.$TUIKitEvent = TIM.EVENT;
  19. // uni.$TUIKitVersion = TIM.VERSION;
  20. // uni.$TUIKitTypes = TIM.TYPES; // 监听系统级事件
  21. // uni.$resetLoginData = this.resetLoginData();
  22. // uni.$TUIKit.on(uni.$TUIKitEvent.SDK_READY, this.onSDKReady);
  23. // uni.$TUIKit.on(uni.$TUIKitEvent.SDK_NOT_READY, this.onSdkNotReady);
  24. // uni.$TUIKit.on(uni.$TUIKitEvent.KICKED_OUT, this.onKickedOut);
  25. // uni.$TUIKit.on(uni.$TUIKitEvent.ERROR, this.onTIMError);
  26. // uni.$TUIKit.on(uni.$TUIKitEvent.NET_STATE_CHANGE, this.onNetStateChange);
  27. // uni.$TUIKit.on(uni.$TUIKitEvent.SDK_RELOAD, this.onSDKReload);
  28. // console.log('IM')
  29. },
  30. onShow: function () {
  31. console.log('App Show')
  32. uni.getSystemInfo({
  33. success: (result) => {
  34. // 获取手机系统的状态栏高度(不同手机的状态栏高度不同)
  35. // console.log('当前手机的状态栏高度',result.statusBarHeight)
  36. let statusBarHeight = result.statusBarHeight + 'px'
  37. // 获取右侧胶囊的信息 单位px
  38. //#ifndef H5 || APP-PLUS
  39. const menuButtonInfo = uni.getMenuButtonBoundingClientRect()
  40. //bottom: 胶囊底部距离屏幕顶部的距离
  41. //height: 胶囊高度
  42. //left: 胶囊左侧距离屏幕左侧的距离
  43. //right: 胶囊右侧距离屏幕左侧的距离
  44. //top: 胶囊顶部距离屏幕顶部的距离
  45. //width: 胶囊宽度
  46. // console.log(menuButtonInfo.width, menuButtonInfo.height, menuButtonInfo.top)
  47. // console.log('计算胶囊右侧距离屏幕右边距离', result.screenWidth - menuButtonInfo.right)
  48. let menuWidth = menuButtonInfo.width + 'px'
  49. let menuHeight = menuButtonInfo.height + 'px'
  50. let menuBorderRadius = menuButtonInfo.height / 2 + 'px'
  51. let menuRight = result.screenWidth - menuButtonInfo.right + 'px'
  52. let menuTop = menuButtonInfo.top + 'px'
  53. let contentTop = result.statusBarHeight + 44 + 'px'
  54. let menuInfo = {
  55. statusBarHeight: statusBarHeight,//状态栏高度----用来给自定义导航条页面的顶部导航条设计padding-top使用:目的留出系统的状态栏区域
  56. menuWidth: menuWidth,//右侧的胶囊宽度--用来给自定义导航条页面的左侧胶囊设置使用
  57. menuHeight: menuHeight,//右侧的胶囊高度--用来给自定义导航条页面的左侧胶囊设置使用
  58. menuBorderRadius: menuBorderRadius,//一半的圆角--用来给自定义导航条页面的左侧胶囊设置使用
  59. menuRight: menuRight,//右侧的胶囊距离右侧屏幕距离--用来给自定义导航条页面的左侧胶囊设置使用
  60. menuTop: menuTop,//右侧的胶囊顶部距离屏幕顶部的距离--用来给自定义导航条页面的左侧胶囊设置使用
  61. contentTop: contentTop,//内容区距离页面最上方的高度--用来给自定义导航条页面的内容区定位距离使用
  62. }
  63. uni.setStorageSync('menuInfo', menuInfo)
  64. //#endif
  65. },
  66. fail: (error) => {
  67. console.log(error)
  68. }
  69. })
  70. },
  71. onHide: function() {
  72. console.log('App Hide')
  73. },
  74. methods: {
  75. // TODO:
  76. resetLoginData() {
  77. // this.globalData.expiresIn = '';
  78. // this.globalData.sessionID = '';
  79. // this.globalData.userInfo = {
  80. // userID: '',
  81. // userSig: '',
  82. // token: '',
  83. // phone: ''
  84. // };
  85. // this.globalData.userProfile = null;
  86. // logger.log(`| app | resetLoginData | globalData: ${this.globalData}`);
  87. },
  88. onTIMError() {},
  89. onSDKReady({name}) {
  90. console.log("im注册:"+name)
  91. const isSDKReady = name === uni.$TUIKitEvent.SDK_READY ? true : false
  92. console.log("im注册:"+isSDKReady)
  93. uni.$emit('isSDKReady', {
  94. isSDKReady: true
  95. });
  96. },
  97. onNetStateChange() {},
  98. onSDKReload() {},
  99. onSdkNotReady() {},
  100. onKickedOut() {
  101. uni.showToast({
  102. title: '您被踢下线',
  103. icon: 'error'
  104. });
  105. }
  106. }
  107. }
  108. </script>
  109. <style lang="scss">
  110. /*每个页面公共css */
  111. // @import 'animate.css';
  112. @import "uview-ui/index.scss";
  113. @import './assets/iconfont/iconfont.css';
  114. // @import './assets/css/common.less';
  115. page{
  116. background-color: #f6f6f6;
  117. }
  118. ::-webkit-scrollbar{
  119. width: 0 !important;
  120. height: 0 !important;
  121. }
  122. </style>
  123. <style lang="less">
  124. @import './assets/css/common.less';
  125. /*引入全局补充样式*/
  126. @import './assets/css/czy/es.1.base.css';
  127. @import './assets/css/czy/es.2.color.css';
  128. @import './assets/css/czy/es.3.icon.css';
  129. @import './assets/css/czy/es.4.view.css';
  130. </style>
  131. <style>
  132. /*每个页面公共css */
  133. /* 解决小程序和app滚动条的问题 */
  134. /* #ifdef MP-WEIXIN || APP-PLUS */
  135. /deep/ ::-webkit-scrollbar {
  136. display: none !important;
  137. width: 0 !important;
  138. height: 0 !important;
  139. -webkit-appearance: none;
  140. background: transparent;
  141. color: transparent;
  142. }
  143. /* #endif */
  144. /* 解决H5 的问题 */
  145. /* #ifdef H5 */
  146. uni-scroll-view .uni-scroll-view::-webkit-scrollbar {
  147. /* 隐藏滚动条,但依旧具备可以滚动的功能 */
  148. display: none;
  149. width: 0 !important;
  150. height: 0 !important;
  151. -webkit-appearance: none;
  152. background: transparent;
  153. color: transparent;
  154. }
  155. /* #endif */
  156. </style>