1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- import {
- ApiModel
- } from './utils/api';
- import {
- evidence,
- update
- } from './utils/pay';
- App({
- onLaunch() {
- //自动登录
- if (wx.getStorageSync('userMsg').token && ![1007, 1008, 1155].includes(wx.getLaunchOptionsSync().scene)) this.globalData.http.basic({
- "classname": "webmanage.site.site",
- "method": "querySite_Parameter",
- "content": {}
- }).then(res => {
- console.log("验证登录", res)
- if (res.msg == '成功') {
- const loginMsg = require("./pages/login/modules/login");
- loginMsg.query_userauth();
- }
- })
- },
- initSocket() {
- let that = this;
- this.globalData.SocketTask = wx.connectSocket({
- url: (this.globalData.http.baseUrl + '/yos/webSocket/').replace("https", "wss").replace("http", "ws") + 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)
- let data = JSON.parse(res.data);
- if (data.message.type == 'pay') update();
- })
- 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"), //权限查询
- socketEstablish: false, //是否已经建立socket
- SocketTask: '', // Socket方法
- socket: { // Socket回调
- that: null, //保存this
- callback: function () {}
- },
- refreshData: null, //保存首页更新应用信息函数
- evidence
- },
- })
|