App.vue 11 KB

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