App.vue 5.4 KB

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