猫妈狗爸伴宠师小程序前端代码
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.

633 lines
15 KiB

  1. <template>
  2. <view class="timeline-container">
  3. <!-- 日期和状态标签 -->
  4. <view class="date-header">
  5. <view class="date-box">
  6. <view class="date-box-color" :style="{'background-color': getTopBgColor()}"></view>
  7. <view class="date-month-day">{{ formatDate(date).month }}-{{ formatDate(date).day }}</view>
  8. </view>
  9. <view class="status-tag" :class="{'status-tag-pending': status}">
  10. <image src="/static/images/ydd/icon1.png"
  11. mode="aspectFit"
  12. v-if="status"
  13. class="status-icon"></image>
  14. <image src="/static/images/order/success.png"
  15. mode="aspectFit"
  16. v-else
  17. class="status-icon"></image>
  18. {{ status ? '待上门' : '已完成' }}
  19. </view>
  20. </view>
  21. <!-- 空状态显示 -->
  22. <view v-if="!processedList || processedList.length === 0" class="empty-state">
  23. <text class="empty-text">暂无订单数据</text>
  24. </view>
  25. <!-- 时间线主体 -->
  26. <view v-else class="timeline-body" v-for="(item, index) in processedList" :key="index">
  27. <view class="timeline-line"></view>
  28. <view class="time-point">
  29. <view class="time-icon">
  30. <image src="/static/images/order/address.png" mode="aspectFit" class="time-image"></image>
  31. </view>
  32. <view class="time-text">{{ item.address }}</view>
  33. <view class="collapse-icon" @click="toggleServiceCard(index)">
  34. {{ serviceCardCollapsed[index] ? '展开' : '收起' }} <text class="arrow" :class="{'arrow-up': !serviceCardCollapsed[index]}"></text>
  35. </view>
  36. </view>
  37. <!-- 服务内容卡片 -->
  38. <view v-if="!serviceCardCollapsed[index]" class="service-card">
  39. <!-- 服务日期 -->
  40. <view class="service-section">
  41. <view class="section-title">
  42. <view class="title-indicator"></view>
  43. <text>服务日期</text>
  44. <text style="margin-left: auto;font-weight: 500;">{{ item.orderId }}</text>
  45. </view>
  46. <view class="section-content date-content" :class="{bgSuccessQ : item.status}">
  47. {{ item.fullDate }}
  48. </view>
  49. </view>
  50. <!-- 陪伴对象 -->
  51. <view class="service-section">
  52. <view class="section-title">
  53. <view class="title-indicator"></view>
  54. <text>陪伴对象</text>
  55. <view class="collapse-icon" @click="togglePetList(index)">
  56. {{ petListCollapsed[index] ? '展开' : '收起' }} <text class="arrow" :class="{'arrow-up': !petListCollapsed[index]}"></text>
  57. </view>
  58. </view>
  59. <view class="section-content pet-list" :class="{bgSuccessQ : item.status}" v-if="!petListCollapsed[index]">
  60. <view v-for="(pet, i) in item.petList" :key="i" class="pet-item">
  61. <view class="pet-avatar">
  62. <image :src="pet.avatar" mode="aspectFill" class="avatar-image"></image>
  63. </view>
  64. <view class="pet-info">
  65. <view class="pet-name">
  66. {{ pet.name }}
  67. <text class="pet-gender" :class="{'pet-gender-male': pet.gender === 'male', 'pet-gender-female': pet.gender === 'female'}">
  68. {{ pet.gender === 'male' ? '♂' : '♀' }}
  69. </text>
  70. </view>
  71. <view class="pet-description">
  72. {{ pet.breed }}{{ pet.bodyType }} | {{ pet.services.join('+') }}
  73. </view>
  74. </view>
  75. </view>
  76. </view>
  77. </view>
  78. <!-- 上门地址 -->
  79. <view class="service-section">
  80. <view class="section-title">
  81. <view class="title-indicator"></view>
  82. <text>上门地址</text>
  83. </view>
  84. <view class="section-content address-content" :class="{bgSuccessQ : item.status}">
  85. {{ item.addressDetail }}
  86. </view>
  87. </view>
  88. <!-- 操作按钮 -->
  89. <view class="action-buttons">
  90. <view class="btn btn-clock" :class="{bgSuccess : item.status}" @click="handleClock(item)">{{ item.status ? '打卡记录' : '打卡' }}</view>
  91. <view class="btn btn-clock" :class="{bgSuccess : item.status}" @click="handlePetFile(item)">宠物档案</view>
  92. <view class="btn btn-clock" :class="{bgSuccess : item.status}" @click="handleServiceFile(item)">服务档案</view>
  93. </view>
  94. </view>
  95. </view>
  96. </view>
  97. </template>
  98. <script setup>
  99. import { ref, computed } from 'vue';
  100. import { getOrderServiceText, getProductNameText } from '@/utils/serviceTime.js';
  101. // 定义组件属性
  102. const props = defineProps({
  103. date: {
  104. type: String,
  105. default: '2024-12-08'
  106. },
  107. orderCount: {
  108. type: Number,
  109. default: 2
  110. },
  111. status : {
  112. type: Boolean,
  113. default: true
  114. },
  115. current: {
  116. type: Number,
  117. default: 0
  118. },
  119. list: {
  120. type: Array,
  121. default: () => []
  122. }
  123. });
  124. // 宠物列表折叠状态 - 使用数组来单独控制每个卡片中的宠物列表
  125. const petListCollapsed = ref([]);
  126. // 服务卡片折叠状态 - 使用数组来单独控制每个卡片
  127. const serviceCardCollapsed = ref([]);
  128. // 切换宠物列表显示状态
  129. const togglePetList = (index) => {
  130. if (petListCollapsed.value[index] === undefined) {
  131. petListCollapsed.value[index] = true;
  132. } else {
  133. petListCollapsed.value[index] = !petListCollapsed.value[index];
  134. }
  135. };
  136. // 切换服务卡片显示状态
  137. const toggleServiceCard = (index) => {
  138. if (serviceCardCollapsed.value[index] === undefined) {
  139. serviceCardCollapsed.value[index] = true;
  140. } else {
  141. serviceCardCollapsed.value[index] = !serviceCardCollapsed.value[index];
  142. }
  143. };
  144. // 格式化日期
  145. const formatDate = (dateString) => {
  146. const date = new Date(dateString);
  147. return {
  148. day: date.getDate().toString().padStart(2, '0'),
  149. month: (date.getMonth() + 1).toString().padStart(2, '0')
  150. };
  151. };
  152. // 处理订单数据,转换为组件所需格式
  153. const processedList = computed(() => {
  154. return props.list.map(order => {
  155. // 获取所有宠物信息
  156. const petList = [];
  157. let orderId = 0
  158. let serviceId = 0
  159. let status = 1
  160. if (order.appletOrderItemDate && order.appletOrderItemDate.length > 0) {
  161. order.appletOrderItemDate.forEach(item => {
  162. if (item.orderServiceList && item.orderServiceList.petVo) {
  163. const pet = item.orderServiceList.petVo;
  164. const services = [];
  165. // 获取服务名称
  166. if (item.orderItemList && item.orderItemList.length > 0) {
  167. item.orderItemList.forEach(orderItem => {
  168. services.push(orderItem.productName);
  169. orderId = orderItem.orderId
  170. });
  171. }
  172. serviceId = item.id
  173. if(item.status == 0){
  174. status = 0
  175. }
  176. petList.push({
  177. name: pet.name,
  178. serviceId : item.id,
  179. gender: pet.gender === '男生' ? 'male' : 'female',
  180. breed: pet.breed,
  181. bodyType: `(${pet.bodyType})`,
  182. services: services,
  183. avatar: pet.photo || (pet.petType === 'dog' ? '/static/images/ydd/dog.png' : '/static/images/ydd/cat.png')
  184. });
  185. }
  186. });
  187. }
  188. return {
  189. id: order.orderId,
  190. orderId,
  191. serviceId,
  192. status,
  193. address: order.cityAddress,
  194. addressDetail: order.address,
  195. fullDate: props.date.replace(/-/g, '/'),
  196. petList: petList
  197. };
  198. });
  199. });
  200. // 按钮事件处理函数
  201. const handleClock = (item) => {
  202. // 根据订单状态确定跳转路径
  203. const paths = [
  204. `/otherPages/myOrdersManage/clock/index?id=${item.orderId}&itemID=${item.id}&serviceId=${item.serviceId}`,
  205. `/otherPages/myOrdersManage/clock/index?isRead=true&id=${item.orderId}&itemID=${item.id}`,
  206. ];
  207. uni.navigateTo({
  208. url: props.status ? paths[0] : paths[1]
  209. });
  210. };
  211. const handlePetFile = (item) => {
  212. uni.navigateTo({
  213. url: "/otherPages/orderTakingManage/pet/index?id=" + item.orderId
  214. });
  215. };
  216. const handleServiceFile = (item) => {
  217. uni.navigateTo({
  218. url: "/otherPages/myOrdersManage/service/index?id=" + item.orderId
  219. });
  220. };
  221. function getTopBgColor(){
  222. return props.status ? '#FFAA48' : '#4CD964';
  223. }
  224. </script>
  225. <style lang="scss" scoped>
  226. .bgSuccess{
  227. background-color: #4CD964 !important;
  228. }
  229. .bgSuccessQ{
  230. background-color: #4CD96422 !important;
  231. }
  232. .timeline-container {
  233. position: relative;
  234. padding: 20rpx;
  235. margin-bottom: 30rpx;
  236. .empty-state {
  237. display: flex;
  238. flex-direction: column;
  239. align-items: center;
  240. justify-content: center;
  241. padding: 80rpx 40rpx;
  242. .empty-image {
  243. width: 200rpx;
  244. height: 200rpx;
  245. margin-bottom: 20rpx;
  246. }
  247. .empty-text {
  248. color: #999;
  249. font-size: 28rpx;
  250. }
  251. }
  252. .date-header {
  253. display: flex;
  254. align-items: center;
  255. margin-bottom: 20rpx;
  256. .date-box {
  257. width: 80rpx;
  258. background-color: #ffffff;
  259. border: 2px solid #333;
  260. border-radius: 0;
  261. display: flex;
  262. flex-direction: column;
  263. justify-content: center;
  264. align-items: center;
  265. margin-right: 20rpx;
  266. box-shadow: 0 2rpx 6rpx rgba(0, 0, 0, 0.05);
  267. border-radius: 14rpx;
  268. .date-box-color{
  269. height: 20rpx;
  270. width: 100%;
  271. border-top-left-radius: 14rpx;
  272. border-top-right-radius: 14rpx;
  273. position: relative;
  274. &::before{
  275. content: '';
  276. display: block;
  277. background-color: #ddd;
  278. width: 100%;
  279. height: 26rpx;
  280. top: 100%;
  281. left: 0;
  282. position: absolute;
  283. }
  284. }
  285. .date-month-day {
  286. position: relative;
  287. font-size: 26rpx;
  288. font-weight: bold;
  289. color: #333;
  290. height: 50rpx;
  291. display: flex;
  292. flex-direction: column;
  293. justify-content: center;
  294. }
  295. }
  296. .status-tag {
  297. background-color: #4CD96422;
  298. color: #4CD964;
  299. border: 4rpx solid #4CD964;
  300. padding: 16rpx 26rpx;
  301. border-radius: 14rpx;
  302. font-size: 26rpx;
  303. display: flex;
  304. align-items: center;
  305. position: relative;
  306. margin-left: 20rpx;
  307. .status-icon {
  308. width: 32rpx;
  309. height: 32rpx;
  310. margin-right: 8rpx;
  311. }
  312. &::after{
  313. content: '';
  314. display: block;
  315. position: absolute;
  316. width: 0;
  317. height: 0;
  318. top: 50%;
  319. transform: translateY(-50%);
  320. left: -16rpx;
  321. border-top: 16rpx solid transparent;
  322. border-bottom: 16rpx solid transparent;
  323. border-right: 16rpx solid #4CD964;
  324. }
  325. &::before{
  326. content: '';
  327. display: block;
  328. position: absolute;
  329. width: 0;
  330. height: 0;
  331. top: 50%;
  332. transform: translateY(-50%);
  333. left: -12rpx;
  334. border-top: 12rpx solid transparent;
  335. border-bottom: 12rpx solid transparent;
  336. border-right: 12rpx solid #4CD96422;
  337. z-index: 1;
  338. }
  339. }
  340. .status-tag-pending {
  341. background-color: #FFAA4822;
  342. color: #FFAA48;
  343. border-color: #FFAA48;
  344. &::after{
  345. border-right-color: #FFAA48;
  346. }
  347. &::before{
  348. border-right-color: #FFAA4822;
  349. }
  350. }
  351. }
  352. .timeline-body {
  353. position: relative;
  354. padding-left: 40rpx;
  355. padding-bottom: 40rpx;
  356. .timeline-line {
  357. position: absolute;
  358. left: 40rpx;
  359. top: 0;
  360. height: 100%;
  361. width: 0;
  362. border-left: 2rpx dashed #707070;
  363. border-left-style: dashed;
  364. border-image: repeating-linear-gradient(to bottom, #707070 0, #707070 8rpx, transparent 8rpx, transparent 20rpx) 1;
  365. z-index: 0;
  366. &::after{
  367. content: '';
  368. display: block;
  369. position: absolute;
  370. width: 8rpx;
  371. height: 8rpx;
  372. background-color: #000;
  373. border: 2rpx solid #707070;
  374. border-radius: 50%;
  375. left: -7rpx;
  376. top: 30rpx;
  377. }
  378. }
  379. .time-point {
  380. display: flex;
  381. align-items: center;
  382. margin-bottom: 20rpx;
  383. position: relative;
  384. z-index: 1;
  385. .time-icon {
  386. width: 60rpx;
  387. height: 60rpx;
  388. background-color: #fff;
  389. border-radius: 50%;
  390. display: flex;
  391. justify-content: center;
  392. align-items: center;
  393. margin-right: 20rpx;
  394. position: relative;
  395. left: 20rpx;
  396. .time-image {
  397. width: 40rpx;
  398. height: 40rpx;
  399. }
  400. }
  401. .time-text {
  402. font-size: 28rpx;
  403. color: #333;
  404. margin-left: 20rpx;
  405. flex: 1;
  406. }
  407. .collapse-icon {
  408. font-size: 24rpx;
  409. color: #999;
  410. padding: 0 20rpx;
  411. .arrow {
  412. transition: transform 0.3s;
  413. display: inline-block;
  414. }
  415. .arrow-up {
  416. transform: rotate(180deg);
  417. }
  418. }
  419. }
  420. .service-card {
  421. background-color: #fff;
  422. border-radius: 12rpx;
  423. padding: 30rpx;
  424. box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.05);
  425. margin-left: 20rpx;
  426. .service-section {
  427. margin-bottom: 30rpx;
  428. .section-title {
  429. display: flex;
  430. align-items: center;
  431. margin-bottom: 15rpx;
  432. .title-indicator {
  433. width: 6rpx;
  434. height: 30rpx;
  435. background-color: #FFAA48;
  436. margin-right: 15rpx;
  437. }
  438. text {
  439. font-size: 28rpx;
  440. color: #333;
  441. font-weight: bold;
  442. }
  443. .collapse-icon {
  444. margin-left: auto;
  445. font-size: 24rpx;
  446. color: #999;
  447. .arrow {
  448. transition: transform 0.3s;
  449. display: inline-block;
  450. }
  451. .arrow-up {
  452. transform: rotate(180deg);
  453. }
  454. }
  455. }
  456. .section-content {
  457. padding: 0 15rpx;
  458. background-color: #FFF9F0;
  459. }
  460. .date-content {
  461. background-color: #FFF9F0;
  462. padding: 20rpx;
  463. border-radius: 8rpx;
  464. font-size: 28rpx;
  465. color: #333;
  466. }
  467. .pet-list {
  468. padding: 15rpx;
  469. .pet-item {
  470. display: flex;
  471. margin-bottom: 20rpx;
  472. &:last-child {
  473. margin-bottom: 0;
  474. }
  475. .pet-avatar {
  476. width: 80rpx;
  477. height: 80rpx;
  478. border-radius: 50%;
  479. overflow: hidden;
  480. margin-right: 20rpx;
  481. .avatar-image {
  482. width: 100%;
  483. height: 100%;
  484. }
  485. }
  486. .pet-info {
  487. flex: 1;
  488. .pet-name {
  489. font-size: 28rpx;
  490. color: #333;
  491. margin-bottom: 8rpx;
  492. .pet-gender {
  493. display: inline-block;
  494. width: 32rpx;
  495. height: 32rpx;
  496. line-height: 32rpx;
  497. text-align: center;
  498. border-radius: 50%;
  499. color: #fff;
  500. font-size: 20rpx;
  501. margin-left: 10rpx;
  502. }
  503. .pet-gender-male {
  504. background-color: #4A90E2;
  505. }
  506. .pet-gender-female {
  507. background-color: #FF6B9A;
  508. }
  509. }
  510. .pet-description {
  511. font-size: 24rpx;
  512. color: #7D8196;
  513. }
  514. }
  515. }
  516. }
  517. .address-content {
  518. padding: 20rpx;
  519. border-radius: 8rpx;
  520. font-size: 28rpx;
  521. color: #7D8196;
  522. }
  523. }
  524. .action-buttons {
  525. display: flex;
  526. justify-content: space-between;
  527. .btn {
  528. width: 30%;
  529. height: 80rpx;
  530. line-height: 80rpx;
  531. text-align: center;
  532. border-radius: 40rpx;
  533. font-size: 28rpx;
  534. }
  535. .btn-clock {
  536. background-color: #FFAA48;
  537. color: #fff;
  538. }
  539. .btn-pet-file, .btn-service-file {
  540. background-color: #F6F7FB;
  541. color: #333;
  542. border: 1px solid #E5E6EB;
  543. }
  544. }
  545. }
  546. }
  547. }
  548. </style>