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

164 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. // todo: check key
  49. const { tagDetails } = this.product || {}
  50. return tagDetails?.length ? tagDetails.split('、') : []
  51. },
  52. productPackage() {
  53. const { time, product } = this.data || {}
  54. const { dateList } = product || {}
  55. return dateList?.find?.(item => item.id === time) || {}
  56. },
  57. days() {
  58. console.log('productPackage', this.productPackage)
  59. const { startDate, endDate } = this.productPackage
  60. return this.$dayjs(endDate).diff(this.$dayjs(startDate), 'day')
  61. },
  62. },
  63. watch: {
  64. data: {
  65. handler(val) {
  66. console.log('watch data', val)
  67. },
  68. deep: true,
  69. immediate: true
  70. },
  71. },
  72. }
  73. </script>
  74. <style scoped lang="scss">
  75. .card {
  76. width: 100%;
  77. padding: 32rpx;
  78. font-family: PingFang SC;
  79. font-weight: 400;
  80. line-height: 1.4;
  81. box-sizing: border-box;
  82. background: #FFFFFF;
  83. border-radius: 24rpx;
  84. &-header {
  85. font-family: PingFang SC;
  86. font-weight: 500;
  87. font-size: 32rpx;
  88. line-height: 1.4;
  89. color: #181818;
  90. }
  91. &-content {
  92. }
  93. }
  94. .row {
  95. margin-top: 16rpx;
  96. }
  97. .desc {
  98. font-size: 26rpx;
  99. white-space: pre-wrap;
  100. color: #8B8B8B;
  101. }
  102. .tags {
  103. justify-content: flex-start;
  104. flex-wrap: wrap;
  105. gap: 16rpx;
  106. .tag {
  107. padding: 2rpx 14rpx;
  108. font-family: PingFang SC;
  109. font-weight: 400;
  110. font-size: 24rpx;
  111. line-height: 1.4;
  112. color: #00A9FF;
  113. background: #E9F8FF;
  114. border: 2rpx solid #00A9FF;
  115. border-radius: 8rpx;
  116. }
  117. }
  118. .time {
  119. justify-content: space-between;
  120. &-item {
  121. &-value {
  122. font-size: 32rpx;
  123. font-weight: 500;
  124. color: #000000;
  125. }
  126. &-label {
  127. margin-top: 4rpx;
  128. font-size: 26rpx;
  129. color: #8B8B8B;
  130. }
  131. }
  132. &-total {
  133. &-line {
  134. width: 64rpx;
  135. height: 2rpx;
  136. background: #8B8B8B;
  137. }
  138. &-value {
  139. padding: 6rpx 22rpx;
  140. font-size: 26rpx;
  141. color: #8B8B8B;
  142. border: 2rpx solid #8B8B8B;
  143. border-radius: 26rpx;
  144. }
  145. }
  146. }
  147. </style>