app.js 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. import {
  2. ApiModel
  3. } from './utils/api';
  4. import {
  5. Language
  6. } from './utils/language';
  7. App({
  8. onLaunch(options) {
  9. //小程序跳转进入
  10. if (options.query.userMsg) {
  11. wx.removeStorageSync('userMsg')
  12. wx.removeStorageSync('auth')
  13. wx.removeStorageSync('userauth');
  14. wx.removeStorageSync('templetList');
  15. wx.setStorageSync('userMsg', JSON.parse(options.query.userMsg));
  16. wx.setStorageSync('auth', JSON.parse(options.query.auth));
  17. wx.setStorageSync('siteP', JSON.parse(options.query.site));
  18. wx.setStorageSync('templetList', JSON.parse(options.query.templetList));
  19. console.log("options.query.templetList", options.query.templetList)
  20. wx.removeStorageSync('languagecode');
  21. wx.setStorageSync('languagecode', options.query.languagecode);
  22. //获取用户权限
  23. this.globalData.http.basic({
  24. "classname": "sysmanage.develop.userauth.userauth",
  25. "method": "query_userauth",
  26. content: {
  27. nocache: true
  28. }
  29. }).then(res => {
  30. console.log("跳转进入查询权限", res)
  31. if (res.code != '1') return wx.showToast({
  32. title: '权限查询失败,请稍后再试',
  33. icon: "none"
  34. })
  35. wx.setStorageSync('userauth', res.data);
  36. });
  37. this.globalData.http.sColors = require("./utils/defaultColors")
  38. _Http.basic({
  39. "classname": "sysmanage.develop.optiontype.optiontype",
  40. "method": "optiontypeselect",
  41. "content": {
  42. "typename": "statuscolors"
  43. }
  44. }).then(res => {
  45. if (res.code != '1') return;
  46. res.data.forEach(v => {
  47. _Http.sColors[v.value] = v.remarks
  48. })
  49. });
  50. } else {
  51. this.globalData.http.sColors = require("./utils/defaultColors")
  52. }
  53. if (!wx.getStorageSync('languagecode')) wx.setStorageSync('languagecode', 'ZH');
  54. this.globalData.Language.getLanguages(wx.getStorageSync('languagecode'));
  55. },
  56. initSocket() {
  57. let that = this;
  58. this.globalData.SocketTask = wx.connectSocket({
  59. url: (this.globalData.http.baseUrl + '/yos/webSocket/').replace("https", "wss").replace("http", "ws") + wx.getStorageSync('userMsg').token,
  60. complete: (res) => {
  61. console.log(res)
  62. }
  63. })
  64. this.globalData.SocketTask.onOpen(function (res) {
  65. that.globalData.socketEstablish = true;
  66. })
  67. this.globalData.SocketTask.onMessage(function (res) {
  68. that.globalData.socketCallback(res)
  69. })
  70. this.globalData.SocketTask.onError(function (res) {
  71. that.globalData.socketEstablish = false;
  72. })
  73. this.globalData.SocketTask.onClose(function (res) {
  74. that.globalData.socketEstablish = false;
  75. })
  76. },
  77. agentOrNot: (ownertable, ownerid) => getApp().globalData.http.basic({
  78. "id": 20230329122604,
  79. "content": {
  80. ownertable,
  81. ownerid
  82. }
  83. }),
  84. globalData: {
  85. http: new ApiModel(), //接口文件
  86. Language: new Language(), //语言包
  87. queryPer: require("./utils/queryPermissions"), //权限查询
  88. socketEstablish: false, //是否已经建立socket
  89. SocketTask: '', // Socket方法
  90. socketCallback: null, // Socket回调
  91. handleSelect: null, //处理选择结果 函数
  92. },
  93. })