西藏巴青项目

index.vue 1.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <template>
  2. <view class="tab-page">
  3. <SupplierOrderPanel
  4. v-if="isSupplier && isLoggedIn"
  5. ref="orderPanel"
  6. />
  7. <DistributorOrderPanel
  8. v-else-if="isDistributor && isLoggedIn"
  9. ref="orderPanel"
  10. />
  11. <GuestView
  12. v-else-if="!isLoggedIn"
  13. hint="登录后查看交易订单"
  14. @login="goLogin"
  15. />
  16. </view>
  17. </template>
  18. <script>
  19. import SupplierOrderPanel from '@/components/supplier/order-panel.vue'
  20. import DistributorOrderPanel from '@/components/distributor/order-panel.vue'
  21. import GuestView from '@/components/partner/guest-view.vue'
  22. import { useUserStore } from '@/store/user'
  23. import { isEffectiveDistributorRole, isEffectiveSupplierRole } from '@/utils/partnerRole'
  24. import { refreshTabPanelOnShow } from '@/utils/tabPanel'
  25. export default {
  26. components: {
  27. SupplierOrderPanel,
  28. DistributorOrderPanel,
  29. GuestView
  30. },
  31. data() {
  32. return {
  33. isLoggedIn: false,
  34. isSupplier: false,
  35. isDistributor: false
  36. }
  37. },
  38. onShow() {
  39. refreshTabPanelOnShow(this, {
  40. refreshRole: this.refreshRole,
  41. refName: 'orderPanel',
  42. shouldReload: () => this.isLoggedIn && (this.isSupplier || this.isDistributor)
  43. })
  44. },
  45. methods: {
  46. refreshRole() {
  47. const userStore = useUserStore()
  48. const roles = userStore.state.roles
  49. this.isLoggedIn = userStore.isLoggedIn()
  50. this.isSupplier = isEffectiveSupplierRole(roles)
  51. this.isDistributor = isEffectiveDistributorRole(roles)
  52. },
  53. goLogin() {
  54. uni.navigateTo({ url: '/pages/login/index' })
  55. }
  56. }
  57. }
  58. </script>
  59. <style lang="scss" scoped>
  60. @import '@/styles/tab-page.scss';
  61. </style>