home.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. <template>
  2. <view id="home">
  3. <teacherHome class="flex-box-page" v-if="userType==1"></teacherHome>
  4. <pupilHome class="flex-box-page" v-if="userType==2"></pupilHome>
  5. </view>
  6. </template>
  7. <script>
  8. import {
  9. systemUserPersonalData,
  10. } from '@/pages/api/index.js'
  11. import {
  12. teacherHome
  13. } from '@/pages/views/teacherPage/teacherHome'
  14. import {
  15. pupilHome
  16. } from '@/pages/views/pupilPage/pupilHome'
  17. export default {
  18. name: "home",
  19. components: {
  20. teacherHome,
  21. pupilHome,
  22. },
  23. data() {
  24. return {
  25. userType: 0,
  26. }
  27. },
  28. onLoad() {
  29. },
  30. onShow() {
  31. uni.removeStorageSync('planSensorList');
  32. if (uni.getStorageSync('token') && uni.getStorageSync('userId') && uni.getStorageSync('userType')) {
  33. this.systemUserPersonalData();
  34. //写入用户
  35. } else {
  36. uni.removeStorageSync('token');
  37. uni.removeStorageSync('userId');
  38. uni.removeStorageSync('userType');
  39. uni.redirectTo({
  40. url: '/pages/views/login/login',
  41. });
  42. }
  43. },
  44. methods: {
  45. async systemUserPersonalData(){
  46. const {
  47. data
  48. } = await systemUserPersonalData();
  49. if (data.code == 200) {
  50. // isInitPwd 初始密码 true 是
  51. // isTutorExist 导师 true 有
  52. // isPhoneExist 电话 true 有
  53. // userType 1教职工 2学生
  54. if(data.data.userType == 1 && !data.data.isPhoneExist){
  55. //教职工
  56. uni.redirectTo({
  57. url: '/pages_basics/views/completeInformation/completeInformation',
  58. });
  59. }else if(data.data.userType == 2 &&(!data.data.isTutorExist || !data.data.isPhoneExist)){
  60. //学生
  61. uni.redirectTo({
  62. url: '/pages_basics/views/completeInformation/completeInformation',
  63. });
  64. }else if(data.data.isInitPwd){
  65. this.userType = uni.getStorageSync('userType')
  66. this.passwrodTips();
  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. height: 100%;
  105. display: flex;
  106. flex-direction: column;
  107. .flex-box-page{
  108. flex:1;
  109. display: flex;
  110. flex-direction: column;
  111. }
  112. }
  113. </style>