index.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. <template>
  2. <view v-if="hasFunction" class="page" @click.stop="closeDropdowns">
  3. <view class="tabs-container">
  4. <view class="tabs">
  5. <view v-if="hasScanFunction" class="tab" :class="{ active: activeTab === 'scan' }" @click="activeTab = 'scan'">
  6. 扫码率</view>
  7. <view v-if="hasReportFunction" class="tab" :class="{ active: activeTab === 'export' }"
  8. @click="activeTab = 'export'">报表导出</view>
  9. <view v-if="hasBlacklistFunction" class="tab" :class="{ active: activeTab === 'blacklist' }"
  10. @click="activeTab = 'blacklist'">黑名单汇总</view>
  11. </view>
  12. </view>
  13. <view class="content" v-show="activeTab === 'scan' && hasScanFunction">
  14. <ScanningRate ref="scanRate" />
  15. </view>
  16. <view class="content" :style="{ padding: '0', marginTop: '85rpx' }"
  17. v-show="activeTab === 'export' && hasReportFunction">
  18. <ReportExport />
  19. </view>
  20. <view class="content" :style="{ padding: '0', marginTop: '85rpx' }"
  21. v-show="activeTab === 'blacklist' && hasBlacklistFunction">
  22. <Blacklist />
  23. </view>
  24. </view>
  25. <view v-else-if="!functionLoading" class="page">
  26. <Empty text="您无权限访问" />
  27. </view>
  28. </template>
  29. <script>
  30. import LoadingImg from "../../static/images/loading.png";
  31. import ReportExport from "./reportExport/index.vue";
  32. import ScanningRate from "./customerScanningRate/index.vue";
  33. import Blacklist from "./blacklist/index.vue";
  34. import Empty from "../../wigets/empty.vue";
  35. import { hasFunction } from '../../utils/utils.js'
  36. export default {
  37. components: {
  38. ScanningRate,
  39. ReportExport,
  40. Blacklist,
  41. Empty,
  42. },
  43. data() {
  44. return {
  45. hasScanFunction: false,
  46. hasReportFunction: false,
  47. hasBlacklistFunction: false,
  48. loading: true,
  49. LoadingImg,
  50. activeTab: "scan",
  51. activeRange: 1,
  52. filterModalOpen: false,
  53. filterForm: { report: "", product: "" },
  54. filterDropdown: { report: false, product: false },
  55. filterDateRange: [],
  56. functionLoading: true,
  57. };
  58. },
  59. created() {
  60. this.getFunc()
  61. },
  62. computed: {
  63. hasFunction() {
  64. return this.hasScanFunction || this.hasReportFunction || this.hasBlacklistFunction
  65. }
  66. },
  67. methods: {
  68. closeDropdowns() {
  69. this.$refs.scanRate.closeDropdown();
  70. },
  71. async getFunc() {
  72. uni.showLoading({
  73. title: '加载中',
  74. })
  75. await hasFunction(['scan-rate-list', 'trace-code-task', 'blacklist-customers-list']).then(res => {
  76. this.hasScanFunction = res[0]
  77. this.hasReportFunction = res[1]
  78. this.hasBlacklistFunction = res[2]
  79. }).catch(err => {
  80. this.hasScanFunction = false
  81. this.hasReportFunction = false
  82. this.hasBlacklistFunction = false
  83. // uni.hideLoading()
  84. })
  85. if (this.hasScanFunction) {
  86. this.active = 'scan'
  87. } else if (this.hasReportFunction) {
  88. this.activeTab = 'export'
  89. } else if (this.hasBlacklistFunction) {
  90. this.activeTab = 'blacklist'
  91. }
  92. this.functionLoading = false
  93. uni.hideLoading()
  94. }
  95. },
  96. };
  97. </script>
  98. <style>
  99. .page {
  100. box-sizing: border-box;
  101. height: calc(100vh - env(safe-area-inset-bottom));
  102. overflow-y: auto;
  103. box-sizing: border-box;
  104. background: #f3f6f9;
  105. padding-bottom: calc(50rpx + env(safe-area-inset-bottom));
  106. }
  107. .content {
  108. padding: 30rpx;
  109. margin-top: 180rpx;
  110. padding-bottom: 160rpx;
  111. }
  112. .tabs-container {
  113. position: fixed;
  114. top: 0;
  115. left: 0;
  116. width: 100%;
  117. height: 116rpx;
  118. background: #f3f6f9;
  119. z-index: 99;
  120. margin-top: -8rpx;
  121. }
  122. .tabs {
  123. box-sizing: border-box;
  124. width: calc(100% - 16rpx);
  125. display: flex;
  126. background: #fff;
  127. border-radius: 16rpx;
  128. padding: 12rpx;
  129. margin: 8rpx;
  130. }
  131. .tab {
  132. flex: 1;
  133. text-align: center;
  134. padding: 18rpx 0;
  135. border-radius: 12rpx;
  136. font-size: 28rpx;
  137. }
  138. .tab.active {
  139. background: #2c69ff;
  140. color: #fff;
  141. }
  142. </style>