App.vue 10 KB

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