App.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494
  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. wsUrl: '',
  9. // appId:'wx0d1a3dd485268521',//益寿缘
  10. appId:'wx50bcb040b4963a7e',//营口市康安健康服务(益寿缘)
  11. },
  12. onLoad: function (){
  13. },
  14. onLaunch: function() {
  15. this.checkUpdate()
  16. // 看课题目字体跟随系统变化
  17. const systemInfo = uni.getSystemInfoSync();
  18. const baseFontSize = 14; // 标准字体大小(你可以自定义)
  19. const userFontSize = systemInfo.fontSizeSetting || baseFontSize;
  20. // 计算比例
  21. const scale = userFontSize / baseFontSize;
  22. // 存储到全局变量或 Vuex
  23. uni.setStorageSync('fontScale', scale);
  24. },
  25. onShow: function () {
  26. console.log('App Show')
  27. uni.getSystemInfo({
  28. success: (result) => {
  29. // 获取手机系统的状态栏高度(不同手机的状态栏高度不同)
  30. // console.log('当前手机的状态栏高度',result.statusBarHeight)
  31. let statusBarHeight = result.statusBarHeight + 'px'
  32. // 获取右侧胶囊的信息 单位px
  33. //#ifndef H5 || APP-PLUS
  34. const menuButtonInfo = uni.getMenuButtonBoundingClientRect()
  35. //bottom: 胶囊底部距离屏幕顶部的距离
  36. //height: 胶囊高度
  37. //left: 胶囊左侧距离屏幕左侧的距离
  38. //right: 胶囊右侧距离屏幕左侧的距离
  39. //top: 胶囊顶部距离屏幕顶部的距离
  40. //width: 胶囊宽度
  41. // console.log(menuButtonInfo.width, menuButtonInfo.height, menuButtonInfo.top)
  42. // console.log('计算胶囊右侧距离屏幕右边距离', result.screenWidth - menuButtonInfo.right)
  43. let menuWidth = menuButtonInfo.width + 'px'
  44. let menuHeight = menuButtonInfo.height + 'px'
  45. let menuBorderRadius = menuButtonInfo.height / 2 + 'px'
  46. let menuRight = result.screenWidth - menuButtonInfo.right + 'px'
  47. let menuTop = menuButtonInfo.top + 'px'
  48. let contentTop = result.statusBarHeight + 44 + 'px'
  49. let menuInfo = {
  50. statusBarHeight: statusBarHeight,//状态栏高度----用来给自定义导航条页面的顶部导航条设计padding-top使用:目的留出系统的状态栏区域
  51. menuWidth: menuWidth,//右侧的胶囊宽度--用来给自定义导航条页面的左侧胶囊设置使用
  52. menuHeight: menuHeight,//右侧的胶囊高度--用来给自定义导航条页面的左侧胶囊设置使用
  53. menuBorderRadius: menuBorderRadius,//一半的圆角--用来给自定义导航条页面的左侧胶囊设置使用
  54. menuRight: menuRight,//右侧的胶囊距离右侧屏幕距离--用来给自定义导航条页面的左侧胶囊设置使用
  55. menuTop: menuTop,//右侧的胶囊顶部距离屏幕顶部的距离--用来给自定义导航条页面的左侧胶囊设置使用
  56. contentTop: contentTop,//内容区距离页面最上方的高度--用来给自定义导航条页面的内容区定位距离使用
  57. }
  58. uni.setStorageSync('menuInfo', menuInfo)
  59. //#endif
  60. },
  61. fail: (error) => {
  62. console.log(error)
  63. }
  64. })
  65. },
  66. onHide: function() {
  67. console.log('App Hide')
  68. },
  69. methods: {
  70. checkUpdate() {
  71. const updateManager = uni.getUpdateManager();
  72. updateManager.onCheckForUpdate(function(res) {
  73. // 请求完新版本信息的回调
  74. console.log('是否有新版本:', res.hasUpdate);
  75. });
  76. updateManager.onUpdateReady(function() {
  77. uni.showModal({
  78. title: '更新提示',
  79. content: '新版本已经准备好,是否重启小程序?',
  80. confirmText: '立即重启',
  81. confirmColor: '#2179f5',
  82. showCancel: false,
  83. success(res) {
  84. if (res.confirm) {
  85. // 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
  86. updateManager.applyUpdate();
  87. }
  88. }
  89. });
  90. });
  91. updateManager.onUpdateFailed(function() {
  92. // 新的版本下载失败
  93. uni.showModal({
  94. title: '更新提示',
  95. content: '新版本下载失败,请检查网络后重试。',
  96. showCancel: false
  97. });
  98. });
  99. },
  100. // TODO:
  101. resetLoginData() {
  102. // this.globalData.expiresIn = '';
  103. // this.globalData.sessionID = '';
  104. // this.globalData.userInfo = {
  105. // userID: '',
  106. // userSig: '',
  107. // token: '',
  108. // phone: ''
  109. // };
  110. // this.globalData.userProfile = null;
  111. // logger.log(`| app | resetLoginData | globalData: ${this.globalData}`);
  112. },
  113. onTIMError() {},
  114. onSDKReady({name}) {
  115. console.log("im注册:"+name)
  116. const isSDKReady = name === uni.$TUIKitEvent.SDK_READY ? true : false
  117. console.log("im注册:"+isSDKReady)
  118. uni.$emit('isSDKReady', {
  119. isSDKReady: true
  120. });
  121. },
  122. onNetStateChange() {},
  123. onSDKReload() {},
  124. onSdkNotReady() {},
  125. onKickedOut() {
  126. uni.showToast({
  127. title: '您被踢下线',
  128. icon: 'error'
  129. });
  130. }
  131. }
  132. }
  133. </script>
  134. <style lang="less">
  135. @import './assets/css/common.less';
  136. </style>
  137. <style lang="scss">
  138. /*每个页面公共css */
  139. @import "uview-ui/index.scss";
  140. @import './assets/iconfont/iconfont.css';
  141. @import '@/assets/css/common.scss';
  142. @import './assets/css/theme.scss';
  143. page{
  144. background-color: #f6f6f6;
  145. }
  146. ::-webkit-scrollbar{
  147. width: 0 !important;
  148. height: 0 !important;
  149. }
  150. view{
  151. box-sizing: border-box;
  152. }
  153. .ellipsis{
  154. overflow:hidden;
  155. text-overflow:ellipsis;
  156. display:-webkit-box;
  157. -webkit-box-orient:vertical;
  158. -webkit-line-clamp:2;
  159. }
  160. .single-line-ellipsis {
  161. width: 480rpx; /* 设置固定宽度 */
  162. white-space: nowrap; /* 文本不换行 */
  163. overflow: hidden; /* 隐藏超出部分 */
  164. text-overflow: ellipsis; /* 超出部分用省略号表示 */
  165. }
  166. .single-ellipsis {
  167. width: 260rpx; /* 设置固定宽度 */
  168. white-space: nowrap; /* 文本不换行 */
  169. overflow: hidden; /* 隐藏超出部分 */
  170. text-overflow: ellipsis; /* 超出部分用省略号表示 */
  171. }
  172. .ellipsis2{
  173. overflow:hidden;
  174. text-overflow:ellipsis;
  175. display:-webkit-box;
  176. -webkit-box-orient:vertical;
  177. -webkit-line-clamp:2;
  178. }
  179. .no-data-box{
  180. height:60%;
  181. width: 100%;
  182. display: flex;
  183. justify-content: center;
  184. align-items: center;
  185. flex-direction: column;
  186. image{
  187. width: 264upx;
  188. height: 212upx;
  189. }
  190. .empty-title{
  191. margin-top: 20rpx;
  192. font-size: 28rpx;
  193. color: gray;
  194. }
  195. }
  196. .w-calc-30 {
  197. padding: 0 30rpx;
  198. width: calc(100% - 60rpx);
  199. }
  200. .hb {
  201. height: 100%;
  202. box-sizing: border-box;
  203. }
  204. .hidden {
  205. overflow: hidden;
  206. }
  207. .base-color {
  208. color: $--base-color;
  209. }
  210. .base-color-2 {
  211. color: $--base-color2;
  212. }
  213. .base-color-3 {
  214. color: $--base-color3;
  215. }
  216. .base-color-9 {
  217. color: $--base-color-9;
  218. }
  219. .base-color-8 {
  220. color: $--base-color-f8;
  221. }
  222. .base-color-6 {
  223. color: $--base-color-6;
  224. }
  225. .base-color-gray {
  226. color: $--base-color-gray;
  227. }
  228. .base-color-red{
  229. color:#ee0a25;
  230. }
  231. .base-color-dark {
  232. color: $--base-color-dark;
  233. }
  234. .base-color-dark2 {
  235. color: $--base-color-dark2;
  236. }
  237. .base-price {
  238. color: $--base-color-price;
  239. }
  240. .base-success {
  241. color: $--base-color-success;
  242. }
  243. .base-bg {
  244. background: $--base-bg;
  245. }
  246. .base-bg-2 {
  247. background: $--base-bg2;
  248. }
  249. .base-bg-red{
  250. background: #ee0a25;
  251. }
  252. .base-bg-f{
  253. background-color:#fff;
  254. }
  255. .base-bg-f8{
  256. background-color: $--base-color-f8;
  257. }
  258. .base-bg-f5{
  259. background-color: $--base-color-f5;
  260. }
  261. .base-bg-9{
  262. background-color: $--base-color-9;
  263. }
  264. .base-bg-blue{
  265. background:$--base-bg-blue;
  266. }
  267. .base-bg-sure{
  268. background:$--base-sure-bg;
  269. }
  270. .base-bg-orange{
  271. background:$--base-bg-orange;
  272. }
  273. .base-bg-false{
  274. background:$--base-false-bg;
  275. }
  276. .bor-blue{
  277. border: 2rpx solid $--base-bor-blue;
  278. }
  279. .bor-red{
  280. border: 2rpx solid $--base-bor-red;
  281. }
  282. .colorf {
  283. color: #fff;
  284. }
  285. .bgf {
  286. background: #fff;
  287. }
  288. .fixed {
  289. position: fixed;
  290. }
  291. .absolute {
  292. position: absolute;
  293. }
  294. .relative {
  295. position: relative;
  296. }
  297. .w100 {
  298. width: 100%;
  299. }
  300. .h100 {
  301. height: 100%;
  302. }
  303. .card {
  304. background: #fff;
  305. border-radius: 15rpx;
  306. }
  307. .cover-height {
  308. height: 100%;
  309. display: flex;
  310. flex-direction: column;
  311. box-sizing: border-box;
  312. }
  313. .row {
  314. display: flex;
  315. flex-direction: row;
  316. }
  317. .column {
  318. display: flex;
  319. flex-direction: column;
  320. }
  321. .justify-start {
  322. display: flex;
  323. justify-content: flex-start;
  324. }
  325. .justify-center {
  326. display: flex;
  327. justify-content: center;
  328. }
  329. .justify-end {
  330. display: flex;
  331. justify-content: flex-end;
  332. }
  333. .justify-around {
  334. display: flex;
  335. justify-content: space-around;
  336. }
  337. .justify-evenly {
  338. display: flex;
  339. justify-content: space-evenly;
  340. }
  341. .justify-between {
  342. display: flex;
  343. justify-content: space-between;
  344. }
  345. .align-start {
  346. display: flex;
  347. align-items: flex-start;
  348. }
  349. .align-center {
  350. display: flex;
  351. align-items: center;
  352. }
  353. .align-end {
  354. display: flex;
  355. align-items: flex-end;
  356. }
  357. .center {
  358. display: flex;
  359. justify-content: center;
  360. align-items: center;
  361. }
  362. .centerV {
  363. display: flex;
  364. justify-content: center;
  365. align-items: center;
  366. flex-direction: column;
  367. }
  368. .wrap {
  369. flex-wrap: wrap;
  370. }
  371. .flex-1 {
  372. flex: 1;
  373. }
  374. .ellipsis {
  375. overflow: hidden;
  376. text-overflow: ellipsis;
  377. display: -webkit-box;
  378. -webkit-box-orient: vertical;
  379. box-sizing: border-box;
  380. width: 100%;
  381. -webkit-line-clamp: 1;
  382. }
  383. .lines-2 {
  384. -webkit-line-clamp: 2 !important;
  385. }
  386. .lines-3 {
  387. -webkit-line-clamp: 3 !important;
  388. }
  389. .bold {
  390. font-weight: bold;
  391. }
  392. .line-through {
  393. text-decoration: line-through;
  394. }
  395. .nowrap {
  396. white-space: nowrap;
  397. }
  398. .scrollx {
  399. overflow-x: scroll;
  400. }
  401. .scrolly {
  402. overflow-y: scroll;
  403. }
  404. .cvauto {
  405. content-visibility: auto;
  406. }
  407. </style>
  408. <style>
  409. /*每个页面公共css */
  410. /* 解决小程序和app滚动条的问题 */
  411. /* #ifdef MP-WEIXIN || APP-PLUS */
  412. :deep(::-webkit-scrollbar ){
  413. display: none !important;
  414. width: 0 !important;
  415. height: 0 !important;
  416. -webkit-appearance: none;
  417. background: transparent;
  418. color: transparent;
  419. }
  420. /* #endif */
  421. /* 解决H5 的问题 */
  422. /* #ifdef H5 */
  423. uni-scroll-view .uni-scroll-view::-webkit-scrollbar {
  424. /* 隐藏滚动条,但依旧具备可以滚动的功能 */
  425. display: none;
  426. width: 0 !important;
  427. height: 0 !important;
  428. -webkit-appearance: none;
  429. background: transparent;
  430. color: transparent;
  431. }
  432. /* #endif */
  433. </style>