app.js 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. import {
  2. ApiModel
  3. } from './utils/Api';
  4. import {
  5. evidence,
  6. update
  7. } from './utils/pay';
  8. App({
  9. onLaunch: function () {
  10. wx.getSystemInfo({
  11. success: e => {
  12. this.globalData.StatusBar = e.statusBarHeight;
  13. let custom = wx.getMenuButtonBoundingClientRect();
  14. this.globalData.Custom = custom;
  15. this.globalData.CustomBar = custom.bottom + custom.top - e.statusBarHeight;
  16. }
  17. })
  18. },
  19. initSocket() {
  20. let that = this;
  21. this.globalData.SocketTask = wx.connectSocket({
  22. url: this.globalData.http.baseUrl.replace("https", "wss").replace("http", "ws") + '/yos/webSocket/' + wx.getStorageSync('userMsg').token,
  23. complete: (res) => {
  24. console.log(res)
  25. }
  26. })
  27. //获取领域对应账户
  28. this.globalData.http.basic({
  29. "classname": "sysmanage.develop.optiontype.optiontype",
  30. "method": "optiontypeselect",
  31. "content": {
  32. "pageNumber": 1,
  33. "pageSize": 9999,
  34. "typename": "domainrelatedaccounts"
  35. }
  36. }).then(res => {
  37. console.log("查询领域对应列表", res)
  38. wx.setStorageSync('domainrelatedaccounts', res.msg == '成功' ? res.data : [])
  39. })
  40. console.log(this.globalData.http.baseUrl.replace("https", "wss").replace("http", "ws") + '/yos/webSocket/' + wx.getStorageSync('userMsg').token)
  41. this.globalData.SocketTask.onOpen(function (res) {
  42. that.globalData.socketEstablish = true;
  43. })
  44. this.globalData.SocketTask.onMessage(function (res) {
  45. that.globalData.socket.callback(res)
  46. let data = JSON.parse(res.data);
  47. if (data.message.type == 'pay') update();
  48. })
  49. this.globalData.SocketTask.onError(function (res) {
  50. that.globalData.socketEstablish = false;
  51. })
  52. this.globalData.SocketTask.onClose(function (res) {
  53. that.globalData.socketEstablish = false;
  54. })
  55. },
  56. globalData: {
  57. http: new ApiModel, //挂载接口文件
  58. queryPer: require("./utils/queryPermissions"), //权限查询
  59. handleSelect: null, //处理选择结果函数
  60. collectCount: "", //购物车商品数量
  61. getCollectCount: null, // 获取购物车数量
  62. socketEstablish: false, //是否已经建立socket
  63. SocketTask: '', // Socket方法
  64. remindchangepassword_str: "",
  65. refreshData: null, //保存首页更新应用信息函数
  66. evidence
  67. },
  68. })