todayOverview.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. <!-- 今日概况 -->
  2. <template>
  3. <view class="overview">
  4. <!-- 顶部切换停车场和路段 -->
  5. <view class="overview-tabs">
  6. <view
  7. class="overview-tabs-item"
  8. v-for="(item, index) in tabs"
  9. :key="index"
  10. :class="{ active: tabCur === item.key }"
  11. @click="tabCur = item.key"
  12. >
  13. <text>{{ item.label }}</text>
  14. </view>
  15. </view>
  16. <template v-if="tabCur === 'road'">
  17. <view class="overview-content">
  18. <view class="overview-content-item" v-for="(item, index) in roadObj.list" :key="index">
  19. <view class="overview-content-item-left">
  20. <view>
  21. <text class="title">{{ item.label }}({{ item.unit }})</text>
  22. </view>
  23. <view>
  24. <count-up
  25. :num="roadData[item.key] || 0"
  26. color="#1767F2"
  27. width="20"
  28. height="42"
  29. fontSize="30"
  30. />
  31. </view>
  32. </view>
  33. <view class="overview-content-item-right">
  34. <template v-if="roadData[item.flag]">
  35. <u--image
  36. v-if="roadData[item.flag].indexOf('-') === -1"
  37. :showLoading="true"
  38. src="/static/icons/upward-trend-icon.svg"
  39. width="60px"
  40. height="35px"
  41. />
  42. <u--image
  43. v-if="roadData[item.flag].indexOf('-') > -1"
  44. :showLoading="true"
  45. src="/static/icons/downward-trend-icon.svg"
  46. width="60px"
  47. height="35px"
  48. />
  49. </template>
  50. <template v-else>--</template>
  51. </view>
  52. </view>
  53. </view>
  54. </template>
  55. <template v-if="tabCur === 'park'">
  56. <view class="overview-content">
  57. <view class="overview-content-item" v-for="(item, index) in roadObj.list" :key="index">
  58. <view class="overview-content-item-left">
  59. <view>
  60. <text class="title">{{ item.label }}({{ item.unit }})</text>
  61. </view>
  62. <view>
  63. <count-up
  64. :num="parkData[item.key] || 0"
  65. color="#1767F2"
  66. width="20"
  67. height="42"
  68. fontSize="30"
  69. />
  70. </view>
  71. </view>
  72. <view class="overview-content-item-right">
  73. <template v-if="parkData[item.flag]">
  74. <u--image
  75. v-if="parkData[item.flag].indexOf('-') === -1"
  76. :showLoading="true"
  77. src="/static/icons/upward-trend-icon.svg"
  78. width="60px"
  79. height="35px"
  80. />
  81. <u--image
  82. v-if="parkData[item.flag].indexOf('-') > -1"
  83. :showLoading="true"
  84. src="/static/icons/downward-trend-icon.svg"
  85. width="60px"
  86. height="35px"
  87. />
  88. </template>
  89. <template v-else>--</template>
  90. </view>
  91. </view>
  92. </view>
  93. </template>
  94. <u-toast ref="uToast"></u-toast>
  95. </view>
  96. </template>
  97. <script>
  98. import countUp from '@/components/p-countUp/countUp.vue';
  99. export default {
  100. components: {
  101. countUp
  102. },
  103. data() {
  104. return {
  105. tabs: [
  106. { key: 'road', label: '路段' },
  107. { key: 'park', label: '停车场' }
  108. ],
  109. tabCur: 'road',
  110. roadObj: {
  111. list: [
  112. { key: 'amtIn', label: '今日营收', unit: '元', flag: 'linkRatIn' },
  113. { key: 'amtOwe', label: '今日欠费', unit: '元', flag: 'linkRatOwe' },
  114. { key: 'countQr', label: '今日停车', unit: '次', flag: 'linkRatQr' },
  115. {
  116. key: 'countVehicle',
  117. label: '今日扫码',
  118. unit: '次',
  119. flag: 'linkRatVehicle'
  120. }
  121. ]
  122. },
  123. roadData: {},
  124. parkData: {}
  125. };
  126. },
  127. onShow() {
  128. this.getTodayData();
  129. this.getRoadData();
  130. },
  131. methods: {
  132. /**
  133. * 获取今日路段概况
  134. */
  135. getTodayData() {
  136. uni.$u.api.todayOverviewApi.getTodayDataApi().then((res) => {
  137. if (res.code === 200) {
  138. this.roadData = res.data;
  139. } else {
  140. this.$refs.uToast.show({
  141. loading: true,
  142. message: res.msg || '获取今日概况失败!',
  143. type: 'error'
  144. });
  145. }
  146. });
  147. },
  148. /**
  149. * 获取今日停车场情况
  150. */
  151. getRoadData() {
  152. uni.$u.api.todayOverviewApi.getParkDataApi().then((res) => {
  153. if (res.code === 200) {
  154. this.parkData = res.data;
  155. } else {
  156. this.$refs.uToast.show({
  157. loading: true,
  158. message: res.msg || '获取路段概况失败!',
  159. type: 'error'
  160. });
  161. }
  162. });
  163. }
  164. }
  165. };
  166. </script>
  167. <style lang="scss">
  168. page {
  169. min-height: calc(100vh - 44px);
  170. background-color: #1767f2;
  171. }
  172. </style>
  173. <style lang="scss" scoped>
  174. @import './todayOverview.scss';
  175. </style>