App.vue 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  1. <script>
  2. export default {
  3. onLaunch: function() {
  4. // 设备高度
  5. const systemInfo = uni.getWindowInfo();
  6. uni.$windowHeight = systemInfo.windowHeight;
  7. },
  8. // 在页面的onShow生命周期中
  9. onShow() {
  10. // 尝试从本地存储中恢复数据
  11. const savedState = uni.getStorageSync('vuex_state');
  12. if (savedState) this.$store.replaceState(Object.assign({}, this.$store.state, savedState));
  13. if (this.$store.getters.user.userId) this.$chat.connect('workark' + this.$store.getters.user.userId);
  14. if (uni.getStorageSync('serveChatId')) this.$customerServe.connect(uni.getStorageSync('serveChatId'));
  15. },
  16. // 在页面的onHide生命周期中
  17. onHide() {
  18. // 保存状态到本地存储
  19. uni.setStorageSync('vuex_state', this.$store.state);
  20. uni.removeStorageSync('chatToken');
  21. uni.removeStorageSync('serveChatToken');
  22. uni.removeStorageSync('serveChatId');
  23. }
  24. }
  25. </script>
  26. <style lang="scss">
  27. /*每个页面公共css */
  28. @import "@/static/font/iconfont.css";
  29. @import '@/static/scss/common.scss';
  30. page {
  31. background-color: $uv-bg-color;
  32. font-size: 28rpx;
  33. }
  34. </style>