App.vue 10 KB

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