App.vue 11 KB

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