App.vue 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <script>
  2. import $api from 'static/js/api.js';
  3. import $app from 'static/js/app.js';
  4. export default {
  5. onLaunch: function(options) {
  6. console.log('App Launch')
  7. },
  8. onShow: function(options) {
  9. // 判断用户是否通过分销码进入------------------------------------------------------
  10. if (options.scene === 1011||options.scene === 1012||options.scene === 1013) {
  11. const decodedUrl = decodeURIComponent(options.query.q);
  12. const urlParts = decodedUrl.split('?');
  13. if (urlParts.length > 1) {
  14. const queryParams = urlParts[1];
  15. const paramPairs = queryParams.split('&');
  16. const resultObj = {};
  17. paramPairs.forEach(pair => {
  18. const [key, value] = pair.split('=');
  19. resultObj[key] = value;
  20. });
  21. const adminUserId = resultObj['adminUserId'];
  22. const frimId = resultObj['frimId'];
  23. console.log(frimId,'----企业用户');
  24. uni.setStorageSync('FRIM_ID',frimId)
  25. uni.setStorageSync('ADMIN_USERID', adminUserId);
  26. console.info(uni.getStorageSync('ADMIN_USERID'),'---用户通过扫码进入')
  27. }
  28. }
  29. // 自动更新管理-------------------------------------------------------------------
  30. const updateManager = uni.getUpdateManager();
  31. updateManager.onUpdateReady(function(res) {
  32. uni.showModal({
  33. title: '更新提示',
  34. content: '新版本已经准备好,是否重启应用?',
  35. success(res) {
  36. if (res.confirm) updateManager.applyUpdate();
  37. }
  38. });
  39. });
  40. updateManager.onUpdateFailed(function(res) {
  41. uni.showModal({
  42. title: '更新失败',
  43. content: '小程序已有新版本,请稍后重试更新!',
  44. showCancel: false
  45. });
  46. });
  47. // 自动登录用户-------------------------------------------------------------------
  48. const userInfo = $app.storage.get("USER_INFO");
  49. if (!userInfo) $api.login();
  50. },
  51. onHide: function() {
  52. console.log('App Hide')
  53. }
  54. }
  55. </script>
  56. <style>
  57. /*每个页面公共css */
  58. @import "components/ax/ax.css";
  59. @import "static/css/app.css";
  60. </style>