App.vue 9.7 KB

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