chargeDetail.vue 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. <script setup lang="ts">
  2. import router from '@/router'
  3. import { StaticUrl } from '@/config'
  4. const { statusBarHeight, MenuButtonHeight } = storeToRefs(useSysStore())
  5. const activeTab = ref('price')
  6. definePage({
  7. name: 'charge-detail',
  8. islogin: false,
  9. style: {
  10. navigationBarTitleText: '充电详情',
  11. navigationStyle: 'custom',
  12. },
  13. })
  14. const stationId = ref()
  15. onLoad((options: any) => {
  16. stationId.value = Number(options.stationId)
  17. activeTab.value = options.type
  18. })
  19. onMounted(() => {
  20. getPricesList()
  21. getConnectorsList()
  22. })
  23. const priceDetail = ref<Api.chargeStationPrices>()
  24. async function getPricesList() {
  25. const res = await Apis.charge.prices({ data: { stationId: stationId.value } })
  26. priceDetail.value = res.data
  27. }
  28. const connectorsDetail = ref<Api.chargeStationConnectors>()
  29. async function getConnectorsList() {
  30. const res = await Apis.charge.connectors({ data: { stationId: stationId.value } })
  31. connectorsDetail.value = res.data
  32. }
  33. /**
  34. * 处理站点设备状态
  35. *status 状态:0-离线 1-空闲 2-占用
  36. */
  37. function getStatusImageByStatus(deviceStatus: number) {
  38. switch (deviceStatus) {
  39. case 1: // 空闲
  40. return 'kx'
  41. case 2: // 占用
  42. return 'zy'
  43. case 0: // 离线
  44. return 'lx'
  45. default:
  46. return 'unknown'
  47. }
  48. }
  49. // 切换选项卡的方法
  50. function switchTab(tab: string) {
  51. activeTab.value = tab
  52. }
  53. // 计算样式的方法
  54. function getTabStyle(tab: string) {
  55. return activeTab.value === tab
  56. ? { background: '#9ED605', color: '#FFF' }
  57. : {}
  58. }
  59. </script>
  60. <template>
  61. <view class="charge-detail-page min-h-screen bg-[linear-gradient(90deg,#F1FECC_0%,#EAFEFA_100%)]">
  62. <wd-navbar
  63. title="充电详情" custom-style="background: linear-gradient(90deg, #F1FECC 0%, #EAFEFA 100%);"
  64. :bordered="false" :z-index="999" safe-area-inset-top left-arrow fixed @click-left="router.back()"
  65. />
  66. <view :style="{ paddingTop: `${(Number(statusBarHeight) || 44) + MenuButtonHeight + 12}px` }" />
  67. <view class="content-page box-border px24rpx">
  68. <view class="flex items-center gap-24rpx">
  69. <view>
  70. <view class="text-32rpx font-bold">
  71. {{ priceDetail?.stationName }}
  72. </view>
  73. <view class="mt-16rpx text-24rpx text-#AAA">
  74. {{ priceDetail?.tips || '--' }}
  75. </view>
  76. </view>
  77. <view>
  78. <image
  79. class="h-132rpx w-140rpx"
  80. :src="`${StaticUrl}/site-name-icon.png`"
  81. />
  82. </view>
  83. </view>
  84. <view class="items-centerrounded-16rpx mt-20rpx flex bg-#FFF p-20rpx">
  85. <view class="w-230rpx text-center">
  86. <view class="text-32rpx text-#9ED605 font-bold">
  87. {{ connectorsDetail?.idleCount }}
  88. </view>
  89. <view class="text-24rpx font-500">
  90. 空闲
  91. </view>
  92. </view>
  93. <view class="h-76rpx w-2rpx bg-#F0F0F0" />
  94. <view class="w-230rpx text-center">
  95. <view class="text-32rpx text-#9ED605 font-bold">
  96. {{ connectorsDetail?.occupiedCount }}
  97. </view>
  98. <view class="text-24rpx font-500">
  99. 占用
  100. </view>
  101. </view>
  102. <view class="h-76rpx w-2rpx bg-#F0F0F0" />
  103. <view class="w-230rpx text-center">
  104. <view class="text-32rpx text-#9ED605 font-bold">
  105. {{ connectorsDetail?.offlineCount }}
  106. </view>
  107. <view class="text-24rpx font-500">
  108. 离线
  109. </view>
  110. </view>
  111. </view>
  112. <view class="mt-28rpx">
  113. <view class="flex items-center justify-between rounded-42rpx bg-#FFF p-6rpx">
  114. <view
  115. class="h-80rpx w-348rpx rounded-60rpx text-center line-height-[80rpx]" :style="getTabStyle('price')"
  116. @click="switchTab('price')"
  117. >
  118. 电站价格
  119. </view>
  120. <view
  121. class="h-80rpx w-348rpx rounded-60rpx text-center line-height-[80rpx]" :style="getTabStyle('terminal')"
  122. @click="switchTab('terminal')"
  123. >
  124. 充电终端
  125. </view>
  126. </view>
  127. </view>
  128. <view v-if="activeTab == 'price'">
  129. <view v-for="item in priceDetail?.priceList" :key="item.timePeriod" class="mt-20rpx rounded-16rpx bg-#FFF p-24rpx" :style="{ border: item.currentPeriod ? '2rpx solid #9ED605' : '' }">
  130. <view class="relative flex items-center justify-between">
  131. <view class="flex items-center gap-20rpx">
  132. <view
  133. class="h-40rpx w-40rpx rounded-8rpx bg-#CCC text-center text-28rpx text-#FFF font-bold line-height-[40rpx]"
  134. >
  135. {{ item.periodFlagName }}
  136. </view>
  137. <view class="text-28rpx font-bold">
  138. {{ item.timePeriod }}
  139. </view>
  140. </view>
  141. <view
  142. v-if="item.currentPeriod"
  143. class="absolute h-40rpx w-152rpx rounded-[0_16rpx_0_16rpx] bg-[linear-gradient(99deg,#D2F670_0%,#9ED605_100%)] text-center text-28rpx text-#FFF font-600 -right-24rpx -top-24rpx"
  144. >
  145. 当前时段
  146. </view>
  147. </view>
  148. <view class="mt-24rpx rounded-16rpx bg-#F6F6F6 p-20rpx">
  149. <view class="flex items-center justify-between">
  150. <view class="text-24rpx text-#222222">
  151. 抵扣券电价
  152. </view>
  153. <view class="text-24rpx" :style="{ color: item.currentPeriod ? '#FF6464' : '', fontWeight: item.currentPeriod ? '800' : '' }">
  154. <text>{{ item.totalPrice }}</text>
  155. <text class="text-#AAA">
  156. 元/度
  157. </text>
  158. </view>
  159. </view>
  160. </view>
  161. </view>
  162. </view>
  163. <view v-if="activeTab == 'terminal'">
  164. <view v-for="item in connectorsDetail?.connectorList" :key="item.connectorId" class="mt-20rpx flex items-center gap-20rpx rounded-16rpx bg-#FFF p-20rpx">
  165. <view
  166. class="h-116rpx w-116rpx text-center line-height-[116rpx]"
  167. :style="{ backgroundImage: `url(${StaticUrl}/site-status-${getStatusImageByStatus(item.status)}.png)`, backgroundSize: 'cover', backgroundPosition: 'center' }"
  168. >
  169. <view class="text-24rpx font-bold">
  170. {{ item.statusName }}
  171. </view>
  172. </view>
  173. <view>
  174. <view class="text-bold text-28rpx">
  175. {{ item.connectorName }}
  176. </view>
  177. <view class="mt-4rpx text-24rpx text-#AAA">
  178. 电类分类:{{ item.equipmentType }}
  179. </view>
  180. <view class="mt-4rpx w-400rpx overflow-hidden truncate whitespace-nowrap text-24rpx text-#AAA">
  181. 终端编号:{{ item.connectorCode }}
  182. </view>
  183. </view>
  184. </view>
  185. </view>
  186. </view>
  187. <view class="h-180rpx" />
  188. <view class="fixed bottom-66rpx left-24rpx h-100rpx w-702rpx rounded-16rpx bg-[linear-gradient(90deg,#DBFC81_0%,#9ED605_100%)] text-center text-28rpx font-800 line-height-[100rpx] shadow-[inset_0rpx_6rpx_20rpx_2rpx_#FFFFFF]">
  189. 扫码充电
  190. </view>
  191. </view>
  192. </template>
  193. <style lang="scss" scoped></style>