home.vue 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. <template>
  2. <view id="home">
  3. <manage-home v-if="userType==1" ref="manage"></manage-home>
  4. <user-home v-if="userType==2"></user-home>
  5. <supplier-home v-if="userType==3"></supplier-home>
  6. <tab-bar v-if="userType!=3"></tab-bar>
  7. </view>
  8. </template>
  9. <script>
  10. import { manageHome } from '@/pages/manageWorkbench'
  11. import { userHome } from '@/pages/studentWorkbench.vue'
  12. import { supplierHome } from '@/pages/supplierWorkbench.vue'
  13. import { tabBar } from '@/component/tabBar.vue'
  14. export default {
  15. name: "home",
  16. components: {
  17. manageHome,
  18. userHome,
  19. supplierHome,
  20. tabBar
  21. },
  22. data() {
  23. return {
  24. userType:0,
  25. }
  26. },
  27. onLoad() {
  28. if (wx.canIUse('getUpdateManager')) {
  29. const updateManager = wx.getUpdateManager()
  30. updateManager.onCheckForUpdate(function (res) {
  31. if (res.hasUpdate) {
  32. updateManager.onUpdateReady(function () {
  33. wx.showModal({
  34. title: '更新提示',
  35. content: '新版本已经准备好,是否重启应用?',
  36. success: function (res) {
  37. if (res.confirm) {
  38. updateManager.applyUpdate()
  39. }
  40. }
  41. })
  42. })
  43. updateManager.onUpdateFailed(function () {
  44. wx.showModal({
  45. title: '已经有新版本了哟~',
  46. content: '新版本已经上线啦~,请您删除当前小程序,重新搜索打开哟~'
  47. })
  48. })
  49. }
  50. })
  51. } else {
  52. wx.showModal({
  53. title: '提示',
  54. content: '当前微信版本过低,无法使用该功能,请升级到最新微信版本后重试。'
  55. })
  56. }
  57. },
  58. onShow(){
  59. if(uni.getStorageSync('token')&&uni.getStorageSync('userId')&&uni.getStorageSync('userType')){
  60. this.userType = uni.getStorageSync('userType')
  61. }else{
  62. uni.removeStorageSync('token');
  63. uni.removeStorageSync('userId');
  64. uni.removeStorageSync('userType');
  65. uni.redirectTo({
  66. url: '/pages/login',
  67. });
  68. }
  69. console.log("onShow")
  70. },
  71. methods: {
  72. },
  73. onHide(){
  74. this.userType = 0;
  75. },
  76. onUnload(){
  77. this.userType = 0;
  78. }
  79. }
  80. </script>
  81. <style lang="stylus" scoped>
  82. #home{
  83. height:100%;
  84. }
  85. </style>