import { ApiModel } from './utils/api'; 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: 'wss://meida.cnyunl.com/yos/webSocket/' + wx.getStorageSync('userMsg').token, url: 'ws://192.168.3.111:8100/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) let data = JSON.parse(res.data); if (data.message.type == 'pay') { that.globalData.http.basic({ "classname": "system.payorder.payorder", "method": "query_userauth", content: { nocache: true } }).then(res => { console.log('更新付费信息', res) wx.setStorageSync('userauth', res.data); wx.showToast({ title: '应用付费信息已更新', icon: "none" }) let page = getCurrentPages().find(v => v.__route__ == 'pages/tabbar/home/index') if (page) { page.refreshData(); } else { that.globalData.refreshData(); } }); } }) 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: item => { //验证付费凭证,通过后跳转 let userType = wx.getStorageSync('userMsg').usertype, isLeader = userType == 21; //应用是否开通,开通直接跳转 if (item.isneedpay) return wx.showModal({ title: '提示', content: `当前模块未付费,是否付费使用?`, confirmText: "前往付费", cancelText: isLeader ? "取消" : "提醒付费", complete: (res) => { if (res.confirm) { getApp().globalData.http.basic({ "classname": "system.payorder.payorder", "method": "createOrder", "content": {}, }).then(res => { console.log("新建订单", res) if (res.msg != '成功') return wx.showToast({ title: res.msg, icon: "none", mask: true }); wx.navigateTo({ url: '/pages/teams/addOrder?sys_payorderid=' + res.data.sys_payorderid }) }) } if (res.cancel) { if (!isLeader) getApp().globalData.http.basic({ "classname": "system.payorder.payorder", "method": "sendMessage", "content": { "sys_payorderid": "" } }).then(s => { wx.showToast({ title: '已发送消息到主体主账号', icon: "none" }) }) } } }) if (item.label == "营销物料") { wx.switchTab({ url: item.path }); } else { wx.navigateTo({ url: item.path }); } } }, })