| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 |
- import {
- ApiModel
- } from './utils/api';
- import {
- Language
- } from './utils/language';
- App({
- onLaunch(options) {
- //小程序跳转进入
- if (options.query.userMsg) {
- wx.removeStorageSync('userMsg')
- wx.removeStorageSync('auth')
- wx.removeStorageSync('userauth');
- wx.removeStorageSync('templetList');
- wx.setStorageSync('userMsg', JSON.parse(options.query.userMsg));
- wx.setStorageSync('auth', JSON.parse(options.query.auth));
- wx.setStorageSync('siteP', JSON.parse(options.query.site));
- wx.setStorageSync('templetList', JSON.parse(options.query.templetList));
- console.log("options.query.templetList", 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);
- });
- this.globalData.http.sColors = require("./utils/defaultColors")
- _Http.basic({
- "classname": "sysmanage.develop.optiontype.optiontype",
- "method": "optiontypeselect",
- "content": {
- "typename": "statuscolors"
- }
- }).then(res => {
- if (res.code != '1') return;
- res.data.forEach(v => {
- _Http.sColors[v.value] = v.remarks
- })
- });
- } else {
- this.globalData.http.sColors = require("./utils/defaultColors")
- }
- 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.socketCallback(res)
- })
- this.globalData.SocketTask.onError(function (res) {
- that.globalData.socketEstablish = false;
- })
- this.globalData.SocketTask.onClose(function (res) {
- that.globalData.socketEstablish = false;
- })
- },
- agentOrNot: (ownertable, ownerid) => getApp().globalData.http.basic({
- "id": 20230329122604,
- "content": {
- ownertable,
- ownerid
- }
- }),
- globalData: {
- http: new ApiModel(), //接口文件
- Language: new Language(), //语言包
- queryPer: require("./utils/queryPermissions"), //权限查询
- socketEstablish: false, //是否已经建立socket
- SocketTask: '', // Socket方法
- socketCallback: null, // Socket回调
- handleSelect: null, //处理选择结果 函数
- },
- })
|