home.vue 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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. teacherHome
  10. } from '@/pages/views/teacherPage/teacherHome'
  11. import {
  12. pupilHome
  13. } from '@/pages/views/pupilPage/pupilHome'
  14. export default {
  15. name: "home",
  16. components: {
  17. teacherHome,
  18. pupilHome,
  19. },
  20. data() {
  21. return {
  22. userType: 0,
  23. }
  24. },
  25. onLoad() {
  26. },
  27. onShow() {
  28. uni.removeStorageSync('planSensorList');
  29. if (uni.getStorageSync('token') && uni.getStorageSync('userId') && uni.getStorageSync('userType')) {
  30. this.userType = uni.getStorageSync('userType')
  31. console.log('检查用户个人信息/初始密码');
  32. this.passwrodTips();
  33. } else {
  34. uni.removeStorageSync('token');
  35. uni.removeStorageSync('userId');
  36. uni.removeStorageSync('userType');
  37. uni.redirectTo({
  38. url: '/pages/views/login/login',
  39. });
  40. }
  41. },
  42. methods: {
  43. //初始密码修改提示
  44. passwrodTips(){
  45. uni.showModal({
  46. title: '提示',
  47. cancelColor: '#999999',
  48. confirmColor: '#0183FA',
  49. content: '为了保证信息安全,是否修改默认密码',
  50. cancelText:'稍后修改',
  51. confirmText:'修改密码',
  52. success(res) {
  53. if (res.confirm) {
  54. console.log('确定')
  55. uni.navigateTo({
  56. url: '/pages_basics/views/editPassword/editPassword',
  57. });
  58. } else if (res.cancel) {
  59. console.log('取消')
  60. }
  61. }
  62. })
  63. },
  64. },
  65. onHide() {
  66. this.userType = 0;
  67. },
  68. onUnload() {
  69. this.userType = 0;
  70. }
  71. }
  72. </script>
  73. <style lang="stylus" scoped>
  74. #home {
  75. height: 100%;
  76. display: flex;
  77. flex-direction: column;
  78. .flex-box-page{
  79. flex:1;
  80. display: flex;
  81. flex-direction: column;
  82. }
  83. }
  84. </style>