App.vue 5.1 KB

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