App.vue 9.0 KB

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