You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

312 lines
6.6 KiB

  1. <template>
  2. <view class="service-items-card">
  3. <view class="card-title">
  4. <text>服务项目及费用</text>
  5. </view>
  6. <!-- 服务项目列表 -->
  7. <view class="service-items-list">
  8. <view class="service-item" v-for="(item, index) in items" :key="index">
  9. <view class="item-header">
  10. <view class="item-id">{{item.id}}</view>
  11. <view class="item-name">{{item.name}}</view>
  12. <view class="item-price-action">
  13. <view class="item-price">¥{{item.price.toFixed(2)}}</view>
  14. <!-- 展开按钮 -->
  15. <view class="expand-btn" @click="toggleExpand(index)" v-if="item.pet || (item.customServices && item.customServices.length > 0)">
  16. <!-- <text>{{ expandedItems.includes(index) ? '收起' : '展开' }}</text> -->
  17. <view class="expand-icon" :class="{'expanded': expandedItems.includes(index)}">
  18. <text class="icon-arrow">{{ expandedItems.includes(index) ? '∧' : '∨' }}</text>
  19. </view>
  20. </view>
  21. </view>
  22. </view>
  23. <!-- 详细信息区域 -->
  24. <view class="detail-area" v-show="expandedItems.includes(index)">
  25. <!-- 宠物名称和头像 -->
  26. <view class="item-pet" v-if="item.pet">
  27. <view class="pet-avatar">
  28. <image :src="item.petAvatar || '/static/images/default-pet.png'" mode="aspectFill"></image>
  29. </view>
  30. <text>{{item.pet}}</text>
  31. </view>
  32. <!-- 定制服务 -->
  33. <view class="custom-services" v-if="item.customServices && item.customServices.length > 0">
  34. <view class="custom-service-item" v-for="(service, serviceIndex) in item.customServices" :key="serviceIndex">
  35. <view class="service-name">{{service.name}}</view>
  36. <view class="service-price">¥{{service.price.toFixed(2)}} × {{service.quantity}} </view>
  37. </view>
  38. </view>
  39. </view>
  40. </view>
  41. </view>
  42. <!-- 费用合计 -->
  43. <view class="cost-summary">
  44. <view class="cost-item">
  45. <text class="cost-label">费用合计</text>
  46. <text class="cost-value">¥{{totalAmount.toFixed(2)}}</text>
  47. </view>
  48. <view class="cost-item discount" v-if="discount > 0">
  49. <text class="cost-label">平台优惠</text>
  50. <text class="cost-value">- ¥{{discount.toFixed(2)}}</text>
  51. </view>
  52. <view class="cost-item discount" v-if="memberDiscount > 0">
  53. <text class="cost-label">会员优惠</text>
  54. <text class="cost-value">- ¥{{memberDiscount.toFixed(2)}}</text>
  55. </view>
  56. <view class="cost-item total">
  57. <text class="cost-label">应付金额</text>
  58. <text class="cost-value">¥{{finalAmount.toFixed(2)}}</text>
  59. </view>
  60. </view>
  61. </view>
  62. </template>
  63. <script>
  64. export default {
  65. props: {
  66. items: {
  67. type: Array,
  68. default: () => []
  69. },
  70. totalAmount: {
  71. type: Number,
  72. default: 0
  73. },
  74. discount: {
  75. type: Number,
  76. default: 0
  77. },
  78. memberDiscount: {
  79. type: Number,
  80. default: 0
  81. },
  82. finalAmount: {
  83. type: Number,
  84. default: 0
  85. }
  86. },
  87. data() {
  88. return {
  89. expandedItems: [] // 存储已展开的项目索引
  90. }
  91. },
  92. methods: {
  93. toggleExpand(index) {
  94. const position = this.expandedItems.indexOf(index);
  95. if (position === -1) {
  96. // 如果不在数组中,则添加(展开)
  97. this.expandedItems.push(index);
  98. } else {
  99. // 如果在数组中,则移除(折叠)
  100. this.expandedItems.splice(position, 1);
  101. }
  102. }
  103. }
  104. }
  105. </script>
  106. <style lang="scss" scoped>
  107. .service-items-card {
  108. background-color: #FFFFFF;
  109. border-radius: 20rpx;
  110. padding: 30rpx;
  111. margin-bottom: 20rpx;
  112. box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.05);
  113. }
  114. .card-title {
  115. font-size: 32rpx;
  116. font-weight: bold;
  117. color: #333;
  118. margin-bottom: 20rpx;
  119. display: flex;
  120. align-items: center;
  121. &::before {
  122. content: '';
  123. display: inline-block;
  124. width: 8rpx;
  125. height: 32rpx;
  126. background-color: #FFAA48;
  127. margin-right: 16rpx;
  128. border-radius: 4rpx;
  129. }
  130. }
  131. .service-items-list {
  132. .service-item {
  133. padding: 20rpx 0;
  134. border-bottom: 1px solid #EEEEEE;
  135. &:last-child {
  136. border-bottom: none;
  137. }
  138. .item-header {
  139. display: flex;
  140. align-items: center;
  141. margin-bottom: 10rpx;
  142. .item-id {
  143. font-size: 24rpx;
  144. color: #999;
  145. margin-right: 10rpx;
  146. }
  147. .item-name {
  148. font-size: 28rpx;
  149. color: #333;
  150. flex: 1;
  151. }
  152. .item-price-action {
  153. display: flex;
  154. align-items: center;
  155. gap: 15rpx;
  156. .item-price {
  157. font-size: 28rpx;
  158. color: #FF5252;
  159. font-weight: bold;
  160. }
  161. }
  162. }
  163. // 展开按钮样式
  164. .expand-btn {
  165. display: flex;
  166. align-items: center;
  167. justify-content: center;
  168. // padding: 6rpx 12rpx;
  169. width: 40rpx;
  170. height: 40rpx;
  171. font-size: 24rpx;
  172. color: #666;
  173. background-color: #FFF5E6;
  174. border-radius: 20rpx;
  175. border: 1px solid #FFAA48;
  176. .expand-icon {
  177. // margin-left: 6rpx;
  178. transition: transform 0.3s ease;
  179. &.expanded {
  180. transform: rotate(180deg);
  181. }
  182. .icon-arrow {
  183. font-size: 24rpx;
  184. color: #FFAA48;
  185. }
  186. }
  187. }
  188. // 详细信息区域
  189. .detail-area {
  190. padding: 15rpx;
  191. animation: fadeIn 0.3s ease;
  192. background-color: #F8F8F8;
  193. border-radius: 10rpx;
  194. margin-top: 10rpx;
  195. }
  196. .item-pet {
  197. font-size: 24rpx;
  198. color: #666;
  199. margin-bottom: 10rpx;
  200. display: flex;
  201. align-items: center;
  202. .pet-avatar {
  203. width: 40rpx;
  204. height: 40rpx;
  205. border-radius: 50%;
  206. overflow: hidden;
  207. margin-right: 10rpx;
  208. border: 1px solid #EEEEEE;
  209. image {
  210. width: 100%;
  211. height: 100%;
  212. }
  213. }
  214. }
  215. .custom-services {
  216. padding: 10rpx 0 10rpx 20rpx;
  217. .custom-service-item {
  218. display: flex;
  219. justify-content: space-between;
  220. align-items: center;
  221. margin-bottom: 6rpx;
  222. .service-name {
  223. font-size: 24rpx;
  224. color: #666;
  225. }
  226. .service-price {
  227. font-size: 24rpx;
  228. color: #999;
  229. }
  230. }
  231. }
  232. }
  233. }
  234. @keyframes fadeIn {
  235. from { opacity: 0; }
  236. to { opacity: 1; }
  237. }
  238. .cost-summary {
  239. margin-top: 30rpx;
  240. padding-top: 20rpx;
  241. border-top: 1px dashed #EEEEEE;
  242. .cost-item {
  243. display: flex;
  244. justify-content: space-between;
  245. align-items: center;
  246. margin-bottom: 10rpx;
  247. .cost-label {
  248. font-size: 26rpx;
  249. color: #666;
  250. }
  251. .cost-value {
  252. font-size: 26rpx;
  253. color: #333;
  254. }
  255. &.discount {
  256. .cost-value {
  257. color: #FF5252;
  258. }
  259. }
  260. &.total {
  261. margin-top: 20rpx;
  262. padding-top: 20rpx;
  263. border-top: 1px dashed #EEEEEE;
  264. .cost-label {
  265. font-size: 28rpx;
  266. font-weight: bold;
  267. color: #333;
  268. }
  269. .cost-value {
  270. font-size: 32rpx;
  271. font-weight: bold;
  272. color: #FF5252;
  273. }
  274. }
  275. }
  276. }
  277. </style>