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.

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