业务交流通
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

app.js 3.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. // app.js
  2. App({
  3. onLaunch() {
  4. // 获取本地用户信息
  5. const userInfo = wx.getStorageSync('userInfo') || null;
  6. if(userInfo){
  7. this.globalData.userInfo = userInfo;
  8. console.log(`从本地拿到的userInfo`)
  9. }
  10. // 版本更新
  11. const updateManager = wx.getUpdateManager()
  12. updateManager.onCheckForUpdate(function (res) {
  13. // 请求完新版本信息的回调
  14. if (res.hasUpdate) {
  15. //准备更新
  16. updateManager.onUpdateReady(function () {
  17. wx.showModal({
  18. title: '业务交流通更新啦~',
  19. content: '新版本已经准备好,请重启应用',
  20. showCancel: false,
  21. success: function (res) {
  22. if (res.confirm) {
  23. // 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
  24. updateManager.applyUpdate()
  25. }
  26. }
  27. })
  28. })
  29. //更新失败
  30. updateManager.onUpdateFailed(function () {
  31. wx.showModal({
  32. title: '出错啦',
  33. content: '更新失败,请检查您的网络状况',
  34. showCancel: false,
  35. success: function (res) {
  36. if (res.confirm) {
  37. // 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
  38. updateManager.applyUpdate()
  39. }
  40. }
  41. })
  42. })
  43. }
  44. })
  45. // 登录
  46. wx.login({
  47. success: (res) => {
  48. if (res.code) {
  49. //获取openid
  50. wx.request({
  51. url: this.mangerUrl + '/service/weixin/getWxOpenId',
  52. data: {
  53. appNum: 12,
  54. js_code: res.code
  55. },
  56. success: (result) => {
  57. console.log("微信LOGIN result")
  58. if (!!result.data && result.data.openid) {
  59. // this.globalData.openid = result.data.openid;
  60. this.globalData.appid = result.data.appid;
  61. this.globalData.sessionKey = result.data.sessionKey;
  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. },
  84. // 跳转登录页
  85. goLogin(e) {
  86. wx.navigateTo({
  87. url: "/pages/login/login"
  88. })
  89. },
  90. // mangerUrl: 'http://test2.hhrchina.com',
  91. mangerUrl: "http://192.168.18.156",
  92. // mangerUrl: "https://www.hhrchina.com",
  93. // mangerUrlPath: "https://www.hhrchina.com",
  94. })