App.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. <script>
  2. import { getUserInfo,getLoginInfo } from '@/utils/auth'
  3. import { checkAttendance } from '@/api/mine.js'
  4. import config from '@/config.js'
  5. import $tab from '@/plugins/tab.js'
  6. import { useConfigStore } from '@/store/config.js'
  7. export default {
  8. onLaunch: function () {
  9. // console.warn('当前组件仅支持 uni_modules 目录结构 ,请升级 HBuilderX 到 3.1.0 版本以上!')
  10. this.initApp()
  11. // console.log('App Launch')
  12. },
  13. onShow: function () {
  14. // console.log('App Show')
  15. },
  16. onHide: function () {
  17. // console.log('App Hide')
  18. },
  19. methods: {
  20. // 初始化应用
  21. initApp() {
  22. // 初始化应用配置
  23. // this.initConfig()
  24. // 检查用户登录状态
  25. this.checkLogin()
  26. },
  27. checkLogin() {
  28. const loginInfo = getLoginInfo()
  29. // console.log(Object.keys(loginInfo).length);
  30. if(Object.keys(loginInfo).length == 0){
  31. $tab.reLaunch('/pages/login')
  32. }else{
  33. $tab.reLaunch('/pages/login?type=autoLogin')
  34. }
  35. // $tab.reLaunch('/pages/login?type=autoLogin')
  36. // const configStore=useConfigStore()
  37. // const user = getUserInfo()
  38. // if (!getUserInfo()) {
  39. // $tab.reLaunch('/pages/login')
  40. // } else {
  41. // // 是否在上班打卡时间段
  42. // configStore.GetAttRule(user).then(()=>{
  43. // if (this.isInTimeRange(...configStore.signInTimeRange)) {
  44. // const now = new Date()
  45. // const params = {
  46. // universalid: user.useId,
  47. // rizi: (now.getFullYear()) + '-' + (now.getMonth() + 1) + '-' + (now.getDate())
  48. // }
  49. // // 获取当天考勤信息
  50. // checkAttendance(params).then(({ returnParams }) => {
  51. // if (returnParams.list.length) {
  52. // // 已签到 跳转消息页
  53. // $tab.reLaunch('/pages/message/index')
  54. // } else {
  55. // // 未签到 跳转考勤页面
  56. // $tab.reLaunch('/pages/message/index?to=clockIn')
  57. // }
  58. // })
  59. // } else {
  60. // $tab.reLaunch('/pages/message/index')
  61. // }
  62. // })
  63. // }
  64. },
  65. //判断时间是否在区间内
  66. isInTimeRange(start, end) {
  67. // 获取当前时间戳
  68. const now = Date.now();
  69. // 获取当前日期
  70. const currentDate = new Date(now);
  71. const year = currentDate.getFullYear();
  72. const month = currentDate.getMonth();
  73. const day = currentDate.getDate();
  74. // 构建当天的起始时间和结束时间的时间戳
  75. const startTime = new Date(year, month, day, ...start.split(':').map(Number)).getTime();
  76. const endTime = new Date(year, month, day, ...end.split(':').map(Number)).getTime();
  77. // 判断当前时间是否在范围内
  78. return now >= startTime && now <= endTime;
  79. }
  80. }
  81. }
  82. </script>
  83. <style lang="scss">
  84. @import "@/static/font/ygoa/oa/iconfont.css";
  85. @import "@/static/font/ygoa/work/iconfont.css";
  86. /* uView+ 样式 */
  87. @import '@/uni_modules/uview-plus/index.scss';
  88. /* 每个页面公共css */
  89. @import '@/uni_modules/uni-scss/index.scss';
  90. /* uni.css - 通用组件、模板样式库,可以当作一套ui库应用 */
  91. @import '@/common/uni.css';
  92. /* #ifndef APP-NVUE */
  93. @import '@/static/font/customicons.css';
  94. /* uParse富文本框渲染 样式 */
  95. @import url("/components/gaoyia-parse/parse.css");
  96. // 设置整个项目的背景色
  97. page {
  98. background-color: #f5f5f5;
  99. }
  100. /* #endif */
  101. // .example-info {
  102. // font-size: 14px;
  103. // color: #333;
  104. // padding: 10px;
  105. // }
  106. </style>