home.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. <template>
  2. <view id="home">
  3. <teacher-home class="flex-box-page" v-if="userType==1"></teacher-home>
  4. <pupil-home class="flex-box-page" v-if="userType==2"></pupil-home>
  5. </view>
  6. </template>
  7. <script>
  8. import {
  9. systemUserPersonalData,
  10. } from '@/pages/api/index.js'
  11. import teacherHome from '@/pages/views/teacherPage/teacherHome'
  12. import pupilHome from '@/pages/views/pupilPage/pupilHome'
  13. export default {
  14. name: "home",
  15. components: {
  16. teacherHome,
  17. pupilHome,
  18. },
  19. data() {
  20. return {
  21. userType: 0,
  22. }
  23. },
  24. onLoad() {
  25. },
  26. onShow() {
  27. uni.removeStorageSync('planSensorList');
  28. if (uni.getStorageSync('token') && uni.getStorageSync('userId') && uni.getStorageSync('userType')) {
  29. this.systemUserPersonalData();
  30. //写入用户
  31. } else {
  32. uni.removeStorageSync('token');
  33. uni.removeStorageSync('userId');
  34. uni.removeStorageSync('userType');
  35. uni.redirectTo({
  36. url: '/pages/views/login/login',
  37. });
  38. }
  39. },
  40. methods: {
  41. async systemUserPersonalData(){
  42. const {
  43. data
  44. } = await systemUserPersonalData();
  45. if (data.code == 200) {
  46. // isInitPwd 初始密码 true 是
  47. // isTutorExist 导师 true 有
  48. // isPhoneExist 电话 true 有
  49. // userType 1教职工 2学生
  50. if(data.data.userType == 1 && !data.data.isPhoneExist){
  51. //教职工
  52. uni.redirectTo({
  53. url: '/pages_basics/views/completeInformation/completeInformation',
  54. });
  55. }else if(data.data.userType == 2 &&(!data.data.isTutorExist || !data.data.isPhoneExist)){
  56. //学生
  57. uni.redirectTo({
  58. url: '/pages_basics/views/completeInformation/completeInformation',
  59. });
  60. }else if(data.data.isInitPwd){
  61. this.userType = uni.getStorageSync('userType')
  62. // 初始密码提示 每次登录只提示一次
  63. if(uni.getStorageSync('isInitPwd')){
  64. uni.setStorageSync('isInitPwd', false);
  65. this.passwrodTips();
  66. }
  67. }else{
  68. this.userType = uni.getStorageSync('userType')
  69. }
  70. }
  71. },
  72. //初始密码修改提示
  73. passwrodTips(){
  74. uni.showModal({
  75. title: '提示',
  76. cancelColor: '#999999',
  77. confirmColor: '#0183FA',
  78. content: '为了保证信息安全,是否修改默认密码',
  79. cancelText:'稍后修改',
  80. confirmText:'修改密码',
  81. success(res) {
  82. if (res.confirm) {
  83. // console.log('确定')
  84. uni.navigateTo({
  85. url: '/pages_basics/views/editPassword/editPassword',
  86. });
  87. } else if (res.cancel) {
  88. // console.log('取消')
  89. }
  90. }
  91. })
  92. },
  93. },
  94. onHide() {
  95. this.userType = 0;
  96. },
  97. onUnload() {
  98. this.userType = 0;
  99. }
  100. }
  101. </script>
  102. <style lang="stylus" scoped>
  103. #home {
  104. width:100%;
  105. height:100%;
  106. display: flex;
  107. flex-direction: column;
  108. overflow: hidden;
  109. .flex-box-page{
  110. flex:1;
  111. display: flex;
  112. flex-direction: column;
  113. }
  114. }
  115. </style>