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.

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