App.vue 5.3 KB

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