index.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. <template>
  2. <view class="price-card" v-if="hasAnyPrice">
  3. <view class="card-header">
  4. <view class="header-row">
  5. <view class="header-dot"></view>
  6. <text class="header-title">收费标准<text class="header-tip">(以场地设备实际功能为准)</text></text>
  7. <view class="header-close" @click="emit('close')">
  8. <text class="close-icon">✕</text>
  9. </view>
  10. </view>
  11. </view>
  12. <view class="price-grid">
  13. <view class="price-item" v-for="item in priceItems" :key="item.label">
  14. <text class="price-label">{{ item.label }}</text>
  15. <text class="price-value">{{ fmtYuanPerMin(item.value) }}</text>
  16. </view>
  17. </view>
  18. <view class="price-footer" v-if="amountMinLimit != null || prepayMoney != null">
  19. <view class="footer-item" v-if="amountMinLimit != null && amountMinLimit > 0">
  20. <text class="footer-label">最低消费</text>
  21. <text class="footer-value">¥{{ (amountMinLimit / 100).toFixed(2) }}</text>
  22. </view>
  23. <view class="footer-item" v-if="prepayMoney != null && prepayMoney > 0">
  24. <text class="footer-label">单次上限</text>
  25. <text class="footer-value">¥{{ (prepayMoney / 100).toFixed(2) }}</text>
  26. </view>
  27. </view>
  28. </view>
  29. </template>
  30. <script setup lang="ts" name="PriceTable">
  31. import { computed } from "vue";
  32. const PRICE_LABELS: Record<string, string> = {
  33. priceSpace: "场地费",
  34. priceWater: "清水",
  35. priceFoam: "泡沫",
  36. priceCleaner: "吸尘",
  37. priceTap: "洗手",
  38. priceUserExt: "扩展项目",
  39. priceCoat: "镀膜",
  40. priceBlow: "吹气",
  41. };
  42. const props = defineProps({
  43. price: {
  44. type: Object,
  45. default: null,
  46. },
  47. });
  48. const emit = defineEmits(["close"]);
  49. const amountMinLimit = computed(() => props.price?.amountMinLimit);
  50. const prepayMoney = computed(() => props.price?.prepayMoney);
  51. const hasAnyPrice = computed(() => {
  52. if (!props.price) return false;
  53. return Object.keys(PRICE_LABELS).some((key) => props.price[key] != null);
  54. });
  55. const priceItems = computed(() => {
  56. if (!props.price) return [];
  57. return Object.entries(PRICE_LABELS)
  58. .filter(([key]) => props.price[key] != null)
  59. .map(([key, label]) => ({ label, value: props.price[key] }));
  60. });
  61. const fmtYuanPerMin = (fen: number) => {
  62. if (fen == null) return "";
  63. const yuan = fen / 100;
  64. return yuan % 1 === 0 ? `¥${yuan}/分钟` : `¥${yuan.toFixed(2)}/分钟`;
  65. };
  66. </script>
  67. <style lang="scss" scoped>
  68. .price-card {
  69. width: 580rpx;
  70. max-height: 80vh;
  71. background: $uni-bg-color-card;
  72. border-radius: 24rpx;
  73. overflow: hidden;
  74. display: flex;
  75. flex-direction: column;
  76. .card-header {
  77. padding: 32rpx 32rpx 0;
  78. .header-row {
  79. display: flex;
  80. align-items: center;
  81. gap: 12rpx;
  82. }
  83. .header-dot {
  84. width: 10rpx;
  85. height: 10rpx;
  86. background: $uni-color-primary;
  87. border-radius: 50%;
  88. flex-shrink: 0;
  89. }
  90. .header-title {
  91. font-size: 30rpx;
  92. font-weight: $uni-font-weight-semibold;
  93. color: $uni-text-color-dark;
  94. flex: 1;
  95. }
  96. .header-close {
  97. width: 48rpx;
  98. height: 48rpx;
  99. border-radius: 50%;
  100. background: $uni-bg-color-page;
  101. display: flex;
  102. align-items: center;
  103. justify-content: center;
  104. flex-shrink: 0;
  105. .close-icon {
  106. font-size: 24rpx;
  107. color: $uni-text-color-tertiary;
  108. }
  109. }
  110. .header-tip {
  111. font-size: 22rpx;
  112. color: $uni-text-color-tertiary;
  113. font-weight: $uni-font-weight-normal;
  114. }
  115. }
  116. .price-grid {
  117. display: flex;
  118. flex-wrap: wrap;
  119. padding: 24rpx 32rpx 12rpx;
  120. overflow-y: auto;
  121. .price-item {
  122. width: 50%;
  123. display: flex;
  124. align-items: center;
  125. justify-content: space-between;
  126. padding: 14rpx 0;
  127. box-sizing: border-box;
  128. &:nth-child(odd) {
  129. padding-right: 20rpx;
  130. }
  131. &:nth-child(even) {
  132. padding-left: 20rpx;
  133. }
  134. .price-label {
  135. font-size: 26rpx;
  136. color: $uni-text-color-hint;
  137. }
  138. .price-value {
  139. font-size: 26rpx;
  140. color: $uni-color-primary;
  141. font-weight: $uni-font-weight-semibold;
  142. }
  143. }
  144. }
  145. .price-footer {
  146. display: flex;
  147. gap: 32rpx;
  148. padding: 16rpx 32rpx 32rpx;
  149. border-top: 1rpx solid $uni-border-color-light;
  150. .footer-item {
  151. display: flex;
  152. align-items: center;
  153. gap: 8rpx;
  154. .footer-label {
  155. font-size: 24rpx;
  156. color: $uni-text-color-tertiary;
  157. }
  158. .footer-value {
  159. font-size: 24rpx;
  160. color: $uni-text-color-dark;
  161. font-weight: $uni-font-weight-medium;
  162. }
  163. }
  164. }
  165. }
  166. </style>