indexRouter.vue 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. <template>
  2. <view>
  3. <Home :height="height" :token="token" :userInfo="userInfo" :orderStatistics="orderStatistics"
  4. v-if="nowchos === 0" :key="Math.random()"></Home>
  5. <Mine :height="height" ref="mine" :token="token" :userInfo="userInfo" v-else-if="nowchos === 1"></Mine>
  6. <view class="bottomboxs">
  7. <x-navbottom :nowchos='nowchos' @botomchos='botomchos'></x-navbottom>
  8. </view>
  9. </view>
  10. </template>
  11. <script>
  12. import Home from './home/index.vue' // 引入首页
  13. import Mine from './mine/index.vue' // 我的
  14. export default {
  15. components: { //在这里注册相应的组件
  16. Home,
  17. Mine,
  18. },
  19. data() {
  20. return {
  21. nowchos: 0, //当前选择了那个底部菜单
  22. isorders: 0,
  23. userType: 3,
  24. token: '',
  25. userInfo: {},
  26. orderStatistics: {},
  27. height: '',
  28. }
  29. },
  30. mounted() {
  31. const arr = uni.getSystemInfoSync().statusBarHeight
  32. this.height = arr
  33. },
  34. onShow() {
  35. var token = this.$cache.getToken()
  36. this.token = token
  37. var userInfo = this.$cache.getCache('userInfo')
  38. if (userInfo) {
  39. this.userInfo = userInfo
  40. } else {
  41. this.userInfo = {}
  42. }
  43. this.getUserInfo()
  44. },
  45. methods: {
  46. getUserInfo() {
  47. this.$api.get('/api/user/profile').then(res => {
  48. if (res.code == 200) {
  49. this.userInfo = res.data.user
  50. this.$cache.setCache('userInfo', this.userInfo)
  51. this.getHomeList()
  52. } else {
  53. this.$cache.removeToken()
  54. this.$cache.removeCache('userInfo')
  55. uni.showToast({
  56. title: '当前用户不存在',
  57. icon: 'none'
  58. });
  59. }
  60. })
  61. },
  62. // 获取订单统计
  63. getHomeList() {
  64. this.$api.get('/api/waybill/applet-count').then(res => {
  65. if (res.code == 200) {
  66. this.orderStatistics = res.data
  67. }
  68. })
  69. },
  70. // tab
  71. botomchos(e) {
  72. const that = this
  73. if (e == 2) {
  74. that.$nextTick(() => {
  75. setTimeout(function() {
  76. that.$refs.mine.refreshTokenil()
  77. }, 100);
  78. })
  79. }
  80. uni.setStorageSync('nowchos', e);
  81. that.nowchos = e
  82. },
  83. }
  84. }
  85. </script>
  86. <style lang="scss" scoped>
  87. .bottomboxs {
  88. position: relative;
  89. bottom: 0;
  90. z-index: 2023;
  91. height: 100rpx;
  92. }
  93. </style>