indexRouter.vue 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <template>
  2. <view>
  3. <Home :token="token" :userInfo="userInfo" :orderStatistics="orderStatistics" v-if="nowchos === 0"
  4. :key="Math.random()"></Home>
  5. <Mine 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. }
  28. },
  29. onShow() {
  30. var token = this.$cache.getToken()
  31. this.token = token
  32. var userInfo = this.$cache.getCache('userInfo')
  33. if (userInfo) {
  34. this.userInfo = userInfo
  35. } else {
  36. this.userInfo = {}
  37. }
  38. this.getUserInfo()
  39. },
  40. methods: {
  41. getUserInfo() {
  42. this.$api.get('/api/user/profile').then(res => {
  43. if (res.code == 200) {
  44. this.userInfo = res.data.user
  45. this.$cache.setCache('userInfo', this.userInfo)
  46. this.getHomeList()
  47. } else {
  48. this.$cache.removeToken()
  49. this.$cache.removeCache('userInfo')
  50. uni.showToast({
  51. title: '当前用户不存在',
  52. icon: 'none'
  53. });
  54. }
  55. })
  56. },
  57. // 获取订单统计
  58. getHomeList() {
  59. this.$api.get('/api/waybill/applet-count').then(res => {
  60. if (res.code == 200) {
  61. this.orderStatistics = res.data
  62. }
  63. })
  64. },
  65. // tab
  66. botomchos(e) {
  67. const that = this
  68. if (e == 2) {
  69. that.$nextTick(() => {
  70. setTimeout(function() {
  71. that.$refs.mine.refreshTokenil()
  72. }, 100);
  73. })
  74. }
  75. uni.setStorageSync('nowchos', e);
  76. that.nowchos = e
  77. },
  78. }
  79. }
  80. </script>
  81. <style lang="scss" scoped>
  82. .bottomboxs {
  83. position: relative;
  84. bottom: 0;
  85. z-index: 2023;
  86. height: 100rpx;
  87. }
  88. </style>