App.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  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. appId: 'wx503cf8ab31f83dd4'
  9. },
  10. onLaunch: function(options) {
  11. console.log("onLaunch在这里", options)
  12. this.checkUpdate()
  13. if (options.query.companyId) {
  14. uni.setStorageSync('share', options.query)
  15. }
  16. if (options.query.scene) {
  17. uni.setStorageSync('scene', options.query.scene)
  18. }
  19. // uni.$TUIKit = TIM.create({
  20. // SDKAppID: 1400693126
  21. // });
  22. // uni.$TUIKit.registerPlugin({
  23. // 'cos-wx-sdk': COS
  24. // });
  25. // uni.$TUIKitTIM = TIM;
  26. // uni.$TUIKitEvent = TIM.EVENT;
  27. // uni.$TUIKitVersion = TIM.VERSION;
  28. // uni.$TUIKitTypes = TIM.TYPES; // 监听系统级事件
  29. // uni.$resetLoginData = this.resetLoginData();
  30. // uni.$TUIKit.on(uni.$TUIKitEvent.SDK_READY, this.onSDKReady);
  31. // uni.$TUIKit.on(uni.$TUIKitEvent.SDK_NOT_READY, this.onSdkNotReady);
  32. // uni.$TUIKit.on(uni.$TUIKitEvent.KICKED_OUT, this.onKickedOut);
  33. // uni.$TUIKit.on(uni.$TUIKitEvent.ERROR, this.onTIMError);
  34. // uni.$TUIKit.on(uni.$TUIKitEvent.NET_STATE_CHANGE, this.onNetStateChange);
  35. // uni.$TUIKit.on(uni.$TUIKitEvent.SDK_RELOAD, this.onSDKReload);
  36. console.log('IM')
  37. },
  38. onShow: function() {
  39. console.log('App Show')
  40. uni.getSystemInfo({
  41. success: (result) => {
  42. // 获取手机系统的状态栏高度(不同手机的状态栏高度不同)
  43. // console.log('当前手机的状态栏高度',result.statusBarHeight)
  44. let statusBarHeight = result.statusBarHeight + 'px'
  45. // 获取右侧胶囊的信息 单位px
  46. //#ifndef H5 || APP-PLUS
  47. const menuButtonInfo = uni.getMenuButtonBoundingClientRect()
  48. //bottom: 胶囊底部距离屏幕顶部的距离
  49. //height: 胶囊高度
  50. //left: 胶囊左侧距离屏幕左侧的距离
  51. //right: 胶囊右侧距离屏幕左侧的距离
  52. //top: 胶囊顶部距离屏幕顶部的距离
  53. //width: 胶囊宽度
  54. // console.log(menuButtonInfo.width, menuButtonInfo.height, menuButtonInfo.top)
  55. // console.log('计算胶囊右侧距离屏幕右边距离', result.screenWidth - menuButtonInfo.right)
  56. let menuWidth = menuButtonInfo.width + 'px'
  57. let menuHeight = menuButtonInfo.height + 'px'
  58. let menuBorderRadius = menuButtonInfo.height / 2 + 'px'
  59. let menuRight = result.screenWidth - menuButtonInfo.right + 'px'
  60. let menuTop = menuButtonInfo.top + 'px'
  61. let contentTop = result.statusBarHeight + 44 + 'px'
  62. let menuInfo = {
  63. statusBarHeight: statusBarHeight, //状态栏高度----用来给自定义导航条页面的顶部导航条设计padding-top使用:目的留出系统的状态栏区域
  64. menuWidth: menuWidth, //右侧的胶囊宽度--用来给自定义导航条页面的左侧胶囊设置使用
  65. menuHeight: menuHeight, //右侧的胶囊高度--用来给自定义导航条页面的左侧胶囊设置使用
  66. menuBorderRadius: menuBorderRadius, //一半的圆角--用来给自定义导航条页面的左侧胶囊设置使用
  67. menuRight: menuRight, //右侧的胶囊距离右侧屏幕距离--用来给自定义导航条页面的左侧胶囊设置使用
  68. menuTop: menuTop, //右侧的胶囊顶部距离屏幕顶部的距离--用来给自定义导航条页面的左侧胶囊设置使用
  69. contentTop: contentTop, //内容区距离页面最上方的高度--用来给自定义导航条页面的内容区定位距离使用
  70. }
  71. uni.setStorageSync('menuInfo', menuInfo)
  72. //#endif
  73. },
  74. fail: (error) => {
  75. console.log(error)
  76. }
  77. })
  78. },
  79. onHide: function() {
  80. console.log('App Hide')
  81. },
  82. methods: {
  83. // TODO:
  84. resetLoginData() {
  85. // this.globalData.expiresIn = '';
  86. // this.globalData.sessionID = '';
  87. // this.globalData.userInfo = {
  88. // userID: '',
  89. // userSig: '',
  90. // token: '',
  91. // phone: ''
  92. // };
  93. // this.globalData.userProfile = null;
  94. // logger.log(`| app | resetLoginData | globalData: ${this.globalData}`);
  95. },
  96. onTIMError() {},
  97. onSDKReady({
  98. name
  99. }) {
  100. console.log("im注册:" + name)
  101. const isSDKReady = name === uni.$TUIKitEvent.SDK_READY ? true : false
  102. console.log("im注册:" + isSDKReady)
  103. uni.$emit('isSDKReady', {
  104. isSDKReady: true
  105. });
  106. },
  107. onNetStateChange() {},
  108. onSDKReload() {},
  109. onSdkNotReady() {},
  110. onKickedOut() {
  111. uni.showToast({
  112. title: '您被踢下线',
  113. icon: 'error'
  114. });
  115. },
  116. checkUpdate() {
  117. const updateManager = uni.getUpdateManager();
  118. updateManager.onCheckForUpdate(function(res) {
  119. // 请求完新版本信息的回调
  120. console.log('是否有新版本:', res.hasUpdate);
  121. });
  122. updateManager.onUpdateReady(function() {
  123. uni.showModal({
  124. title: '更新提示',
  125. content: '新版本已经准备好,是否重启小程序?',
  126. confirmText: '立即重启',
  127. confirmColor: '#2179f5',
  128. showCancel: false,
  129. success(res) {
  130. if (res.confirm) {
  131. // 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
  132. updateManager.applyUpdate();
  133. }
  134. }
  135. });
  136. });
  137. updateManager.onUpdateFailed(function() {
  138. // 新的版本下载失败
  139. uni.showModal({
  140. title: '更新提示',
  141. content: '新版本下载失败,请检查网络后重试。',
  142. showCancel: false
  143. });
  144. });
  145. },
  146. }
  147. }
  148. </script>
  149. <style lang="scss">
  150. /* 注意要写在第一行,同时给style标签加入lang="scss"属性 */
  151. @import "@/uni_modules/uview-ui/index.scss";
  152. @import '@/assets/css/commonTheme.css';
  153. @import '@/assets/css/common.scss';
  154. </style>
  155. <style lang="less">
  156. /*每个页面公共css */
  157. // @import 'animate.css';
  158. @import './assets/iconfont/iconfont.css';
  159. @import './assets/css/common.less';
  160. page {
  161. background-color: #f6f6f6;
  162. }
  163. ::-webkit-scrollbar {
  164. width: 0 !important;
  165. height: 0 !important;
  166. }
  167. </style>
  168. <style>
  169. /*每个页面公共css */
  170. /* 解决小程序和app滚动条的问题 */
  171. /* #ifdef MP-WEIXIN || APP-PLUS */
  172. ::v-deep ::-webkit-scrollbar {
  173. display: none !important;
  174. width: 0 !important;
  175. height: 0 !important;
  176. -webkit-appearance: none;
  177. background: transparent;
  178. color: transparent;
  179. }
  180. /* #endif */
  181. /* 解决H5 的问题 */
  182. /* #ifdef H5 */
  183. uni-scroll-view .uni-scroll-view::-webkit-scrollbar {
  184. /* 隐藏滚动条,但依旧具备可以滚动的功能 */
  185. display: none;
  186. width: 0 !important;
  187. height: 0 !important;
  188. -webkit-appearance: none;
  189. background: transparent;
  190. color: transparent;
  191. }
  192. /* #endif */
  193. </style>