App.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  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. if (this.globalData.socket != null) {
  70. this.globalData.socket.stop();
  71. }
  72. },
  73. onAppBackground() {},
  74. methods: {
  75. generateUUID() {
  76. return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
  77. const r = Math.random() * 16 | 0;
  78. const v = c === 'x' ? r : (r & 0x3 | 0x8);
  79. return v.toString(16);
  80. });
  81. },
  82. }
  83. };
  84. </script>
  85. <style lang="scss">
  86. /*每个页面公共css */
  87. @import 'colorui/main.css';
  88. @import 'colorui/icon.css';
  89. @import 'style/FontStyle.css';
  90. @import 'common/uni.css';
  91. @import "uni_modules/cl-uni/index.scss";
  92. @import "./common/common.css";
  93. /*每个页面公共css */
  94. /* 引入动画库 */
  95. @import './common/animate.css';
  96. @import "./common/iconfont-video.css";
  97. @import "./common/icon.css";
  98. @import "./common/free.css";
  99. body {
  100. -webkit-text-size-adjust: none;
  101. overscroll-behavior-y: contain;
  102. -webkit-overflow-scrolling: touch;
  103. background-color: #161616;
  104. // background: url('./http://c.yujianmate.com/images/v1/bg.png');
  105. // background-size: 750rpx 1624rpx;
  106. background-repeat: repeat-y;
  107. }
  108. /* 超出一行省略号 */
  109. .one-omit {
  110. white-space: nowrap;
  111. /*规定段落中的文本不进行换行*/
  112. overflow: hidden;
  113. /*内容会被修剪,并且其余内容是不可见的。*/
  114. text-overflow: ellipsis;
  115. /*显示省略号来代表被修剪的文本*/
  116. }
  117. .two-omit {
  118. display: -webkit-box;
  119. -webkit-line-clamp: 2;
  120. overflow: hidden;
  121. text-overflow: ellipsis;
  122. -webkit-box-orient: vertical;
  123. }
  124. img {
  125. width: 100%;
  126. }
  127. uni-modal {
  128. z-index: 998 !important;
  129. }
  130. .cu-modal {
  131. z-index: 997 !important;
  132. }
  133. </style>