业务交流通
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

app.js 4.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. // app.js
  2. App({
  3. onLaunch() {
  4. // 版本更新
  5. const updateManager = wx.getUpdateManager()
  6. updateManager.onCheckForUpdate(function (res) {
  7. // 请求完新版本信息的回调
  8. if (res.hasUpdate) {
  9. //准备更新
  10. updateManager.onUpdateReady(function () {
  11. wx.showModal({
  12. title: '需求对对碰更新啦~',
  13. content: '新版本已经准备好,请重启应用',
  14. showCancel: false,
  15. success: function (res) {
  16. if (res.confirm) {
  17. // 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
  18. updateManager.applyUpdate()
  19. }
  20. }
  21. })
  22. })
  23. //更新失败
  24. updateManager.onUpdateFailed(function () {
  25. wx.showModal({
  26. title: '出错啦',
  27. content: '更新失败,请检查您的网络状况',
  28. showCancel: false,
  29. success: function (res) {
  30. if (res.confirm) {
  31. // 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
  32. updateManager.applyUpdate()
  33. }
  34. }
  35. })
  36. })
  37. }
  38. })
  39. // 登录
  40. wx.login({
  41. success: (res) => {
  42. if (res.code) {
  43. //获取openid
  44. wx.request({
  45. url: this.mangerUrl + '/service/weixin/getWxOpenId',
  46. data: {
  47. appNum: 12,
  48. js_code: res.code
  49. },
  50. success: (result) => {
  51. if (!!result.data && result.data.openid) {
  52. this.globalData.openid = result.data.openid;
  53. this.globalData.appid = result.data.appid;
  54. this.globalData.sessionKey = result.data.sessionKey;
  55. // 获取本地用户信息
  56. const userInfo = wx.getStorageSync('userInfo') || null;
  57. const businessCommunicationCustomer = wx.getStorageSync('businessCommunicationCustomer') || null;
  58. if(userInfo){
  59. this.globalData.userInfo = userInfo;
  60. }
  61. if(businessCommunicationCustomer){
  62. this.globalData.businessCommunicationCustomer = businessCommunicationCustomer;
  63. this.globalData.customerId = businessCommunicationCustomer.customerId;
  64. }
  65. }
  66. }
  67. })
  68. } else {
  69. wx.showToast({
  70. title: '获取登录信息失败',
  71. icon: 'none',
  72. duration: 2000
  73. })
  74. }
  75. }
  76. })
  77. },
  78. globalData: {
  79. userInfo: null,
  80. // openid: "oBkT7vu1Q8l-xsbux_i1FNmRWuJ4",
  81. openid: "",
  82. appid: "",
  83. sessionKey: "",
  84. suiteCode: "",
  85. customerId: null,
  86. businessCommunicationCustomer:null,
  87. // websocket 是否已连接 用于底部tab收到新消息时消息有红点
  88. isOnSocketOpen:false,
  89. },
  90. // 跳转登录页
  91. goLogin(e) {
  92. wx.navigateTo({
  93. url: "/pages/login/login"
  94. })
  95. },
  96. mangerUrl: 'http://test2.hhrchina.com',
  97. //mangerUrl: "http://192.168.18.138",
  98. //mangerUrl: "https://www.hhrchina.com",
  99. // mangerUrlPath: "https://www.hhrchina.com",
  100. //webSocketUrl:"ws://192.168.18.138",
  101. webSocketUrl:"ws://test2.hhrchina.com",
  102. //webSocketUrl:"wss://www.hhrchina.com",
  103. })