鸿宇研学生前端代码
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.

163 lines
3.5 KiB

  1. <template>
  2. <view class="card info" :style="style">
  3. <view class="card-header">{{ product.title }}</view>
  4. <view class="card-content">
  5. <view class="row desc">{{ product.brief }}</view>
  6. <view class="flex row tags" v-if="tagList.length">
  7. <view class="tag" v-for="(tag, tIdx) in tagList" :key="tIdx">
  8. {{ tag }}
  9. </view>
  10. </view>
  11. <view class="flex row time">
  12. <view class="time-item">
  13. <view class="time-item-value">{{ $dayjs(productPackage.startDate).format('MM月DD日') }}</view>
  14. <view class="time-item-label">出发日期</view>
  15. </view>
  16. <view class="flex time-total">
  17. <view class="time-total-line"></view>
  18. <view class="time-total-value">{{ `${days}` }}</view>
  19. <view class="time-total-line"></view>
  20. </view>
  21. <view class="time-item">
  22. <view class="time-item-value">{{ $dayjs(productPackage.endDate).format('MM月DD日') }}</view>
  23. <view class="time-item-label">结束日期</view>
  24. </view>
  25. </view>
  26. </view>
  27. </view>
  28. </template>
  29. <script>
  30. export default {
  31. props: {
  32. data: {
  33. type: Object,
  34. default() {
  35. return {}
  36. }
  37. },
  38. style: {
  39. type: String,
  40. default: ''
  41. }
  42. },
  43. computed: {
  44. product() {
  45. return this.data?.product || {}
  46. },
  47. tagList() {
  48. const { tagDetails } = this.product || {}
  49. return tagDetails?.length ? tagDetails.split('、') : []
  50. },
  51. productPackage() {
  52. const { time, product } = this.data || {}
  53. const { dateList } = product || {}
  54. return dateList?.find?.(item => item.id === time) || {}
  55. },
  56. days() {
  57. console.log('productPackage', this.productPackage)
  58. const { startDate, endDate } = this.productPackage
  59. return this.$dayjs(endDate).diff(this.$dayjs(startDate), 'day')
  60. },
  61. },
  62. watch: {
  63. data: {
  64. handler(val) {
  65. console.log('watch data', val)
  66. },
  67. deep: true,
  68. immediate: true
  69. },
  70. },
  71. }
  72. </script>
  73. <style scoped lang="scss">
  74. .card {
  75. width: 100%;
  76. padding: 32rpx;
  77. font-family: PingFang SC;
  78. font-weight: 400;
  79. line-height: 1.4;
  80. box-sizing: border-box;
  81. background: #FFFFFF;
  82. border-radius: 24rpx;
  83. &-header {
  84. font-family: PingFang SC;
  85. font-weight: 500;
  86. font-size: 32rpx;
  87. line-height: 1.4;
  88. color: #181818;
  89. }
  90. &-content {
  91. }
  92. }
  93. .row {
  94. margin-top: 16rpx;
  95. }
  96. .desc {
  97. font-size: 26rpx;
  98. white-space: pre-wrap;
  99. color: #8B8B8B;
  100. }
  101. .tags {
  102. justify-content: flex-start;
  103. flex-wrap: wrap;
  104. gap: 16rpx;
  105. .tag {
  106. padding: 2rpx 14rpx;
  107. font-family: PingFang SC;
  108. font-weight: 400;
  109. font-size: 24rpx;
  110. line-height: 1.4;
  111. color: #00A9FF;
  112. background: #E9F8FF;
  113. border: 2rpx solid #00A9FF;
  114. border-radius: 8rpx;
  115. }
  116. }
  117. .time {
  118. justify-content: space-between;
  119. &-item {
  120. &-value {
  121. font-size: 32rpx;
  122. font-weight: 500;
  123. color: #000000;
  124. }
  125. &-label {
  126. margin-top: 4rpx;
  127. font-size: 26rpx;
  128. color: #8B8B8B;
  129. }
  130. }
  131. &-total {
  132. &-line {
  133. width: 64rpx;
  134. height: 2rpx;
  135. background: #8B8B8B;
  136. }
  137. &-value {
  138. padding: 6rpx 22rpx;
  139. font-size: 26rpx;
  140. color: #8B8B8B;
  141. border: 2rpx solid #8B8B8B;
  142. border-radius: 26rpx;
  143. }
  144. }
  145. }
  146. </style>