App.vue 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  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. // 芳华岁悦通、芳华禧年米、茶园新区店、御君坊、享纨、良信优、健康V我、玉马路店、智慧云医长电路店 智慧云医茶花路店 青南路店的logo和名字用御君方
  8. // appId:'wx33f884436cb7e915',// 霍显同大药房
  9. // appId:'wx0e27a4bba0e27116',//翔通工具18
  10. // appId:'wxfddcaf95906254ad',//灏岚工具27
  11. // appId:'wxed673f922f042596',//慈仁康养
  12. // appId:'wxdcce87497e1cd83d',//星天合
  13. // appId:'wxcb3ccf36f28fd750',//望优洋绿工具
  14. // appId:'wx55d23ddcf396c673',//望优洋紫工具
  15. // appId:'wxcb3ccf36f28fd750',//尼古拉大药房
  16. // appId:'wx712e5be7698fd9ea',//宏盛凯大药房
  17. // appId:'wx6c9ad585eb26f767',//康宁盛
  18. // appId:'wxbf79e9c831eef54f',//塰天晟康
  19. // appId:'wx9673daca924af85d',//睦觅橙工具
  20. // appId:'wx7997305b39239f88',//琴书武橙工具
  21. // appId:'wxf1f28ff4a745045b',//铜亦橱窗
  22. // appId:'wx714e4972920746e0',//芝坑好工具
  23. // appId:'wx7aed12798c76ea25',//菜菜壳大药房
  24. // appId:'wxfe009544f436236b',//棘璟一百货
  25. // appId:'wxd277f7efe7eb58c2',//橘满枝精品荟
  26. // appId:'wxf157766142df37e4',//孙佳助手1
  27. appId:'wxb3fc72b741362758',//坤德精选a
  28. // 福袋小程序
  29. wsUrl: 'wss://websocket.cdwjyyh.com',
  30. isShowMenu: 0 // 1展示,0 关闭
  31. },
  32. onLaunch: function() {
  33. this.checkUpdate()
  34. // uni.$TUIKit = TIM.create({
  35. // SDKAppID: 1400693126
  36. // });
  37. // uni.$TUIKit.registerPlugin({
  38. // 'cos-wx-sdk': COS
  39. // });
  40. // uni.$TUIKitTIM = TIM;
  41. // uni.$TUIKitEvent = TIM.EVENT;
  42. // uni.$TUIKitVersion = TIM.VERSION;
  43. // uni.$TUIKitTypes = TIM.TYPES; // 监听系统级事件
  44. // uni.$resetLoginData = this.resetLoginData();
  45. // uni.$TUIKit.on(uni.$TUIKitEvent.SDK_READY, this.onSDKReady);
  46. // uni.$TUIKit.on(uni.$TUIKitEvent.SDK_NOT_READY, this.onSdkNotReady);
  47. // uni.$TUIKit.on(uni.$TUIKitEvent.KICKED_OUT, this.onKickedOut);
  48. // uni.$TUIKit.on(uni.$TUIKitEvent.ERROR, this.onTIMError);
  49. // uni.$TUIKit.on(uni.$TUIKitEvent.NET_STATE_CHANGE, this.onNetStateChange);
  50. // uni.$TUIKit.on(uni.$TUIKitEvent.SDK_RELOAD, this.onSDKReload);
  51. const systemInfo = uni.getSystemInfoSync();
  52. const baseFontSize = 14; // 标准字体大小(你可以自定义)
  53. const userFontSize = systemInfo.fontSizeSetting || baseFontSize;
  54. // 计算比例
  55. const scale = userFontSize / baseFontSize;
  56. // 存储到全局变量或 Vuex
  57. uni.setStorageSync('fontScale', scale);
  58. console.log('IM')
  59. },
  60. onShow: function () {
  61. console.log('App Show')
  62. uni.getSystemInfo({
  63. success: (result) => {
  64. // 获取手机系统的状态栏高度(不同手机的状态栏高度不同)
  65. // console.log('当前手机的状态栏高度',result.statusBarHeight)
  66. let statusBarHeight = result.statusBarHeight + 'px'
  67. // 获取右侧胶囊的信息 单位px
  68. //#ifndef H5 || APP-PLUS
  69. const menuButtonInfo = uni.getMenuButtonBoundingClientRect()
  70. //bottom: 胶囊底部距离屏幕顶部的距离
  71. //height: 胶囊高度
  72. //left: 胶囊左侧距离屏幕左侧的距离
  73. //right: 胶囊右侧距离屏幕左侧的距离
  74. //top: 胶囊顶部距离屏幕顶部的距离
  75. //width: 胶囊宽度
  76. // console.log(menuButtonInfo.width, menuButtonInfo.height, menuButtonInfo.top)
  77. // console.log('计算胶囊右侧距离屏幕右边距离', result.screenWidth - menuButtonInfo.right)
  78. let menuWidth = menuButtonInfo.width + 'px'
  79. let menuHeight = menuButtonInfo.height + 'px'
  80. let menuBorderRadius = menuButtonInfo.height / 2 + 'px'
  81. let menuRight = result.screenWidth - menuButtonInfo.right + 'px'
  82. let menuTop = menuButtonInfo.top + 'px'
  83. let contentTop = result.statusBarHeight + 44 + 'px'
  84. let menuInfo = {
  85. statusBarHeight: statusBarHeight,//状态栏高度----用来给自定义导航条页面的顶部导航条设计padding-top使用:目的留出系统的状态栏区域
  86. menuWidth: menuWidth,//右侧的胶囊宽度--用来给自定义导航条页面的左侧胶囊设置使用
  87. menuHeight: menuHeight,//右侧的胶囊高度--用来给自定义导航条页面的左侧胶囊设置使用
  88. menuBorderRadius: menuBorderRadius,//一半的圆角--用来给自定义导航条页面的左侧胶囊设置使用
  89. menuRight: menuRight,//右侧的胶囊距离右侧屏幕距离--用来给自定义导航条页面的左侧胶囊设置使用
  90. menuTop: menuTop,//右侧的胶囊顶部距离屏幕顶部的距离--用来给自定义导航条页面的左侧胶囊设置使用
  91. contentTop: contentTop,//内容区距离页面最上方的高度--用来给自定义导航条页面的内容区定位距离使用
  92. }
  93. uni.setStorageSync('menuInfo', menuInfo)
  94. //#endif
  95. },
  96. fail: (error) => {
  97. console.log(error)
  98. }
  99. })
  100. },
  101. onHide: function() {
  102. console.log('App Hide')
  103. },
  104. methods: {
  105. checkUpdate() {
  106. const updateManager = uni.getUpdateManager();
  107. updateManager.onCheckForUpdate(function(res) {
  108. // 请求完新版本信息的回调
  109. console.log('是否有新版本:', res.hasUpdate);
  110. });
  111. updateManager.onUpdateReady(function() {
  112. uni.showModal({
  113. title: '更新提示',
  114. content: '新版本已经准备好,是否重启小程序?',
  115. confirmText: '立即重启',
  116. confirmColor: '#2179f5',
  117. showCancel: false,
  118. success(res) {
  119. if (res.confirm) {
  120. // 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
  121. updateManager.applyUpdate();
  122. }
  123. }
  124. });
  125. });
  126. updateManager.onUpdateFailed(function() {
  127. // 新的版本下载失败
  128. uni.showModal({
  129. title: '更新提示',
  130. content: '新版本下载失败,请检查网络后重试。',
  131. showCancel: false
  132. });
  133. });
  134. },
  135. // TODO:
  136. resetLoginData() {
  137. // this.globalData.expiresIn = '';
  138. // this.globalData.sessionID = '';
  139. // this.globalData.userInfo = {
  140. // userID: '',
  141. // userSig: '',
  142. // token: '',
  143. // phone: ''
  144. // };
  145. // this.globalData.userProfile = null;
  146. // logger.log(`| app | resetLoginData | globalData: ${this.globalData}`);
  147. },
  148. onTIMError() {},
  149. onSDKReady({name}) {
  150. console.log("im注册:"+name)
  151. const isSDKReady = name === uni.$TUIKitEvent.SDK_READY ? true : false
  152. console.log("im注册:"+isSDKReady)
  153. uni.$emit('isSDKReady', {
  154. isSDKReady: true
  155. });
  156. },
  157. onNetStateChange() {},
  158. onSDKReload() {},
  159. onSdkNotReady() {},
  160. onKickedOut() {
  161. uni.showToast({
  162. title: '您被踢下线',
  163. icon: 'error'
  164. });
  165. }
  166. }
  167. }
  168. </script>
  169. <style lang="less">
  170. /*每个页面公共css */
  171. // @import 'animate.css';
  172. @import './assets/iconfont/iconfont.css';
  173. @import './assets/css/common.less';
  174. page{
  175. background-color: #f6f6f6;
  176. }
  177. ::-webkit-scrollbar{
  178. width: 0 !important;
  179. height: 0 !important;
  180. }
  181. </style>
  182. <style lang="scss">
  183. @import './assets/css/common.scss';
  184. @import './assets/css/commonTheme.css';
  185. /* 注意要写在第一行,同时给style标签加入lang="scss"属性 */
  186. @import "@/uni_modules/uview-ui/index.scss";
  187. /*每个页面公共css */
  188. /* 解决小程序和app滚动条的问题 */
  189. /* #ifdef MP-WEIXIN || APP-PLUS */
  190. ::v-deep ::-webkit-scrollbar {
  191. display: none !important;
  192. width: 0 !important;
  193. height: 0 !important;
  194. -webkit-appearance: none;
  195. background: transparent;
  196. color: transparent;
  197. }
  198. /* #endif */
  199. /* 解决H5 的问题 */
  200. /* #ifdef H5 */
  201. uni-scroll-view .uni-scroll-view::-webkit-scrollbar {
  202. /* 隐藏滚动条,但依旧具备可以滚动的功能 */
  203. display: none;
  204. width: 0 !important;
  205. height: 0 !important;
  206. -webkit-appearance: none;
  207. background: transparent;
  208. color: transparent;
  209. }
  210. /* #endif */
  211. </style>