App.vue 3.5 KB

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