12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- <script>
- import {
- getToken
- } from './utils/auth.js'
- import {
- getDayTime,
- timeToDate
- } from '@/utils/date.js'
- export default {
- onLaunch: function() {
- //console.log('App Launch')
- const token = getToken()
- if (token) {
- // #ifdef APP-PLUS
- uni.reLaunch({
- // url: "/pages/reportForm/index",
- url: "/pages/homePage/index",
- success: () => {
- // #ifdef APP-PLUS
- plus.navigator.closeSplashscreen();
- // #endif
- }
- })
- // #endif
- } else {
- uni.reLaunch({
- url: "/pages/login/index",
- success: () => {
- // #ifdef APP-PLUS
- plus.navigator.closeSplashscreen();
- // #endif
- }
- })
- }
- //定时器获得用户的报警信息
- setInterval(function(){
- let dDate = getDayTime();
- let queryParams={
- startDate:'',
- endDate:''
- }
- queryParams.startDate = timeToDate(dDate[0])
- queryParams.endDate = timeToDate(dDate[1])
- uni.$http.get('/mobileAlarm/loadAllAlarmData', queryParams).then(res => {
- const data = res.data
- if (data.code === 200) {
- console.log(data)
- }
- })
- },60000)
- //定时器获取未读报警数量
- setInterval(function(){
- uni.$http.get('/mobileAlarm/getNotReadAlarmUserLogCount').then(res => {
- const data = res.data
- if (data.code === 200) {
- if(data.data.notReadCount>0){
- uni.setTabBarBadge({
- index:2,
- text:data.data.notReadCount + ''
- })
- }else{
- uni.removeTabBarBadge({
- index:2
- })
- }
-
- }
- })
- },5000)
- },
- onShow: function() {
- //console.log('App Show')
-
- },
- onHide: function() {
- //console.log('App Hide')
- }
- }
- </script>
- <style>
- /*每个页面公共css */
- @import '@/uni_modules/uview-ui/theme.scss';
- uni-button:after {
- border: none;
- }
- uni-page-head .uni-page-head__title{
- font-size: 18px !important;
- }
- </style>
|