App.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. <script>
  2. import wsRequest from './common/websocketUtil.js'
  3. export default {
  4. globalData: {
  5. postHeader: null,
  6. headerSign: '',
  7. uuid: '',
  8. skey: '',
  9. isLogin: 0,
  10. socket: null,
  11. postHeader: null,
  12. systemInfo: null
  13. },
  14. beforeDestroy() {},
  15. onLaunch: function(options) {
  16. let deviceId = "";
  17. let systemInfo = uni.getSystemInfoSync();
  18. deviceId = systemInfo.deviceId;
  19. if (deviceId == undefined || deviceId == "") {
  20. deviceId = uni.getDeviceInfo().deviceId;
  21. }
  22. if (deviceId == undefined || deviceId == "") {
  23. //随机取一个
  24. let uuid2 = uni.getStorageSync("app_uuid");
  25. if (uuid2 != null && uuid2 != "" && uuid2 != undefined) {
  26. deviceId = uuid2;
  27. } else {
  28. deviceId = this.generateUUID();
  29. uni.setStorageSync("app_uuid", deviceId);
  30. }
  31. console.log(deviceId);
  32. }
  33. this.globalData.uuid = deviceId;
  34. let skey = uni.getStorageSync("wapptoken");
  35. if (skey != null && skey != "" && skey != undefined) {
  36. this.globalData.skey = skey;
  37. }
  38. if (this.globalData.headerSign == "") {
  39. let headerSignKKK = uni.getStorageSync("headerSign");
  40. if (headerSignKKK != null && headerSignKKK != "" && headerSignKKK != undefined) {
  41. this.globalData.headerSign = headerSignKKK;
  42. }
  43. }
  44. if (this.globalData.socket == null) {
  45. //{"seq":"1565336219141-266129","cmd":"login","data":{"userId":"马远","appId":101}}
  46. this.globalData.socket = new wsRequest(
  47. `wss://e.yujianmate.com/Gapi2/ws`,
  48. this.globalData.uuid
  49. );
  50. }
  51. uni.getPushClientId({
  52. success: (res) => {
  53. console.log(res.cid);
  54. // this.push_token = res.cid;
  55. },
  56. fail(err) {
  57. console.log(err)
  58. }
  59. })
  60. },
  61. onShow: function(options) {
  62. console.log('App Show');
  63. // setTimeout(()=>{
  64. // uni.hideTabBar()
  65. // },100)
  66. },
  67. onHide: function() {
  68. console.log('App Hide');
  69. },
  70. onAppBackground() {},
  71. methods: {
  72. generateUUID() {
  73. return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
  74. const r = Math.random() * 16 | 0;
  75. const v = c === 'x' ? r : (r & 0x3 | 0x8);
  76. return v.toString(16);
  77. });
  78. },
  79. }
  80. };
  81. </script>
  82. <style lang="scss">
  83. /*每个页面公共css */
  84. @import 'colorui/main.css';
  85. @import 'colorui/icon.css';
  86. @import 'style/FontStyle.css';
  87. @import 'common/uni.css';
  88. @import "uni_modules/cl-uni/index.scss";
  89. @import "./common/common.css";
  90. /*每个页面公共css */
  91. /* 引入动画库 */
  92. @import './common/animate.css';
  93. @import "./common/iconfont-video.css";
  94. @import "./common/icon.css";
  95. @import "./common/free.css";
  96. body {
  97. -webkit-text-size-adjust: none;
  98. overscroll-behavior-y: contain;
  99. -webkit-overflow-scrolling: touch;
  100. background-color: #161616;
  101. // background: url('./http://c.yujianmate.com/images/v1/bg.png');
  102. // background-size: 750rpx 1624rpx;
  103. background-repeat: repeat-y;
  104. }
  105. /* 超出一行省略号 */
  106. .one-omit {
  107. white-space: nowrap;
  108. /*规定段落中的文本不进行换行*/
  109. overflow: hidden;
  110. /*内容会被修剪,并且其余内容是不可见的。*/
  111. text-overflow: ellipsis;
  112. /*显示省略号来代表被修剪的文本*/
  113. }
  114. .two-omit {
  115. display: -webkit-box;
  116. -webkit-line-clamp: 2;
  117. overflow: hidden;
  118. text-overflow: ellipsis;
  119. -webkit-box-orient: vertical;
  120. }
  121. img {
  122. width: 100%;
  123. }
  124. uni-modal {
  125. z-index: 998 !important;
  126. }
  127. .cu-modal {
  128. z-index: 997 !important;
  129. }
  130. </style>