import { ApiModel } from './utils/Api'; import { Language } from './utils/language'; App({ onLaunch(options) { console.log("options.query", options.query) //小程序跳转进入 if (options.query.userMsg) { let userMsg = JSON.parse(options.query.userMsg) wx.removeStorageSync('userMsg'); wx.setStorageSync('userMsg', userMsg); console.log("userMsg", wx.getStorageSync('userMsg')) wx.removeStorageSync('auth'); wx.removeStorageSync('userauth'); wx.setStorageSync('auth', JSON.parse(options.query.auth)); wx.removeStorageSync('userrole'); wx.removeStorageSync('templetList'); wx.removeStorageSync('siteP'); wx.setStorageSync('userrole', userMsg.usertype == 1 ? '业务员' : '经销商'); wx.setStorageSync('siteP', JSON.parse(options.query.site)); wx.setStorageSync('templetList', JSON.parse(options.query.templetList)); wx.removeStorageSync('languagecode'); wx.setStorageSync('languagecode', options.query.languagecode); //获取用户权限 this.globalData.http.basic({ "classname": "sysmanage.develop.userauth.userauth", "method": "query_userauth", content: { nocache: true } }).then(res => { console.log("跳转进入查询权限", res) if (res.code != '1') return wx.showToast({ title: '权限查询失败,请稍后再试', icon: "none" }) wx.setStorageSync('userauth', res.data); }); _Http.basic({ "classname": "sysmanage.develop.optiontype.optiontype", "method": "optiontypeselect", "content": { "typename": "statuscolors" } }).then(res => { if (res.code != '1') return; res.data.forEach(v => { this.globalData.sColors[v.value] = v.remarks }) }); } if (!wx.getStorageSync('languagecode')) wx.setStorageSync('languagecode', 'ZH'); this.globalData.Language.getLanguages(wx.getStorageSync('languagecode')); }, 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) }) this.globalData.SocketTask.onError(function (res) { that.globalData.socketEstablish = false; }) this.globalData.SocketTask.onClose(function (res) { that.globalData.socketEstablish = false; }) }, globalData: { sColors: { "ACTIVE": "#67C23A", "上架": "#67C23A", "下架": "#F56C6C", "交期待确认": "#F56C6C", "交期确认": "#3874f6", "代开始": "#3874f6", "借出": "#e6a23c", "停用": "#999999", "关闭": "#999999", "历史售后": "#999999", "发布": "#67C23A", "发放": "#67C23A", "合作中": "#67C23A", "否": "#999999", "启用": "#67C23A", "售中": "#e6a23c", "售出": "#67C23A", "售前": "#3874f6", "售后": "#67C23A", "在库": "#3874f6", "在职": "#67C23A", "复核": "#F56C6C", "多次成交": "#67C23A", "审核": "#e6a23c", "已下达": "#67C23A", "已使用": "#67C23A", "已入账(人工)": "#3874f6", "已入账(系统)": "#67C23A", "已入账(非贷款)": "#e6a23c", "已入账(人工)": "#3874f6", "已入账(系统)": "#67C23A", "已入账(非贷款)": "#e6a23c", "已分配": "#333333", "已备货": "#3874f6", "已失败": "#F56C6C", "已完成": "#e6a23c", "已审核": "#67C23A", "已开票": "#67C23A", "已成交": "#67C23A", "已截止": "#999999", "已截至": "#999999", "已报备": "#67C23A", "已提交": "#67C23A", "已无效": "#999999", "已核销": "#67C23A", "已确认(非货款)": "#e6a23c", "已终止": "#999999", "已结案": "#999999", "已读": "#999999", "已转化": "#e6a23c", "已过期": "#999999", "开启": "#67C23A", "待分配": "#3874f6", "待处理": "#F56C6C", "待审核": "#3874f6", "待执行": "#3874f6", "待指派": "#3874f6", "待接单": "#999999", "待评审": "#3874f6", "待跟进": "#3874f6", "意向": "#3874f6", "报备中": "#e6a23c", "报废": "#999999", "提交": "#67C23A", "收货": "#67C23A", "新建": "#3874f6", "无需评审": "#67C23A", "是": "#F56C6C", "暂停": "#F56C6C", "暂缓": "#e6a23c", "未使用": "#999999", "未入账": "#F56C6C", "未备货": "#F56C6C", "未开票": "#F56C6C", "未成交": "#3874f6", "未报备": "#3874f6", "未核销": "#F56C6C", "正式": "#67C23A", "潜在": "#3874f6", "禁用": "#999999", "离职": "#999999", "结束": "#999999", "置顶": "#F56C6C", "评审中": "#e6a23c", "评审拒绝": "#F56C6C", "评审通过-已有成品": "rgba(103,194,58,0.5)", "评审通过-暂无成品": "#67C23A", "跟进中": "#67C23A", "进行中": "#67C23A", "部分备货": "#67C23A", "部分开票": "#e6a23c", "部分核销": "#e6a23c", "预提交": "#e6a23c" }, http: new ApiModel, //挂载接口文件 Language: new Language(), //语言包 queryPer: require("./utils/queryPermissions"), //权限查询 handleSelect: null, //处理选择结果 函数 socketEstablish: false, //是否已经建立socket SocketTask: '', // Socket方法 socketCallback: null, // Socket回调 } })