123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104 |
- <script>
- import Vue from 'vue';
- import {
- getUserInfo
- } from "@/common/utils/util"
- import api from '@/common/http/'
- var getUserValTimeId = null
- export default {
- onLaunch: function() {
- // #ifdef MP-WEIXIN
- // 小程序更新
- const updateManager = uni.getUpdateManager();
- // 请求完新版本信息
- updateManager.onCheckForUpdate((res) => {
- // console.log(res.hasUpdate);
- });
- // 新的版本已经下载好
- updateManager.onUpdateReady((res) => {
- uni.showModal({
- title: '更新提示',
- content: '新版本已经准备好,是否重启应用?',
- success(res) {
- if (res.confirm) {
- // 调用 applyUpdate 应用新版本并重启
- updateManager.applyUpdate();
- }
- },
- });
- });
- // 新的版本下载失败
- updateManager.onUpdateFailed((res) => {});
- // #endif
- uni.$on('updateUserInfo', () => {
- this.updateUserInfo();
- });
- uni.$on('getSendMsg', () => {
- this.getSendMsg();
- });
- if (this.$store.state.user.token) {
- this.getSendMsg();
- }
- uni.getSystemInfo({
- success: function(e) {
- console.log(e);
- Vue.prototype.StatusBar = e.statusBarHeight;
- // #ifdef MP-WEIXIN
- let custom = wx.getMenuButtonBoundingClientRect();
- Vue.prototype.Custom = custom;
- Vue.prototype.CustomBar = custom.bottom + custom.top - e.statusBarHeight + 4;
- // #endif
- // #ifndef MP-WEIXIN
- Vue.prototype.CustomBar = 48
- // #endif
- //用来判断是否iphoneX类型的全面屏设备
- if (e.model.indexOf('iPhone X') == 0) {
- Vue.prototype.isIphoneX = 68;
- } else {
- Vue.prototype.isIphoneX = 0;
- }
- },
- });
- },
- onShow: function() {
- },
- onHide: function() {
- },
- methods: {
- async getSendMsg() {
- // #ifndef H5
- (function getUserVal() {
- if (getUserValTimeId) {
- clearTimeout(getUserValTimeId)
- }
- api.get('/user/talk/unread').then((res) => {
- uni.setTabBarBadge({
- index: 2,
- text: res.data
- })
- getUserValTimeId = setTimeout(getUserVal, 2000)
- })
- .catch((error) => {});
- })()
- // #endif
- },
- async updateUserInfo() {
- },
- },
- }
- </script>
- <style lang="scss">
- /*每个页面公共css */
- @import "uview-ui/index.scss";
- @import "styles/iconfont.css";
- </style>
|