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

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