App.vue 11 KB

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