123456789101112131415161718192021222324252627282930313233343536 |
- <script>
- export default {
- onLaunch: function() {
- // 设备高度
- const systemInfo = uni.getWindowInfo();
- uni.$windowHeight = systemInfo.windowHeight;
- },
- // 在页面的onShow生命周期中
- onShow() {
- // 尝试从本地存储中恢复数据
- const savedState = uni.getStorageSync('vuex_state');
- if (savedState) this.$store.replaceState(Object.assign({}, this.$store.state, savedState));
- if (this.$store.getters.user.userId) this.$chat.connect('workark' + this.$store.getters.user.userId);
- if (uni.getStorageSync('serveChatId')) this.$customerServe.connect(uni.getStorageSync('serveChatId'));
- },
- // 在页面的onHide生命周期中
- onHide() {
- // 保存状态到本地存储
- uni.setStorageSync('vuex_state', this.$store.state);
- uni.removeStorageSync('chatToken');
- uni.removeStorageSync('serveChatToken');
- uni.removeStorageSync('serveChatId');
- }
- }
- </script>
- <style lang="scss">
- /*每个页面公共css */
- @import "@/static/font/iconfont.css";
- @import '@/static/scss/common.scss';
- page {
- background-color: $uv-bg-color;
- font-size: 28rpx;
- }
- </style>
|