业务交流通
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

app.js 3.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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. console.log("微信LOGIN result")
  52. if (!!result.data && result.data.openid) {
  53. this.globalData.openid = result.data.openid;
  54. this.globalData.appid = result.data.appid;
  55. this.globalData.sessionKey = result.data.sessionKey;
  56. // 获取本地用户信息
  57. const userInfo = wx.getStorageSync('userInfo') || null;
  58. console.log(userInfo,'userInfo')
  59. if(userInfo){
  60. this.globalData.userInfo = userInfo;
  61. }
  62. }
  63. }
  64. })
  65. } else {
  66. wx.showToast({
  67. title: '获取登录信息失败',
  68. icon: 'none',
  69. duration: 2000
  70. })
  71. }
  72. }
  73. })
  74. },
  75. globalData: {
  76. userInfo: null,
  77. // openid: "oBkT7vu1Q8l-xsbux_i1FNmRWuJ4",
  78. openid: "",
  79. appid: "",
  80. sessionKey: "",
  81. suiteCode: "",
  82. customerId: null,
  83. customer:null,
  84. },
  85. // 跳转登录页
  86. goLogin(e) {
  87. wx.navigateTo({
  88. url: "/pages/login/login"
  89. })
  90. },
  91. // mangerUrl: 'http://test2.hhrchina.com',
  92. mangerUrl: "http://192.168.18.156",
  93. // mangerUrl: "https://www.hhrchina.com",
  94. // mangerUrlPath: "https://www.hhrchina.com",
  95. })