123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145 |
- <script>
- import wsRequest from './common/websocketUtil.js'
- export default {
- globalData: {
- postHeader: null,
- headerSign: '',
- uuid: '',
- skey: '',
- isLogin: 0,
- socket: null,
- postHeader: null,
- systemInfo: null
- },
- beforeDestroy() {},
- onLaunch: function(options) {
- let deviceId = "";
- let systemInfo = uni.getSystemInfoSync();
- deviceId = systemInfo.deviceId;
- if (deviceId == undefined || deviceId == "") {
- deviceId = uni.getDeviceInfo().deviceId;
- }
- if (deviceId == undefined || deviceId == "") {
- //随机取一个
- let uuid2 = uni.getStorageSync("app_uuid");
- if (uuid2 != null && uuid2 != "" && uuid2 != undefined) {
- deviceId = uuid2;
- } else {
- deviceId = this.generateUUID();
- uni.setStorageSync("app_uuid", deviceId);
- }
- console.log(deviceId);
- }
- this.globalData.uuid = deviceId;
- let skey = uni.getStorageSync("wapptoken");
- if (skey != null && skey != "" && skey != undefined) {
- this.globalData.skey = skey;
- }
- if (this.globalData.headerSign == "") {
- let headerSignKKK = uni.getStorageSync("headerSign");
- if (headerSignKKK != null && headerSignKKK != "" && headerSignKKK != undefined) {
- this.globalData.headerSign = headerSignKKK;
- }
- }
- if (this.globalData.socket == null) {
- //{"seq":"1565336219141-266129","cmd":"login","data":{"userId":"马远","appId":101}}
- this.globalData.socket = new wsRequest(
- `wss://e.yujianmate.com/Gapi2/ws`,
- this.globalData.uuid
- );
- }
- uni.getPushClientId({
- success: (res) => {
- console.log(res.cid);
- // this.push_token = res.cid;
- },
- fail(err) {
- console.log(err)
- }
- })
- },
- onShow: function(options) {
- console.log('App Show');
- // setTimeout(()=>{
- // uni.hideTabBar()
- // },100)
- },
- onHide: function() {
- console.log('App Hide');
- if (this.globalData.socket != null) {
- this.globalData.socket.stop();
- }
- },
- onAppBackground() {},
- methods: {
- generateUUID() {
- return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
- const r = Math.random() * 16 | 0;
- const v = c === 'x' ? r : (r & 0x3 | 0x8);
- return v.toString(16);
- });
- },
- }
- };
- </script>
- <style lang="scss">
- /*每个页面公共css */
- @import 'colorui/main.css';
- @import 'colorui/icon.css';
- @import 'style/FontStyle.css';
- @import 'common/uni.css';
- @import "uni_modules/cl-uni/index.scss";
- @import "./common/common.css";
- /*每个页面公共css */
- /* 引入动画库 */
- @import './common/animate.css';
- @import "./common/iconfont-video.css";
- @import "./common/icon.css";
- @import "./common/free.css";
- body {
- -webkit-text-size-adjust: none;
- overscroll-behavior-y: contain;
- -webkit-overflow-scrolling: touch;
- background-color: #161616;
- // background: url('./http://c.yujianmate.com/images/v1/bg.png');
- // background-size: 750rpx 1624rpx;
- background-repeat: repeat-y;
- }
- /* 超出一行省略号 */
- .one-omit {
- white-space: nowrap;
- /*规定段落中的文本不进行换行*/
- overflow: hidden;
- /*内容会被修剪,并且其余内容是不可见的。*/
- text-overflow: ellipsis;
- /*显示省略号来代表被修剪的文本*/
- }
- .two-omit {
- display: -webkit-box;
- -webkit-line-clamp: 2;
- overflow: hidden;
- text-overflow: ellipsis;
- -webkit-box-orient: vertical;
- }
- img {
- width: 100%;
- }
- uni-modal {
- z-index: 998 !important;
- }
- .cu-modal {
- z-index: 997 !important;
- }
- </style>
|