App.vue 6.4 KB

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