App.vue 11 KB

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