price-desc.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. <template>
  2. <view class="dialog flex-align-end">
  3. <view class="desc-dialog">
  4. <view class="desc-dialog_head flex-center">
  5. <view class="fw-500 color-000" style="font-size: 16px"
  6. >充电费用说明</view
  7. >
  8. <view class="close" @click="close">
  9. <uni-icons type="closeempty" size="24" color="#2D284B"></uni-icons>
  10. </view>
  11. </view>
  12. <view class="desc-dialog_body">
  13. <view class="table">
  14. <view class="tr flex">
  15. <view class="th flex-center fs-28">时间</view>
  16. <view class="th flex-center flex-column">
  17. <view>电费</view>
  18. <view class="fs-24 lh-24" style="color: rgba(0, 0, 0, 0.5)"
  19. >(元/kwh)</view
  20. >
  21. </view>
  22. <view class="th flex-center flex-column">
  23. <view>服务费</view>
  24. <view class="fs-24 lh-24" style="color: rgba(0, 0, 0, 0.5)"
  25. >(元/kwh)</view
  26. >
  27. </view>
  28. </view>
  29. <view
  30. class="tr flex"
  31. v-for="(item, index) in _desc"
  32. :key="index"
  33. :style="{
  34. 'border-top': `1rpx solid ${
  35. index === 0 ? 'transparent' : '#E5E5E5'
  36. }`,
  37. 'background':`${item.isCurrentTimePeriod?'rgba(45, 158, 149, 0.10)':'transparent'}`
  38. }"
  39. >
  40. <view class="td flex-center">
  41. <text style="width: 158rpx; text-align: center">{{
  42. item.startTimeFormat
  43. }}</text>
  44. <text
  45. class="ml-16 width-38 height-38 br-round fs-24 flex-center"
  46. v-if="item.iconIndex >= 0"
  47. :style="{
  48. color: iconColor[item.iconIndex],
  49. backgroundColor: iconBgColor[item.iconIndex],
  50. }"
  51. >{{ item.pricePeriod }}</text
  52. ></view
  53. >
  54. <view class="td flex-center">{{ item.elecPrice }}</view>
  55. <view class="td flex-center">{{ item.servicePrice }}</view>
  56. </view>
  57. </view>
  58. </view>
  59. </view>
  60. </view>
  61. </template>
  62. <script lang="ts">
  63. import { defineComponent } from "vue";
  64. export default defineComponent({
  65. props: {
  66. desc: Array<any>,
  67. },
  68. data() {
  69. return {
  70. _desc: [],
  71. iconText: ["谷", "平", "峰", "尖", "统"],
  72. iconBgColor: [
  73. "rgba(0, 218, 179, 0.20)",
  74. "rgba(100, 116, 139, 0.25)",
  75. "rgba(255, 153, 0, 0.20)",
  76. "rgba(255, 46, 0, 0.20)",
  77. "rgba(0, 218, 179, 0.20)"
  78. ],
  79. iconColor: ["#00DAB3", "#2d9e95", "#FF9900", "#FF2E00", "#006b57"]
  80. };
  81. },
  82. mounted() {
  83. // console.log(this.desc);
  84. let currentHour = new Date().getHours()
  85. if (this.desc && this.desc.length) {
  86. this._desc = this.desc.map((item) => {
  87. let isCurrentTimePeriod = false;
  88. if(item.startTimeFormat){
  89. let split = item.startTimeFormat.split("~");
  90. if(split&&split.length===2){
  91. isCurrentTimePeriod =
  92. currentHour>=Number(split[0].split(":")[0])&&
  93. currentHour<Number(split[1].split(":")[0])
  94. }
  95. }
  96. return {
  97. ...item,
  98. isCurrentTimePeriod,
  99. iconIndex: this.iconText.findIndex(
  100. (text) => item.pricePeriod === text
  101. ),
  102. };
  103. });
  104. // console.log(this._desc)
  105. }
  106. },
  107. methods: {
  108. close() {
  109. this.$emit("close");
  110. },
  111. },
  112. });
  113. </script>
  114. <style lang="scss">
  115. @use "../../../styles/layout.scss";
  116. @use "../../../styles/font.scss";
  117. @use "../../../styles/flex.scss";
  118. @use "../../../styles/dialog.scss";
  119. .desc-dialog {
  120. background-color: transparent;
  121. width: 100%;
  122. overflow: hidden;
  123. border-radius: 20rpx 20rpx 0px 0px;
  124. &_head {
  125. padding: 24rpx 0px;
  126. position: relative;
  127. background-color: #fff;
  128. .close {
  129. position: absolute;
  130. right: 30rpx;
  131. top: 50%;
  132. transform: translateY(-50%);
  133. }
  134. }
  135. &_body {
  136. box-sizing: border-box;
  137. padding: 0rpx 30rpx 80rpx 30rpx;
  138. background-color: #fff;
  139. .table {
  140. border: 1rpx solid #e5e5e5;
  141. border-radius: 10rpx;
  142. overflow: hidden;
  143. }
  144. .tr {
  145. width: 100%;
  146. & > view:nth-child(1) {
  147. width: 254rpx;
  148. flex-shrink: 0;
  149. border-right: 1rpx solid #e5e5e5;
  150. }
  151. & > view:nth-child(2) {
  152. width: 200rpx;
  153. flex-shrink: 0;
  154. border-right: 1rpx solid #e5e5e5;
  155. }
  156. & > view:nth-child(3) {
  157. flex-grow: 1;
  158. }
  159. }
  160. .tr:nth-child(2n) {
  161. background-color: #fbfcff;
  162. }
  163. .th {
  164. border-bottom: 1rpx solid #e5e5e5;
  165. background-color: #f1f6ff;
  166. height: 92rpx;
  167. color: rgba(0, 0, 0, 0.7);
  168. font-size: 28rpx;
  169. view {
  170. color: rgba(0, 0, 0, 0.7);
  171. font-size: 28rpx;
  172. }
  173. }
  174. .td {
  175. color: #000;
  176. font-size: 26rpx;
  177. height: 76rpx;
  178. }
  179. }
  180. }
  181. </style>