App.vue 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <script>
  2. import { getUserInfo } from '@/utils/auth'
  3. import { CheckAttendance } from '@/api/mine.js'
  4. import $tab from '@/plugins/tab.js'
  5. export default {
  6. onLaunch: function () {
  7. console.warn('当前组件仅支持 uni_modules 目录结构 ,请升级 HBuilderX 到 3.1.0 版本以上!')
  8. this.initApp()
  9. console.log('App Launch')
  10. },
  11. onShow: function () {
  12. console.log('App Show')
  13. },
  14. onHide: function () {
  15. console.log('App Hide')
  16. },
  17. methods: {
  18. // 初始化应用
  19. initApp() {
  20. // 初始化应用配置
  21. // this.initConfig()
  22. // 检查用户登录状态
  23. this.checkLogin()
  24. },
  25. checkLogin() {
  26. const user = getUserInfo()
  27. if (!getUserInfo()) {
  28. $tab.reLaunch('/pages/login')
  29. } else {
  30. const now = new Date()
  31. const params = {
  32. universalid: user.useId,
  33. rizi: (now.getFullYear()) + '-' + (now.getMonth() + 1) + '-' + (now.getDate())
  34. }
  35. CheckAttendance(params).then(({ returnParams }) => { // 获取当天考勤信息
  36. if (returnParams.list.length) {
  37. // 已签到 跳转消息页面
  38. $tab.reLaunch('/pages/message/index')
  39. } else {
  40. // 未签到 跳转考勤页面
  41. $tab.reLaunch('/pages/message/index?to=clockIn')
  42. }
  43. })
  44. }
  45. }
  46. }
  47. }
  48. </script>
  49. <style lang="scss">
  50. /*每个页面公共css */
  51. @import '@/uni_modules/uni-scss/index.scss';
  52. /* uni.css - 通用组件、模板样式库,可以当作一套ui库应用 */
  53. @import '@/common/uni.css';
  54. /* #ifndef APP-NVUE */
  55. @import '@/static/font/customicons.css';
  56. /* uParse富文本框渲染 样式 */
  57. @import url("/components/gaoyia-parse/parse.css");
  58. // 设置整个项目的背景色
  59. page {
  60. background-color: #f5f5f5;
  61. }
  62. /* #endif */
  63. .example-info {
  64. font-size: 14px;
  65. color: #333; padding: 10px;
  66. }
  67. </style>