12345678910111213141516171819202122232425262728293031323334353637383940 |
- import {
- ApiModel
- } from './utils/Api';
- App({
- onLaunch() {},
- initSocket() {
- let that = this;
- this.globalData.SocketTask = wx.connectSocket({
- url: 'wss://meida.cnyunl.com/yos/webSocket/' + wx.getStorageSync('userMsg').token,
- complete: (res) => {
- console.log(res)
- }
- })
- this.globalData.SocketTask.onOpen(function (res) {
- that.globalData.socketEstablish = true;
- })
- this.globalData.SocketTask.onMessage(function (res) {
- that.globalData.socket.callback(res)
- })
- this.globalData.SocketTask.onError(function (res) {
- that.globalData.socketEstablish = false;
- })
- this.globalData.SocketTask.onClose(function (res) {
- that.globalData.socketEstablish = false;
- })
- },
- globalData: {
- http: new ApiModel(),
- queryPer: require("./utils/queryPermissions"),
- handleSelect: null,
- savePage: null,
- socketEstablish: false,
- SocketTask: '',
- socket: {
- that: null,
- callback: function () {}
- },
- }
- })
|